Welcome to the forum   
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

2 Pages<12
Share
Options
View
Go to last post in this topic Go to first unread post in this topic
Offline osoraku  
#51 Posted : 02 April 2025 21:54:22(UTC)
osoraku

Portugal   
Joined: 22/01/2025(UTC)
Posts: 48
Location: Setubal, Palmela
Dear Adrian -

Sorry it wasn't clear - both marklin.py and threadsafe.py are at the github site where the rest of the code is.

Osoraku
thanks 2 users liked this useful post by osoraku
Offline xxup  
#52 Posted : 05 April 2025 11:21:23(UTC)
xxup

Australia   
Joined: 15/03/2003(UTC)
Posts: 9,578
Location: Australia
Good news! Everything is working and I am up to the point of connecting to Rocrail.

I had a little stumble, when I forgot to change the pin assignments for the waveshare board in the TCP-CAN.py file. I was too focused on getting the wifi working - I needed to set up the new MRR VLAN on the switch so that the pico would get the correct IP address. I keep my networks isolated.

If I have some time tomorrow, I will figure out Rocrail (I normally use WinDigiPet) and try the connection.

Hopefully, there will be an s88 pico pi solution so that I can try automation on the test track.

One question. Now that main.py is loaded on to the pico. Will it autostart when I start the pico, the track box and Rocrail?
Adrian
UserPostedImage
Australia flag by abFlags.com
thanks 1 user liked this useful post by xxup
Offline osoraku  
#53 Posted : 06 April 2025 01:35:12(UTC)
osoraku

Portugal   
Joined: 22/01/2025(UTC)
Posts: 48
Location: Setubal, Palmela
Dear Adrian -

Originally Posted by: xxup Go to Quoted Post
Good news! Everything is working and I am up to the point of connecting to Rocrail.

….

One question. Now that main.py is loaded on to the pico. Will it autostart when I start the pico, the track box and Rocrail?


Yes.

I reworked the code to auto-configure the CAN board.

Osoraku

Edited by user 27 April 2025 14:17:05(UTC)  | Reason: Updated code to auto-configure

thanks 2 users liked this useful post by osoraku
Offline revmox  
#54 Posted : 10 April 2025 12:48:09(UTC)
revmox

Australia   
Joined: 26/05/2021(UTC)
Posts: 198
Location: Australia, East Maitland, NSW
As a side issue to the CAN control capability, does anyone have a full circuit diagram of a track box - any version. I have searched several times both in English and via gleisbox schaltplan and found what looked like promising links but no luck - but usually just dead links or access barred.

Also, cables for the track box can sometimes be found cheap on eBay or Amazon under 10 pin S video cables - if you get a male to male version you get two usable project cables for the price of one.

Mark

S video 2.jpg
thanks 2 users liked this useful post by revmox
Offline revmox  
#55 Posted : 13 April 2025 02:53:48(UTC)
revmox

Australia   
Joined: 26/05/2021(UTC)
Posts: 198
Location: Australia, East Maitland, NSW
Find the circuit for a 60113 gleisbox in my cloud storage using the link below-

Also in there you will find data sheets for the chips it uses.

C5081F502 MCU processor
MAX3058 CAN transceiver
CD4555 dual 1 of 4 decoder
SAA6579 and PT2579 RDS decoder, my 60116 track box has the PT2579 equivalent
ZXCT1009 high-side current monitor - a nifty device that I haven't seen before that produces an isolated output current proportional to the voltage on its input terminals, I think it picks up the mfx feedback from decoders and also provides the over current protection sensing?

https://mega.nz/folder/g...I#59XJTLCZ9wx1t5pihgbrww

thanks 2 users liked this useful post by revmox
Offline osoraku  
#56 Posted : 13 April 2025 09:58:32(UTC)
osoraku

Portugal   
Joined: 22/01/2025(UTC)
Posts: 48
Location: Setubal, Palmela
Dear Mark -

Originally Posted by: revmox Go to Quoted Post
...
ZXCT1009 high-side current monitor - a nifty device that I haven't seen before that produces an isolated output current proportional to the voltage on its input terminals, I think it picks up the mfx feedback from decoders and also provides the over current protection sensing?


That makes sense to me (though I am no electronics wizard).

The 60113/60116 are DCC & MFX capable so they both use a form of current loop feedback from the decoder. This schematic should be helpful for Roland's MFX decoder feedback work.

Osoraku

Offline bobyAndCo  
#57 Posted : 13 April 2025 10:22:11(UTC)
bobyAndCo

France   
Joined: 20/02/2024(UTC)
Posts: 20
Location: France - Bretagne
Originally Posted by: revmox Go to Quoted Post
Find the circuit for a 60113 gleisbox in my cloud storage using the link below-

Also in there you will find data sheets for the chips it uses.

C5081F502 MCU processor
MAX3058 CAN transceiver
CD4555 dual 1 of 4 decoder
SAA6579 and PT2579 RDS decoder, my 60116 track box has the PT2579 equivalent
ZXCT1009 high-side current monitor - a nifty device that I haven't seen before that produces an isolated output current proportional to the voltage on its input terminals, I think it picks up the mfx feedback from decoders and also provides the over current protection sensing?

https://mega.nz/folder/g...I#59XJTLCZ9wx1t5pihgbrww



Thanks for sharing but what you present here uses an RDS component (SAA6579 or PT2579). These components are difficult to find today and expensive.

I tested the MFX feedback with these RDS components and another schematic but I couldn't isolate the useful information. So I gave up on the piss.

I was very interested when you published this schematic that didn't use RDS components. Is this the wrong way to go?

UserPostedImage

If not, I'd be very interested if you could provide some clarification, particularly on the choice of coil.

I'll then try to implement it and share my results.

MFX feedback is the only thing missing from my otherwise perfectly functioning power plant.

https://www.marklin-user...es-without-CS-2-3-or-MS2

Christophe
Offline xxup  
#58 Posted : 13 April 2025 10:53:01(UTC)
xxup

Australia   
Joined: 15/03/2003(UTC)
Posts: 9,578
Location: Australia
@osoraku

Sorry to digress, but have you had time to check out the S88 solution using a Pico? I realise that a pico-based automated layout would be small due to the current (as in electric) limitations of the track box, but I would like to make a modest automated layout to show some people how easy it is to set up and use.
Adrian
UserPostedImage
Australia flag by abFlags.com
Offline osoraku  
#59 Posted : 13 April 2025 11:33:24(UTC)
osoraku

Portugal   
Joined: 22/01/2025(UTC)
Posts: 48
Location: Setubal, Palmela
Dear Adrian -

Sorry, not yet. I am away from my hardware for a few weeks and can't test anything attached to the real world.

I'm sure that Christophe's design works. Of interest to me is whether enough of the spare pins on the Joy-IT or Waveshare CAN boards can be used the same way and integrated into a single device (with, say, 8 or so S88-equivalent feedback inputs). That would be a simple, cheap, integrated device to go with a starter set.

(Edited later): This has now been tested and the code is updated

Osoraku

Edited by user 27 April 2025 14:18:33(UTC)  | Reason: Tested and updated

thanks 2 users liked this useful post by osoraku
Offline revmox  
#60 Posted : 13 April 2025 12:42:41(UTC)
revmox

Australia   
Joined: 26/05/2021(UTC)
Posts: 198
Location: Australia, East Maitland, NSW
Originally Posted by: bobyAndCo Go to Quoted Post
Originally Posted by: revmox Go to Quoted Post
Find the circuit for a 60113 gleisbox in my cloud storage using the link below-

Also in there you will find data sheets for the chips it uses.

C5081F502 MCU processor
MAX3058 CAN transceiver
CD4555 dual 1 of 4 decoder
SAA6579 and PT2579 RDS decoder, my 60116 track box has the PT2579 equivalent
ZXCT1009 high-side current monitor - a nifty device that I haven't seen before that produces an isolated output current proportional to the voltage on its input terminals, I think it picks up the mfx feedback from decoders and also provides the over current protection sensing?

