Jump to content
 

Using a PIC micro-processor to control trains


MarshLane
 Share

Recommended Posts

  • RMweb Gold
7 hours ago, AndyID said:

 

Hi Dave,

 

Perhaps I missed it but I rather think the only person who brought up RFID is your good-self. Feel free to correct me. I'm usually wrong (according to MrsID).

 

Andy


Hi Andy,

In fairness I did suggest RFID but also commented in a subsequent post that such a system was just one thought, there are other ways to handle loco ID on DC of course. All very dependent on the layout.

 

Rich

Link to post
Share on other sites

18 hours ago, AndyID said:

 

Hi Andy,

 

I think it's very relevant to the substance of the topic (the OP and others might have a different opinion).

 

With DCC you can tell a locomotive what speed it should run at but you don't have that option with DC unless you do some tricks. The idea of using some sort of voltage boost to compensate for changes in load is an old idea. I think I saw it first in a US model railroad mag I picked up in Glasgow many many moons ago.

 

For a basic feedback controller, my method is to use a couple of op-amps. One sums the demand and the feedback, and the other provides the current value and these are summed into a virtual earth. The snag (as you point out) is, unless you know the resistance of the motor in advance, how much do you compensate for the current? Well, with a PIC or similar just measure the motor's resistance before it gets going, add a fudge factor, and carry on.

 

Reply here or please PM me for more details if you think we are heading into the undergrowth.

 

Cheers!

AndyID

 

 

I think the multiple risks here are first that this topic will spend a lot of time and effort bit by bit designing and redesigning a non-standard system, from the bottom up , without a clear overall top down specification or even basic requirements. Second, DC is fundamentally an analog system and while I agree micros can switch digital data around quickly and efficiently,  the same does not apply to analog control voltages and motor currents. Sometimes those are most economically routed by very inexpensive relays, controlled by some simple logic. My background covers all the above, plus some analog computing, so I'm not writing hypothetically.

 

Andy

 

 

  • Agree 1
Link to post
Share on other sites

2 hours ago, Andy Reichert said:

 

I think the multiple risks here are first that this topic will spend a lot of time and effort bit by bit designing and redesigning a non-standard system, from the bottom up , without a clear overall top down specification or even basic requirements. Second, DC is fundamentally an analog system and while I agree micros can switch digital data around quickly and efficiently,  the same does not apply to analog control voltages and motor currents. Sometimes those are most economically routed by very inexpensive relays, controlled by some simple logic. My background covers all the above, plus some analog computing, so I'm not writing hypothetically.

 

Andy

 

 

 

Andy,

 

That's certainly a valid point but I think it's one of those "whatever floats your boat" things. Rich may be more interested in learning through hands-on experimentation than producing an automated layout in the shortest time. After all, it's supposed to be a hobby although it certainly is a hobby that can teach lots of things in many fields.

 

Cheers!

Andy

(well to your North where it is currently raining)

  • Like 1
Link to post
Share on other sites

On 23/01/2020 at 21:04, Andy Reichert said:

 

I think the multiple risks here are first that this topic will spend a lot of time and effort bit by bit designing and redesigning a non-standard system, from the bottom up , without a clear overall top down specification or even basic requirements. Second, DC is fundamentally an analog system and while I agree micros can switch digital data around quickly and efficiently,  the same does not apply to analog control voltages and motor currents. Sometimes those are most economically routed by very inexpensive relays, controlled by some simple logic. My background covers all the above, plus some analog computing, so I'm not writing hypothetically.

 

Andy

 

 

These days you get an awful lot of “ simple logic “ ability in a $0.90 micro controller ! 

 

 

  • Agree 2
Link to post
Share on other sites

15 minutes ago, Junctionmad said:

These days you get an awful lot of “ simple logic “ ability in a $0.90 micro controller ! 

 

 

 

And for the same 90c, you can get 10 LM 324's.  And they can work directly with the whole range track voltage range of +12v to -12v .  (Analog full forward to stop to full reverse).

 

And all the various ideas mentioned already have similarly low [priced main component cost.

 

I designed my throttle around '75, for a lot of money back then, but it looks like I could make it nowadays into a remotely switchable section controller to do the OP's basic need for around a couple of Bucks parts cost.

 

But the final spec would have to signed off first :)

 

Andy

 

 

 

 

 

 

 

 

Link to post
Share on other sites

2 hours ago, Junctionmad said:

These days you get an awful lot of “ simple logic “ ability in a $0.90 micro controller ! 

 

2 hours ago, Andy Reichert said:

And for the same 90c, you can get 10 LM 324's.  And they can work directly with the whole range track voltage range of +12v to -12v .  (Analog full forward to stop to full reverse).

 

