PDA

View Full Version : Programming with PicBasic Compiler



Raycher
- 17th September 2005, 06:12
Hi, Iam trying to compile code given for the insectronics bot with the pic basic compiler but only get error messages (new to programming chips).
Eg. Here is the code:

temp var byte ' initialize variables
freq var byte
m_servo var byte
l_servo var byte
r_servo var byte

portb.7 = 0 ' set initial logic states to 0
portb.6 = 0
portb.5 = 0

freq = 13 ' delay value

start:

m_servo = 140 ' set servo position values
l_servo = 140
r_servo = 140

gosub servo

goto start


servo: ' servo positioning subroutine
for temp = 1 to 10
pulsout portb.7,m_servo
pulsout portb.6,l_servo
pulsout portb.5,r_servo
pause freq ' set frequency between 50 - 60 Hz
next temp
return

If I try to compile this is the error messages I get:

error servo- ~1.bas,8:':'or '=' expected (token 'var')
error servo- ~1.bas,9:':'or '=' expected (token 'var')
error servo- ~1.bas,10:':'or '=' expected (token 'var')
error servo- ~1.bas,11:':'or '=' expected (token 'var')
error servo- ~1.bas,12:':'or '=' expected (token 'var')
error servo- ~1.bas,14:'illegal character '.'
error servo- ~1.bas,14:':'or '=' expected (token '7')
etc....etc..etc

I will appreciate any help
PS I use a 16F84A chip.

Regards

Melanie
- 17th September 2005, 08:10
Actually your posted example code compiles without error with the command line...

pbp -p16f84a test



temp var byte ' initialize variables
freq var byte
m_servo var byte
l_servo var byte
r_servo var byte

portb.7 = 0 ' set initial logic states to 0
portb.6 = 0
portb.5 = 0

freq = 13 ' delay value

start:

m_servo = 140 ' set servo position values
l_servo = 140
r_servo = 140

gosub servo

goto start


servo: ' servo positioning subroutine
for temp = 1 to 10
pulsout portb.7,m_servo
pulsout portb.6,l_servo
pulsout portb.5,r_servo
pause freq ' set frequency between 50 - 60 Hz
next temp
return


Ahh... pain... just realised your using PBC not the pro version... you are going to have to go through your manual and assign your variable names and Pins to allowed variables and pins.

Raycher
- 17th September 2005, 16:11
Thanks! I will try again.

saturnX
- 19th September 2005, 17:18
hi raycher, was just wondering what your codes was used for? kinda interested in similar projects to do with servomotors. i've only just recently built a walking gait robot using servo motors with the help of melanie.

bartman
- 19th September 2005, 22:16
Looks like the code from that book with the 3 servo walking robot that I mentioned in the other thread.

That book is also written in PCB Pro so converting it to basic would take a little more effort.

Everyone building robots these days?

Bart

Raycher
- 20th September 2005, 15:15
Hi, the code were used for a insec bot. I used the book called "Insectronics" by Karl Williams to built a six legged insec - works pretty well once one can program the chip.

Regards
r