Hello,
what can I do to make my arduino Uno a RS232(serial) host? Is it just to build the TTL-Serial to RS232-Serial converter used on the Arduino serial and then transmit and send as usual?
Jan
Hello,
what can I do to make my arduino Uno a RS232(serial) host? Is it just to build the TTL-Serial to RS232-Serial converter used on the Arduino serial and then transmit and send as usual?
Jan
s it just to build the TTL-Serial to RS232-Serial converter
Yes I use a MAX202 but there are lots of others
So I don't need to do any other things like handshake etc.?
Jan
Excuse me; I want to control an Intellibox IR http://www.uhlenbrock.de/GERMANY/download/1/english/I96EEA64-016.apd/Bes65050e.pdf with an ardunio over RS232 serial. As I can see it I will need the following:
Baudrate: 2400/4800/9600/19200
Startbits: 1
Stopbits: 2
Databits: 8
Paritybit: none
Handshake: RTS and CTS
So this looks to me like handshake in both directions. But how do I connect the handshake and what do I need to implement in the code?
Jan
Thanks for the fast answer, but was is DTE and DCE?
I already thought something like what I need some level converters.
Jan
The document says (on page 34) that it look like is DCE, it not using DTR signal.
Richard: Ok i think that help some.
BillHo: DTR? Now what's that? Is that another sort of handshake?
DTE is the same as a PC port or in this case arduino,
DCE is a device attached to a DTE
DCE is what the intellibox is wired as
1 is Data Carrier Detect internally tied to 6 and 4 not used
2 is RX and goes to TX on PC/arduino
3 is TX and goes to RX on PC/arduino
4 internally tied to 6 and 1 not used otherwise
5 ground is tied to the PC/arduino
6 internally tied to 1 and 4 not used
7 not used
8 is CTS and tied to CTS on PC/arduino
The default settings of the serial interface are as follows:
Speed: 2400, 4800, 9600 or 19200
Start bits: 1
Stop bits: 2
Data bits: 8
Parity: none
Handshake: hardware, RTS-CTS
Marklin protocol
http://home.arcor.de/dr.koenig/digital/motorola.htm
On the uno reference board you can remove the two resistors hooking the usb chip to the TX/RX lines and hook those and which ever pin will be CTS to the TTL to RS-232 device. I do not know how you can keep the USB device connected and still use tx/rx to communicate with the intellibox.
Could someone please make me a schematic and perhaps some source code for how to use CTS? Please?
Jan
Would this be a good/ok schematic for adding a half universal RS232 host to an arduino?
Arduino_Tx should be connected to the Tx pin of the arduino,
Arduino_Rx should be connected to the Rx pin of the arduino,
Arduino_CTS should be connected to a Digital pin of the arduino,
Arduino_RTS should be connected to another Digital pin of the arduino.
You can use jumpers to set if you want to use RTS and/or CTS.
Can anyone see anything wrong?
Jan
One more question: How many Start/Stop/Parity bits does the Standard serial port on the Arduino use? Because if it doesn't use the same number i think It could make problems.
Jan
JanD I can't spot a fault. Now it would just be coding I think. The image is kind of busy so it's hard to read but looks as if there is an sch file behind it?
Grumpy
New soft serial seems to have it but ____ if I can find it.
> Configurability, i.e. “E, 7, 1[ch8243] style parity, data and stopbit configuration.
http://arduiniana.org/2009/05/direct-port-io-in-newsoftserial-9/
void NewSoftSerial::write(uint8_t b)
{
if (_tx_delay == 0)
return;
activate();
uint8_t oldSREG = SREG;
cli(); // turn off interrupts for a clean txmit
// Write the start bit
tx_pin_write(_inverse_logic ? HIGH : LOW);
tunedDelay(_tx_delay + XMIT_START_ADJUSTMENT);
// Write each of the 8 bits
if (_inverse_logic)
{
for (byte mask = 0x01; mask; mask <<= 1)
{
if (b & mask) // choose bit
tx_pin_write(LOW); // send 1
else
tx_pin_write(HIGH); // send 0
tunedDelay(_tx_delay);
}
tx_pin_write(LOW); // restore pin to natural state
}
else
{
for (byte mask = 0x01; mask; mask <<= 1)
{
if (b & mask) // choose bit
tx_pin_write(HIGH); // send 1
else
tx_pin_write(LOW); // send 0
tunedDelay(_tx_delay);
}
tx_pin_write(HIGH); // restore pin to natural state
}
SREG = oldSREG; // turn interrupts back on
tunedDelay(_tx_delay);
}
This is the original write function from New soft serial. If I see it right the start bit is set with
// Write the start bit
tx_pin_write(_inverse_logic ? HIGH : LOW);
tunedDelay(_tx_delay + XMIT_START_ADJUSTMENT);
Before that the interrupts are turned of. Then i think the if...else... statement is to do the actual sending and then the interrupts are turned back on. But I can't find any thing for the start and stop bits. But I think that it should be possible to just add
tx_pin_write(HIGH);
tunedDelay(_tx_delay);
to write an serial 1 and
tx_pin_write(LOW);
tunedDelay(_tx_delay);
to write an serial 0.
Has anyone here also read my http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1289849547 thread about 9-bit serial? Shouldn't it be easy to just add an if...else... statement to check if the ninth bit is high or low and write it? Would this version of the write function do that?:
void NewSoftSerial::write(uint8_t b, boolean bit9)
{
if (_tx_delay == 0)
return;
activate();
uint8_t oldSREG = SREG;
cli(); // turn off interrupts for a clean txmit
// Write the start bit
tx_pin_write(_inverse_logic ? HIGH : LOW);
tunedDelay(_tx_delay + XMIT_START_ADJUSTMENT);
// Write each of the 8 bits
if (_inverse_logic)
{
for (byte mask = 0x01; mask; mask <<= 1)
{
if (b & mask) // choose bit
tx_pin_write(LOW); // send 1
else
tx_pin_write(HIGH); // send 0
tunedDelay(_tx_delay);
}
tx_pin_write(LOW); // restore pin to natural state
}
else
{
for (byte mask = 0x01; mask; mask <<= 1)
{
if (b & mask) // choose bit
tx_pin_write(HIGH); // send 1
else
tx_pin_write(LOW); // send 0
tunedDelay(_tx_delay);
}
tx_pin_write(HIGH); // restore pin to natural state
}
//Write the ninth bit
if(bit9 == true) //choose bit
tx_pin_write(HIGH); //send 1
else
tx_pin_write(LOW); //send 0
tunedDelay(_tx_delay);
SREG = oldSREG; // turn interrupts back on
tunedDelay(_tx_delay);
}
Would this work? And how should I modify the read function?
Jan