Walking robot with 08M2

#1
Hello everybody,
I am kindly asking for help. I built a walking robot - inspiration from here: http://www.lollybotrobotics.co.uk/resources.html
I would like the robot to beep while turning. I cannot achieve this. I tried multitasking with start0 and start1 where start1 handled the beeping but it did not work. Maybe the 08M2 is too busy handling the servos. I was only able to make sound before it starts turning and I learned at Let's make robots that is better to add command low after sound command to let the corresponding pin be at log 0. Can anybody advice? Thank you for help. Code is attached:
Code:
rem c.1  servo
rem c.4  servo
rem c.2  HC-SR04 trigger
rem c.3  HC-SR04 echo
rem c.0  piezzo

#no_data

symbol time1 = 100


servo c.1,150
servo c.4,150
pause 500


main:

pause 10
pulsout c.2,5
pulsin c.3,1,w1
pause 10

w1 = w1*10/58
;sertxd ("w1 = ",#w1," Cm ",cr,lf)
pause 50
if w1<15 then

	gosub turn
   else
	gosub walk_forward
endif
goto main

#rem
servos_mid_position:
servo c.1,150
servo c.4,150
pause 20
return
#endrem

walk_forward:
servo c.1,120
pause time1
servo c.4,120
pause time1
servo c.1,180
pause time1
servo c.4,180
pause time1
return

turn:
sound c.0,(120,50,0,50,120,50,0,50,120,50,0,50) low c.0
for b1 = 1 to 5
servo c.4,120
pause time1
servo c.1,90
pause time1
servo c.4,180
pause time1
servo c.1,150
pause time1
next b1
return
walker.jpg
 

hippy

Technical Support
Staff member
#2
SOUND is a blocking command so everything stops while the sound is played, even when SOUND is put in a separate task.

The best way to do SOUND in parallel to something else is to use a second PICAXE to generate the sound which can be triggered from the pin which would have been used to output the sound.

If SEROUT is used ( and SERIN or HSERIN on the sound generating PICAXE ) you can have it generate different sounds, but it's probably best to start with just triggering a single sound with HIGH and LOW signals.
 

erco

Senior Member
#4
I'm a huge fan of these tiny 10-cent buzzers and rarely build a circuit without one: http://www.ebay.com/itm/232045296534 The types used in fire alarms.

No SOUND command required, they emit a LOUD fixed beep tone just from a 5V signal, pulling ~20mA. For best results, connect buzzer's +pin to +5V, other pin to Picaxe pin, drive low to activate. Works fine with servo and pwm commands, even at 4.5V (3xAA) https://www.youtube.com/watch?v=IrRRgLXzl3U

They come with a wash sticker in place, which reduces volume considerably. Handy, tape works too.

You can also send various SOUNDs through them if you like:

https://www.youtube.com/watch?v=WBJq6RZhOvw
https://www.youtube.com/watch?v=EF1-noeMqVI
https://www.youtube.com/watch?v=NMX5kicEoJw
https://www.youtube.com/watch?v=ggah9mkvx-U
 

erco

Senior Member
#8
And their Budvar is the proper stuff :)
+1, Budweiser is a very poor substitute. Not even close.

I lived in Japan with a team for several months. Our Japanese host Bandai often splurged and hosted fancy dinners with (ugh) Budweiser, an expensive imported beer from the US. We tried a few times to tell them how much we preferred Asahi & Sapporo but they politely insisted that we deserved the finest (Budweiser), so we just had to roll with it. :)
 

erco

Senior Member
#11
At $2.78, they are practically giving these Catalex serial MP3 players away. Grab two: http://www.ebay.com/itm/112042307835

Simple to use, they work great, I just built one in a project. Uses a micro SD card to store your files on. A nice feature is that while one file is playing, you can interrupt that file just by sensing a new play command. I connected the output to a dollar store amplified speaker. Great audio quality and
VERY LOUD, had to reduce the volume in software.

Everything you need to get started at http://www.picaxeforum.co.uk/showthread.php?26798-Catalex-Serial-MP3-Player

Manual in post #3.
 
Top