https://mega.nz/folder/g...I#59XJTLCZ9wx1t5pihgbrww



Thanks for sharing but what you present here uses an RDS component (SAA6579 or PT2579). These components are difficult to find today and expensive.

I tested the MFX feedback with these RDS components and another schematic but I couldn't isolate the useful information. So I gave up on the piss.

I was very interested when you published this schematic that didn't use RDS components. Is this the wrong way to go?

UserPostedImage

If not, I'd be very interested if you could provide some clarification, particularly on the choice of coil.

I'll then try to implement it and share my results.

MFX feedback is the only thing missing from my otherwise perfectly functioning power plant.

https://www.marklin-user...es-without-CS-2-3-or-MS2

Christophe


Thanks,

Yes, some work has gone on in the background to eliminate the need for a dedicated RDS chip and a transformer. I am working on a method to do the extraction using common MCUs or even a common-as-muck Arduino Nano as an RDS co-processor - seems quite promising so far. Getting the signal to feed into it without using a current transformer was the issue. The ZXCT1009 is cheap and plentiful - even down here, close to the South Pole.

Once the RDS carrier is cleanly extracted you can sync into an edge in the early part of the waveform, shift timing by quarter of a pulse (4.75uS), then sample every 9.5uS at the centre of the pulses. If the second part of the waveform stays in sync with the first then you have a 1, if it reverses you have a 0. Then it's just processing ...

RDS_Nano.jpg

Cheers.
thanks 2 users liked this useful post by revmox
Offline bobyAndCo  
#61 Posted : 13 April 2025 21:18:54(UTC)
bobyAndCo

France   
Joined: 20/02/2024(UTC)
Posts: 20
Location: France - Bretagne
revmox

Thanks for the feedback. Can you give me more details on the electronic schematic that would be suitable.

Is the schematic obsolete???

UserPostedImage

I have the skills and equipment to decode binary signals. But not enough electronics.

I know that the MFX return signal can be analyzed either by an Arduino, an ESP32, an RP Pi Pico or even an ATTiny.

If I could have the schematic of this feedback part alone, I could make a great contribution, and the control unit I've proposed is open source and works very well. It would be a great plus for the community.

Thanks in advance.

Christophe

PS: It would probably be better to continue on another thread or by private message!
thanks 1 user liked this useful post by bobyAndCo
Offline patnaik  
#62 Posted : 13 April 2025 23:39:56(UTC)
patnaik

United States   
Joined: 22/08/2020(UTC)
Posts: 39
Location: Maryland, Silver Spring
I have just gotten my setup to work. I have manually added a DCC loco separately to the MS2 and Rocrail. I am able to control the loco from either Rocrail or the MS2 controller. My question how do I add a MFX loco to Rocrail? The MS2 does it automatically.

Regards,
Gopal
Offline revmox  
#63 Posted : 14 April 2025 02:04:25(UTC)
revmox

Australia   
Joined: 26/05/2021(UTC)
Posts: 198
Location: Australia, East Maitland, NSW
Hi Christophe,

I’ve posted the gleisbox information here as it might in some way be useful to people working through it. I’m not trying to produce a train controller – RDS is just an interesting technical puzzle for me to solve that seems to be an obstacle for those that are.

The circuit using the 567 tone decoder works but is NOT recommended – it uses a current transformer and these are always difficult for others to replicate. It has a high component count and either needs 1% components or some decent electronic equipment to set up the PLL centre frequency. The tone decoder output momentarily drops lock when an RDS phase reversal occurs and this is what must be detected. If you want to push ahead (and obviously you have seen my previous posts) then the only information you are missing is the transformer. Unfortunately, it has gone out with the trash, as I’m cleaning up in preparation for moving house but it used the same unknown core from my glory box as shown on the right in the picture of the bread boarded circuit, 17 OD, 10 ID, 5H, 2T primary, 8T secondary loaded with 10 ohms as best I can recall.

