There are a few different threads talking about this in a few of the different forums (SSC, remote control, …) so I am not sure where the best place is to talk about this. I thought about the thread talking about Xans phoenix code, but I did not want to hijack that thread, so I decided maybe it deserves it’s own thread…
First I would again like to say that Xan did a great job with version 2 of the phoenix code, which works great Among other things he has done a lot of work to improve the performance from version 1.
But there is always a need for speed One of the bottle necks has been the communications between the BAP and the SSC-32. Currently in my versions of the code that was adapted to use XBEE input from the DIY remote, I have made some changes to the version 2.0 code to speed up these communications, which include:
a) If you are about to tell a servo to go to same place it is, don’t output the data. Should be a big win for example if you are doing one leg movements and the like…
b) Used my own serial output function that allowed me to drive the SSC-32 at full speed (115200). This has been working well for me and I think it works OK for Zenta as well.
Now this week, there is an Alpha version of new firmware for the SSC-32 that introduces a binary command set that reduces the number of characters that are transmitted, by maybe half which should again give us a speed up. Last night I made a version of my phoenix code that used this binary mode, which I think is working. I will do some more optimizing of this code later today (or tomorrow…)
I am also looking at maybe rearranging some of the code and would appreciate input. Example: The code below is the main code that drives the legs. It waits a sufficient amount of time for the previous command to complete before it issues the next command. It however has to do some fudging with the -45 on the sleep time to guess how long it will take to output the new command and subtract that from the time we wait.
[code] ;Drive Servos
IF HexOn THEN
IF HexOn AND Prev_HexOn=0 THEN
Sound P9,[60\4000,80\4500,100\5000]
Eyes = 1
ENDIF
;Set SSC time
IF(ABS(TravelLengthX)>cTravelDeadZone | ABS(TravelLengthZ)>cTravelDeadZone | ABS(TravelRotationY*2)>cTravelDeadZone) THEN
SSCTime = NomGaitSpeed + (InputTimeDelay*2) + SpeedControl
;Add additional delay when Balance mode is on
IF BalanceMode THEN
SSCTime = SSCTime + 100
ENDIF
ELSE ;Movement speed excl. Walking
SSCTime = 200 + SpeedControl
ENDIF
;Sync BAP with SSC while walking to ensure the prev is completed before sending the next one
IF (GaitPosX(cRF) OR GaitPosX(cRM) OR GaitPosX(cRR) OR GaitPosX(cLF) OR GaitPosX(cLM) OR GaitPosX(cLR) OR |
GaitPosY(cRF) OR GaitPosY(cRM) OR GaitPosY(cRR) OR GaitPosY(cLF) OR GaitPosY(cLM) OR GaitPosY(cLR) OR |
GaitPosZ(cRF) OR GaitPosZ(cRM) OR GaitPosZ(cRR) OR GaitPosZ(cLF) OR GaitPosZ(cLM) OR GaitPosZ(cLR) OR |
GaitRotY(cRF) OR GaitRotY(cRM) OR GaitRotY(cRR) OR GaitRotY(cLF) OR GaitRotY(cLM) OR GaitRotY(cLR)) THEN
;Get endtime and calculate wait time
GOSUB GetCurrentTime], lTimerEnd
CycleTime = ((lTimerEnd-lTimerStart) * WTIMERTICSPERMSMUL) / WTIMERTICSPERMSDIV
#ifdef DEBUG_MAIN
lsumCycleTime = lsumCycleTime + CycleTime ; BUGBUG::: debug
cCycleTime = cCycleTime + 1 ;
#endif
;Wait for previous commands to be completed while walking
pause (PrevSSCTime - CycleTime - 45) MIN 1 ; Min 1 ensures that there alway is a value in the pause command
ENDIF
GOSUB ServoDriver
[/code]
What I am thinking of doing differently is to try to take advantage that the SSC-32 does not do anything until the end of the command is received. In ASCII mode that is the CR and in binary mode when it receives the 3 byte move time: 0xe1 <Time Low).
That is to change the code such that before we do the pause we output all of the new command except the termination stuff and that way we only have the fudge of time for 0 (nothing changed) 1(normal mode) or 3 (binary mode) characters at the right time. Thoughts?
Also are there others who are interested in playing with stuff? That is should I try to build a version with most of these changes that would run on a phoenix/chr3 that does not rely on our xbee stuff (ie PS2 or serial…). If I do this I will probably not include the stuff for b) above as most of you probably don’t want to see a lot of assembly language stuff…
Kurt