serial communication between Mega2560 and Intellibox

I have a rather old Intellibox to operate my model railroad.
Now I would like to sent commands to this device from an Arduino Mega 2560.
I bought a RS232 to TTL unit and thought this would suffice to speak to my
IB (Serial1). But it doesn't work.
Is ther anyone who has any experience with sending commands to an IB
from an Arduino board?

Can you post a link to the datasheet or user manual for the IntelliBox?

Also post the program you have been trying and tell us what it actually does and what you want it to do. "Doesn't work" conveys no useful information from which to help you.

...R

You can find the manual at

http://mckinleyrailway.com/downloads/manuals/uhlenbrock/IntelliBox%20Manual.pdf

See section 5.9 (Menu "Interface") and section 10 (The PC interface).

The used protocol/language is p50X, descibed in several pdf-files.

I have a very 'simple' wish: when I type the symbol 'g' in the serial monitor, the
the locomotive with address 32 starts to drive with speed 20. When this succeeds,
then I can play on.
On the Mega 2560 I connected the RS232 to TTL device to the Serial3 pins.
(First try Rx3 to Rx and Tx3 to Tx; second try the other way round).
The RS232 to TTL device is connected to the IB with a male - male cable.

On the IB I tried all possible combinations of parameters (I think),,every time
with 9600 bps.
There is no reaction.
In stead of printing a string of characters I tried to write a sequence of bytes.
No reaction,
This is my code:

String go;

// -----------------------
void setup () {
Serial.begin (9600);
Serial3.begin (9600);

while (!Serial) {
; // wacht op de standaard seriele poort
}

Serial.println ("Poort aangetroffen");
go = "XL 32 20";
} // setup

void loop () {
if (Serial.available ()) {
char ch = Serial.read ();
if (ch == 'g') {
Serial3.print (go);
Serial.println (go);
Serial3.write (13);
}
}

if (Serial3.available ()) {
byte ch = Serial3.read ();
Serial.write (".." + ch);
}

} // loop

I hoped anyone has tried something like this before....

For the "benefit" of anyone else who may be reading this Thread I have only taken the trouble to study the manual because I am interested in model trains!

I reckon you also need to get the document that describes the p50x protocol. I suspect the list on page 77 is only part of the story.

I note, also, that the default baud rate is 2400 and you are using 9600.

And, it says that the CTS line is used (Page 15). The Arduino USART does not supprt CTS directly so you would have to emulate that in your program.

And, it says (page 65) that is connects to a PC with a "modem cable". These are always confusing - I never remember whether those cables have the Rx and Tx wires swapped end to end or not. And the diagram on Page 15 does not identify the pin functions.

...R

  while (!Serial) {
    ; // wacht op de standaard seriele poort
  }

This is only needed on the 32U4 boards, which do not have 4 hardware serial ports.

      Serial3.print (go);

Does that device really expect a string with spaces in it?

Are you able to connect the device directly to the PC and send it strings, and have it do anything?

PaulS:
Are you able to connect the device directly to the PC and send it strings, and have it do anything?

A while back I wrote a program to communicate with a Hornby Elite DCC controller which uses the xpressnet protocol. For that the data messages had to be formed with a preamble and postamble[?] and a checksum. I suspect the OP's system will need something similar which is why I suggested he needs to get the document that describes the protocol.

...R

I suggested he needs to get the document that describes the protocol.

I was just wondering if there was a PC app that already knew how to communicate with it. If so, spoofing the device would be relatively simple, so one could learn what that program was sending, so one could tell what to make the Arduino send to it.

I know there are (free) programs to communicate with the IB. But they are so big that I can't figure out the basics.
So I never send massages from PC to IB.
The suggestion to emulate the CTS with an arduino pin asks for a detailed understanding of the RS232 protocol,
I suppose. I will have a look, but possible it is to complicated for me.
I hoped an intermediate RS232 to TTL device would suffice. Unfortunately it doesn't.
Thanks for your time.

Harm_Bakker:
I hoped an intermediate RS232 to TTL device would suffice. Unfortunately it doesn't.
Thanks for your time.

Don't give up yet!

Have you looked up the document I suggested in Reply #3? I have been expecting you to post a link to it.

...R

Robin2:
For the "benefit" of anyone else who may be reading this Thread I have only taken the trouble to study the manual because I am interested in model trains!

I reckon you also need to get the document that describes the p50x protocol. I suspect the list on page 77 is only part of the story.

I note, also, that the default baud rate is 2400 and you are using 9600.

And, it says that the CTS line is used (Page 15). The Arduino USART does not supprt CTS directly so you would have to emulate that in your program.

And, it says (page 65) that is connects to a PC with a "modem cable". These are always confusing - I never remember whether those cables have the Rx and Tx wires swapped end to end or not. And the diagram on Page 15 does not identify the pin functions.

...R

The SOP from 40 years ago was for the terminal device to raise the RTS(request to send) pin and wait for the modem to raise the CTS(clear to send) pin. We faked the modem by jumping the RTS pin to the CTS pin and all was well.

In this case, just applying +5 to the CTS will accomplish the same thing.

Paul

Paul_KD7HB:
The SOP from 40 years ago was ...

I agree - it should not be difficult. But I suspect the real "magic" is in the protocol document.

...R