Total Pageviews

Showing posts with label H0. Show all posts
Showing posts with label H0. Show all posts

Wednesday, May 18, 2022

How to define, store, test and control the turnouts (with servo) in DCC++Ex

    As a beginner with model railroading I tested also DCC control using a custom locomotive.

My custom locomotive was make using just bogie from an old locomotive, adding DCC ready board and NEM652decoder.


   DCC control was choose as DCC++EX
so, I used for as Command Station: Arduino Mega development board, a Motor shield, ESP8266-01 with logical level adapter, i2c LCD1602 (and than OLED)  display + 4 servos connected at an expander board on i2c with 16 outputs using PCA9685 chip, using info from
https://dcc-ex.com/get-started/wifi-setup.html
https://dcc-ex.com/get-started/installer.html
  For the throttle I used 2 versions:
   I was interested to control servos (for future turnouts) so I used info from:
https://dcc-ex.com/reference/software/command-summary.html
   Base commands for turnouts in DCC++EX are:
and for SG90 servo:
   Easiest mode is to use web throttle (serial control)
   So, for first servo (turnout), command is <T 200 SERVO 100 410 205 3>, where 200 is choose ID for turnout, 100 is VPIN (virtual pin for first servo connected at PCA9685), 410 is PWM number for throw (open) for SG90, 205 is PWM number for close position and 3 is slowest movement (0 is fastest movement).
   For second servo (turnout), command is <T 201 SERVO 101 410 205 3>, where 201 is choose ID for turnout, 101 is VPIN (virtual pin for second servo connected at PCA9685), 410 is PWM number for throw (open) for SG90, 205 is PWM number for close position and 3 is slowest movement..
   So, for third servo (turnout), command is <T 202 SERVO 102 410 205 3>, where 202 is choose ID for turnout, 102 is VPIN (virtual pin for third servo connected at PCA9685), 410 is PWM number for throw (open) for SG90, 205 is PWM number for close position and 3 is slowest movement .
   So, for first servo (turnout), command is <T 203 SERVO 103 410 205 2>, where 200 is choose ID for turnout, 100 is VPIN (virtual pin for first servo connected at PCA9685), 410 is PWM number for throw (open) for SG90, 205 is PWM number for close position and 2 is medium movement.
   Next step (mandatory) is to store this turnouts in EEPROM memory using <E> command
   I can check the defined turnouts using <T> command
   Base commands are:
- to throw (open) thefirst turnout
- to close the first turnout

   When open Android "Engine Driver" I saw the turnouts defined
so I ca control the servos:
- all turnouts throw (open)

- first turnout closed, rest turnouts open

- all turnouts closed

     You can see a video with control the turnouts with servo: 4 servo (turnouts) controlled by Arduino as DCC++Ex Station and Engine Driver app


Bibliography:

Thursday, March 3, 2022

Arduino automatic model train

original article

   As a noobie with the model train system and because I haven't too much free space for test with big railways, I search for an automatic model train system, where it used IR module for define frake momment (stop position is not instant, as in rea case, if push brake pedal and car stop is after few meters).

    First I found the video I Made an Automated Model Train With An Arduino! where it used direct control (DC voltage with normal or reversed polarity). I tested manually the functionality of the system with my adapted sketch as in video Automatic Model Train (test)

After that, I found article Back-and-forth train control by Arduino with IR sensor

with PWM control for speed, so I adapt the sketch (my sketch) and made a first test with push a carriage push by me, to see how system work, as in video Automatic Model Train (test 2)
   Finally, I added L298 H-bridge module as in schematic
    First video is Arduino automatic model train

and second (with an oscilloscope on railway power) is Arduino automatic model train (2)


5-March-2022
    After I clean and greased an old Fleischmann 1966 as in movie 1966 Fleischmann 1306 Shunter: O&K MV9 - Bringing it back to life I make a new video named Fleischmann 1966 on Arduino automatic model train.
   PS: Improved sketch is controlled_model_train_1b.ino where it used for start PWM at 105 (aprox. 40%) not 0, remain maximum at 255 from 255 (100%). This mode to start the loco is useful for old DC motor.
   In next image you can see how automatic system for control the train ("loco") works:
   If train go forward, speed is constant, at maximum, if IR module 2 is actuated, speed decrease slow until train stop. After a small pause, train go backward, with speed increase from zero to maximum, and than IR module 1 is actuated, speed decrease slow to until train stop. Again, after a small pause, train go forward and cycle is repeated, as in next image: