Saturday, February 03, 2018

How I reprogrammed a Deltang Rx102 with a Prog4 module to operate a MyLocoSound sound card

Preamble

Although I have previously written a post about reprogramming the Rx102 receiver (see How I reprogrammed a Deltang Rx102), things have changed a little since then and so I felt it was time I replaced that post with a more fully detailed, up to date version.

I wanted to reprogram an Rx102 receiver so that I could use spare pins to trigger the effects on a MyLocoSound sound card. The MyLocoSound card (like most sound cards) need a 0v signal to trigger additional effects. The default outputs from the Rx102 are either for servos (on Pins 1 to 5) or for directional lighting (on Pins 6 and 7). As I wanted to use my Deltang Tx22 transmitter to trigger the effects, I wanted to use the Bind Button (Channel 5) and the Direction switch (Channel 3) as sound effect triggers. For more information on interfacing the MyLocoSound card with Deltang receivers see How to interface Deltang receivers with sound cards - MyLocoSound

The outputs could just as easily be reprogrammed to provide 3.2v positive outputs to power LEDs eg for interior lighting (see below). There is no need to include a load resistor when wiring up LEDs to the signal pins of the Rx102 as the receiver outputs include appropriate resistors.

Contents


The Prog4 Programma module

 The Prog4 (like the Prog1, Prog2 and Prog3) is a modified Rx102 receiver. The most significant difference is that the Prog4 has a rather prominent push button mounted on one side. This is the bind button (on the other Prog modules, it is also used for transmitting the programming instructions).

The Prog4 needs to be connected a computer with an RS232/USB (CH340) cable.

I got mine via eBay by searching for PL2303TA TTL to RS232 Converter Serial Cable
. The first one I purchased failed to work (not sure why) but the second one (and a third) worked well so it might be worth persevering if things do not work out OK the first time you try.

When it arrived, I connected the lead to the Prog4:
  • Black lead to the Bottom Pin 7
  • Red lead to Middle Pin 7
  • Green lead to Upper Pin 7
  • White lead to Upper Pin 6

Installing the software (on a Windows 10 PC)

Before installing the software, I needed to download and install a driver for the interface cable. This was downloaded from https://serialio.com/drivers-and-set-up-usb-rs-232-adapter-in-windows. As indicated on the web page, once the .EXE file was downloaded and saved, I had to install it 'as an administrator'. I right-clicked on the saved file and selected 'Run as administrator'.

Once that was installed I downloaded CoolTerm from http://freeware.the-meiers.org/ . The zipped file needed to be extracted which I did by right-clicking and selecting Extract all.

 I dragged the resultant folder on to my desktop so that I would know where to find it in future (the program does not install to the programs list in the Windows menu).

Setting up CoolTerm

Before starting up the program, I inserted the USB lead into a USB socket. The driver had installed successfully (I had rebooted the computer to make sure) and so there were no error messages. The LED on the Prog4 came on to show it was connected.

In the CoolTerm folder on the desktop were a couple more folders and the CoolTerm.exe file. I doubled clicked this to start up the program.


The program loaded OK and the LED on the Prog4 started flashing 3 times, then pause, three times, etc. (ie 3-flash) to show the software was communicating with it.

Before using the software, I needed to set it up for the Prog4. Clicking on the Options Button ......


.......... took me to the Options screen.

On my computer and with my USB socket, the Prog4 was showing up as COM3. You might need to click on the 'Re-Scan Serial Ports' button to get your Prog4 to show up. If it doesn't you might need to try another USB socket (or buy another lead - see above). Your USB lead/Prog4 might show up on a different port (it was COM7 on my old laptop).

The settings needed to be changed to those above, ie:
  • Baud rate = 115200
  • Data bits = 8
  • Parity = Even
  • Stop Bits = 1
  • XON check box ticked
I also clicked on the 'Receive' settings and ticked the Ignore receive signal errors check box.

The program was now ready to send information to the Rx102

Binding the receiver to the Prog4

Before the programming info could be sent to the Rx102, the receiver needed to be bound to the Prog4. The receiver was put into Bind Mode by connecting the black bind plug (supplied with the receiver) across signal Pins 5 and 7 (ie the uppermost row) and turning on the receiver.

The LED on the receiver started flashing rapidly showing it was in Bind Mode and so I removed the bind plug.

