Serial communication

Hi Everyone,

I am using an Arduino mega to send serial data to a controller that has 7 flip dots connected to it (like the signs in railway stations). The lead bit must be 0. So to turn them all on I should send the following: 01111111

I am using the following code:

Serial.begin(9600); byte on =B01111111; Serial.write(on);

When I do this it only turns on the first flipdot so it thinks it has received: 00000001

I'm 99% sure that the controller works fine as I have had it working not on an Arduino. I have tried quite a lot of values, so here is a list of what I send and what it thinks its receiving:

Sent Received 00000001 01111111 00000010 01111101 00000011 00111111 00000100 01111100 00000101 01011111

There seems to be a patter, some of the sent and received add to 128 and some of them seem to be the inverse. Any suggestions on what is going wrong would be greatly appreciated.

Thanks, hal

Make sure the serial controller is expecting bits at TTL levels and not RS232. If it is expecting RS232 these are not only different voltages but are also upside down. This leads to the receiver missing the start bit and hence bits being shifted and also most bits are upside down.

Hi,

It is expecting RS232. Is there a way for me to send RS232 format from the arduino? Or could you point me towards some documentation that would allow me to sort it out.

Thanks a lot, hal

think you need something like:

http://www.electronics-lab.com/blog/?tag=max232 or http://www.sparkfun.com/commerce/product_info.php?products_id=449

http://www.sparkfun.com/commerce/product_info.php?products_id=449

Thanks guys, that's great. I wasted so much time thinking it was some kind of logic error! hal

It might not be too awful just to drive one of the Arduino's digital outputs "by hand" for this application?

Regarding the inverting... if you are using someone else's circuit to achieve the necessary different voltage levels, you might find that it is doing the inverting at the same time.

See....

http://wulfden.org/TheShoppe/pa/index.shtml#P4

for a TTL to RS-232 adapter, $7 / $11 kit/assembled, inc p&p