Need help for a small automatic layout

RocNet(RaspberryPi), mergCBUS and LocoNet based hardware developed by Peter Giling. (GCA)
Documentation: http://wiki.rocrail.net/doku.php?id=english#hardware
Order information: http://wiki.rocrail.net/doku.php?id=gca:gca-index-en/

Need help for a small automatic layout

Postby DIYglenn » 13.05.2015, 09:29

Hi!
I'm an IT system administrator at a museum, and in one of our exhibits we're going to have a (very) small layout that we would like automated, I've never done this before and I would really appreciate if some of you could guide me through with baby steps. We're thinking of using a Raspberry Pi 2 and SPROG 3 for controlling the trains.

Info
There will be two trains;
- One passenger train with two wagons in a loop (Märklin 29478 Regional Express)
- One cargo train going back and forth between 2-3 end stops where it will pick up/drop off wagons alternating the tracks. (Märklin 29183 Construction Site)

The idea is to have one button to push (child friendly) that activates the railroad. The passenger train is simple; do a loop, then wait by the tunnel entry for the next run. We're not sure how to do it with the cargo train, if it should be activated alternative to the passenger train, or be fully automatic.
If possible, there could be a list of 5-6 actions that goes to the next line for each button press;
F.ex.
1. "Cargo train picks up wagon at track 1, returns 'home'".
2. "The passenger train does a loop"
3. "Cargo train drops of wagon at the same place, returns home"
4. "The passenger train does a loop"
5. "Cargo train picks up wagon on track 2, returns home"
etc.

It all depends on how simple and stable this is to set up.

Here's a quick mockup of the track we're going to use:
Track-mockup.png


The hidden service door will actually be the same one, and the station for the passenger train will most likely be in one of the turns, ready to pop out when activated.
After looking through the different hardware available from Peter Giling, I've come up with these parts in addition to RPi and SPROG:
- GCA_PI01 Rasberry Pi HAT
So I can use the GPIO on RPi.
- GCA_PI02 32 bits I/O board
So I have something to connect I/O boards to
- GCA_PI03 16 channel PWM board
So I can control some LEDs (sparks, campfire etc) and servos for the turnouts and decoupler (DIY system)
- GCA173 Hall-sensor and/or reed-switch input unit
So I can tell SPROG when to start/stop a train

AFAIK this should be enough to control all functions on the layout except two: The goods stations. After decoupling a wagon, then going back and forth, I need to couple it to the locomotive again. I was thinking a micro switch at the end of the track, so the locomotive can go slowly towards the wagon, push it to the end, and when there's resistance the coupler will snap on, and the microswitch will be activated - telling the train that the wagon is (most likely) connected and ready to return to the hidden station. Also, the sensor for decoupling has to be deactivated for a short while, so it doesn't decouple again before leaving the track. I couldn't find a way to connect the micro switches to any boards though?

It seems like the GCA173 has everything included, but there's an extra €4 to pre-program the prosessor? Anyways - those 8 hall sensors should be enough right? One in each tunnel end (activate horn etc), one on each hidden station, goods, decoupler etc.

What do you think? Am I way off here? We're thinking as cheap as possible, reliable for almost 1 year in use, no need for future expansions etc. We want to be able to set it up relatively quick.

I'm sorry if this post is way too long, but I'm trying to make sure our idea is clear.
You do not have the required permissions to view the files attached to this post.
DIYglenn
 

Re: Need help for a small automatic layout

Postby DIYglenn » 13.05.2015, 13:34

Very short version; Can I easily connect a micro switch (button-type) to RocRail on Raspberry?

Is the API available, so that I can maybe trigger with an external button?
DIYglenn
 

Re: Need help for a small automatic layout

Postby peter&basti » 13.05.2015, 22:37

Hi Glenn,

When using Rocrail, also the Push Button to Start one or more schedules ist possible. No API is necessary when using the right DIY Hardware around.

Have a Look on RocNetNode, using Pi02 as I/O you can Connect both Inputs (Push Button, Feedback Sensors e.g. GCA173) and Outputs (switch Control, lights, Signals) on one board.

http://wiki.rocrail.net/doku.php?id=roc ... netnode-en
Liebe Grüße / best regards
Peter


System: DCC 2-Leiter H0, Rocrail 64bit auf Win10 Pro 64
Traktion: OpenDCC GBM
Fahrweg: RocNetNode & GCA PI01/2/3, GCA41/Arduino RFID, GCA145 Drehscheibe, etc.
Decoder: 99% Zimo
Experimentell: MQTT & Node-Red
peter&basti
 

Re: Need help for a small automatic layout

Postby DIYglenn » 13.05.2015, 22:41

That is great news! Thank you!

But I got a bit confused with the RocNetNode. How does that differ from the modules I listed in the first post?
Which can I connect a pushbutton/micro switch to?
DIYglenn
 

Re: Need help for a small automatic layout

Postby peter&basti » 13.05.2015, 22:57

Hi Glenn,

My mistake, i Did not scroll down completely your First Post :oops:

