Go Down

Topic: Trouble with Serial and relay board (Read 1 time) previous topic - next topic


Greetings all.
I'm having trouble interfacing an arduino board with a National Control Devices/Control Anything ProXR Relay board.
The ProXR looks for serial commands, in DEC format, such as:

(254, 108) //254=command address, 108=activate relay1, bank1

So, I've tried outputting this data in multiple ways, but haven't been able to get the Arduino to activate, or even be recognized by the relay board. I know I've achieved this in the past by using serout on a basic stamp board without issue.

I've been trying the simplest command sets possible, something like:

int ledPin = 13;

void setup(){

void loop(){

Serial.print('254', DEC);
Serial.println('108', DEC);
digitalWrite(ledPin, HIGH);
Serial.print('254', DEC);
Serial.println('100', DEC);
digitalWrite(ledPin, LOW);


I've tried this with variations, such as:

Serial.print(254, DEC);
Serial.println(108, DEC);

Or no println, just prints, etc. Or with quotations. Or without DEC.
Nothing works. The baud rate is correct, and the relay board functions from it's PC control software without issue.
It has a log which shows each command set being entered on a separate lines, but in the manual, it details the commands codes such as this:

(254, 108)

If anyone has any thoughts, please let me know! I'm perplexed!



Use NewSoftSerial to "create" a second serial port (assuming you're not living in the land of Mega luxury), and "talk" to your device on a serial channel not shared with programming and the serial monitor...




Actually I do have a Mega (I've been testing on it, and a Diecimila), and even using Serial2 (or any other for that matter) didn't improve the situation!


Reading the documentation for the board, I think it wants you to send the ASCII character code for the decimal number therefore I would think the statement:

Serial.print('254', BYTE);

Would be more appropriate.


I just tried replacing DEC with BYTE, and also tried some changes to print/println, but still no luck.
Although the manual states the ASCII character code, it also specifically states in DEC format elsewhere, and in their windows software the log window also indicates it is transmitting as DEC...?


Try sending the value without the single quotes:

Serial.print(254, BYTE);


joec - just tried that, with various combos of print/println, and no still no luck!


That really should work, Serial.print(254, BYTE); should emulate the VB function MSComm1.output = Chr$(254); that they use in their documentation examples.

[font=Verdana]To Send ASCII 254 from Visual Basic, you will use the following
MSComm1.Output = Chr$(254)

In Qbasic, you can send ASCII 254 using the following line of
Print #1, Chr$(254);
Note that sending ASCII character code 254 is NOT the same
as sending ASCII characters 2, 5, and 4 from a terminal program.
Typing 2, 5, and 4 on the keyboard will transmit three
ASCII character codes.[/font]


That was my conclusion as well, which is why this is so frustrating!

I have to have this board done by tomorrow evening, so any other thoughts or suggested would be much appreciated.
Given what the manual says, and the Arduino reference info for Serial.print and Serial.println, this should be working!


If you are using the Serial.print(254, BYTE); construct in your program it should be sending the correct data. If it still doesn't work I would review the hardware connection. It appears the relay board requires an RS232 interface, are you using an RS232 converter shield with your Ardunio. Are you sure your cable is correct, Xmit to Rec and Rec to Xmit. Is baud rate correct? I think you have the software correct, you can verify the Serial.print(254, BYTE); construct by sending Serial.print(65, BYTE); out to your PC, decimal 65 should display as an ASCII 'A' character, unfortunately 254 does not have an ASCII equivilant character so you can't check that very easily.


Try "talking" to the board from a PC, using Hyperterminal or PuTTY, just to see if it is listening. If it won't work that way either, maybe the board is faulty.

You HAVE dealt with the RS-232 vs TTL signal level issues, haven't you?

Need more on THAT?... see...



You need to check the input to the NCD device to see if it accepts ttl or the inverted rs232, and you may need to put a cr/lf on the end of the transmission using something like Serial.println(readString);
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0


Hello - thanks for this recent round of remarks.

@tkybd: I noted testing it form the PC software, and it operates without a hitch.

@zoomcat/joec: I'm using the serial shifter seen here: http://www.sparkfun.com/datasheets/Prototyping/RS232-Shifter-v2.pdf - however with or without it I don't get positive results (powering it with +12V by the way).
The CR issues has had me wondering a few times, but seeing that I've tried various combinations of Serial/print vs Serial.println and nothing changes, well, I've started to rule it out as being the issue.

As far as hardware, I've swapped the wires around (tx/rx) but it doesn't change a thing.


No Termination such as lf/cr are required.  The controller is expecting a real RS 232 input.  The arduino may have a uart output which would need to go through a Max 202 chip to bring the signal to true RS 232 levels and polarity.  This Chip inverts the polarity of the data which may be why this is not working.

Go Up