The Arduino Z-Scale Trolley Project.

Curn Jul 17, 2023

  1. Curn

    Curn TrainBoard Member

    752
    500
    32
    Yes, I suppose I forgot the mention the layout base. I’m using a 6” by 24” birch wood painting panel made by US Art Supply with the 1-1/2 inch deep base. They have a variety of other sizes. I have also purchased panels from American Easel for past projects. They sell a 24x48 panel which is great for starter layouts. I made a N scale layout for my kid with one of those.

    IMG_7635.jpeg

    Inspired by John Cubbins wood veneer tutorial, I ordered some walnut veneer to put in the ends of the layout.

    https://www.raildig.com/raildig-build-projects/diorama-fascia-wood-veneer/

    Except I used the iron on, heat glue kind. It worked about the same.

    This is it before staining:
    IMG_7627.jpeg

    I then stained it with similar-transparent dark walnut stain, and it turned out much darker than John’s ebony on red oak. I then sealed it with polyurethane.

    IMG_7637.jpeg

    I also bought a better potentiometer. The first ones I got said they were linear, but the one I was using had poor useable range. The new one is a B103 that says it’s made by Cosmos Tokyo, but was sold as a “Taiss RV24YN20S 10K”. I like this new one much better. I can see from the serial monitor that it is much more accurate.

    IMG_7633.jpeg

    -Matt
     
    gmorider, CNE1899, rray and 2 others like this.
  2. Curn

    Curn TrainBoard Member

    752
    500
    32
    Ok, I have updated the code to move the analog sensors over to the digital inputs. I added code to support an optional display and a optional small vibrate motor to auto correct stalls when the train starts. I also reconfigured it to support multiple layout types. So you can configure the code by setting the layout type and number of stations, and it will operate the layout appropriately. Instructions on how to change these configurations are in the code: https://github.com/Wonruc/ZScalePoint-to-Point

    The code by default supports 4 stations on pins D4, D5, D6, and D7. This could be expanded utilizing pins D2, D10, A3, A6, and A7. Drop the display and you could get A4 and A5 too. As the Uno motor shield has D5 and D6 inputs, I used those for stations A and B. So now the basic setup for an uno system looks like this:
    ArduinoUnoPointToPoint.png

    I got everything put together on mine and it is operating well.
    IMG_7765.jpg

    Here is the vibrate motor. It actually works pretty well to correct when the trolley occasionally stalls when it stops or starts at a station, just to give it a little nudge.
    IMG_7767.jpg

    Here is the diaplay I used, a white Hiletgo 128x64 pixel white oled I2C display connected to pins A4 and A5 for the Uno/Nano. I also got a layer of dirt, track painted, and ballasting done.
    IMG_7786.jpg

    -Matt
     
    Last edited: Aug 15, 2023
  3. Curn

    Curn TrainBoard Member

    752
    500
    32
    Now for the display, I created some little images to show what the layout is doing so that you don't need the serial monitor to diagnose issues.

    At Station A
    IMG_7739.jpg

    Going to Station B
    IMG_7740.jpg

    At Station B
    IMG_7741.jpg

    Going to Station A
    IMG_7742.jpg

    And, Something is Wrong:
    IMG_7743.jpg
     
    Last edited: Aug 14, 2023
    gmorider, SJ Z-man, Kez and 2 others like this.
  4. rray

    rray Staff Member

    8,312
    9,462
    133
    I am impressed most by thinking of an anti stall feature, perfect use for a pager motor to help balky locos. [​IMG][​IMG][​IMG][​IMG][​IMG]
     
    SJ Z-man, Curn and Kurt Moose like this.
  5. mdvholland

    mdvholland TrainBoard Member

    532
    891
    30
    So Matt, how does the pager motor help to prevent stalling?

    Matt
     
  6. rray

    rray Staff Member

    8,312
    9,462
    133
    Place a pager motor at each stop of the loco, and if the loco (assuming it's a small 2 axle or otherwise non optimal electrical pickup loco) looses electrical conductivity at that stop, the pager motor cycle vibrates the track, causing intermittent electrical conductivity, until the loco motor can spin up to speed. It's a fail safe for reliable operation of repeating point to point operation.

    Smaller locos often have an electrical pickup hysteresis where changing directions or rolling a bit backwards at a stop, often develops a small buildup of crud that can cause those locos to not have good track power pickup.
     
  7. Curn

    Curn TrainBoard Member

    752
    500
    32
    It is not to prevent a stall, but to correct for a stall. And it surprisingly works well. It went from something where the trolley might go in 20-30 cycles before it would get stuck at a station, to where I come back hours later and it is still running. It is the same as me physically tapping the layout to get a stalled train moving again. And really this only happens while the train is departing a station. This vibrate motor is small and not very strong. This works because this is a tiny layout. On a much larger table, I suppose you could use a larger vibrate motor, or even a solenoid to tap the table, but the same concept could be used to automate table bumps.

    The trolley runs fine most all the time. The code has acceleration and deceleration feature to it, and so when you are at the slowest speeds at stops and starts, all trains tend to stall more under those conditions.

    But I also have the current sensing code for short protection, and I utilize the current reading to detect stalls. The current is a noisy reading. At high current, this noise is because of the PWM to the track power, and you have no practical control over when you sample the signal (at a "on" or "off" of the PWM). To overcome this, I sample the current 50 times and report the highest reading detected. One sample is taken every 10 ms. With 50 readings, one every 10 ms, the current value is updated ever 500 ms.

    How the stall detection is working, is when a train leaves a station, the current should spike as the train starts moving. After 1000 ms (two current reading updates) after the train should depart the station, if a current spike above a 5 ma threshold is not detected, the code turns on the vibrate motor for 1000 ms to bump the layout.

    Unfortunately the OLED display is causing me some feedback issue causing low non zero readings in the current sensor (Usually 1-2 mA). With the display removed, and a true stall, the current sensor reads 0 with no noise. So without the OLED display I could modify the code to detect 0 current at any time and auto-bump the table to get things going, but for now, the solution to detect the motor start current spikes works well enough.
     
    SJ Z-man, CNE1899, Kez and 2 others like this.
  8. mdvholland

    mdvholland TrainBoard Member

    532
    891
    30
    Thanks for explaining, Matt.
     
  9. Kurt Moose

    Kurt Moose TrainBoard Member

    9,860
    14,346
    147
    I noticed you have ballast down now, Curn.

    Got an updated pic?;)
     
    Curn likes this.
  10. Curn

    Curn TrainBoard Member

    752
    500
    32
    Yeah. I was going to wait to get more scenery done. I seem to have misplaced my static grass applicator, and a better new one is one the way. I may have thrown my old one away on purpose to force me to get a better one, and then forgot about it. It was a cheap one and didn't do much, so no big loss.

    The ballast I used was Arizona Rock and Mineral Z scale Pennsylvania RR ballast and the dirt is their Low Desert Soil. I had stocks of these, and I like the way the look. Track was painted Mission Models Dark Rust and ties are Rotbraun RAL 8017. And I remembered how to do Focus Stacked photography.
    DirtAndRock.jpg
     
    SJ Z-man, Gen, gmorider and 5 others like this.
  11. Kurt Moose

    Kurt Moose TrainBoard Member

    9,860
    14,346
    147
    Lookin' good!!(y)
     
  12. Svein-Martin Holt

    Svein-Martin Holt TrainBoard Member

    348
    377
    26
    Great project, but I wonder why you have connected the potentiometer like you indicate in the schematic. The "normal" way to use a potentiometer is to connect the ends to +5 V and GND, and the analog input pin to the slider. Then you will have a value og 0 to 1023 on the arduino pin when you do a digitalRead and can map the values to another range if you want. And if you need any "specialities", you can manage that in the code. Just wondering :)
     
    Curn likes this.
  13. Curn

    Curn TrainBoard Member

    752
    500
    32
    You are correct.

    As far as the potentiometer wiring goes, I copied that directly from this video at 3:20:


    It worked so I didn't put much thought into it.

    And looking at the comments a few others noticed the same issue you have, however the configuration does provide a 0 to 5V (or a ~ 47 to ~1022 mv reading from the analog input) where counter clockwise is low and clockwise is high. Although I'm sure things are flowing backwards through the potentiometer than how it is intended to work.

    But according to other documentation, the outside pins should be GND and +5 V and the center should be signal, and no resistor is needed when using a 10K potentiometer.

    I'm not sure what the 470 ohm resistor is for. A quick look at other projects, it seems to only be used when directly powering an LED through a potentiometer to limit current going through the LED. So for this project it would be irrelevant.

    I will update the gethub to removed the resistor, and re-arrange the wires correctly. I appreciate the catch. Like I said, I'm an armature at this.[/URL]
     
    SJ Z-man and Svein-Martin Holt like this.
  14. Svein-Martin Holt

    Svein-Martin Holt TrainBoard Member

    348
    377
    26
    I wrote digitalRead in my post, the correct should be analogRead. :)
     
  15. Curn

    Curn TrainBoard Member

    752
    500
    32
    I got the bulk of the scenery done. There is one big thing I haven't done and I'm not sure if I'm going to. I haven't done the catenary, mostly because I'm not sure how to make good period appropriate catenary. The Rokuhan and Marklin ones are too modern. To do it right, to look right on a rural railway, it would be toothpick power poles, with wooden arms holding a single electric line out there. If anyone has ideas on what to use for the wire, I would love to hear it. I thought about using a single line of piano wire. It needs to be robust, because there is no keeping people from touching it.

    I made some little stations out of kits from Mike Basher, who sells these laser kits on ebay (Miata Mike). He is using a paper laser material similar to arch-stories, and they build up well. I used his loading dock kit and a speeder shed kit. Both turned out well, took paint well, and were easy to build. The instructions are pretty much all text.

    PtoP1s.jpg

    PToP2s.jpg

    PtoP3s.jpg

    The ground cover was build up in layers on top of the dirt/rock ground cover. Basically, I work in sections, putting down a layer of white glue, adding some grass tuffs(Late Summer Green 2mm Tuffs), a light sprinkling of ground ground foam, a sprinkling of green 2mm (I think late summer) static grass, then some WS harvest gold static grass, and last some Heki winter or prairie (HK3363) static grass. This gives the grass an early/mid California summer look where things are starting to dry out, and the tops of the grass are drying out, but the bottoms of the grass is still green.

    Trees are Scenic Express SuperTrees, which is a sagebrush like plant material that you typically dip in diluted mat medium and then sprinkle ground foam on. Rather than dipping them in the mat medium they recommend, I just sprayed them with 3M super 77 spray glue and sprinkled with foam. I have also used hairspray in the past, but this 3M spray glue, the foam isn't falling off with handling, so this is my new preferred method.

    And of course, a video showing it operating:



    -Matt
     
  16. CNE1899

    CNE1899 TrainBoard Member

    1,118
    1,899
    36
    Matt,
    The module looks great!(y)(y)(y)
    Nice work on the buildings and Beautiful grass work!
    Thanks for the video and explanations.

    Scott
     
  17. John Bartolotto

    John Bartolotto TrainBoard Supporter

    1,532
    1,064
    46
    Very cool!!
     
  18. Kurt Moose

    Kurt Moose TrainBoard Member

    9,860
    14,346
    147
    Great work on that, too cool!(y)
     
  19. mdvholland

    mdvholland TrainBoard Member

    532
    891
    30
    Kurt Moose, Kez and CNE1899 like this.
  20. JoeS

    JoeS TrainBoard Member

    3,214
    1,249
    64
    I like it a lot! I like the way you trimmed it out too!
     

Share This Page