All very true.

 

My question is, "What are you guys trying to prove?"

 

The OP asked a simple enough question and he seems to be interested in learning some things but, please forgive me if I'm wrong, y'all seem to be much more interested in demonstrating your superior knowledge than anything else.

 

So far all I've seen are a load of "do this" "don't do that" statements with next to nothing to back any of them up. This isn't an Olympics ice skating competition.

  • Like 3
Link to post
Share on other sites

Identification of train types can be obtained by attaching magnets positioned north/south, and left, right, centre,  similarlto how its been done for switching junctions on the Faller car system. But I think you are in danger of unnecessarily complicating matters if you have too many types. Performance of individual trains was often varied, particularly in the steam era.

  • Agree 1
Link to post
Share on other sites

My own interest is actually based on a project “ I’m supposed “ to be developing for a friends layout. , even if I’m snowed with other things 

 

I’m looking at deploying MERG CBUS alongside some custom modules to achieve this 

 

hence I’m interested in a realistic discussion , not an airy fairy “ micro do wonder “ or a discussion around deploying post office relays :D 

 

a reasonable discussion is useful , otherwise it descends onto speculative design theory , rather then practical Applications. 
 

DC based train identification and speed profiling is in practice too complex to achieve real useful results 

 

unlike others I actually contributed. a sketch of a digital superbloc solution that’s practical 

 

 

Link to post
Share on other sites

On 25/01/2020 at 18:57, AndyID said:

 

 

All very true.

 

My question is, "What are you guys trying to prove?"

 

The OP asked a simple enough question and he seems to be interested in learning some things but, please forgive me if I'm wrong, y'all seem to be much more interested in demonstrating your superior knowledge than anything else.

 

So far all I've seen are a load of "do this" "don't do that" statements with next to nothing to back any of them up. This isn't an Olympics ice skating competition.

 

It may have sounded like a simple question, but it raises a myriad of further needed precise definition questions and the probability of many pages of very complex multiple answers.

 

Andy

 

Link to post
Share on other sites

On 26/01/2020 at 03:33, Junctionmad said:

DC based train identification and speed profiling is in practice too complex to achieve real useful results 

 

Those are both assertions but without more data they are simply your opinions. Typically, assertions are not conducive to "reasonable discussions". In other words, if you are going to be dogmatic there is little point in having a discussion.

Link to post
Share on other sites

5 hours ago, Andy Reichert said:

 

It may have sounded like a simple question, but it raises a myriad of further needed precise definition questions and the probability of many pages of very complex multiple answers.

 

Andy

 

 

Of course it does! But who are we to think we know all the answers? Isn't the OP allowed discover answers for himself? That might result in plenty of "dead ends" but I suspect the OP will learn a lot more through experimentation than being told exactly what to do and what not to do.

  • Like 1
Link to post
Share on other sites

4 hours ago, AndyID said:

 

Those are both assertions but without more data they are simply your opinions. Typically, assertions are not conducive to "reasonable discussions". In other words, if you are going to be dogmatic there is little point in having a discussion.

AndyID , Your last set of posts are close to trolling. You come across as arguing against the poster and not the topic , yet you contribute nothing to the subject 

 

I’m a professional EE and a MR for 30 years. I’ve seen an awful lot of layouts in that time and worked on many 

 

loco identification is a difficult task. RFID has problems , barcodes don’t work , magnet systems are very limiting . I’ve yet to see a good solution for dc 

 

then you have to tie speed profiling  in again . 
 

MERG over the last 40 years probably contains the greatest number of expert contributors and almost every aspect of layout and loco control has been investigated and various solutions developed 

 

nobody there ( MERG ) has solved the issue there either , there are partial solutions, and some are quite complex 

 

yes my views ate subjective but they are backed by a lot of experience in both the technology and model railways. 
 

it’s not always possible to engage in a long technical discussion about certain aspects to show what’s difficult . But if the OP wants I can do so 

 

outside of that all i can do is express my personal perspective 

 

 

 

Edited by Junctionmad
  • Funny 1
Link to post
Share on other sites

4 hours ago, AndyID said:

 

Of course it does! But who are we to think we know all the answers? Isn't the OP allowed discover answers for himself? That might result in plenty of "dead ends" but I suspect the OP will learn a lot more through experimentation than being told exactly what to do and what not to do.

This is a forum. If the OP wants to debate any aspects he or she merely has to post. 
 

in that absence , it’s just a discussion 

Link to post
Share on other sites

On 23/01/2020 at 21:04, Andy Reichert said:

 