RocNetNode ist using a RasPi to Control the Layout and Rocrail is usually Running on a different Computer (RasPi or any other, in my Case a very outdated Tower PC with Windows XP)

Some Colleagues tried to run both on one RasPi (maybe successful, i read about here in the Forum but i am not sure)

The simple way (for me, i am not a IT specialist) Is using the Standard RR and Rocnetnode deliverables on different computers
Liebe Grüße / best regards
Peter


System: DCC 2-Leiter H0, Rocrail 64bit auf Win10 Pro 64
Traktion: OpenDCC GBM
Fahrweg: RocNetNode & GCA PI01/2/3, GCA41/Arduino RFID, GCA145 Drehscheibe, etc.
Decoder: 99% Zimo
Experimentell: MQTT & Node-Red
peter&basti
 

Re: Need help for a small automatic layout

Postby peter&basti » 13.05.2015, 23:01

Hi Glenn,

PI02 is a Universal IO Board. In RR you can configure each of 32 Connectors as Input or Output. Therefore you can Connect both turnouts and your push button(s)

All Definition Can be Done easily in RR.
Liebe Grüße / best regards
Peter


System: DCC 2-Leiter H0, Rocrail 64bit auf Win10 Pro 64
Traktion: OpenDCC GBM
Fahrweg: RocNetNode & GCA PI01/2/3, GCA41/Arduino RFID, GCA145 Drehscheibe, etc.
Decoder: 99% Zimo
Experimentell: MQTT & Node-Red
peter&basti
 

Re: Need help for a small automatic layout

Postby DIYglenn » 13.05.2015, 23:22

I will definitely run the RPi2 as server only, client on my MacBook Pro, that's my main reason for choosing RocRail. The absolute correct way to go.

So to clear things up a a bit:
-PI01 is of course needed to have the interface available to my RPi.
-PI02 is the ACTUAL I/O module and can work standalone for all sensors, switches and LEDs? This is the "Arduino" of RocNet?

The other boards are just extensions for PI02, all occupying 8 out of the 32 pins? So 1 pin is 0V, one is 5V and the other 8 are signal?

If so, the reason for the extension boards are to have ready solutions for PWM (soft LEDs and servos) and to have a pre-thought layout with pulldown resistors etc?

I'm sorry, but I'm just a bit confused here. F.ex, do I have to use GCA-173 for hall sensors? What does pic16f628a do that the PI02 board can't?

How would I connect a typical NC/NO micro switch to PI02? 0V + a pin? Multiple switches would have to be connected to a common ground wire from the one ground pin, the rest to the other 8 pins? The 5V pin is only for external modules when using a 10-pin connector?

I can easily make a small expansion board with veroboard for 2-3 micro switches and buttons, I'm just a bit unsure how PI02 wants to interact with a micro switch. Does it want pulldown resistors etc?

Do I have to buy all the boards I listed to make my small layout work?

Sorry for all my questions. I love the idea of RocRail, the elegant server/client solution etc, but I'm finding it hard to get started with little experience.
If i ever get good at this I would love to contribute with tutorials for absolute beginners etc. I'm not the best programmer, not the best electrical engineer, but I know computers, and I like tinkering with small scripts and functions.

Thanks for helping me. I appreciate it! :beer:
DIYglenn
 

Re: Need help for a small automatic layout

Postby peter&basti » 14.05.2015, 08:47

Hi Glenn,

The PI02 converts from I2C Bus to 32 IO Ports. you can Connect. Max 4 PI02 to one Node (128 IO Ports)
The PI03 converts from I2C Bus to 16 PWM Channels. Max 8 Pi03 to one Node (128 Channels) in Addition to the IO Ports.

One Node = one RasPi + PI01 GPIO --> I2C Header

The RocNet HW was designed for compatible use of other GCA Boards e.g. Driver for Motor or magnetic turnouts, turntable Stepper Motor drivers and a lot more.

So i am using still the GCA136 Servo driver which i had implemented initialliy with gca50 Loconet I/O

The PIC on the GCA173 have only the Job to generate a pulse of min. 100 ms for Secure recognition of the Hall at IO Port.
http://wiki.rocrail.net/doku.php?id=gca173-en#features
Liebe Grüße / best regards
Peter


System: DCC 2-Leiter H0, Rocrail 64bit auf Win10 Pro 64
Traktion: OpenDCC GBM
Fahrweg: RocNetNode & GCA PI01/2/3, GCA41/Arduino RFID, GCA145 Drehscheibe, etc.
Decoder: 99% Zimo
Experimentell: MQTT & Node-Red
peter&basti
 

Re: Need help for a small automatic layout

Postby DIYglenn » 14.05.2015, 10:26

Got it!
Excellent! Thank you so much for helping!

I was a bit confused with the pricing of the GCA173, is the pre-programmed chip included when you buy the kit? Or do you also have to spend an extra €3.95 for the chip?

Or is it if you only want the chip with firmware installed, for DIY purposes?
DIYglenn
 

Re: Need help for a small automatic layout

