Phoenix code running on an Arduino Mega with an SSC-32

Not sure, it builds fine on my machine :laughing: But I see that the current build is 22 and I have been using 21… Downloading now. Will need to check to see if I need to report the Serial port code I changed earlier or not. I added TX buffering…

In your JPG was that the first error line you showed highlighted or were the previous ones…

Just want to say something:

Do you have sellected the right platform to bluild ?

(Sorry if my answer is dum)

OK, Arduino build 22 now downloaded. I tried build got the same errors. I then copied the PS2X_LIB directory that was in my Zip file (about Jan 22nd?) in this thread into the Arduino Library directory. Exited from Arduino, restarted the Arduino program and now it compiles. I have not tried it out as I don’t have the Arduino hooked up to my CHR-3 hex currently. I am pretty sure I would not take my Serial library code for Build 21 and put it into Build 22 as it sounds like they made changes to serial… You probably don’t need them to start off anyway. it simply hopefully sped things up to allow the output to the serial port to be buffered instead of waiting for each character to be output…

Kurt

Where in the code can be made offset by feet? Can someone help?. I use the Arduino IDE 22v and mega1280 .Code is working alright just do not find where made the offset.
Here’s my hexabot
yfrog.com/bhimage081qj

The servo offsets can be stored in the EEPROM of the SSC-32. Couple of ways to do it. If you can hookup the SSC-32 such that it can communicate using the 9 pin RS-232 connector and connect the SSC-32 up to your PC. Then use the program LynxTem, which you can download from Lynxmotion: lynxmotion.com/p-567-free-do … xterm.aspx

With Lynxterm talking to your SSC-32, you can move all of the servos, now click on the “Reg.” button. Here you can read in the current registers including the servo offsets. You can then adjust the different values here until things are properly aligned and you can away the correct servo offsets. This process is explained in the tutorial: lynxmotion.com/images/html/build159.htm

The other way is if I port over the code I have in some other some servo offset code I have on some other platforms. On some other platforms I have some debug monitor code that in the main code loop checks for keyboard input and then I have a command that does some servo offset setting code. Could easily do it here as this uses a USART for the serial port so little overhead to check to see if some pending characters exist… Maybe if I have some time soon, I will play some more with this.

Kurt

O.K. I know it. I mean the Arduino program. Because I have only one way communication. Arduino -> ssc32 through blutuf. all hardware is home made. I have done is offset in the ssc32. but when the I start Arduino software offset is not working.
Maybe it possible write offset in to the atmega 1280 eprom?

I was curious if the current code would work on build 22 so today I hooked up the Seeeduno Mega back up to my CHR03 with XBee. I used the default serial library (did not have write caching) and the program worked fine. May add the caching back in or not…

But I was curious about updating my servo offsets so I ported over a simple debug monitor from my Arduino Brat program and started an servo offset mode. I have the code in place but not yet tested… But then I wondered if it would be simple enough to write a SSC-32 forwarder mode that simply forwords anything I receive on the USB serial port to the SSC-32 serial port and vise versa. It was a piece of cake as both are running on uarts. I then was able to use Lynxterm to update the servo positions, without having to update the wiring… The forwarder looks like:

[code]void SSCForwarder(void)
{
int sChar;
int sPrevChar;
Serial.println(“SSC Forwarder mode - Enter $ to exit”);

for (;;) {
    if ((sChar = Serial.read()) != -1) {
        SSCSerial.print(sChar & 0xff, BYTE);
        if (((sChar == '\n') || (sChar == '\r')) && (sPrevChar == '$'))
            break;    // exit out of the loop
        sPrevChar = sChar;
    }
    

    if ((sChar = SSCSerial.read()) != -1) {
        Serial.print(sChar & 0xff, BYTE);
    }
}
Serial.println("Exited SSC Forwarder mode");

}[/code]

I updated the zip file with the current stuff in case anyone wishes to play with it
Arduino Phoenix.zip (53.2 KB)

That could be useful!

But that’s the mega, with multiple USARTS? I have UNO.

Alan KM6VV

Yep, it is nice to have multiple (4) usarts. The UNO is like the BAP28 with just one USART and their software serial library does not do any input caching so it would be more difficult… You could probably hack in this type of capability as I know some other libraries for ATMegas use timer interrupts and the like to emulate a hardware serial port…

Kurt

code works nice. remained fix up the master blutuf.slave module fixed. I Found the problem in the level of data 5v> 3v and 3v > 5v. I using BTM-222 modules. youtube.com/watch?v=BfyhbcKKhbE

