PINGs on robot freezing?? Servos are not to blame! HELP ME!!!
Microcontrolled
Posts: 2,461
Sorry for the odd title. I have a robot that I have built that has 2 PING's, an Xbee, an SD card and audio out. The robot is moved by 2 Parallax continuous rotation servos. I am powering it all off 4 D cells. The robot will relay sensor information back to the home through the Xbee, and the home commands the robot with simple 1 byte serial commands. My problem is: The ping's will be working for a while, then all of a sudden the lights will stop flashing and data will stop being returned. I can't figure any reason for this happening, as I once thought that it was the servos, but after isolating the servos from the program and making my own servo driver, and I made both a serial and analog one, it still happened. I then tryed decresing the speed of the reads on the PINGs. No luck. I've tryed everything that I can think of and there still seems to be no rhyme or reason to what is happening. I am using Kye's duel servo driver and the default PING driver. I know that it is not the home end because it acts the same if controlled by typing the commands in on a PC terminal. Can someone help?? Here's the code:
As you can see the sound and SD card are not used in this program.
Thanks in advance,
Micro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my new website!!
Use the Propeller icon!!
Follow me on Twitter! Search "Microcontrolled"
''This is version 2 of the RC bot. This version allows it to be fully automated, and turned on and off ''(the automation) from the transmitter. It can not be turned back manuel from the remote at this ''time. The RC bot also features a park function (2 PINGS needed) that will park itself in a corner and ''sleep until the sound sensor is triggered. '' ''Version 2.2 has lots of added wireless commands that give the controller full power and monitoring ''over the robot. ''Version 2.3 corrects a bug that was case conflicts on the incoming characters. Now they have been moved ''to hexadecimal values. ''Version 2.4 lets the control see values bigger then a byte length by changing the value from inches ''to feet automatically and by adding in a type byte. ''Version 2.5 removes the features of 2.4 due to no functionallity, and it improves the autopilot by ''allowing it to use both the front and side sensor to know what direction to turn, or if it is drifting ''into a wall due to slightly unbalenced servos. ''Version 2.6 removes conflicting between the PINGs and the rest of the program by putting them in a ''seperate cog. ''Version 2.7 added FSRW and Rayman's WAV player. Also have adapted code to use the SD/sound card ''I built for the robot. CON _CLKMODE = XTAL1 + PLL16x _XINFREQ = 5_000_000 '80Mhz clock rate Ppin = 0 speed = 0 buffSize = 100 VAR long state long cstate long stack[noparse][[/noparse]20] long minutes, seconds byte time long dist long side byte type ''///////////WAV player vars//////////////////////////////////////////////////// long parameter1 'to pass @buff1 to ASM long parameter2 'to pass @buff2 to ASM long parameter3 'to pass sample rate to ASM long parameter4 'to pass #samples to ASM long buff1[noparse][[/noparse]buffSize] long buff2[noparse][[/noparse]buffSize] byte Header[noparse][[/noparse]44] OBJ servo : "servoEngine" ping : "Ping" xb : "Xbee_Object" sd : "fsrw" PUB Start | i, cntn xb.start(8,9,0,9600) servo.servoEngine time := 5 sd.mount(16) cognew(GetPing,@stack) Manuel PUB Manuel ' state := @idle 'cstate := @man servo.SetPositionA(90) servo.SetPositionB(90) ' Automatic repeat case xb.rx "u": xb.tx($FA) servo.SetPositionA(0+speed) servo.SetPositionB(180-speed) 'state := @active "d": xb.tx($FA) servo.SetPositionA(180-speed) servo.SetPositionB(0+speed) 'state := @active "r": xb.tx($FA) servo.SetPositionA(180-speed) servo.SetPositionB(180-speed) 'state := @active "l": xb.tx($FA) servo.SetPositionA(0+speed) servo.SetPositionB(0+speed) 'state := @active $FD: xb.tx($FA) servo.SetPositionA(90) servo.SetPositionB(90) 'state := @idle $0A: reboot $0B: time := xb.rx ' $0C: ' speed := xb.rx $0D: 'state := @dormant Nap "i": waitcnt(clkfreq/50 + cnt) xb.tx(dist) xb.tx(side) xb.tx(speed) xb.tx(ina[noparse][[/noparse]10]) "I": waitcnt(clkfreq/50 + cnt) xb.dec(dist) xb.dec(side) xb.dec(speed) xb.dec(ina[noparse][[/noparse]10]) "a": xb.tx($FA) cognew(Timer,@stack) Automatic $0F: waitcnt(clkfreq/50 + cnt) xb.str(string("Distance from objects: ")) xb.dec(ping.Inches(Ppin)) xb.str(string(13,"State: ")) xb.str(state) xb.str(string(13,"Control: ")) xb.str(cstate) PUB Automatic | count servo.SetPositionA(0) servo.SetPositionB(180) repeat if xb.rxcheck == "M" Manuel if xb.rxcheck == "P" Park if side < 6 servo.SetPositionA(180) servo.SetPositionB(180) waitcnt(clkfreq/3 + cnt) servo.SetPositionA(0) servo.SetPositionB(180) if dist < 36 side := ping.Inches(1) if side < 48 servo.SetPositionA(180) servo.SetPositionB(180) else servo.SetPositionA(0) servo.SetPositionB(0) repeat dist := ping.Inches(Ppin) waitcnt(clkfreq/100 + cnt) count++ if count == 700 Start if dist > 48 Automatic if minutes == time Park PUB Park | edge servo.SetPositionA(0) servo.SetPositionB(180) repeat waitcnt(clkfreq/100 + cnt) if dist =< 12 quit servo.SetPositionA(180) servo.SetPositionB(180) repeat waitcnt(clkfreq/100 + cnt) if side =< 15 quit servo.SetPositionA(0) servo.SetPositionB(180) repeat waitcnt(clkfreq/100 + cnt) if side =< 10 servo.SetPositionA(180) servo.SetPositionB(180) waitcnt(clkfreq/20 + cnt) servo.SetPositionA(0) servo.SetPositionB(180) if side => 13 servo.SetPositionA(0) servo.SetPositionB(0) waitcnt(clkfreq/20 + cnt) servo.SetPositionA(0) servo.SetPositionB(180) if side > 18 Park if dist <= 12 Sleep PUB Sleep repeat waitcnt(clkfreq/20 + cnt) if ina[noparse][[/noparse]10] == 1 Automatic PUB Nap dira[noparse][[/noparse]12]~~ outa[noparse][[/noparse]12]~ repeat waitcnt(clkfreq*2 + cnt) outa[noparse][[/noparse]12]~~ waitcnt(clkfreq/300 + cnt) outa[noparse][[/noparse]12]~ if ina[noparse][[/noparse]11] == 1 quit return true PRI GetPing repeat dist := ping.Inches(Ppin) side := ping.Inches(1) waitcnt(clkfreq/20 + cnt) PRI Timer | dT, T dT := clkfreq T := cnt repeat T += dT waitcnt(T) seconds ++ if seconds == 60 seconds~ minutes++
As you can see the sound and SD card are not used in this program.
Thanks in advance,
Micro
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my new website!!
Use the Propeller icon!!
Follow me on Twitter! Search "Microcontrolled"
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my new website!!
Use the Propeller icon!!
Follow me on Twitter! Search "Microcontrolled"
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my new website!!
Use the Propeller icon!!
Follow me on Twitter! Search "Microcontrolled"
··- Sparks
The ping and timer cogs use the same stack - will cause problems, you need 2 stacks one for each.
The ping and timer cogs use the same stack - will cause problems, you need 2 stacks one for each.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Check out my new website!!
Use the Propeller icon!!
Follow me on Twitter! Search "Microcontrolled"