−Table of Contents
Lenz
Content → Command Stations → Lenz
- XpressNet Future replacement for this library.
Lenz XpressNet support.
Protocol
- LI101F: xpressnet_li101f.pdf
Preface
Rocrail supports the LI100/LI100F, LI101 and LI-USB computer interfaces.
Setup
LI-101
Linux
<digint iid="lenz-1" lib="lenz" device="/dev/ttyS0" bps="19200"/>
Windows
<digint iid="lenz-1" lib="lenz" device="com1" bps="19200"/>
Note: /dev/ttyS0 or com1 has to be replaced with the port where your interface is connected.
Nodes, attributes and values are explaned here: wrapper-en.html#digint
LI-USB
Mac OS X
The FTDI device driver must be installed to be able to use the LI-USB under OS X.
On the MacBook, running OS X 10.6, the device name is:
/dev/tty.usbserial-00001004
The device name changes slightly when using another USB port; Check the Mac OS X Wiki page for more details.
Linux
The Linux kernel (at least up to 2.6.27) has a working driver for the LI_USB, but does not know the Lenz vendor id and product id. Therefore, the LI-USB is not recognised automatically when plugged in. There are two methods to overcome that problem:
- udev - this is the standard method for Linux to recognise hardware when plugged in. In order for this to work, we need to tell the kernel about the vendor- and product id.
- static - install the driver at boot time
Both mehtods are described below, you need to use one or the other. The author did not get the udev method to work with openSUSE 11.1 and therefore used the static method.
Method using udev
Disconnect the LI-USB from the PC. Login as root and change to the directory
/etc/udev/rules.d/
Now create a file named
10-liusb.rules
and open it with an editor. The only content is (without any line breaks):
SYSFS{idVendor}==“1111”, SYSFS{idProduct}==“1234”, RUN+=”/sbin/modprobe -q ftdi_sio vendor=0x1111 product=0x1234”
(Yes, really ;) - but see the comment in the section on the static method below)
Save and close the file.
<digint iid="lenz-1" lib="lenz" sublib="usb" device="/dev/ttyUSB0"/>
Static method (install driver at boot time)
This method is proven to work with openSUSE 11.1 and therefore the recommended method for this distribution. You will have to adjust filenames etc. for other distributions, but the principle should also apply to other distributions.
You need to modify the file rocrail.ini
. However, when you are new to Rocrail, you do not yet have a file rocrail.ini
. First start the rocrail server. This will create a directory rocrail
in your home directory. Then start the rocview client. You should now have a number of files in your rocrail
directory, but no rocrail.ini
yet. Now select File → Rocrail Properties from the main menue bar at the top of the client window. This should open a dialog window. At this stage, do not worry about the many tabs it offers you, simply press OK. This now generates the rocrail.ini
file in your rocrail
directory. Next Shutdown Rocrail and exit.
Now that we have got the rocrail.ini
file, we use an editor to replace the following line:
<digint lib="virtual" iid="vcs-1" stress="false" libpath="/opt/rocrail"/>
with the new line:
<digint iid="lenz-1" lib="lenz" sublib="usb" device="/dev/ttyUSB0"/>
Please note the /dev/ttyUSB0
may have to be changed to point to the actual device, if you have other USB devices connected. However, you cannot verify at this stage, therefore we leave it for now as is.
In the interface box, Lenz use a chip from Future Technology Devices International, Ltd. That chip works with the driver ftdi_sio
. However, when the interface is plugged in, the driver is not loaded automatically, because the kernel does not know the Lenz product ID. Based on http://forums.opensuse.org/hardware/395149-ftdi-usb-serial-adapter-unknown-vendor-device-id.html do the following:
Use an editor to modify the file /etc/sysconfig/kernel
such that the driver ftdi_sio
gets always loaded at boot time. You will have to do this as root. The only change you need to make, is insterting ftdi_sio
in between the ""
, as shown in the following extract of /etc/sysconfig/kernel
.
## Type: string ## ServiceRestart: boot.loadmodules # # This variable contains the list of modules to be loaded # once the main filesystem is active # You will find a few default modules for hardware which # can not be detected automatically. # MODULES_LOADED_ON_BOOT="ftdi_sio"
Now you also need to make sure the driver knows about the vendor and procut ID of the Lenz interface, by adding that data to the file /etc/modprobe.conf.local
. Again, you can do this as root by using an editor. This is what an example modprobe.conf.local
looks like:
# # please add local extensions to this file # options ftdi_sio vendor=0x0403 product=0xd780
The above vendor and product id are the ones my interface came with. This should in theory be the same for all the Lenz boxes. However, from the text on the udev method written by another author, I take it that Lenz may have shipped some with dummy values of vendor=0x1111 and product=0x1234.
You can find out the values of your box by connecting it and typing lsusb
, which e.g. on my machine shows:
hans@Taurus:/> lsusb Bus 008 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 004: ID 0403:d780 Future Technology Devices International, Ltd Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 003: ID 046a:0050 Cherry GmbH Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 002 Device 003: ID 0c4b:0100 Reiner SCT Kartensysteme GmbH cyberJack e-com/pinpad Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub hans@Taurus:/>
Having done all of the above, you will find that rocrail still cannot talk to the Lenz interface. This is because the device /dev/ttyUSB0
is created with rw permissions for root and goup uucp only. Ordinary users do not have permission. Therefore, you need to make your users who want to use rocrail, a member of the group uucp.
You can do this e.g. in yast with Security and Users → User and Groupmanagement → double click on the user you want to add → Details → check the box for uucp on the right (you may have to scroll down to see uucp). Finish by clicking OK twice.
Now
- reboot your machine
- plug in the interface and switch on the power to your Lenz equipment
- check in the
/dev
directory thatttyUSB0
is the correct device. It may bettyUSB1
or so, if you have other devices connected to your USB. If needed, modify yourrocrail.ini
file to point to the correct device. - start the rocrail server
- start rocview
- go to Tables → Locomotive table… and create a new locomotive table
- the new locomotive table will appear above the clock - double click on it
- don't forget to switch on the power using Control → Power on
- and hopefully you're off running your first loco !!!!!!
Windows:
You have to install the driver which ships with your LI-USB. But the LI-USB-Server has to be stopped!
<digint iid="lenz-1" lib="lenz" sublib="usb" device="com1"/>
Note: /dev/ttyUSB0 or com1 has to be replaced with the port where your interface is connected.
Sensor adressing
the calculation is:
address_rocrail = (lenz_address - 1) *8 + port ∀ lenz_address ∈ [1..128], port ∈ [1..8]
Example
lenz address → rocrail address (from..to)
1: 1..8 → 1..8
2: 1..8 → 9..16
…
64: 1..8 → 505..512
65: 1..8 → 513..520
66: 1..8 → 521..528
…
and so on …
Sensor offset
The attribute fboffset="X"
allows you to shift the addresses of the sensors up or down.
Debouncing sensors
If you have problems with slow or flickering sensors you can set sensordebounce="xxx"
in the ini. A smaller number will lead to faster debouncing.
Use this parameter with care because under most conditions a value of zero is better when running in auto mode; the first event is processed and the bouncing will be ignored. |
---|
Startup power state
The default startup power state is off. You can change this behavior by checking this option.
Fastclock
Some xPressNet Command Stations, like OpenDCC, are supporting the fast clock operation.
Check this if Rocrail should send this command every layout minute.
Accessory Decoder Address
You can set up the Address in rocrail style, or what is more cool in PADA style. Then the address of the decoder will match with the address in your LH*.