I removed the Prog4's USB plug from the computer and then, holding down the bind button on the Prog4, I re-inserted the USB plug - this puts the Prog4 into Bind Mode.

I removed my thumb from the bind button and the LEDs on the Prog4 and the Rx102 flashed once a second in unison and then after a few seconds they both started flashing three times and pausing, three flashes, pause, etc. The Prog4 and the Rx102 were now bound together (Note: if the Rx102 had previously been bound to a transmitter such as the Tx22, it will not forget that bind).

The Prog4 was now ready to reprogram the receiver.

Creating the text files

The easiest way to reprogram a receiver with the Prog4 is to create a series of text files with the instructions for the receiver. I wanted to set up my Rx102 so that I could use the bind button and direction switch on my Tx22 transmitter to trigger sound effects on a MyLocoSound sound card. The Bind Button sends Channel 5 low when it is pressed and the Direction Switch sends Channel 3 high or low depending on which way it is switched.

To discover what instructions need to be sent to the receiver, I consulted the table for the Rx102 on the Deltang website. (click on the image to enlarge it).

This table showed that the codes needed to reprogram pin 5 on the receiver were:

1,5,2,5,4
  • 1 = menu one
  • 5 = Pin 5
  • 2 = on/off
  • 5 = Channel 5
  • 4 = Off when the channel is Low
In other words, when the Bind Button is pressed on the transmitter (sending Channel 5 low), the receiver will turn off the output from Pin5 (ie the output from Pin5 will become 0v)

The codes for the Direction Switch were:

1,3,2,3,6

ie. The output from Pin3 will become 0v when the Direction Switch is flicked in reverse (ie sends Channel 3 high).

And.......

1,4,2,3,4

The output from Pin4 will become 0v when the Direction Switch is flicked forward (ie sends Channel 3 low).

I used Notepad on my computer to create the text files (if you can't find it, type Notepad into the search box on the bottom left of the screen and press return). NOTE: Although you can save text files from MS Word, the files include all sorts of additional gobbledegook which could confuse the Prog4.

The text file for the Bind Button instructions........

The text file for the Reverse Direction Switch ......

and the text file for the Forward Direction Switch......

 Each text file was saved (in a folder inside the CoolTerm folder) so they could be used later.

Sending the text files to the receiver

 With the receiver bound to the Prog4 and the Prog4 communicating with the computer through CoolTerm, I was now ready to send the instructions to the Rx102.

I needed to unplug the USB lead and re-insert it because the Prog4 had gone to sleep. It switches off after 5 minutes if nothing is happening.

The first job was to open the connection between CoolTerm and the Prog4. I clicked on the Connect button.

Once connected, I then clicked on the Connection menu and selected Send Textfile...


I navigated to the folder where I had stored the text files and then clicked on the first of them and clicked the Open button.

The information in the text file was sent from the computer to the Prog4 and then on to the Rx102.

The other two text files were also sent in the same way. I got a series of messages in the CoolTerm window to show the files had been transmitted OK
Note: these messages do not always appear straight away, even though the files have been transmitted successfully. The best way to find out if they have worked is to check the receiver (as below).

The receiver was turned off (to save the changes).

Checking

 To check that the receiver had been programmed correctly, I wired-up an LED to a servo plug. There is no need to include a resistor with the LED as the Rx102 includes load resistors in the circuitry for the output pins. The black lead from the servo plug was connected to the negative leg of the LED and the white (or yellow) lead was connected to the positive leg of the LED. The middle (red) lead from the plug was left unconnected.

The receiver was bound to the Tx22. The LED was connected in turn to Pins 3, 4 and 5 and the relevant button or switch operated on the transmitter. When first connected, the LED glowed steadily but when the switch or button was operated on the Tx the LED was extinguished showing the output was going from 3.2v to 0v.

I will attempt to make a video showing this process but it will have to be a combination of screen captures and live action and so it might take a while to figure out the best way to achieve this. In the meantime, I hope the information above is useful.

2 comments:

Unknown said...

I just received a Prog4 from DavidT, and that one worked on 9600 Baud only. So check that setting, too, if 115KBd doesn't work. I also found that on this particular item I had to connect its TxD and RxD directly to the TxD and RxD outlets ( no crossing! ) of the USB-to-serial adapter in order to communicate with it.

GE Rik said...

Glad you managed to get it sorted our, Helmut. I find it does sometimes take a bit of tweaking to get it to work.

Rik