Joined: 10/04/2012(UTC) Posts: 5 Location: East Coast
|
Hi everyone,
I am trying to control a Marklin set using the 6051 digital interface connected to the 6021 control unit. The code is running under Windows XP and I am using the RXTX v2.1 (http://rxtx.qbang.org/) library to communicate via computer's serial port.
The serial connection is set up with the settings prescribed on the Marklin website (baud rate is 2400, 2 stop bits, no parity, 8 bit word size).
Sending one-byte commands (system-wide go/stop) works fine. However, any two-byte commands (e.g. loco control) fail. Following such an attempt also prevents subsequent one-byte commands from working until the system is hard-reset.
Any suggestions?
Thanks! Frank
|
|
|
|
Joined: 16/02/2004(UTC) Posts: 15,463 Location: DE-NW
|
Hi, Frank, and welcome here!
Did you activate hardware hand-shake (RTS, CTS)? |
Regards Tom --- "In all of the gauges, we particularly emphasize a high level of quality, the best possible fidelity to the prototype, and absolute precision. You will see that in all of our products." (from Märklin New Items Brochure 2015, page 1) ROFLBTCUTS  |
|
|
|
Joined: 10/04/2012(UTC) Posts: 5 Location: East Coast
|
Originally Posted by: H0  Hi, Frank, and welcome here!
Did you activate hardware hand-shake (RTS, CTS)? Thanks for the welcome and your reply! I have gone into the Windows XP device manager and, under the properties for the serial port, set the port's settings to: Bits per second: 2400 Data bits: 8 Parity: None Stop bits: 2 Flow control: Hardware I believe that the "Hardware" setting for flow control should enable the CTS/RTS handshake. Is that correct? Or does this need to be configured somehow in the code (that is, via the serial communication library that I am using)? I am very much a beginner in this area, but it is confusing to me that the one-byte commands work fine, but I have never been able to get any two-byte command to work at all, and I don't have a good guess of where to begin troubleshooting. Thanks again for your help! Frank
|
|
|
|
Joined: 16/02/2004(UTC) Posts: 15,463 Location: DE-NW
|
Originally Posted by: frankthetank  I believe that the "Hardware" setting for flow control should enable the CTS/RTS handshake. Is that correct? Yes, that should do it. I never tried a 6051, but IIRC there can be a problem if commands come to fast. You could try a Sleep for 500 milliseconds after each byte - maybe this will get the two-byte commands to work. Or maybe a 6051 expert can help ... |
Regards Tom --- "In all of the gauges, we particularly emphasize a high level of quality, the best possible fidelity to the prototype, and absolute precision. You will see that in all of our products." (from Märklin New Items Brochure 2015, page 1) ROFLBTCUTS  |
|
|
|
Joined: 19/03/2004(UTC) Posts: 976 Location: Gorizia, Italy
|
Hi Frank,
If I remember well, first the command byte and then the locomotive address byte are sent.
Did you do this or did you inverted the two bytes?
Kind regards
Renato
|
|
|
|
Joined: 10/04/2012(UTC) Posts: 5 Location: East Coast
|
Originally Posted by: H0  Originally Posted by: frankthetank  I believe that the "Hardware" setting for flow control should enable the CTS/RTS handshake. Is that correct? You could try a Sleep for 500 milliseconds after each byte - maybe this will get the two-byte commands to work. Ok, I will try later with a sleep before each byte (I think I might have tried this already, but I can't remember) and then update this post. Originally Posted by: Renato  If I remember well, first the command byte and then the locomotive address byte are sent.
Did you do this or did you inverted the two bytes?
Yes, I took note of this order and sent the command byte (loco speed/function) before the address byte. I also tried it in the reverse order, just in case, but (of course) that did not work either. Thank you both for your input! EDIT: Putting a 500ms sleep between bytes had no effect... Edited by user 11 April 2012 19:56:29(UTC)
| Reason: Not specified
|
|
|
|
Joined: 14/12/2011(UTC) Posts: 58 Location: Katonah, NY
|
You really need to put a loop in your code to keep polling RTS/CTS to see if the device (6051) is ready to accept the second byte of any two-byte command sequences (locomotives, turnouts, etc.). I struggled with this when I wrote my own software (TPL) in VB3 a long time ago; this caused me some issues as well. And, as you've discovered, sending the second byte before the Interface is ready will indeed lock it up. I can only tell you what I did with VB (but I did get it to work perfectly). Please contact me via e-mail if you think I might be able to help you. |
|
|
|
|
Joined: 10/04/2012(UTC) Posts: 5 Location: East Coast
|
Originally Posted by: rjftrains  You really need to put a loop in your code to keep polling RTS/CTS to see if the device (6051) is ready to accept the second byte of any two-byte command sequences (locomotives, turnouts, etc.). I struggled with this when I wrote my own software (TPL) in VB3 a long time ago; this caused me some issues as well. And, as you've discovered, sending the second byte before the Interface is ready will indeed lock it up. I can only tell you what I did with VB (but I did get it to work perfectly). Please contact me via e-mail if you think I might be able to help you. Thanks for the input. Yes, it sounds like my problems are similar to those that you faced. I have since checked to ensure that flow control is set to CTS/RTS and added a loop to poll the device for CTS before any byte is sent (and if not, wait 100 ms and try again). This is what I'm observing now: One-byte commands continue to work. So, for example, if I want to start the whole system, I poll for CTS (the device is immediately ready) and then send the number 96 and the system responds. This change has not fixed two-byte commands. However, at least I understand what's going on a little better (but not why). If, for example, I want to set train #26 to speed 10, I poll for CTS (the device is immediately ready) and send the number 10 (speed). Again, I poll for CTS (again, the device is ready) and send the number 26 (loco address). However, the locomotive does not change speed. Now, if I want to send any subsequent command (e.g. stop the system by sending the a single byte, the number 97), I first poll for CTS, and at this point the device has locked up, it remains in the loop indefinitely (well, I've waited for ~20 seconds), and I need to reset the system. I'll continue experimenting in this area, but it's starting to feel like I've tried everything.
|
|
|
|
Joined: 31/12/2010(UTC) Posts: 4,000 Location: Paremata, Wellington
|
Originally Posted by: frankthetank  Originally Posted by: rjftrains  You really need to put a loop in your code to keep polling RTS/CTS to see if the device (6051) is ready to accept the second byte of any two-byte command sequences (locomotives, turnouts, etc.). I struggled with this when I wrote my own software (TPL) in VB3 a long time ago; this caused me some issues as well. And, as you've discovered, sending the second byte before the Interface is ready will indeed lock it up. I can only tell you what I did with VB (but I did get it to work perfectly). Please contact me via e-mail if you think I might be able to help you. Thanks for the input. Yes, it sounds like my problems are similar to those that you faced. I have since checked to ensure that flow control is set to CTS/RTS and added a loop to poll the device for CTS before any byte is sent (and if not, wait 100 ms and try again). This is what I'm observing now: One-byte commands continue to work. So, for example, if I want to start the whole system, I poll for CTS (the device is immediately ready) and then send the number 96 and the system responds. This change has not fixed two-byte commands. However, at least I understand what's going on a little better (but not why). If, for example, I want to set train #26 to speed 10, I poll for CTS (the device is immediately ready) and send the number 10 (speed). Again, I poll for CTS (again, the device is ready) and send the number 26 (loco address). However, the locomotive does not change speed. Now, if I want to send any subsequent command (e.g. stop the system by sending the a single byte, the number 97), I first poll for CTS, and at this point the device has locked up, it remains in the loop indefinitely (well, I've waited for ~20 seconds), and I need to reset the system. I'll continue experimenting in this area, but it's starting to feel like I've tried everything. Hi Frank, For what it's worth, make sure you rule out the Cable. Are you using the one that came with the 6051? And assuming also that if you are, it is connected directly to a 9-pin COM port on your PC? (rather than through a 9pin-25pin adapter)? If the Handshaking wires are not connected as required you will also get weird symptoms. Cheers Cookee Melbourne |
Cookee Wellington  |
|
|
|
Joined: 31/12/2010(UTC) Posts: 4,000 Location: Paremata, Wellington
|
One other thing I might suggest is confirming if everything works normally with one of the other control programs, Digipet for example has a Demo version for download... http://www.windigipet.de/downloads-international/win-digipet-english/ although these demo version are usually crippled to prevent saving files or limited to only 1 or 2 loco's, it might still be a good test for your setup to aid in troubleshooting. |
Cookee Wellington  |
|
|
|
Joined: 22/01/2009(UTC) Posts: 14,878 Location: On 1965 Märklin Boulevard just around from Roco Square
|
Hi, I'm watching this with some interest and hopefully will one day get my interface going but to connect it to a computer, the computer must have some type of program to receive or operate or is able to communicate with both components. What would some of you recommend which program to use ?
regards.,
John |
|
|
|
|
Joined: 12/12/2005(UTC) Posts: 2,448 Location: Wellington, New_Zealand
|
Make sure you DO NOT have the loco dialed up on the 6021 (or any 603x)
|
Peter
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.