...designing and redesigning a non-standard system...,

 

 

Having seen 'DC controllers' with smooth regulated DC, unregulated and unsmoothed rectified AC, voltage control, current control, feedback, no feedback, various PWM schemes... is there even such a thing as a 'standard system' when dealing with DC controlled model railways?

 

Edited by sharris
  • Like 1
Link to post
Share on other sites

1 hour ago, sharris said:

 

Having seen 'DC controllers' with smooth regulated DC, unregulated and unsmoothed rectified AC, voltage control, current control, feedback, no feedback, various PWM schemes... is there even such a thing as a 'standard system' when dealing with DC controlled model railways?

 

 

I was thinking of the "communications" aspects of designing a custom bus or daisy chain module system to link multiple PIC's. Due to the sparsely known requirements, the detail aspects of that could be unique to the OP's application.

 

Andy

Link to post
Share on other sites

14 hours ago, Andy Reichert said:

 

I was thinking of the "communications" aspects of designing a custom bus or daisy chain module system to link multiple PIC's. Due to the sparsely known requirements, the detail aspects of that could be unique to the OP's application.

 

Andy

 

No doubt that could get pretty complicated but assuming reliable communication between the PICs it is not so different from passing data between objects that produce similar functions to the PICs in a central computer. There are probably a lot of valid arguments for adopting either approach.

 

Lots of interesting issues either way.

 

In theory it is possible to determine the position of any "motor" on the track in real-time with DC although it is a bit complicated and it does require modifications to locomotives. I'll post it here as an example of "thinking outside the box" and brave the adverse comments that could well I anticipate will are more than likely to result:

 

I'm pretty sure we all know that nickel-silver has quite a bit of resistance. On DC trains can slow down unless we do something about it but why not take advantage of it to determine train position? If we could measure the track resistance between the controller and the train we should be able to develop a pretty good idea of where the train was in real-time.

 

According to the conventional wisdom it's pretty obvious that this is completely nuts.

 

(But are we so sure about that?)

 

If the train responds to current rather than voltage it can actually work. The controller outputs a DC current that represents the desired motor voltage. The train (locomotive) maintains the desired motor voltage by shunting excess current. The track resistance results in a potential difference between the train and the controller. But the controller "knows" what the motor voltage is so it can easily compute the track resistance and hence the distance between the controller and the motor.

 

Simple enough, just a few minor details to sort out ;)

 

I may not be able to reply for a bit. It's ski season.

 

  • Like 1
Link to post
Share on other sites

A question to the original poster:

 

How big is your layout, and are you trying to over complicate things?

 

You say you are looking for realism in your operation - have you considered the size of a block section on a real railway? A bit of reading around seems to indicate that a main line block is a little over a km in length 

 

E.g. Ref: http://www.railway-technical.com/signalling/infopaper-6-basic-railway.pdf

 

In 2mm scale that represents about 23 feet (sorry for the mixed units!) so if you are looking for prototypical operation and unless you have a large layout, it might not actually represent many prototypical blocks.

 

Link to post
Share on other sites

On 29/01/2020 at 07:37, AndyID said:

 

No doubt that could get pretty complicated but assuming reliable communication between the PICs it is not so different from passing data between objects that produce similar functions to the PICs in a central computer. There are probably a lot of valid arguments for adopting either approach.

 

Lots of interesting issues either way.

 

In theory it is possible to determine the position of any "motor" on the track in real-time with DC although it is a bit complicated and it does require modifications to locomotives. I'll post it here as an example of "thinking outside the box" and brave the adverse comments that could well I anticipate will are more than likely to result:

 

I'm pretty sure we all know that nickel-silver has quite a bit of resistance. On DC trains can slow down unless we do something about it but why not take advantage of it to determine train position? If we could measure the track resistance between the controller and the train we should be able to develop a pretty good idea of where the train was in real-time.

 

According to the conventional wisdom it's pretty obvious that this is completely nuts.

 

(But are we so sure about that?)

 

If the train responds to current rather than voltage it can actually work. The controller outputs a DC current that represents the desired motor voltage. The train (locomotive) maintains the desired motor voltage by shunting excess current. The track resistance results in a potential difference between the train and the controller. But the controller "knows" what the motor voltage is so it can easily compute the track resistance and hence the distance between the controller and the motor.

 

Simple enough, just a few minor details to sort out ;)

 

I may not be able to reply for a bit. It's ski season.

 

You have mentioned this before Andy. It’s issues are the problems of real world applications , the resistivity of track varies, from section to section , the round trip resistance includes the motor which again is again variable , the noise floor is high compared to the measured quantity.

 

