SSC based Hex - servo zero finder

A quick follow up on the issue brought up by Innerbreed… I also usually don’t like to go through the hassle of update the wiring to the SSC-32 to allow me to use the PC to talk to it, so my servos are never totally alligned as they should be. I know that my CHR-3 really needs to have the servos zeroed, and my phoenix parts should arrive later in the week and I most likely will be too lazy to get this right either. So I decided to have some fun and code this up a servo config program for the Hex.

In this case I am now using the keyboard (S_out/S_IN). I currently have a separate program that I am testing on my test board. The code is somewhat more complicated than it needs to be. First of I am using my own serial functions to talk to the SSC-32. This allows me to continue to talk to it at 115200, it should also work at 38400, with a simple define change.

Also somewhat complicated is that I was trying to emulate being able to have a pointer table in basic. This would allow me to create a table of strings that are used to show the name of the pin that you are adjusting. Having this display has saved me in previous robots where I mixed up a few servo wires…

The code is still in the process of being tested. So far it appears to be able to read in the register values for the current servo offsets. It allows you to select the different servos and increment/decrement the servo to hopefully find the right zero point. Hitting enter appears to work in writing values back out the registers on the SSC-32, including R0 to make sure the appropriate bits are set. I still need to test this on the CHR-3 to see how well it works.

Also I need to experiment to see things like if I read in that for example R32 (offset for servo 0) is equal to 30 and then I find that it really should be 50. If I then do a write this register (R32=50). What will happen after that point until the SSC-32 is reset? Will it use the 50? Will it add it and use 80? or will it ignore it until it is reset? If it does not simply use the new value, can I reboot the SSC-32? Is there an easy way to do this? My first thought is to issue a “GOBOOT” command, probably pause slightly and then issue: “g0000” Suggestions?

In case anyone else wants to play along, I have included the current source. But again still testing!!! Configured for I115200.

Kurt

OK, I decided to split this off as to not Hijack Xan’s thread.

I see that I need to do some additional work with my own CHR-3 hex. When I run it on mine I get the output:

[code]Read Servo Offsets: Try Read Servo 0

RS0 = FFFF

+++Read Initial Servo Offsets+++
A) RR Hip Hor = -276
B) RR Hip Vert = 0
C) RR Knee = 0
D) MR Hip Hor = 0
E) MR Hip Vert = 0
F) MR Knee = 0
G) FR Hip Hor = 0
H) FR Hip Vert = 0
I) FR Knee = 0
J) RL Hip Hor = 0
K) RL Hip Vert = 0
L) RL Knee = 0
M) ML Hip Hor = 0
N) ML Hip Vert = 0
O) ML Knee = 0
P) FL Hip Hor = 0
Q) FL Hip Vert = 0
R) FL Knee = 0[/code]

So it looks like my one servo is way off. From the the SSC manual I think they are supposed to only have the range ±100. Will now add another keystroke to say clear all of the values (set to zero) and store them…

Kurt

Update: I am debugging some issues now. Will update the sources later. Some things I found include:
a) I was misreading bit15 of R0. At first I thought it was a global ENABLE but instead it is a global disable.
b) My reading/writing of register values was not handling negative numbers properly…
Will Do new post with updated code when these appear to be working!!!

I think I have it working reasonably well right now!!! :smiley:

For the fun of it, I decided that I may be also too lazy to change baud rates or dig down into where the SSC-32 is to find out what the baud rate is, so I have the code try to figure it out. It tries to find out which version of the software the SSC-32 is running. First it tries at 115200. If it gets nothing back it tries at 38400, then 9600, then 2400.

Now back to the regular programming :laughing:

Sounds like a good idea. It reminds me of the conditional compile commands Parallax uses for their programs to work on multiple stamp controllers.

Nice job Kurt!

Impressive little program. Considerable use of ASM, should also be useful as a tutorial!

Now if I could just get back to my 'quad with the 'pro processor…

Alan KM6VV

Going from memory here, but I am pretty sure this is correct. When register values are written, the SSC-32 will store them but will not use the new value until reset (it will continue to use the old value). The reason for this is to discourage the use of registers for normal run-time adjustments by software. The register values are stored in EEPROM, which has a limited number of write cycles before it wears out. The limit is around 100,000 writes per byte, so you are not likely to reach it by manually setting register values, but software could reach the limit pretty quickly.

The GOBOOT, pause, g0000 method is only way I can think of to force a “reset”. You won’t need much of a pause, if any. 100us would probably be overkill – the natural pacing of the serial output from your controller may be sufficient.

Mike

:laughing:
It’s the lazy people that often come up with the briliant solutions! (Like the TV remote control, dishwasher and so on)
I’ve not had time to study this code yet. I hope that some part of this program also can be used on the ARC-32 for setting servo offsets? The ARC-32 doesn’t have any offset register so I believe it had to be done similar to what you did to the brat?

Thanks for sharing you work Kurt!

Thanks everyone.

MikeD: I will try that. So far I simply power cycle to get it to reset, but the other way is nicer…

Alan: The code is all table driven, so you could always simply update the tables to use it with your quad.

Zenta: I enjoy sharing! Will have to rework most of this to work with the Arc32. It will actually be a combination of this and the one I did for the Brat that uses HSERVO. Shouldn’t be hard!

Still trying to decide if I should remove some of the assembly code, with the pointer table. My old version kept all of the strings in one table with a null character inbetween and I had to scan loooking for the 0s to find the right string…

Kurt

If it had no ASM code, then maybe it would be portable to the BasicAtom. Could be quite useful for some! But that might require some generalization for the servo numbers, or legs. Like my 'quad.

Alan KM6VV

I added the code to reset the SSC-32 after I save away the values. I then jump back up to the start of the program and reload everything. This should help to verify that everything is back to known state…

Kurt

I have not removed the assembly look up yet, may later when I rework for Arc32 (when it arrives).

This will probably be the last of the changes for now, but I did do a few minor changes:
I limited the offsets to ±100 instead of 200 as that is what the doc said.

I added support for the 0 key to clear the offset back to zero for the current servo

Also changed the code to allow the increment and decrement value from the hard coded 5. You set it by using the numbers keys 1-9…

That is all for now. Will probably work on the Arc32 version so when it arrives I Will be able to do the same… Phoenix parts should arrive tomorrow! Yeah!!!

Kurt

Edit: did silent update to have the keyboard count how many updates and cr and output after every 5 so you don’t scroll horizontally forever…
sschexsf.bas (40.3 KB)

Nice fixes Kurt! I look forward to using it on my 'quad.

Thanks!

Alan KM6VV

Thanks,

Just a note: the current programs do not compile on versions 15 or 16 of studio as SLONG does not work. In this case I think it would be safe to convert to SWORD. Should be fixed with the new studio when it comes out. Had to go back to latest for Hservo2 support…

Kurt