PDA

View Full Version : Compilation Errors – Code Designer Lite and PicBASIC Pro Compiler (MicroCode Studio)



zz22
- 30th June 2008, 19:45
Would you kindly identify the source of the compiling errors?
This program has worked before.


B. Here is the beginning of the error list.

PBP,7: undefined Variable 'TRISA'
PBP,8: undefined Variable 'TRISB'
PBP,10: ':' 'or =' Expect (Token 'VAR')
PBP,11: to 23: ':' 'or=' Expect (Token 'VAR') is repeated for lines 11 to 23

PBP,30: Undefined variable 'num_samples'
PBP,30: Undefined variable '1_threshold'
PBP,30: Undefined variable 'r_threshold'
PBP,30: Varible expected (Token 'temp')
PBP,30: Variable or Constant Expected (Token 'PORT B')
PBP,30: Illegal Character '.'
PBP,30: End of line or ':' Expected (Token ',')
PBP,30: Illegal Character '['



B. Here are the compiling steps.

1. MicroCode Studio
Go to the Project Menu
Choose “Compile and Program”
Be sure that 16F627A is selected in the Target Processor pulldown window.

2. EPIC settings in the Configuration Menu.
Oscillator: XT INTRC (IN)
Code Protection: Off
Watch Dog Timer: enabled
Power-up Timer: enabled
Brown-Out Reset: enabled
Master Clear Reset: enabled
Memory Size: 1 K

3. Open the Hexapod zip file containing the code.

4. Extract only the insect-explore.bas.
All of the other files are for experiments.

5. Open insect-explore.bas in Microcode Studio.

6. Make sure that a 16F627A chip is in the programmer.
Notch faces the Centronix connector (for parallel cable).

7. In MicroCode Studio, go to the Project Menu.
Select “Compile and Program.”
This action brings up the EPIC program.

8. Erase, and verify that the chip is clear.
Go to the Run menu and select “Program.”





C. Here is the code (Karl Williams, www.thinkbotics.com)

'************************************************* *******
' insect-explore.bas
' exploration with obstacle avoidance control program
' PicBasic Pro Compiler
'************************************************* *******

trisa = %11111111 ' set porta to inputs
trisb = %00001100 ' set portb pins 2 & 3 to inputs

m_servo var byte ' initialize variables
l_servo var byte
r_servo var byte
temp var byte
timer var byte
decision var word
ir_left var byte
ir_right var byte
l_count var byte
r_count var byte
l_threshold var byte
r_threshold var byte
num_samples var byte
behavior var byte

num_samples = 30 ' number of samples taken per i.r. module
l_threshold = 5 ' noise floor threshold for left detector
r_threshold = 5 ' noise floor threshold for right detector

for temp = 1 to 10 ' delay for approximately 1 second by
sound portb.4,[90 + (temp*3),2] ' flashing LED's and making sounds so that
toggle portb.1 ' the infrared detecor board has time to
toggle portb.0 ' stabalize on power up.
pause 100
next temp

start:

gosub infrared ' get sensor values from infrared subroutine

portb.1 = ir_left
portb.0 = ir_right

behavior = ir_left * 2 + ir_right

branch behavior,[walk_forward, turn_left, turn_right, walk_reverse]

walk_reverse:
sound portb.4,[90,1,80,2,125,1,90,2,100,2]
for temp = 1 to 2
m_servo = 170
gosub servo
l_servo = 120
r_servo = 120
gosub servo
m_servo = 100
gosub servo
l_servo = 160
r_servo = 160
gosub servo
next temp

random decision

if decision.0 = 1 then turn_right
turn_left:
sound portb.4,[140,1,80,2,125,1,95,2]
for temp = 1 to 2
m_servo = 170
gosub servo
l_servo = 120
r_servo = 160
gosub servo
m_servo = 100
gosub servo
l_servo = 160
r_servo = 120
gosub servo
next temp
goto start
turn_right:
sound portb.4,[140,1,120,2,110,1,100,2]
for temp = 1 to 2
m_servo = 170
gosub servo
l_servo = 160
r_servo = 120
gosub servo
m_servo = 100
gosub servo
l_servo = 120
r_servo = 160
gosub servo
next temp
goto start
walk_forward:
m_servo = 170
gosub servo
l_servo = 160
r_servo = 160
gosub servo
m_servo = 100
gosub servo
l_servo = 120
r_servo = 120
gosub servo
goto start

infrared:

l_count = 0
r_count = 0
ir_left = 0
ir_right = 0

for temp = 1 to num_samples ' take 30 samples per detector

if portb.2 = 0 then ' if left module senses an object
l_count = l_count + 1 ' increase the left count
endif

if portb.3 = 0 then ' if left module senses an object
r_count = r_count + 1 ' increase the right count
endif

next

if l_count >= l_threshold then ' if left count is greater than the threshold
ir_left = 1 ' then an object was sensed with left detector
endif

if r_count >= r_threshold then ' if right count is greater than the threshold
ir_right = 1 ' then an object was sensed with right detector
endif

return ' return to main program

servo: ' subroutine to set servos

for timer = 1 to 10
pulsout portb.7,m_servo
pulsout portb.6,l_servo
pulsout portb.5,r_servo
pause 13
next timer
return

end




Thank you.

Catherine Wang

gringobomba14
- 30th June 2008, 21:49
Works just fine for me, so I have to ask, did you follow your own instructions? Try this. Open up PicBasic, open a new page, and copy/paste your code straight in. Make sure the PIC is the right one, and it should work just fine for you.

skimask
- 1st July 2008, 00:19
Almost looks like this person is compiling a PicBasicPro program with PicBasic.

gringobomba14
- 1st July 2008, 21:07
almost.................................