PXL_20250413_222903968.jpg

It would seem the far better approach would be to lean on Marklin’s mass produced method that is working satisfactorily in so many gleisboxes. Tracing the gleisbox path from the current monitor chip to the RDS chip MUX input should provide what is needed – and also give the possibility of overload protection to those that don’t already have it. Here’s a copy of some private chatter that may help you if you go down that path, it works on the bench detecting 1s and 0s from an RDS generator.

I’ve used an Arduino Nano, with the more advanced platforms you gain many, many things but lose that level of visibility and control. (My staff used to call it the “Rule of 4” – 4 cores, 4GHz, 4GB and 4 obscure, deprecated libraries to turn one LED on in 4 seconds. Defence contractors, who charge by the line, just love it).

First, I’ve written a program to lock into the initial RDS waveform edges – then shift by a quarter of the RDS period 4.75uS to place sampling at mid-pulse – then sample every 9.5uS to capture the phase of the RDS signal. I then take 30 samples pre the phase change point and 30 samples post the phase change point. This gives a tolerance of tens of microseconds in response time for the loco decoder. If >27 of the samples in Sample 1 are in phase with the start then I consider it a valid RDS start (allows for some noise), if >27 of the 30 samples in Sample 2 are also in phase then I consider it a valid RDS logic 1, if <3 of the 30 samples in Sample 2 are in phase then I consider it a valid RDS logic 0. If those overall conditions aren’t met then I consider the reading invalid. Easier than focusing on the exact point of phase reversal. I’ll christen this the Mox Method and work on seeing if it comes together in the real world.

RDS_Code.jpg

Good luck with your project.

Revmox
thanks 1 user liked this useful post by revmox
Offline osoraku  
#64 Posted : 14 April 2025 10:56:18(UTC)
osoraku

Portugal   
Joined: 22/01/2025(UTC)
Posts: 48
Location: Setubal, Palmela
Dear Gopal -

Originally Posted by: patnaik Go to Quoted Post
... My question how do I add a MFX loco to Rocrail? The MS2 does it automatically.


In Rocrail, navigate to Tables -> Locomotive. Under the Interface tab, you select the protocol with the Protocol menu. MFX is one of the choices.

Osoraku
Offline patnaik  
#65 Posted : 15 April 2025 03:47:12(UTC)
patnaik

United States   
Joined: 22/08/2020(UTC)
Posts: 39
Location: Maryland, Silver Spring
I can add in a MFX loco by hand. I don’t know what address to put in. Is there a way to make Rocrail auto detect the MFX loco?

Gopal
thanks 1 user liked this useful post by patnaik
Offline xxup  
#66 Posted : 15 April 2025 13:52:23(UTC)
xxup

Australia   
Joined: 15/03/2003(UTC)
Posts: 9,578
Location: Australia
I have had a look at the other s88 solution, but it requires special boards. I think that I will use my old LDT HSI-S88-RS232 with the normal s88 decoders to talk to rocrail directly. For this small layout, I only need 5 contact points.

If I do this, does this mean that I need to switch the pico setup to UDP from the TCP I have set currently?
Adrian
UserPostedImage
Australia flag by abFlags.com
Offline osoraku  
#67 Posted : 15 April 2025 20:24:34(UTC)
osoraku

Portugal   
Joined: 22/01/2025(UTC)
Posts: 48
Location: Setubal, Palmela
Dear Adrian -

Originally Posted by: xxup Go to Quoted Post
...If I do this, does this mean that I need to switch the pico setup to UDP from the TCP I have set currently?


No. With Rocrail, there's no need to use UDP unless you want multiple controllers/throttles to run locos. Anything coming over the CAN bus will get forwarded. Your other hardware will have its own comm path (over RS232?) to Rocrail and won't be using WiFi.

Osoraku

thanks 1 user liked this useful post by osoraku
Offline xxup  
#68 Posted : 15 April 2025 21:56:06(UTC)
xxup

