Menu

Errors in Program-- AHH!

Help
2007-04-14
2013-05-30
  • Nobody/Anonymous

    Hello!
    I've tried to compile this code (located at the end of this post), and it seems that MPLAB is yelling at me that there are three errors. I am not sure what the problem is, and the window pops up and closes too fast for me to tell. Any help will GREATLY be appreciated. I've added some comments (goofy ones) that may help you to figure out my code =P
    -Omar

    ---------------------------------------------------------
    #chip 16F684, 8
    #config INTRC_OSC_NOCLKOUT
                                                                                                'Setting Variables
    ReadingOne = 0
    ReadingTwo = 0
    ReadingThree = 0
    ReadingFour = 0
    Reado = 0
    Readt = 0
    LINEo = 0
    LINEof = 0
                                    'I/Os
    dir PORTC.0 OUT                    'motor1
    dir PORTA.4 OUT                    'motor1
    dir PORTC.1 OUT                    'motor2
    dir PORTC.5 OUT                    'motor2
    dir PORTC.4 OUT                    'LED
    dir PORTA.0 IN                    'sensor
    dir PORTA.2 IN                    'calibration
    dir PORTA.3 IN                    'on
                                                                            'The PIC is turned on, wait for the start button
    IF PORTA.2 ON THEN CALIBRATE
                                                                                'Calibrate is not yet pressed
    WAIT UNTIL PORTA.3 ON
    WAIT 20 ms
                                                    'Just read the line values this assumes that you have already calibrated
    EPRead (0, LINEo)
    EPRead (1, LINEof)
                                                                                'Just start going left (hopefully)
    SET PORTC.1 OFF
    SET PORTC.5 OFF
    SET PORTC.0 ON
    SET PORTA.4    OFF
                                                    'The looped part of the program. Anything above will only happen once.
    START:
        DO WHILE ReadAD (AN0) >= LINEo
            SET PORTC.1 OFF
            SET PORTC.5 OFF
            SET PORTC.0 ON
            SET PORTA.4    OFF
        LOOP 
        IF ReadAD (AN0) <= LINEof
            SET PORTC.1 OFF 
            SET PORTC.5 OFF
            SET PORTC.0 ON 
            SET PORTA.4    OFF
            DO UNTIL ReadAD (AN0) <= LINEof
                SET PORTC.1 OFF 
                SET PORTC.5 OFF
                SET PORTC.0 ON 
                SET PORTA.4    OFF
            LOOP 
        END IF
        IF ReadAD (AN0) <= LINEof
            SET PORTC.1 ON 
            SET PORTC.5 OFF
            SET PORTC.0 OFF
            SET PORTA.4    OFF
        END IF
    GOTO START
                                                                                'Subs. This is for calibration!
    SUB CALIBRATE
    WAIT 20 ms
                                                    SET PORTC.4 ON                'The light is on. I repeat, the light is on.
        WAIT UNTIL PORTA.2 ON                                                    'Scramble on the line and get the line.
        WAIT 20 ms
        IF PORTC.3 ON THEN ReadingOne = ReadAD (AN0)                            'The reading, flashing and then wait.
                                                    SET PORTC.4 OFF
                                                    WAIT 1 s
                                                    SET PORTC.4 ON
        WAIT UNTIL PORTA.2 ON                                                    'Reading, flashing and wait again.
        WAIT 20 ms
        IF PORTC.3 ON THEN ReadingTwo = ReadAD (AN0)
                                                    SET PORTC.4 OFF
                                                    WAIT 1 s
                                                    SET PORTC.4 ON
        WAIT UNTIL PORTA.2 ON                                                    'You heard it.
        WAIT 20 ms
        IF PORTC.3 ON THEN ReadingThree = ReadAD (AN0)
                                                    SET PORTC.4 OFF
                                                    WAIT 1 s
                                                    SET PORTC.4 ON
        WAIT UNTIL PORTA.2 ON                                                    'Last time this is happening. YAY.
        WAIT 20 ms
        IF PORTA.2 ON THEN ReadingFour = ReadAD (AN0)
                                                    SET PORTC.4 OFF
        Reado = Average(ReadingOne, ReadingTwo)                                 'Very important. Just average out the values.
        Readt = Average(ReadingThree, ReadingFour)
                                                    SET PORTC.4 ON                'TRIPPY! Now write the values
        EPWrite (0, Reado)
        EPWrite (1, Readt)
                                                    SET PORTC.4 OFF                'Lights are out! Go back to the beginning.
    END SUB

     
    • Hugh Considine

      Hugh Considine - 2007-04-15

      There are two IFs that do not have THENs on the end of them, but other than that I can see no problem with your program and have no trouble compiling or assembling it myself.

      If MPLAB is generating errors, there should be a .err file for your program somewhere that has the list of errors in it. If the assembly file for your program is called compiled.asm, the error listing will be called compiled.err. This is just a text file, you can open it up in Notepad.

       
    • Nobody/Anonymous

      Thank you very much. I fixed that part but it also still gives me the three errors. I opened the ERR file up, and this is what it states:
      Error[111]   COMPILED.ASM 15 : Missing symbol
      Error[113]   COMPILED.ASM 332 : Symbol not previously defined (EEPGD)
      Error[113]   COMPILED.ASM 349 : Symbol not previously defined (EEPGD)

      and when I look at the ASM file, it seems to be pointing to these lines:
          equ    32

          bcf    EECON1,EEPGD

          bcf    EECON1,EEPGD

      I have no experiance with Assembly so I have no idea what that means. Is there something wrong with my coding that is causing this?

      Thank you very much, either way I will compile and see what happens to the IC with the circuit.

       
    • Hugh Considine

      Hugh Considine - 2007-04-15

      That's due to a bug in GCBASIC, which I'm pretty sure I fixed before the release of 0.9.3.0. Are you using the latest version of GCBASIC, and in particular is the eeprom.h file dated 9/2/2007?

       
    • Nobody/Anonymous

      Oh noes. That could be it, I'm using the old version. I should update it now, thank you very much. Is it possible to just get the new EEPROM.H file without having to reinstall?

      Omar

       
    • Nobody/Anonymous

      It seems the downloads are not working. I cannot download the file from the downloads section (it tells me that the file doesn't exist).

      Is it possible to have that fixed?

       
    • Nobody/Anonymous

      I made the robot, but it seems I am stuck. I cannot get the AD conversion to occur correctly. I was wondering how do you compare some AD values?

      My voltage on the tape is ~2V and off the tape is ~0.8. When comparing the voltages on the PIC, which values should I use (do I convert that to hex or something?)

      Thanks

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.