Hello!
I'm a bit outside my comfort zone and need some help. I need to create a library that can send data over a Bus called RS bus. This bus is used for relaying sensor data from a model railroad to its control system (Command station). To my understanding this bus is a serial interface with 8 data bits and one parity bit.
Background
I'm building a model railroad layout and I want (of course) automate this. To do this I need to know where my trains are and relay this information to my Command System that controls all the turnouts. To buy a relaying device (Feedback module) that can relay data from 16 sensors would cost about € 50. I'm building a small layout, but i would still need 28 sensors to be able to automate this. This made me interested in making my own relaying unit with an Arduino.
I started googling and didn't find as much as I hoped for. I did not find one Arduino project that could help me. But I found source code for an Atimel processor (Not the one on my Arduino UNO). I thought I could use this, but this proved to be too much for my knowledge and this i why I'm here. Below you can found the information I found out:
Facts about the RS-Bus
The command station I'm using is Lenz LZV100. This is described as Master below. I want to create a Feedback module, (Above referred as a relaying device) Below I will refer this as a Slave.
The Master sends out a pulse train of 130 pulses (aprox. 109us high and 96us low) After this it sends out a pulse of aprox 7ms.
If a slave has a message to send it will send its package at 'its' pulse. Each pulse in the masters pulse train corresponds to a adress of the slave.
Baud 4800 bit/sec
The parity bit is sent first, unlike ordinary UART.
The slave Sends its data package in two bytes. The data will look like this:
- StartBit
- ParityBit (Even)
- Two TT Bits (Will always be 10 for a Feedback module
- 1 Nibble bit (0 = lower nibble, 1 = upper Nibble)
- 4 data bits (Lower or upper nibble depending the above bit)
- StopBit
The above information comes from this German site:
http://www.der-moba.de/index.php/RS-Rückmeldebus
The code I found using this is found here:
Conclution
I would like some help writing a library for Arduino som I can relay sensor data from digital pins of my Arduino to my command station. I'm thinking och two functions:
RSBusInit(unsigned char Adress)
RSBusSend(unsigned char DataToSend)
Where RSBusInt(Adress) initializes the data transfer with the slave adress Adress
And the RSBusSend(DataToSend) Divides the data into two nibbles and sends this data to the master on it's turn.
Is any one interested in helping me with this?