BasicMicroUK - Forums

www.basicmicro.co.uk
It is currently Wed Oct 17, 2018 12:24 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: robot code
PostPosted: Sat Apr 23, 2011 3:59 am 
Offline
Citizen

Joined: Sat Apr 23, 2011 3:29 am
Posts: 9
hi im in trying to build a sensor drivin racing robot using the basic atom 24. im using a parallax ping sensor and a couple ir sensors. also using a tamia double motor and a pololu motor driver. im having some issues with a line of code the studio doesnt like. can you give me some hints? mabey i cant use a string??? ill attach the code and this is the error im getting

Error: FILE F:\DE3\ROBOT 3.BAS(LINE 173) : [TOKEN TASK0] : Unexpected token type

Attachment:
robot 3.txt [8.92 KiB]
Downloaded 335 times


Top
 Profile  
 
 Post subject: Re: robot code
PostPosted: Sat Apr 23, 2011 2:59 pm 
Offline
Master

Joined: Tue Nov 21, 2006 5:34 pm
Posts: 662
It does not like the line:
Code:
   task = GOSUB  Task0, Task1, Task2, Task3, Task4


This is not a valid syntax for a GOSUB statement. A gosub can only go to one location. Also it does not return a value that can be assigned in this way. You can return values, but the syntax would be:
gosub x[], returnval
Also none of your subroutines appear to return anything. If your intent was to call all 5 of them you could:
Code:
gosub Task0
gosub Task1
...

If your intent was to call Task0 when Task=0, Task1 when Task=1... You could do it like:
Code:
IF Task=0 THEN
    gosub TASK0
ELSEIF Task=1
    gosub TASK1
...


or if this is the last thing you wish for the subroutine, you could use the branch statement
Code:
branch Task, [Task0, Task1, Task2, Task3, Task4]
; Task was not in range...
return

Task0:
...
return

Note in this method, the return in Task0 will not return to after the branch statement but instead to after the call to the function that contained the branch (I hope I am being clear here).

Good Luck
Kurt


Top
 Profile  
 
 Post subject: Re: robot code
PostPosted: Sat Apr 23, 2011 7:36 pm 
Offline
Citizen

Joined: Sat Apr 23, 2011 3:29 am
Posts: 9
thx kurt ill try it all of those ways but right now i am just fleshing out the code for when we get our stuff in. but yes very clear and very helpfull ill let you know how it goes. thx again


Top
 Profile  
 
 Post subject: Re: robot code
PostPosted: Tue May 03, 2011 3:51 pm 
Offline
Citizen

Joined: Sat Apr 23, 2011 3:29 am
Posts: 9
ok i have another issue and i dont know why i fixed the sub routine but when i send my serial data it dont like how its written i guess it says it expects a ')' i dont know why and i have wrote this code according to how the syntax manual says as well and still tells me that. if i add the ')' then it says it wants a [ in there also


Top
 Profile  
 
 Post subject: Re: robot code
PostPosted: Tue May 03, 2011 6:03 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
Need to post your program. Not just single line snippets. Then we can try compiling it and see where the syntax error is.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: robot code
PostPosted: Tue May 03, 2011 7:29 pm 
Offline
Citizen

Joined: Sat Apr 23, 2011 3:29 am
Posts: 9
heres the copy of the code the compiler likes it up untill the serial communication under the motordriver


Attachments:
robot 3.bas [8.98 KiB]
Downloaded 310 times
Top
 Profile  
 
 Post subject: Re: robot code
PostPosted: Wed May 11, 2011 3:44 am 
Offline
Citizen

Joined: Sat Apr 23, 2011 3:29 am
Posts: 9
ok as asked to do eariler tonight here is the copy of code we was using(motor), the link to the driver pdf is http://www.pololu.com/file/0J59/smc05a_guide.pdf

and for the ping servo i write it like this
pulsout pingservo, 3000
pause 17
pulsout pingservo, 2500
pause17
pulsout pingservo, 3500
pause17

and then add the code to read what the sensor sends to the controller to that right?


Top
 Profile  
 
 Post subject: Re: robot code
PostPosted: Wed May 11, 2011 10:41 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
The datasheet says the serial signals must be non-inverted, 1s are high voltage and 0s are low voltage.

So you need to use nBaud modes.(n1200,n9600,n19200).

serout motorpin,n9600,[0x80,0,0,0x3F] ;run the motor at half power

Note the example in the motor controller manual is for a basic stamp so you may need to add pacing to the serout command.

For the ping sonar this is how another user runs it.

Code:
pingrange var long

low ping
high ping
pulsin ping, 0, pingRaw 'read the ping
low ping
pingRange = pingRaw / 148 'convert to inches

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
 Post subject: Re: robot code
PostPosted: Thu May 12, 2011 3:45 am 
Offline
Citizen

Joined: Sat Apr 23, 2011 3:29 am
Posts: 9
thanks nathan the ping sensor is now working still having trouble with the motordriver idk if the chip is good or not still trying to figure that out. but the sensor is working fine and im going to work on the servo tonight or tomm. thx again and if i do need to pace the driver command what would be a good value for that?


Top
 Profile  
 
 Post subject: Re: robot code
PostPosted: Thu May 12, 2011 6:17 pm 
Offline
Site Admin
User avatar

Joined: Thu Mar 01, 2001 7:00 pm
Posts: 1316
Location: Temecula, CA
pacing is in 0.5us increments. So to add a 1ms delay between bytes sent you would put a pace of 2000. Thats a pretty long delay. At 9600bps each bit is 104us so you would be delaying between each byte about the equivilent of 1 bytes width of time(10*104us ~= 1ms). If it doesn't work at that pacing or faster its probably not going to work at longer delays.

At that point I'd think there may be some configuration setting you have to make to get the motor controller to function but I didn't study that part of the datasheet.

_________________
Tech Support
Basic Micro - Robotic Technology Evolved


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO