Code works great on the Mega 2560 but not on any other Arduino

Hi:

I can't seem to figure this one out. I have written a program that controls a motor speed controller (the Roboteq AX-3500) and it works fantastic when I load it in the Mega 2560 but when I load it in any of the other Arduinos I have (Duemilanove, Professional and Uno) it does not work at all.

When talking to the motor speed controller all I am doing is setting the output pin High or Low to send 10 bits to the controller. I have tried different pins but none seem to work. However, all the pins I have tried work with the Mega 2560. Again the software is working perfectly with the Mega 2560 but I get nothing happening on the other Arduinos (not even wrong behavior) just no movement at all from the motors connected to the AX-3500.

Any help would be appreciated!

Regards,
Blake

(deleted)

The code was too big to post in the text field so I am attaching as a sketch.

Regards,
Blake

XBee_Receiver_AX_3500.pde (15.3 KB)

It's possible you are running out of RAM. Try changing each case of (things like):

    Serial.print("m1HexSpeedChars[0] = ");

to:

    Serial.print(F("m1HexSpeedChars[0] = "));

That's using version 1.0+ of the IDE. That keeps the string literals in Flash memory. That may or may not help, but it won't hinder.

An interesting thought but somehow I don't think I am running out of RAM. I was able to run the program on an UNO and using print statements view the output values in the Serial monitor and they looks exactly like the output from the Mega.

So it looks like the output is happening but I just get no response from the AX-3500.

// To use the Arduino Uno, or Profesional or other Arduino boards that have only a single 
// UART you will need to set the requied pins as serial rx and tx pins.
//SoftwareSerial mySerial(rx, tx); // Sets up an additional set of rx & tx serial pins (6 & 7)

I don't see where you setup the SoftwareSerial. How do you differentiate when talking to Serial and the Xbee?

Actually I thought that I needed the software serial for a second serial port on the Uno, or professional but I really don't. That is just an old comment I forgot to take out.

I use the one hardware serial port to receive data from the XBee but when talking to the AX-3500 I simply set a single pin High/Low to send the data in the DigitalWrite() function.

bmanncsci:
I use the one serial port to receive data from the XBee but when talking to the AX-3500

Thanks for explaining what the AX-3500 is and posting a link to it. It was very clear it was a motor controller and that everyone who reads this board knows what it is.

bmanncsci:
simply set a single pin High/Low to send the data in the DigitalWrite() function.

It’s a real shame the compiler doesn’t allow for more descriptive names. It would be much easier for others to read your code if it did.

bmanncsci:
I use the one hardware serial port to receive data from the XBee but when talking to the AX-3500 I simply set a single pin High/Low to send the data in the DigitalWrite() function.

Which pin(s) is the XBee connected to?

On both the Uno and the Mega the XBee is connected to the 0(rx) and 1(tx) whcih is the hardware based serial port

So you believe the Xbee is communicating alright? Then is the output pin toggling or not?

Yes the XBee is definitely communicating (i.e. the Arduino is receiving the data from the XBee) I know because I can see the comm light come on on the XBee carrier board and also from running the Serial monitor I can see the incoming data. It just seems like the output to the AX-3500 via the DigitalWrite function is not working but at the same time that also seems to be working from the Serial monitor output. So I am stumped as to what is wrong.

Oh, the DigitalWrite function, not the digitalWrite function, eh? I see. Perhaps some needless confusion there.

Ah, why are you writing this way? And this here:

    if(printLines == true){
      Serial.println(" ");}

Won't that throw timing out?

That gives me a return after printing the output character. It just makes the output in the Serial monitor easier to read. In any case the final version running in both the Mega and the Uno or profesional has that print statement commented out. In the final version the only thing I use for timing is the delay().

I'm thinking it has something to do with the hardware differences between the Mega and the other Arduinos.

Let me put my question another way: why aren’t you using Software Serial rather than rolling your own?