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

Hi kurte,

I’ve changed your code, the streaming-lib and the ps2x-lib for compiling on the new Arduino 1.0.

file-server.servemp3.com/download/Streaming.zip
file-server.servemp3.com/download/Arduino_Hex.zip
file-server.servemp3.com/download/PS2X_lib.zip

SoftSerial is now included in the normal Arduino build (Release Notes).

Sounds great. I keep hearing about Arduino 1.0, but all I see up on your release notes is build 0023… Is there a difference? I downloaded 23, but it looked like from the release points that they simply added some new board definitions…

Thanks again

Kurt

Edit: I see that the official 1.0 was released since I last looked (yesterday), now downloading…

A quick update, I am starting to move all of my stuff to the new release. I have not tried the Phoenix on it yet, but I did find the PS2X_Lib that was posted above was with the older version which is not interrupt safe and causes problems if you use servos…

So here is one that should work.

Kurt
PS2X_lib.zip (15.3 KB)

Is it intentional that at line 1457 of Arduino_Hex still stands 1059 in place of cPwmDiv?

Looks like a bug to me… Thanks
Kurt

And what about make code for UNO32 or MAX32
digilentinc.com/Products/Detail. … PKIT-UNO32

Funny you should mention that. I do have it compiling on their MPIDE (Test build from 1123) and will try it out very soon with the UNO32.

I will be honest and say I don’t know how much interest there is in this, as I get very little comments or suggestions up on the chipKIT.cc forum. Example: The PS2X_lib plain did not compile nor work, which I use as the default controller with the Phoenix code. I believe I now have it working and I posted this last Wednesday up on their site with updated code, which FYI does fast digitalReads and Writes… So far there have been no comments and no one has downloaded the zip file…

Other issues with the chipKits:
SoftwareSerial: Is currently not ported over to it. There is some version up there that is very rundimentary, Should be completely reworked to be more like the Software Serial of Arduino 1.0 (was NewSoftserial beta, I mentioned earlier).

digitalWriteFast/digitalReadFast: There has been an attempt, that there is one report that write is working but read is not…

Pin Change Interrupt and Pull-up resistors: First off not all IO pins have PU resistors. If I read the Pic32 manual correctly there are some that do, which is the same ones that support Pin Change Interrupts. Documentation is unclear to me, but I think I could figure some of this out. But regardless on nornal Arduinos, you can do something like: pinMode(2, INPUT); digitalWrite(2, HIGH); and this will make pin 2 an input pin with the PU resistor enabled. On Uno32, this does not do that, it first makes the pin input, but than the digital write probably puts the pin into the output state with a high value… Also I have not seen any examples if anyone has tried out the pin change interrupts…

Enough winning :laughing: - It still would be fun to see how well it runs on a 32 bit 80mhz processor that is somewhat compatible. Hopefully in the next day or so, I will know.

Kurt

Again not sure if anyone is interested, but:

I think I now have the Phoenix code running on the chipKit Uno32 with the SSC-32. When I first was trying it out, it was tying the servos up in knots, but finally traced it down to the GetArcCos function. It appears the reading of the byte table with PGM_READ_BYTE was returning a signed value instead of an unsigned value which got propagated up to the signed long value used in the function. Need to add some casting of the byte to (byte) and now things are working a lot better! :smiley:

Kurt

Kurt,

I’m interested, and I’ve got boards for the task. I have a pre-Phoenix 'bot that could use an upgrade. Maybe order the Phoenix parts!

Alan KM6VV

Hi Alan,

Next step is to make it all compile as one code base for Arduinos, Arduino Megas, and the chipkit… I think the version I have is pretty close, but still need
to do things like conditionally include Arduino.h versus WProgram.h depending on which version of Arduino you are running.

As I think I have mentioned, my testing is being done on what I call my TH4-R hex robot. Started off life as a CH3-R, has gone through several different leg configurations, currently a T-Hex 4DOF leg. So should handle most Lynxmotion robots, by setting up the appropriate configuration information.

Kurt

Hi Kurt,

Making your code conditionally compile for Arduinos, Arduino Megas, and the ChipKIT would be a great way to go!

I would very quickly take advantage of the additional serial (real hardware) ports on the Mega. I also have the Mega, and it looks like I will use the extra serial port to talk to a Wheel Commander.

Alan KM6VV

Hello, you have a schematic to connect the ese32 with arduino and code?

I have a Phoenix with PS2 controller and I want to replace the BASIC Atom Pro with arduino.

Thanks
Dimos

hi kurt,
can you explain to me how do I declare the SSC32 servo pin?

thanks
khalid

They are defined in the file hex_cfg.h

In the section:

[code]#define cRRCoxaPin 0 //Rear Right leg Hip Horizontal
#define cRRFemurPin 1 //Rear Right leg Hip Vertical
#define cRRTibiaPin 2 //Rear Right leg Knee
#define cRRTarsPin 3 // Tar

#define cRMCoxaPin 4 //Middle Right leg Hip Horizontal
#define cRMFemurPin 5 //Middle Right leg Hip Vertical
#define cRMTibiaPin 6 //Middle Right leg Knee
#define cRMTarsPin 7 // Tar

#define cRFCoxaPin 8 //Front Right leg Hip Horizontal
#define cRFFemurPin 9 //Front Right leg Hip Vertical
#define cRFTibiaPin 10 //Front Right leg Knee
#define cRFTarsPin 11 // Tar