so the theory is sound , but so is controlled fusion:D 

Edited by Junctionmad
Link to post
Share on other sites

  • RMweb Gold
On 29/01/2020 at 07:46, sharris said:

A question to the original poster:

 

How big is your layout, and are you trying to over complicate things?

 

You say you are looking for realism in your operation - have you considered the size of a block section on a real railway? A bit of reading around seems to indicate that a main line block is a little over a km in length 

 

E.g. Ref: http://www.railway-technical.com/signalling/infopaper-6-basic-railway.pdf

 

In 2mm scale that represents about 23 feet (sorry for the mixed units!) so if you are looking for prototypical operation and unless you have a large layout, it might not actually represent many prototypical blocks.

 

 

Hi sorry,

Things have been a bit busy and I'd missed your original post - sorry about that. Without doubt the proposal is over complicated for the layout - but the aim was a bit of education and fun :)  In essence, I want to get things set up so that when running the layout, the operator(s) take the role of a signaller, with the layout (in the main) controlling the trains automatically depending on the route and signals set by the signaller.  However, it needs to have the capability for some manual control input in some situations, and in sidings etc.  There are many ways to do this, and initially I was looking to go down a computer controlled DCC system with TrainController - for which I had resolved most (98%) of the issues.  

 

However, having now decided that I dont want to have to modify each loco with a DCC chip in N gauge, the logic comes back to a DC system.  I started looking around, and again there are various ways of doing it - but the MERG Superbloc boards were 95% of the what I wanted. If there was already a microprocessor on the board, I could adapt it very easily to the other 5%, unfortunately, there isn't.  So the starting point became updating the boards, but in order to do that effectively and accurately, I need to improve my electronic components knowledge, hence where I am.

 

I am taking block sections to be varying lengths depending on their position on the layout, the potential for having some out of sight areas, and the hidden sidings etc.  I estimate that there is the potential for 30-40 individual section control areas on the layout once fully built, but that takes in hidden sidings, and the eventual way I choose to operate those gives a couple different options that significantly change that total up and down!

 

So thats the background - yes massively over complicated, and at the end of the day, it may not work - but trying is half of the fun isn't it.  To me, learning, making a mistake, fault finding and eventually succeeding is the other 50%.

 

I haven't taken a backseat to this thread, just not had a lot of time to do much of anything this past 10-14 days.  I do keep reading on different things, and I am still trying to get my head around how I can start a circuit in Designspark (is there any better PCB design software?) so once I've cracked that, I'll be back, with some thoughts and hopefully a circuit design.  I am determined to see this through, at least to a prototype board, in order to prove to myself I can do it.

 

Rich

Link to post
Share on other sites

1 hour ago, Mike Buckner said:

Forgive me;  what are RLSC and LSC?

 

They're pretty obscure acronyms.

 

The most likely Google Scholar could find was autonomous sliding cube architecture robots. 

 

https://link.springer.com/chapter/10.1007/978-3-030-05816-6_1

"Distributed Tunneling Reconfiguration of Sliding Cubic Modular Robots in Severe Space Requirements"

LSC = limited sliding cube. 

RLSC = root limited sliding cube. 

 

(I'm on an academic computer, so the link may be behind a paywall).

 

Otherwise the only fields I could find those abbreviations were in modelling the Earth's gravitation field (where it stood for 'Residual Lease Squares Collocation'), or in the chemistry of fuel cells, or in genetics. 

 

I'm not sure any of those are particularly relevant! 

 

 

Link to post
Share on other sites

LSC = Linked Section Control

RLSC = Reverse Linked Section Control

They are both a means of setting up a route, usually without using section switches just the point and signal controls.

With LSC the train is driven from the sending end, and with RLSC the train is driven from the receiving end.

 

 

  • Thanks 2
Link to post
Share on other sites

9 hours ago, Mike Buckner said:

Forgive me;  what are RLSC and LSC?

To be fair I didn’t spell them out , simply to see what level of research has been done. If you are interested in signal controlled layouts where the progress of the train is controlled by signals , then these are a good read as they provide solutions (  analog like super bloc ) to typically what you want to do. I know the archive documents are on the Merg  site , but I think they are around elsewhere.  LSC and RLSC ( which followed ) don’t have any speed control aspect however , merely a means of linking the dc controller section by section 

 

the issues with all these systems is that conceptually the idea  is simple, but the implementation on a “ real “ model  railway can get complex very fast, especially where a comprehensive solution is desired ( as in the throat of a complex signal controlled station approach, for example ) 

 

ive seen two super bloc layouts , lots of work etc. 

 

 

Edited by Junctionmad
  • Thanks 1
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...