|
Raspberry Pi Pico |
x 1 | |
|
L298N motor driver module |
x 1 | |
|
Male to male breadboard jumpers |
x 4 | |
|
Male to female jumpers |
x 6 | |
|
12-volt DC adapter |
x 1 | |
|
Female DC jack |
x 1 |
Raspberry Pi Pico Controlled Simple Automated Model Railroad
Intro:
A while back, I got hands-on with a Raspberry Pi Pico. It is indeed quite a good value-for-money microcontroller made by the Raspberry Pi Foundation. Being a model railroad hobbyist, I decided to make a basic model railroad automation project with this microcontroller. The Raspberry Pi Pico is programmed using the Arduino IDE, which you can learn how to do from here.
How it works:
In this project, a model train is driven with the help of an L298N motor driver, controlled by a Raspberry Pi Pico, which gets feedback from the layout with the help of a 'sensored' track. The speed of the train is controlled by applying a PWM signal to the EN pin of the motor driver. You can watch the project working here:
A great feature of the L298N motor driver module is the onboard voltage regulator. It makes it easy to power other modules and microcontrollers from the 5-volt supply of the motor driver itself without needing any discrete voltage regulator.
Let's build it!
Step 1: Get the Required Parts and Components
You will need:
A Raspberry Pi Pico
An *L298N motor driver
A 'sensored' track.
4 male to male breadboard jumpers(2 for connecting track power lines to the motor driver and 2 for connecting Pico's power and GND to the motor driver)
6 male to female jumper wires(3 for connecting the output pins of the Pico to the motor driver and 3 for connecting the sensor to the Pico)
A female DC jack connector(Optional, you need this if your power adapter has a barrel jack like usual, or you can also cut it off, strip the wire insulation and connect them directly to the motor driver's power terminals)
A screwdriver
*A good feature of this motor driver is its onboard voltage regulator which can create 5-volts, not only for the motor driver but also for other external modules and microcontroller which can be powered through the +5V terminal of the motor driver module.
Step 2: Program the Pico
Program the microcontroller with the given code using the Arduino IDE. I would recommend you go through the code to get an idea of how it works and how you can tinker with it. The source code can be found here.
You can learn how to program a Raspberry Pi Pico with the Arduino IDE from here.
Step 3: Set Up the Layout.
The upper arrow is showing the location of the 'sensored' track and the lower one is showing the approximate starting/stopping position of the train. Make sure to make proper rail joints to prevent derailing. After setting up the layout, clean the rails to ensure proper electrical contact between the locomotive's wheels and the rails.
Step 4: Connect Track Power to the Motor Driver
Connect the track power wires to the output terminals OUT1 and OUT2 of the motor driver.
Step 5: Connect Input and Output Power Wires to the Motor Driver
Connect the female DC jack's +ve wire to the +12-volt(Left) terminal, connect a male jumper and the -ve wire of the DC jack to the GND(Center) terminal. Connect a jumper wire to the +5V(Right) terminal of the motor driver.
Now there will be two jumper wires coming from the motor driver's GND and 5V pin which will power the Pico.
Step 6: Connect the Pico to the Motor Driver
Connect the 5V wire from the motor driver to the pin VSYS of the Pico, connect the wire from the GND of the motor driver to the GND pin of Pico. Then make the following connections between Pico and the motor driver:
GP7 -> ENA
GP8 -> IN1
GP9 -> IN2
You can change the above three wiring connections by changing the pin numbers in the code.
Step 7: Connect the 'sensored' Track to the Pico
Connect the VCC pin of the sensor to the 3V3 pin(Not 3V3 EN) of the Pico, GND of the sensor with GND pin of the Pico, and the output pin of the sensor to pin GP1 of the Pico.
Step 8: Tidy Up the Wires
Although optional, keeping the track power and sensor wires tied up can prevent them from getting on the track and help prevent derailments.
Step 9: Connect the Setup to Power
Check all of the wiring connections and then connect the driver to the 12-volt adapter.
Step 10: Place the Train on the Tracks
The use of a rerailing tool is highly recommended, especially for steam locomotives.
Step 11: Power Up the Setup
- If the train starts to move in the wrong direction, reverse the polarity of the track power.
- If the train does not move at all, check the wiring and ensure both the motor driver and Pico are powered up, the LEDs on both of them should be lit.
- Make sure the LED on the sensor lights up only when the train crosses it. If the LED is lit all the time, adjust the sensitivity using the potentiometer on the sensor.
Step 12: Tinker With the Project
Now that you have got your train running around, try changing some values in the code to adjust the speed of the train, stopping time, and a lot more. You can also add some more functions, like another 'sensored' track in the layout, and adjust the code to make the train stop at two points on the layout. All the best!
Raspberry Pi Pico Controlled Simple Automated Model Railroad
- Comments(0)
- Likes(1)
- ElectroMaker May 27,2021
- 1 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
8design
-
7usability
-
10creativity
-
10content
More by KushagraK7
- Raspberry Pi Pico RC Vehicle SuppliesA Raspberry Pi Pico(Almost any microcontroller can be used here, but the Pico offers great f...
- Stepper Motor Controlled Stepper Motor Without Microcontroller! Step 1: Watch the VideoWatch the video to get a full understanding of the project and learn how to t...
- Automated Model Railroad Layout Running Two Trains I made an Automated Model Train Layout with Passing Siding a while back. Upon request from a fellow ...
- Program the Raspberry Pi Pico With the Arduino IDE The Raspberry Pi Pico is a recently launched product in the family of microcontrollers and its load ...
- Reuse an Old Laptop's Touchpad to Control a Computer! PS/2 laptop touchpads are among the coolest user interface devices to use with a microcontroller. Th...
- Automated Model Railroad Layout With Reverse Loops In one of my previous projects, I showed how to make a Simple Automated Point to Point Model Railroa...
- Use a Stepper Motor As a Rotary Encoder Rotary encoders are great for use in microcontroller projects as an input device but their performan...
- Keyboard Controlled Model Train(PS/2 Interface) Using Arduino microcontrollers, there are a lot of ways of controlling model railway layouts. A keyb...
- Stepper Motor Speed and Direction Control Without a Microcontroller In one of my previous projects, I showed you how to control a stepper motor's speed using a 555 time...
- Smartphone Controlled 4X4 Robot With ESP8266 SuppliesFor this project, you will need:An ESP8266 microcontroller(Node MCU)A dual H-bridge motor dr...
- Touchpad Controlled Digital Servo Motor Here is a quick and simple project where we control a digital servo motor with the slide of our fing...
- Smartphone Controlled Model Railroad With an ESP8266 IntroA while back, I made a project where a stepper motor's position is controlled using a smartphon...
- Simple USB Volume Controller with Arduino This project uses a rotary encoder connected to an Arduino Leonardo to control the audio volume of a...
- Motor Speed and Direction Control with a Web-Server using an ESP01 Supplies:For this project, you will need:An ESP01 microcontroller(You can use any ESP8266-based micr...
- Wi-Fi Controlled Stepper Motor With an ESP Microcontroller Step 1: Get All the Required StuffFor this project, you will need:An ESP8266 microcontrollerA Steppe...
- Simple Automated Model Railroad Loop With Yard Siding Video:Supplies: For this project, you will require:An Arduino microcontroller board compatible with ...
- Laptop Touchpad Controlled Model Railroad Supplies:For this project, you will require:An Arduino microcontroller compatible with Adafruit Moto...
- Control a Stepper Motor with a Slide of Your Finger Supplies:An Arduino microcontroller boardA PS/2 touchpad from a laptop(Try to get one with a Synapti...
-
-
Helium IoT Network Sensor Development board | H2S-Dev V1.2
91 0 0 -
-
-
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
176 1 1