#define cLRCoxaPin 16 //Rear Left leg Hip Horizontal
#define cLRFemurPin 17 //Rear Left leg Hip Vertical
#define cLRTibiaPin 18 //Rear Left leg Knee
#define cLRTarsPin 19 // Tar

#define cLMCoxaPin 20 //Middle Left leg Hip Horizontal
#define cLMFemurPin 21 //Middle Left leg Hip Vertical
#define cLMTibiaPin 22 //Middle Left leg Knee
#define cLMTarsPin 23 // Tar

#define cLFCoxaPin 24 //Front Left leg Hip Horizontal
#define cLFFemurPin 25 //Front Left leg Hip Vertical
#define cLFTibiaPin 26 //Front Left leg Knee
#define cLFTarsPin 27 // Tar[/code]

Note: Like all the 2.1 versions of the code, the Tar pins are only used if you define that you are using 4 degrees of freedom…

Kurt

I too am interested. Just got my chipkit UNO32 and have been figuring it out. I want to put it on my hex with SSC32:)
Thanks all for sharing i have been learning a lot studying the different versions of code.

Hello, can you tell me which file to use to upload to an arduino uno code for Phoenix with SSC32 and PS2 controller?

Thanks
Dimos

I need to look to see what versions are up here now… IE, did I upload a version yet that runs on Arduino 1.0? I have been working on a cleaned up/stripped down version for the BotBoardDuino, that only has the files in it to using the SSC-32 plus PS2. The version I have been testing it on is configured for a CHR-3, but can be configured for Phoenix by changing the configuration information. I have been doing some cleanup in this version of the code that I would then like to merge back into my master version that also has XBEE and on Mega’s or Chipkits can also run the servos on the actual processor. But that may be a little while before I upload that version…

So hopefully soon will have a full setup up here again.

Kurt

Thank you very much kurte, I will wait for your code.

I am still doing some cleanup and rearranging code. Things like trying to add more scoping of variables into the code. Creating classes for the Input controllers and for the Servo Drivers… Still very much a WIP.

I split off the code to start this off, where it is specific to the BotBoardDuino, Using an SSC-32, with a PS2 controller and is configured for a CH3-R type Hex. For other Round Hex robots, you will probably simply need to play with the configuration file (Hex_Cfg.h) and probably update the sections:

//-------------------------------------------------------------------- //[LEG DIMENSIONS] //Universal dimensions for each leg in mm #define cXXCoxaLength 29 // This is for CH3-R with Type 3 legs #define cXXFemurLength 57 #define cXXTibiaLength 141 #define cXXTarsLength 85 // 4DOF only...
And the Initial position:

//[START POSITIONS FEET] #define cHexInitXZ 80 #define CHexInitXZCos60 40 // COS(60) = .5 #define CHexInitXZSin60 69 // sin(60) = .866 #define CHexInitY 80 //30

You can get some pretty good estimates for the Leg information from an output file generated by Powerpod…

[code];****************************************************
; 3DOF-A Leg Dimensions (TibiaAngle constant = 0)
;HipV_HipH con 38 ;1.50" = 38mm (1.50 * 25.4)
;Femur_Length con 57 ;2.25" = 57mm (2.25 * 25.4)
;Tibia_Length con 124 ;4.875" = 124mm (4.875 * 25.4)

; 3DOF-B Leg Dimensions (TibiaAngle constant = 0)
;HipV_HipH con 29 ;1.14" = 29mm (1.14 * 25.4)
;Femur_Length con 57 ;2.25" = 57mm (2.25 * 25.4)
;Tibia_Length con 108 ;4.25" = 108mm (4.25 * 25.4)

; 3DOF-C Leg Dimensions (TibiaAngle constant = 20)
;HipV_HipH con 29 ;1.14" = 29mm (1.14 * 25.4)
;Femur_Length con 57 ;2.25" = 57mm (2.25 * 25.4)
;Tibia_Length con 141 ;5.55" = 141mm (5.55 * 25.4)

; 3DOF-(Old) Leg Dimensions (TibiaAngle constant = 0)
;HipV_HipH con 32 ;1.25" = 32mm (1.25 * 25.4)
;Femur_Length con 70 ;2.75" = 70mm (2.75 * 25.4)
;Tibia_Length con 108 ;4.25" = 108mm (4.25 * 25.4)
;****************************************************[/code]

Would also like to get a configuration file set up for Phoenix, (But I don’t want to mess with my Arc32 phoenix… ).

But if anyone else starts to play with this and sets up a good configuration, it would be great if you shared :smiley:.

In this cleanup of code, I believe I have removed many of the external library references I was using before. Some of it made it nicer to code, but thought I should reduce it. However this code is still very much reliant on the PS2X library (billporter.info/playstation- … rary-v1-0/)

Note: While maybe not necessary, there were some fixes/enhancements that went into the PS2x code this week, that you may want to get. You can download from GitHub (github.com/madsci1016/Arduino-PS2X).

Kurt

P.S - Again this is a WIP so expect things to change. I will now work on merging this back into my older version such that I have the Non-SSC-32 version, Plus XBee, plus…
BotBoardDuino_CHR3_PS2-120413a.zip (29.1 KB)

Do you think this code would work on a Teensy? … since its tiny!?

I’d totally buy another teensy if thats the case… or is it missing a key feature some of the larger arduinos requires?

–Trouble maker…err Aaron.