i am really new to Arduino and programming at all. I got a Pan-Tilt Unit-D46-70 (http://www.flir.com/mcs/view/?id=53712). I can tilt and pan the device without any problem using the serial interface via rs232.
Now i had the idea to create a little arduino sketch to use a Saintsmart LCD keypad shield to use it to tilt/pan the device in a certain time (to make timelapse recordings with dslr). I wrote a sketch wich sends the commands needed to move the pan/tilt thing.
But now i need to send these commands not to the serial interface of the arduino app, but to a real rs232 interface.
What hardware and software do i need, to send these commands to a “real” rs232 interface?
Thanks a lot!
PS.: here is the sketch, but like i said: i am really new to programming! Everything which is “Serial.print…” should be send to the rs232 interface… (attachment…)
PPS.: please tell me how to make the code “better” it looks waayy too long, but for now it works…
v1_menu.ino (10.6 KB)
Look for devices like the Maxim MAX232.
thanks! is this what i am looking for? -- http://arduino.cc/en/Tutorial/ArduinoSoftwareRS232
Looks good to me as a place to start
Nice! But there is something i do not understand:
if i want to send something to the serial device, is there something like a handshake needed? I have no idea how to convert my serial.print() to "write.to.rs232"
So in short: is every RS232 device communicating the same way (besides the baudrate)? Or are there differences? If yes, how do i find that out?
Or is there a library i can use for that?
PS.: btw, thanks for moving the topic to the right subforum!
You'll need to check the specification of the device you're connecting to.
Things to look for are:
Number of data bits,
Number of stop bits,
Parity (odd, even, none)
Flow control (hardware or xon/xoff).
Are you using an UNO?
You can use Serial.print(ln) instructions.
If the Arduino is the DTE device, you may need to set RTS and/or DTR.
If the Arduino is the DCE device, you may have to set CTS and/or DSR.
Pololu makes a very versatile adapter for RS232, that provides hardware handshaking signals and generates the proper RS232 voltages (-12 and 12 V) from either 3.3 V or 5 V power: Pololu 23201a Serial Adapter Partial Kit
For interfacing with genuine RS232 devices, you really need to know what the device expects. In addition to the basic baud rate, handshaking can be in software (with start and stop transmission characters) or hardware -- involving any of several different control lines (RTS, DCD, DTR, etc.). There can be different numbers of bits per character (7 or 8 are common) plus possibly a parity bit, which can be even, odd or none. Finally, there can be 1 or 2 stop bits.
is every RS232 device communicating the same way (besides the baudrate)? Or are there differences?
There can be extensive differences, including complex communications protocols and data packaging. In this case, it looks like you're in luck and the interface is very ordinary, and uses plain text for most of the commands. From the FLIR manual:
An RS-232 terminal or host computer connects to the female DB-9 connector on the Pan-Tilt Unit Controller (PTU-C). The host terminal or computer should be set to 9600 baud, 1 start bit, 8 data bits, 1 stop bit, and no parity. Hardware handshaking and XON/XOFF are not used.
From computer networking, you get the concept of "layering." At the bottom "physical" layer, you have the allowed voltages levels and such. This is different between the arduino ("TTL serial") and "real rs232" as used by your PTU, which is why you need that "adaptor" board or chip (the common max232.)
At the next layer you have the "data link layer" which describes the formats of bits and bytes and flowcontrol and stuff. These happen to be the same for arduino serial ports and the PTU. Then there are a bunch more layers, which in this case are pretty minimal and amount to "send text commands." (arguably, the "commands are composed of ascii text strings ending with a delimiter" is a separate layer than "The H command halts all movement.")
Wow! Thank you so much for your help!
So its probably pretty easy to get this working! I just ordered a max232 and some capacitors... ill see what i can do! It would be a great tool if it works!
There's also the max233, which doesn't need external capacitors (well, maybe a decoupler).