I slight update to this and soon maybe trying out XBee control of my Hex as well…
I decided to prepare the Hex code based off of Xans phoenix 1.3 code to try it with the DIY remote with XBee. Zenta mentioned that he now has some XBees and would like to try it on his hex as well. But we have concerns that the HSERIAL to control the XBee may cause the serouts to the SsC to not work properly. So I decided to try converting the hex code to use my Timer assisted serout functions, so I am now in the process of doing that. I now have the code compiling for both Bap28s and Bap40s. While at it I removed the TimerW interrupts for a timer and on the Bap28 used TimerA and Bap40 TimerB1 where timer increments on clock/8192. Also updated the TASerout function to hopefully work on Bap40. TimerV is on both modules, but had to scale the times for the differences in clock speeds. If it works, I may also be able to drive the SSC-32 at full speed, but we will see…
Since my output function only works with a buffer and size, I had to do some conversion of ServoDriver function. I now calls functions to output each pin and looks something like:
[code]ServoDriver:
;Front Right leg
gosub ServoOutputPin[RFCoxaPin,TOINT(TOFLOAT(-RFCoxaAngle +90)/0.10588238)+650]
gosub ServoOutputPin[RFFemurPin,TOINT(TOFLOAT(-RFFemurAngle+90)/0.10588238)+650]
gosub ServoOutputPin[RFTibiaPin,TOINT(TOFLOAT(-RFTibiaAngle+90)/0.10588238)+650]
…
;Send
gosub ServoOutputTime[SSCTime]
PrevSSCTime = SSCTime
return
;--------------------------------------------------------------------
;[SOItoAVal] Internal convert the number into ascii in our output buffer…
; Warning:: this uses the variables internal to the two output functions…
SOPin var WORD
SOVal var WORD
SOIndex var WORD
SOBuf var byte(12)
SOIToAVal:
SOPin = 10000 ; reuse here...
; find the first digit to output
while (SOPin >= SOVal) and (SOPin > 1)
SOPin = SOPin / 10
wend
do
SOBuf(SOIndex) = SOVal/SOPin + "0"
SOIndex = SOIndex + 1
SOVal = SOVal // SOPin
SOPin = SOPin / 10
while (SOPIN > 0)
return
;--------------------------------------------------------------------
;[ServoOutputPin] Output information about one pin
ServoOutputPin[SOPin, SOVal] :
SOBuf(0) = “#”
SOBuf(1) = (SOPin/10) + “0”
SOBuf(2) = (SOPin//10) + “0”
SOBuf(3) = “P”
SOIndex = 4
gosub SOItoAVal ; use our internal function to convert SOVal to ascii starting at SOIndex in SOBuf
gosub TASerout[SSC_OUT, SSC_BAUTE, @SOBuf, SOIndex]
return
;--------------------------------------------------------------------
;[ServoOutputTime] Output Time Value
ServoOutputTime[SOVal] :
SOBuf(0) = “T”
SOIndex = 1
gosub SOIToAVal ; convert our time value to ascii string starting at SOIndex
SOBuf(SOIndex) = 13 ; end with CR
gosub TASerout[SSC_OUT, SSC_BAUTE, @SOBuf, SOIndex + 1] ; output our string remember to add CR at end!
return
;--------------------------------------------------------------------
;[FREE SERVOS] Frees all the servos
FreeServos
for Index = 0 to 31
gosub ServoOutputPin[Index,0]
next
gosub ServoOutputTime[200]
return
[/code]
Now off to testing it out and then trying out an XBee on it!
Kurt