RS232 serial Data not sending

Just want to hang out with other Makers and chat about stuff? This is the place to do it.
Post Reply
madScientist001
Posts: 1
Joined: Mon Aug 10, 2015 1:37 am

RS232 serial Data not sending

Post by madScientist001 » Mon Aug 10, 2015 2:58 am

Hello to all!

I just got my first arduino uno board 2 months ago and have been progressing quite well until now. I've spend the last month trying to troubleshoot why my arduino board is not sending serial commands over RS232 to a card dispenser device. The card dispenser uses RS232 to control it. I have a arduino Uno and a linksprit RS232 shield with a MAX3232 chip. Starting simple I'm just trying to code the Eject Front command shown below under command structure. The device receives ASCII codes. According to the device manual it reads:

Communication Protocol:
Baud rate(BPS): Can be set by controller(Default at 9600BPS)
Communicate Mode: Asynchronous communication
Transmit mode: Half duplex
Data frames structure: Start bit: 1bit
Data bit:8bits
A Check Bit: No
Stop Bit:1bit

Command Structure:
Eject Front command
<STX>15FC<ETX> <BCC>
<STX> : 0 2 H , Frame start
<ETX> : 0 3 H , Frame end
<BCC>: <STX> ⊕ O ⊕ O ⊕ O ⊕ O ⊕ <ETX> ,Block checkout

I've written the code below in HEX only because I'm confused on how to send the start and end frame in ASCII. Also because I listened to the communication between the device and PC and matched the HEX commands but the code send should be ASCII according to the manual.

#include <SoftwareSerial.h>

SoftwareSerial deviceSerial(6, 7); // RX, TX

void ejectFront();

void setup() {
Serial.begin(9600);
deviceSerial.begin(9600);
}

void loop() {
ejectFront();
}

void ejectFront() {
deviceSerial.write(0x02);
deviceSerial.write(0x31);
deviceSerial.write(0x35);
deviceSerial.write(0x46);
deviceSerial.write(0x43);
deviceSerial.write(0x30);
deviceSerial.write(0x03);
deviceSerial.write(0x30);
}

Thank you for taking your time to read this.

effgee
Posts: 64
Joined: Tue Aug 07, 2012 2:41 am

Re: RS232 serial Data not sending

Post by effgee » Tue Sep 22, 2015 6:41 am

why use softwareserial when you have 4 hardware uarts ? https://www.arduino.cc/en/Reference/Serial

Hardware serial will always be more reliable, some devices are fussy about exact timings, which software serial can't provide, especially depending what else your program is doing.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: RS232 serial Data not sending

Post by angusgr » Thu Sep 24, 2015 4:55 am

This looks like it should work to me, at a glance. Can you ask the card dispenser vendor for any feedback on the code?

Regarding soft vs hard serial, I think SoftwareSerial is the right approach if you're using an 'uno'-compatible board. An Arduino Mega compatible (like the EtherMega) has 4 UARTs but Uno-compatible (like Freetronics Eleven) does not.

I'm going to move this thread out of the EtherMega forum though, as I think that's what caused the confusion.

Post Reply