Australia   
Joined: 15/03/2003(UTC)
Posts: 9,578
Location: Australia
Originally Posted by: osoraku Go to Quoted Post
... (over RS232?) ...


I have two HSI-88 units. The HSI-88-USB will be used on the main layout with the CS3 running WinDigiPet on one laptop, while the HSI-SS-RS232 will be used with a RS232 to USB adaptor on a separate test layout with the pico-can controller and running Rocrail on another laptop. Looking at the Rocrail documentation suggests that the newer HSI-88-USB unit is not supported. (In any case, it is packed in a box somewhere waiting to be unpacked, when the shed is built later this year).
Adrian
UserPostedImage
Australia flag by abFlags.com
Offline osoraku  
#69 Posted : 15 April 2025 22:43:28(UTC)
osoraku

Portugal   
Joined: 22/01/2025(UTC)
Posts: 48
Location: Setubal, Palmela
Dear Adrian -

Originally Posted by: xxup Go to Quoted Post
... The HSI-88-USB will be used on the main layout with the CS3 running WinDigiPet on one laptop, while the HSI-SS-RS232 will be used with a RS232 to USB adaptor on a separate test layout with the pico-can controller and running Rocrail on another laptop. Looking at the Rocrail documentation suggests that the newer HSI-88-USB unit is not supported....


If you're concerned that the pico-can controller will use up the USB ports on your computer, you can hook it up to USB power from a wall plug. Then the RS232↔︎USB adapter is available for your feedback device, making it look like an RS232 connection to Rocrail. Or do I misunderstand?

Osoraku
Offline xxup  
#70 Posted : 16 April 2025 06:37:22(UTC)
xxup

Australia   
Joined: 15/03/2003(UTC)
Posts: 9,578
Location: Australia
Nup. I am not worried about the USB ports as I can always buy a USB hub.

There are two versions of the LDT HSI-88:

- HSI-88-USB - https://www.ldt-infocent...oku.php?id=en:hsi-88-usb
- HSI-88 - https://www.ldt-infocent...ki/doku.php?id=en:hsi-88

The USB version is not supported on Rocrail (according to the Rocrail and LDT documentation), but looks like I can use the older unit with a USB to serial cable.

https://wiki.rocrail.net/doku.php?id=hsi88-en

I plan to use the RS232 version to test out the pico controller on a test layout so that I can understand the limitations for automation.

Does this make sense?
Adrian
UserPostedImage
Australia flag by abFlags.com
Offline osoraku  
#71 Posted : 16 April 2025 11:18:01(UTC)
osoraku

Portugal   
Joined: 22/01/2025(UTC)
Posts: 48
Location: Setubal, Palmela
Dear Adrian -

No worries. Rocrail will do the feedback integration and control via its separate comm paths. It makes no odds to the pico-can controller.

From the links that you posted, Rocrail apparently handles the HSI-88 as a feedback route to it via a serial port (RS232). You must have one of the USB dongles to connect RS232 to your Macbook Air test bed. Rocrail will probably see the HSI-88 as a serial device at /dev/cu.usbmodemxxxxx and show it as a choice on its setup page.

I may have a combined CAN-WiFi and feedback hub tested in a week or so. A Waveshare board is on its way to me as I type but I'll need some way to simulate feedback for testing. Pushbuttons, maybe. Fingers crossed.

Osoraku
Offline xxup  
#72 Posted : 16 April 2025 11:38:57(UTC)
xxup

Australia   
Joined: 15/03/2003(UTC)
Posts: 9,578
Location: Australia
Hello osoraku,

There is no hurry, but I am interested in testing a feedback enhancement based on the PICO.

One thing to note. When I first started with a computer controlled layout, I used an Intellibox connected to a PC running WinDigiPet. When I got to six or seven locos (even with two boosters) the Intellibox would run out of steam. By this I mean that the Intellibox would miss instructions and not switch a turnout or slow down a loco resulting in a crash. One way to fix this problem was to separate the role of occupancy detection from the Intellibox's control of the locos, turnouts and signals. This is how the first HSI-88 came into being - it used to be connected to a serial board on the original layout's Windows PC.

