My first robot

russbow

Senior Member
At last, my first Picaxe project. Many thanks to all on this forum that helped me get to this point.

It is based on a 28x1, an L293D motor chip, a homebrew IR and a servo mounted SRF005 which is seriously under-used.

In one of the brief discussions on the forum, it was asked “why a 28x, an 08 would do” I felt I needed lots of inputs / outputs to play with, my coding capability being very noobie.

Here is my code 1st attempt. Very over commented.

Code:
'TOKENS
' output pin 0 =
' output pin 1 =	Servo
' output pin 2 =	Peizo
' output pin 3 =	Sonic out
' output pin 4 =	Motor A+
' output pin 5 =	Motor A-
' output pin 6 =	Motor B+
' output pin 7 =	Motor B=
'
' Input pin 0 =	IR1 left
' Input pin 1 =	IR2 right
' Input pin 2 =
' Input pin 3 =
' Input pin 4 =
' Input pin 5 =
' Input pin 6 =	echo pulse in
' Input pin 7 =

' ADC 1 =	  =	LDR 
' ADC 2 = 
' ADC 3 = 

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

symbol range = w1	'word variable for range value
symbol trig = 3	'sonic pulse out
symbol echo = 6 	'received sonic pulse

servo 1,150		'set servo ahead
main:

high 4,6
low 5,7		'both forward
gosub ir		'check side clearances
gosub ping		'check obstacles
goto main

''''''''''''''   Use ultrasonic detect forwaed   '''''''''''''''''''''''

ping:
pulsout trig,2 		‘ produce 20uS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range 	‘ measures the range in 10uS steps
pause 10 			‘ recharge period after ranging completes
				‘ now convert range to cm (divide by 5.8) or inches (divide by 14.8)
				‘ as picaxe cannot use 5.8, multiply by 10 then divide by 58 instead
let range = range * 10 / 58 ‘ multiply by 10 then divide by 58

if range < 20 then gosub right
return

'''''''''''''''''  Check L & R for clearance   '''''''''''''''''''''''''''''
ir:

if pin0 = 1 then gosub right
if pin1 = 1 then gosub left

return

'''''''''''''''   motor controls. Always backup before turn   '''''''''''''''
right:
gosub back	'short reverse
high 4,7
low 5,6	' spin right
pause 100
return

left:
gosub back	'short reverse
low 4,7
high 5,6	' spin left
pause 100
return

back:
low 4,6
high 5,7	' reverse
gosub buzz
pause 100
return

''''''''''''''''''  make sound ''''''''''''''''''''''''''''''

buzz:

let b0 = b0 + 1 ‘ increment b0
sound 7,(b0,50) ‘ make a sound


return













'low 4,6
'low 5,7	' stop
'pause 5000
I would appreciate some critical comments / suggestions how to do it better.

How on earth could this go to an 08? I am using four pins for motor control. That don’t leave a lot for other jobs. I want to try speed control next by PWMing the motor chip enables, another pin. Of board CD4xxx chips, although easily implemented defeat the object.

Lastly, the SRF isn’t really used. I can scan the field, record the blips, even decide where the biggest is – servo angle and distance. How do I use this information? I think I need to delve into wheel code disks and revolution counting . How far do I turn etc
 

cactusface

Senior Member
Robots &amp; things....

Hi Russbow,
Nice to hear about your robot/buggy, it would have been even nicer if you could have included a picture or schematic. I too am working on my first Buggy-bot, See my resent post. It's up and running, just added an IR detector for the rear end, hope to add Ultrasonics for the front. It runs on a 18X Picaxe with an L293 for the motor control, LED turn indicators and sound.
If I can help or even if you can help me give us a shout.
Regards
Cactusface
 
Top