0
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« on: April 27, 2011, 08:40:08 am » |
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(){ Serial.begin(9600); }
void loop(){
Serial.print('254', DEC); Serial.println('108', DEC); digitalWrite(ledPin, HIGH); delay(500); Serial.print('254', DEC); Serial.println('100', DEC); digitalWrite(ledPin, LOW); delay(500);
}
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) (etc...)
If anyone has any thoughts, please let me know! I'm perplexed!
Thanks, Jason
|
|
|
|
|
Logged
|
|
|
|
|
Sussex UK / CT USA
Offline
Edison Member
Karma: 0
Posts: 1026
Forums forever
|
 |
« Reply #1 on: April 27, 2011, 09:36:22 am » |
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... Details... http://sheepdogguides.com/arduino/art4SeIntro.htm
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #2 on: April 27, 2011, 09:41:32 am » |
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!
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 10
|
 |
« Reply #3 on: April 27, 2011, 10:07:49 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #4 on: April 27, 2011, 10:26:12 am » |
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...?
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 10
|
 |
« Reply #5 on: April 27, 2011, 10:37:33 am » |
Try sending the value without the single quotes:
Serial.print(254, BYTE);
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #6 on: April 27, 2011, 05:05:48 pm » |
joec - just tried that, with various combos of print/println, and no still no luck!
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 10
|
 |
« Reply #7 on: April 27, 2011, 05:25:22 pm » |
That really should work, Serial.print(254, BYTE); should emulate the VB function MSComm1.output = Chr$(254); that they use in their documentation examples.
To Send ASCII 254 from Visual Basic, you will use the following line: MSComm1.Output = Chr$(254)
In Qbasic, you can send ASCII 254 using the following line of code: 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.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #8 on: April 28, 2011, 10:05:28 am » |
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!
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 10
|
 |
« Reply #9 on: April 28, 2011, 11:31:29 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Sussex UK / CT USA
Offline
Edison Member
Karma: 0
Posts: 1026
Forums forever
|
 |
« Reply #10 on: April 28, 2011, 12:05:54 pm » |
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... http://www.arunet.co.uk/tkboyd/ec/ec1ser232.htm
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 50
Posts: 6538
Arduino rocks
|
 |
« Reply #11 on: April 28, 2011, 01:25:49 pm » |
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);
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 21
|
 |
« Reply #12 on: April 28, 2011, 03:47:40 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 1
|
 |
« Reply #13 on: April 28, 2011, 04:48:23 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
|