When I updated to the eCOS I retained the separation and had no problems running even more trains automatically. It was a change of PC that required me to replace the original HSI-88 with the HSI-88-USB.

It will be interesting to see if the Pico can handle all the tasks without being overwhelmed. Of course, the limitation here will be the maximum current output from the Gleisbox, which means that we will probably be limited to 3-4 locos anyway.

Kind regards,
Adrian
Adrian
UserPostedImage
Australia flag by abFlags.com
Offline osoraku  
#73 Posted : 16 April 2025 13:27:32(UTC)
osoraku

Portugal   
Joined: 22/01/2025(UTC)
Posts: 48
Location: Setubal, Palmela
Dear Adrian -

After reading the CS2 protocol definition (version 1.0 and 2.0) and how they implement feedback, it is pretty clear that there is an "old" way and a "new" way to implement feedback. The "old" way broadcast the whole 16 state bits of an S88 module 10 times a second. This wastes bandwidth and clogs comms paths. In version 2.0 this use is deprecated. The "new" way only reports state changes, which lowers bandwidth demands enormously. I plan to use that approach, which shouldn't burden the pico at all.

As before:- fingers crossed; testing required.

Osoraku

Offline xxup  
#74 Posted : 16 April 2025 21:56:54(UTC)
xxup

Australia   
Joined: 15/03/2003(UTC)
Posts: 9,578
Location: Australia
Awesome! Count me in for testing. BigGrin
Adrian
UserPostedImage
Australia flag by abFlags.com
Offline osoraku  
#75 Posted : 17 April 2025 20:42:10(UTC)
osoraku

Portugal   
Joined: 22/01/2025(UTC)
Posts: 48
Location: Setubal, Palmela
Dear Adrian -

Originally Posted by: xxup Go to Quoted Post
Awesome! Count me in for testing. BigGrin


You're enlisted then! I got the code running and tested (TCP & UDP versions) as well as I can with what hardware I have at the moment. You can download it from the github repository. The pins to use for the feedback connections are documented in the README for it.

The main problem is how to hook up feedback devices: neither board offers easy connections. (I tested the hardware with breadboard jumpers and Rocrail reporting the feedback.) Male breadboard jumpers work best with the Joy-IT board and female with the Waveshare board.

I worked out a way to get sensor feedback into the Raspberry Pi using the header pins on the Joy-IT board. The Waveshare board could be attached similarly. Tests OK with Rocrail and JMRI.

feedback setup image

Osoraku

Edited by user 30 April 2025 11:58:56(UTC)  | Reason: Added image of connected feedback devices & JMRI testing

thanks 1 user liked this useful post by osoraku
Offline revmox  
#76 Posted : 20 April 2025 00:02:48(UTC)
revmox

Australia   
Joined: 26/05/2021(UTC)
Posts: 198
Location: Australia, East Maitland, NSW
Has anybody tried this method to increase the number of devices working through a gleisbox? In my case it could be 2 x MS2s and a direct control panel for accessories or it could allow CAN bus sniffing while two devices are in use.

There are plenty of CAN bus hubs out there but I've never seen anything in 10 pin.

SY 1.jpg

thanks 1 user liked this useful post by revmox
Offline osoraku  
#77 Posted : 20 April 2025 09:10:25(UTC)
osoraku

Portugal   
Joined: 22/01/2025(UTC)
Posts: 48
Location: Setubal, Palmela
Dear Mark - The connector provides power & CAN signals. Because you can daisy-chain CAN devices with the bus wiring (a sniffer with a comms/output path), methinks the main benefit for this cable would be to power > 2 MS2s.

Osoraku
Users browsing this topic
Guest
2 Pages<12
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.

| Powered by YAF.NET | YAF.NET © 2003-2025, Yet Another Forum.NET
This page was generated in 0.814 seconds.