Postby peter&basti » 14.05.2015, 17:21

Usually the Kit includes the Programmed PIC.
Liebe Grüße / best regards
Peter


System: DCC 2-Leiter H0, Rocrail 64bit auf Win10 Pro 64
Traktion: OpenDCC GBM
Fahrweg: RocNetNode & GCA PI01/2/3, GCA41/Arduino RFID, GCA145 Drehscheibe, etc.
Decoder: 99% Zimo
Experimentell: MQTT & Node-Red
peter&basti
 

Re: Need help for a small automatic layout

Postby peter&basti » 14.05.2015, 17:24

Hi Glenn,

Just a question: where Is the museum located? Maybe somebody want to have a Look on your layout when finished :wink:
Liebe Grüße / best regards
Peter


System: DCC 2-Leiter H0, Rocrail 64bit auf Win10 Pro 64
Traktion: OpenDCC GBM
Fahrweg: RocNetNode & GCA PI01/2/3, GCA41/Arduino RFID, GCA145 Drehscheibe, etc.
Decoder: 99% Zimo
Experimentell: MQTT & Node-Red
peter&basti
 

Re: Need help for a small automatic layout

Postby DIYglenn » 30.05.2015, 07:43

peter&basti wrote:Hi Glenn,

Just a question: where Is the museum located? Maybe somebody want to have a Look on your layout when finished :wink:

I'm sorry for not responding earlier.
It's in Trondheim, Norway :)
DIYglenn
 

Re: Need help for a small automatic layout

Postby DIYglenn » 23.06.2015, 15:11

I'm finally getting closer with my test setup. I've setup two blocks (end stations) and I got a train running on a schedule. Actually what I did was just create the schedule, from block 1 to block 2, and now it is running automatically back an forth (even though the tutorial says it should run once).
It's starting at random, probably because delay is set to 60 seconds. It is still on absolute time, and 00:00 on both blocks.

I'll experiment some more from here, now as I have a test setup.

One more thing; How do I automatically start it in "Auto Mode" without having to log in to RocView? Power is on automatically, I set that under Interfaces in RocRail properties, but how about auto mode?
DIYglenn
 

Re: Need help for a small automatic layout

Postby DIYglenn » 23.06.2015, 17:04

DIYglenn wrote:The idea is to have one button to push (child friendly) that activates the railroad. The passenger train is simple; do a loop, then wait by the tunnel entry for the next run. We're not sure how to do it with the cargo train, if it should be activated alternative to the passenger train, or be fully automatic.
If possible, there could be a list of 5-6 actions that goes to the next line for each button press;
F.ex.
1. "Cargo train picks up wagon at track 1, returns 'home'".
2. "The passenger train does a loop"
3. "Cargo train drops of wagon at the same place, returns home"
4. "The passenger train does a loop"
5. "Cargo train picks up wagon on track 2, returns home"
etc.

Not quite sure how to achieve this, but hopefully I'll find something the next few days.

How about "disabling" the button until the active schedule is finished? This is meant for children, they will push that button 100 times before the first passenger train loop is finished.
Also, I was considering splitting it up in two buttons - one for each train, could this be achieved in a simple way?
- That way button 1 will always send the passenger train in a loop (maybe 2-3 scheduled with different speed?)
- Button 2 will switch between the different cargo operations (pick up wagon 1, put it back, pick wagon 2, put it back etc.)

Also I'm a bit unsure on how to use the uncouplers, is it possible to have a micro switch that doesn't just toggle on/off, but toggles position 1, position 2 (servo position left or right)? That way it will couple the first time the cargo train comes (and picks up the cargo) and the next time it hits the switch, the decoupler will be activated, and the cargo remains on the track (maybe I'll have a small angle so it rolls away from the train).

I hope someone can guide me through this. I've realized that RocRail is definitely capable of a lot of configurations, but I'm not entirely sure on how to achieve my goal here, which isn't a typical setup.
DIYglenn
 

Re: Need help for a small automatic layout

Postby DIYglenn » 09.10.2015, 10:41

So, here I am a few weeks before opening the exhibit.

The model is now just a loop. Push a button, Train goes from "Station" block to "Through" block (where wait = no), and back to station.
This works perfectly...until a reboot...

For some reason after a reboot, the train never stops running after pushing the button?!!

- If I manually put the train in the "Station" block and click the button, it works, but never stops
- If I manually put the train in "Station", then drag from "Station" to "Through", it goes to that block, and stops (With BBT)
- If I drag from "Through" to "Station", it goes back to "Station", and stops (with BBT)

If I THEN click the button, everything works fine again, it does a circle, and starts breaking at the Station_enter sensor, and stops at Station_in.

If I do a reboot, I have to manually make it go through the blocks, and then the button works as normal again.

Why is this?
Is it a bug?

I'm running Rocrail 2.0-9271.

For some reason git pull doesn't work so I can't update it either.
Last edited by DIYglenn on 09.10.2015, 11:22, edited 1 time in total.
DIYglenn
 

Next

Return to GCA (Hardware by Peter Giling)