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

Quick Update: I updated to the lated PS2 library and verified that the PS2 still works.

Kurt
Arduino Phoenix.zip (50.9 KB)

Thanks for the tips!

I’ve got code running on the UNO now for the HBRobotics 'bot (incomplete).

And after I get a state machine for the obstacle avoidance ported over, I should be in good shape.

I have CVavr, if I can get it moved off of an old laptop. But the little UNO has a boot loader and USB built-in, so it’s good for a simple project like this.

The AtomPro would have been easier. the ARC-32 would be really nice to use, but the UNO is $30 vs $100. Oh well.

Alan KM6VV

Hi Kurte,

can you explain me how to connect SSC32 with Arduino?

Thaks!!!

Note: I am using an Arduino Mega (actually mostly the seeeduino version…). So I simply connect up the 3 TTL pins of the SSC-32 (same ones you connect something like the BB2 to). I choose one of the serial ports to use (in my case 1):
#define SSCSerial Serial1

I use a servo extension wire, I use a longer one. I plug the one end into the SSC-32. I take the longer Male/Male connector that comes with the servo extender cable, I pull one of the pins out of it and stick it into one of the ground pin (female connectors on the Arduino), I plug the other two into the Recv and transmit pins of Uart1, I plug the appropriate wires coming from the SSC-32 into the Arduino pins I put the pins into…

Code wise, I then simply: Initialize the serial port.
SSCSerial.begin(38400);

I then use the standard serial communications to the SSC-32. Example here is the function to see if the SSC-32 supports GP…

[code]boolean FIsSSCGPEnabled(void)
{
char abVer[40]; // give a nice large buffer.
byte cbRead;
SSCSerial.print(“ver\r”);

cbRead = SSCRead((byte*)abVer, sizeof(abVer), 10000, 13);

DBGPrintf("Check GP Enable - cb %d\r", cbRead);
if (cbRead > 0) {
    byte iT;
    for (iT = 0; iT < cbRead; iT++)
        DBGPrintf("%2x ", abVer[iT]);
    DBGSerial.write((byte*)abVer, cbRead);
}
    
if ((cbRead > 3) && (abVer[cbRead-3]=='G') && (abVer[cbRead-2]=='P') && (abVer[cbRead-1]==13))
    return true;

MSound (SOUND_PIN, 2, 40, 2500, 40, 2500);
    XBeePlaySounds(2, 40, 2500, 40, 2500);

return false;

}
[/code]

Note: the SSCPrintf/SSCRead functions mentioned above are quick and dirty wrappers, that in the Printf function, simply uses the vsprintf standard c function to format stuff into a buffer and then uses, the standard serial write method to do the actual write to the SSC-32. Details are in the zip file that was posted.

Kurt

Thank You Kurte!!!

I wont to connect Arduino 2009 for my CH3 hexapod project.
Is it possible connect Arduino 2009 instead of Arduino Mega?

You should be able to. Note: I have not used a non mega, but you should be able to plug the SSC-32 into any two digital IO pins of the Duemilanove and use the SoftwareSerial library, which is part of the standard Arduino library… Note: with software serial you have the same caveats of using the BAP28. That is your code will be sitting doing the transmit until the write is done and if you are not in a read statement and IO comes back from the SSC-32 that IO will be lost…

Kurt

Ok!!!
I want to try to complete my project changing BBII/BasicAtomPro28 with Arduino 2009!!!

Sounds good,

I hope you have the one that is based on a 328 and not the 168 as the 168 only has 16K of memory and 1K of RAM, where the 328 has double each.

In either case, if you are using my code as a starting point, you will probably have to trim things out. I am spoiled with the Mega with 128K of memory and 8K or ram…

Kurt

Edit: Side note, one thing I like about the Arduino stuff versus the Bap basic software, is you can abstract which type of serial (hardware or software) you are using at the start of the program and none of the rest of the program has to change. Except of course where you are using functionality specific to one or the other…

Yes I’ve 328 Atmega on my Arduino 2009!
I’ve also an Arduino UNO that is a new version of Arduino.

Yes I will starting with your code; My goal is use arduino and PS2 controller to move my hexapod.

