Stingray not working with Xbee
Microcontrolled
Posts: 2,461
I have a stingray connected to an Xbee module, with the module connected to (of course) power, and DOUT to 16 and DIN to 17. I have a remote to work with the Xbee, but although the signals are coming though when I plug the USB cable into the Xbee, I don't get anything with the stingray. Here is the code I am using. If I start the function with "Auto" it works fine, as the Xbee isn't used.
Thanks,
Microcontrolled
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 VAR byte dir[4] byte speed OBJ ping : "Ping" pwm : "PWMx8" ser : "FullDuplexSerial" PUB Start ser.start(16,17,0,9600) pwm.start(24, %0000_1111, 23000) dira[24..27]~~ dira[0]~~ outa[0]~ Manuel PUB Manuel | command, i speed := 128 repeat case ser.rxcheck ' "a": Auto "*": ser.tx("@") "u": dir[1] := speed dir[2] := speed dir[3]~ dir[4]~ "d": dir[1]~ dir[2]~ dir[3] := speed dir[4] := speed "r": dir[1]~ dir[2] := speed dir[3]~ dir[4]~ "l": dir[1] := speed dir[2]~ dir[3]~ dir[4]~ "s": repeat i from 1 to 4 dir[i]~ pwm.duty(24, dir[1]) pwm.duty(25, dir[3]) pwm.duty(26, dir[4]) pwm.duty(27, dir[2]) PUB Auto | dist, v1, v2, v3, v4, dirc, cntr, distback dir := "r" repeat dist := ping.Inches(8) distback := ping.Inches(9) ' ser.tx(0) 'ser.dec(dist) if dist < 16 if distback > 16 v1~ v2~ v3 := 128 v4 := 128 else v1 := 128 v2~ v3~ v4 := 128 elseif dist < 36 outa[0]~~ if dirc == "r" v1~ v2 := 128 if dirc == "l" v1 := 128 v2~ v3~ v4~ cntr++ if cntr == 5 cntr~ if dirc == "r" dirc := "l" else dirc := "r" ' ser.str(string(" Close")) else v1 := 128 v2 := 128 v3~ v4~ 'ser.str(string(" Far")) 'waitcnt(clkfreq/4 + cnt) ' if dist > 13 outa[0]~ pwm.duty(24, v1) pwm.duty(25, v3) pwm.duty(26, v4) pwm.duty(27, v2) 'outa[25..26] := %00 waitcnt(clkfreq/8 + cnt)
Thanks,
Microcontrolled
Comments