Nice Hexapod man!
Do you mind to tell me how you wire up your board(Arduino,ssc32 etc) and the code you use?
Currently I want to move my hexapod to arduino but having diffeculty to get it to work:

Much appreciated if you could help :slight_smile:

arduino mega 1280 + PS2 GAME PAD >tx1 rx1> btm-222(MASTER) BTM-222(SLAVE)> RX TX >SSC32

The final version of the code contains an error. If two or three times click a R3 the program and controller stops working.

While Xan is having fun merging the code bases for T-Hex, I thought I would play a little more with the Arduino code. Up till now I have only tried to make the code work with an Arduino Mega as it has lots of IO pins and lots of Uarts and the like. But I wondered, could this work with a normal Arduino? I quickly decided to only try to make it work with the newer Arduinos that are Atmega328 based Arduinos. The 328 gives me 32K code space and 2K data. The 32K for program space appeared to be enough so I started and I ordered an Arduino UNO.

On the Mega I relied on the multiple UARTS (1 for USB, 2nd for SSC32, 3rd XBee if I built for XBee). With the UNO I had 1 (USB). So I first looked at using SoftSerial library for SSC-32, but it’s documentation said good up to 9600 baud (ick). But I found a contributed Library NewSoftSerial, which appears to work at much higher speeds. In addition it use the hardware Pin Change interrupt to start inputs and it caches the characters received ( :slight_smile: ) So I went with that.

Very quickly I was able to get the code to compile and link, but when I tried to run it, it died very quickly and randomly. using avr-objdump to dump the executable, I found I was exceeding the 2K data. With the AVR GCC compiler it turns out that defining data tables as const static did not put the table into code space like it did for H8 compiler… So I converted to using the PROGMEM keyword and updated each of the usages for these tables to get it from the program space. I actually updated them twice as the first way made it look less readable. Example: change
cCoxaMin1[LegIndex] to pgm_read_word(cCoxaMin1 + LegIndex) [This is the way the documents for PROGMEM showed how to do this…]
Which to some could be confusing as the compiler knew that cCaxMin1 was an array of words so when it added LegIndex to it, it actually added 2*LegIndex… , but it turns out, you can also do it like: pgm_read_word(&cCoxaMin1[LegIndex])
Which I like better… This cut down the memory back to something that works!

The Mega has 8K of data, so I could be sloppy and when doing SSC or Debug output I would call a function with an 80 byte buffer which did sprintf and then output to the device. I wanted to get away from this, so I also included the Streaming utility library, which allowed you to not have to type as much:
That is if before in C you were to do something like:
printf(“XBee DL: %x\n\r”, wDL);

In Arduino you might do:
DBGSerial.write("XBee DL: ");
DBGSerial.println(wDL, HEX);

With Streaming you can do:
DBGSerial << "XBee DL: " << _HEX(wDL) << endl;

So today I connected up the Ardino UNO up to my CHR-3 with a PS2 and the SSC-32 at 115200 and it appears to work. I have not tried it yet with XBee and I have not tried this updated code back on MEGA yet. Lots more testing needs to be done, like running a sequence appears to run the sequence and either resets or turns hex off… Will debug…

But in case anyone wants to play along, I have uploaded the archived version (build 22 of Arduino).

Warning: This is a work in progress…
Arduino_Hex-110416a.zip (37 KB)

Here is a quick and dirty video showing it running on the CHR-3. Please pardon that the CHR-3 has wires hanging off everywhere as this robot gets pulled apart often… Also that the video was taken in the Attic with box’s and the like sitting around…

Kurt

Looks good Kurt!

Is that with the UNO board?

Alan KM6VV

Yes, that is with the Arduino UNO, SSC32, Lynxmotion PS2, Radioshack speaker for sound.

thanks Kurt,

Compiles, after I found streaming.h and NewSoftSerial.

Now to get something wire up.

Alan KM6VV

Hi Kurt, great work!
I did post a comment on your youtube too, but its probably better to do it here.
I like the moves you do at 00:29 - 00:32. What exactly do you do there? A body rotation and lower body to ground and then up again? Very cool though! :smiley:

Thanks,
Thanks Zenta,
I am not sure what I did to get it to rotate like that on the ground, but I thought it looked pretty good, especially since it is running on an Arduino with PS2 as input…

Alan: Sorry I should have mentioned more about where to download those libraries from. They are mentioned in the contributed libraries of their HTML documents…

Kurt