I’ve another questions: It’s difficoult connect Xbee with BBII in order to use an homemade remote control???
Can you explain me the connection between xbee and BBII?

There is lots of information about this on the thread: viewtopic.php?f=21&t=5447

It is similar to adding it to an Arduino. Like the Arduino the BB2 (with some chip like a Basic Atom Pro 28) runs with it’s IO lines at +5V and the XBee is +3.3V, so you will need some form of voltage conversion. You can use ones from sparkfun (parallax.com/Store/Accessori … fault.aspx)

Most of these (except the more expensive Parallax one) will require you to solder something, like wires or pins or the like. But you will need at least 4 wires (+5v, Gnd, TX, RX) connected to the adapter, maybe a 5th (RTS). You have the choice of connecting the XBee up to any 2/3 IO pins on the BB2. One choice is to use pins 14/15 (assuming BAP), which allows you to use the hardware serial port on the BAP. If you are using RTS line with the sparkfun adapter it is best to connect it to either IO pins 7 or 8 on the BAP28 as these output at a lower voltage…

As for software and the like there is lots of stuff up in the thread I mentioned earlier… Things like hardware serial port or not, issues of using the RTS line with the software serial support of the BAP (You can have the serin command tell the XBee that it does not want any more characters, but the XBee may send up to 2 more characters which the standard serin command will lose). One of the reasons I wrote my own serin command at the time.

Than there are issues/questions for you to decide on protocol and the like between your remote and your robot. Things like are you using the XBee as simple serial replacement or using it in packet mode… Again lots of stuff on the other thread.

Kurt

Thanks Kurte,
29 pages of topics about Xbee!!! :open_mouth:

I use this board to connect Arduino with Xbee:

Looking at your adapter, it says 3.3V on it, so I am taking it your Arduino was running at 3.3v and not 5V? I know that me Seeeduino Megas have a switch to choose which voltage to use. But it also looks like a voltage regulator on it… So maybe it does voltage conversion? Not sure what to tell you here.

Kurt

Hi Kurte,
Arduino 2009 or new Arduino UNO have a 3.3V and 5V pin:

Thanks Jeeg,

I was aware that the Arduino boards can supply a 3.3V… I was just wondering what voltages is this board expecting in on DIN and RTS…

But re-looking at the XBEE board, I now think it is probably fine. That is I missed VIN going into the board. My guess is that you use that pin to connect to the BB2 and that you probably don’t use the 3.3v pin… I can not tell if it has any voltage conversion circuitry or not on the IO pins… Which unit is this one?

Thanks
Kurt

Kurt,

That’s the Arduino UNO. There’s a 3.3v reg on it alright, But I don’t see it going to anything!

Also, schematic shows two 16MHz XTALS, although I only see one on my board. I suspect they’ve realized that one OSC output pin on one uP can feed the OSC input pin on the other…

I’m looking at the “Arduino UNO reference design”.

Alan KM6VV

Is it possible to keep the current code, only the SSC function and PS2?

Not sure what the question is!

There is a PS2 library for the Arduino UNO.

Talking to an SSC-32 is a text string. The pseudo-C code used on the Arduino doesn’t appear to have a fully implemented printf() function, so the strings must be made up peace-meal. Not sure if there is adequate string concatenation either. But the job can be done.

So, some work on the code would have to be done to “port” it to the Arduino.

Alan KM6VV

FYI - you have most of the full set of GCC libraries. So my port of the code that runs in the Arduino environment on an Arduino Mega uses the library function vsprintf to play with. In that code I did some quick and dirty wrapper functions like:

SSCPrintf(const  *format, ...)
{
    char szTemp[80];
   int ich;
    va_list ap;
    va_start(ap, format);
    ich = vsprintf(szTemp, format, ap);
    SSCSerial.write((byte*)szTemp, ich);
    va_end(ap);
}

The code is not very pretty but got the job done.
Kurt

Thanks for the tip. I never really liked vasprintf(), but I suppose in a pinch…

What have you seen of the string concatenation functions?

I did discover that it accepts #define, and full ANSI function prototypes. It’s getting comfortable!

Alan KM6VV