RudyB Posted February 28, 2019 Author Share Posted February 28, 2019 Fun with Arduino 18 Railway Crossing, Servo Motor to Operate the Gate In part 2 of the railway crossing project we are going to connect the servo motor that operates the gate and control it with the Arduino. With the example in the video, the gate beam is mounted directly on the servo. On a layout, the servo motor will probably be mounted under the board, and a metal rod pulls / pushes the beam up and down, through a hole. No matter how it is mounted ... we need to find the correct servo angles. We will write some code with which we can fine tune the servo to find the angles to be used in the code later on. Fun with Arduino 18 Railway Crossing, Servo Motor to Operate the Gate 2 Link to comment Share on other sites More sharing options...
richard brown Posted February 28, 2019 Share Posted February 28, 2019 I watched this video and found it very useful thank you for sharing Richard 1 Link to comment Share on other sites More sharing options...
RMweb Premium melmerby Posted February 28, 2019 RMweb Premium Share Posted February 28, 2019 7 hours ago, richard brown said: I watched this video and found it very useful thank you for sharing Richard Yes. Rudy's videos (on various aspects of model railways) are definitely worth a look. Seeing it in pictures makes it so much easier to understand. Link to comment Share on other sites More sharing options...
RudyB Posted March 7, 2019 Author Share Posted March 7, 2019 Fun with Arduino 19 Railway Crossing Train Detection with Optical Sensor There are several ways to do train detection, like sensing rail current, or a magnet under the train that triggers reed switches along the track, or with an optical sensor. The latter is used in this video, only because I had some TRCT5000's lying around and they were easy to setup for a demo. As soon as we have them working, we have some fun with them by making a train speed measurement device. Fun with Arduino 19 Railway Crossing Train Detection with Optical Sensor 2 Link to comment Share on other sites More sharing options...
RudyB Posted March 10, 2019 Author Share Posted March 10, 2019 Fun with Arduino 20 Railway Crossing Putting it all Together We have seen the separate ingredients for a level crossing in the previous three videos: blinking LEDs, servo to operate the gate, sensors to detect the train ... it is time to put it all together now into one piece of software. We'll use the State Transition Diagram as our starting point and build up the software in 5 easy to follow steps. Fun with Arduino 20 Railway Crossing Putting it all Together Railway Crossing UK version 1 Link to comment Share on other sites More sharing options...
RudyB Posted March 14, 2019 Author Share Posted March 14, 2019 Fun with Arduino 22 Step Sequencer for LEDs with array[] and for() loop A police car, fire fighter car or an ambulance with flashing lights can liven up any model railway laout. The challenge that we set ourselves is not to have to write different code any time we want another flashing pattern. We want to hav one and the same code and we only want to configure the number of stepd, number of LEDs and the flashing step sequence. Can we manage that? Yes of course we can ... Fun with Arduino 22 Step Sequencer for LEDs Link to comment Share on other sites More sharing options...
RMweb Premium melmerby Posted March 15, 2019 RMweb Premium Share Posted March 15, 2019 (edited) If you are interested in buying an Arduino compatible and would rather buy from a UK supplier with next day service, Rapidonline are doing 30% off their Orangepip range until Easter Quote "Arduino2019" at the checkout BTW If you want to use lots of sensors with an Arduino (Part 19) there is a model railway aimed shield here: http://www.azatrax.com/arduino-shield-ir-detector.html Edited March 15, 2019 by melmerby Link to comment Share on other sites More sharing options...
RudyB Posted March 21, 2019 Author Share Posted March 21, 2019 Fun with Arduino 23 Neopixel Addressable LED, WS2812, struct{...} Neopixels, or addressable LEDs, are color LEDs with a built in chip that takes care of the one wire data communication and of the Pulse Width Modulation for the built in RGB(+W) LEDs. The LEDs are connected via just 3 wires, GND, 5V, Data. The Data line is connected to an Arduino output and we can control the color and brightness of multiple LEDs, via just one output. Wonderful to use in say a village with multiple houses on our model railway layout. The wiring is super simple and the lights in every house switch independently and can each have their own color an brightnes ... just like real. Link to Fun with Arduino 23 Neopixel Addressable LED, WS2812, struct{...} Link to comment Share on other sites More sharing options...
RudyB Posted March 29, 2019 Author Share Posted March 29, 2019 Fun with Arduino 24 Neopixel Sequencer with Flexible Timing and Colors In video 23 we made a step sequencer for addressable LEDs (Neopixel). The beauty of it is that a LED on/off sequence is created in a visual way by editing a series of ‘1’s and ‘0’s: 1,1,1,0,0,0,1,1,0,0,1,0,1,1,0,0. The drawback being that the color of every LED is fixed and also the interval time is fixed. The sequencer in this video has full flexibility, every action step has its own timing and LED color / brightness. Link to Fun with Arduino 24 Neopixel Sequencer with Flexible Timing and Colors Link to comment Share on other sites More sharing options...
RudyB Posted April 11, 2019 Author Share Posted April 11, 2019 Fun with Arduino 26 Tune a Servo with a Rotary Encoder In the previous video we wrote code to read out the pulses and the switch of a rotary encoder. We are now going to use this to tune a servo motor. With every mechanical construction where a servo is used to move something (garage doors, a gate beam, a turnout), the minimum and maximum servo angles need to be found for the construction to operate like we want it to. In this video we are going to build a 'servo tuner' to find those angles. Fun with Arduino 26 Tune a Servo with a Rotary Encoder 1 Link to comment Share on other sites More sharing options...
RMweb Premium melmerby Posted April 11, 2019 RMweb Premium Share Posted April 11, 2019 Hi Rudy What happened to "Fun with Arduino 25"? 1 Link to comment Share on other sites More sharing options...
RudyB Posted April 15, 2019 Author Share Posted April 15, 2019 (edited) Oops, that must have been a small case of Alzheimer ... NR 25 did not get posted. Here it is ... Fun with Arduino 25 Rotary Encoder with Switch A rotary encoder is a digital device, approximately the size of an analog potentiometer. When rotated, it generates 2 pulse signals from which we can deduct the number of rotation steps and the direction of rotation. It also has a push button on board. When connected to the Arduino we can read out the encoder and change the value of a variable. The variable can be used for anything we like: control the brightness of a LED(strep), control the angle of a servo motor, and more. In this video we build the software to read out the encoder and switch and control the brightness of a LED (via PWM). In the next video we are going to beuild a servo tune application based on it. Fun with Arduino 25 Rotary Encoder with Switch Edited April 15, 2019 by RudyB 1 Link to comment Share on other sites More sharing options...
RudyB Posted April 18, 2019 Author Share Posted April 18, 2019 Fun with Arduino 27 Recognize Slow / Fast Rotation of Rotary Encoder The Servo Tuner that we built in the previous video can be enhanced with two features: 1: Recognition of slow or fast rotation of the rotary encoder, to be able to increment the motor with small steps or with larger steps. 2: Recognition of short or long press of the button, to be able to move to the min/max angles or to the midpoint of the servo. In this video we will have a look how we can add these functions. On the blog there's also code available to operate the Servo Tuner with a wire or with push buttons, in case you don't have a rotary encoder available. Link to Fun with Arduino 27 Rotary Encoder Slow / Fast Recognition 1 Link to comment Share on other sites More sharing options...
RudyB Posted April 25, 2019 Author Share Posted April 25, 2019 (edited) Fun with Arduino 28 Use an External Editor like Notepad++ When writing more code than just a few lines, it might be worthwhile to invest a little bit of time to to start using a more capable editor than the one integrated in the Arduino IDE. There are several free editors around that have a wealth of features that make code editing more efficient and more pleasurable. Link to Fun with Arduino 28 Use an External Editor like Notepad++ Edited April 25, 2019 by RudyB Link to comment Share on other sites More sharing options...
RMweb Premium melmerby Posted April 25, 2019 RMweb Premium Share Posted April 25, 2019 (edited) Hi Rudy If you want to go the whole hog Microsoft Visual Studio is free to non commercial users and covers the Arduino IDE. Obviously Windows only. Sorry it is Visual Studio! Edited April 25, 2019 by melmerby Link to comment Share on other sites More sharing options...
Robin2 Posted April 25, 2019 Share Posted April 25, 2019 4 hours ago, RudyB said: When writing more code than just a few lines, it might be worthwhile to invest a little bit of time to to start using a more capable editor than the one integrated in the Arduino IDE. I use the Geany editor for all my programming. ...R Link to comment Share on other sites More sharing options...
RudyB Posted May 6, 2019 Author Share Posted May 6, 2019 Fun with Arduino 29 DCC Accessory Decoder With the aid of very little extra hardware we can use Arduino as a DCC decoder, with a price tag that is almost 10x lower than commercially available decoders. In this video we create a DCC Accessory Decoder. In the next video we'll make a DCC Servo Decoder. In stead of DIY, alternatively you can use the ARCOMORA software, which is fully configurable via a user interface. Link to Fun with Arduino 29 DCC Accessory Decoder 1 Link to comment Share on other sites More sharing options...
RMweb Premium melmerby Posted May 8, 2019 RMweb Premium Share Posted May 8, 2019 (edited) Hi Rudy. Wouldn't it be better to get the DCC decoder code direct from Mynabay/Github rather than as a download from Dropbox where you need an account? https://github.com/MynaBay/DCC_Decoder Edited May 8, 2019 by melmerby Link to comment Share on other sites More sharing options...
smokebox Posted May 8, 2019 Share Posted May 8, 2019 (edited) 3 hours ago, melmerby said: Hi Rudy. Wouldn't it be better to get the DCC decoder code direct from Mynabay/Github rather than as a download from Dropbox where you need an account? https://github.com/MynaBay/DCC_Decoder I don't think you need to be a member. When it asks you to sign up, there is a "No Thanks" option that you can click on to go to the downloads. Edit. looks like I can't download the zip file but the contents of it are visible but not downloadable. Edited May 8, 2019 by smokebox Link to comment Share on other sites More sharing options...
RMweb Premium melmerby Posted May 8, 2019 RMweb Premium Share Posted May 8, 2019 (edited) 23 minutes ago, smokebox said: I don't think you need to be a member. When it asks you to sign up, there is a "No Thanks" option that you can click on to go to the downloads. Edit. looks like I can't download the zip file but the contents of it are visible but not downloadable. I tried that. An attempt to copy the file and paste into an editor wouldn't work. EDIT I did have a dropbox account yonks ago but haven't logged on for maybe 5 or more years and can't remember the log on details! Edited May 8, 2019 by melmerby Link to comment Share on other sites More sharing options...
RudyB Posted May 13, 2019 Author Share Posted May 13, 2019 Fun with Arduino 30 DCC Servo Decoder Based on the code for the DCC Accessory Decoder we can create a Servo Decoder. All we have to do is add a couple lines of code to toggle the setpoint of the servo, based on the DCC status, and add the code to rotate the servos based on a millis() timer. Link to Fun with Arduino 30 DCC Servo Decoder 2 1 Link to comment Share on other sites More sharing options...
RudyB Posted May 23, 2019 Author Share Posted May 23, 2019 Fun with Arduino 31 Stepper Motor with 4 Pulse Driver With some applications a stepper motor is prefered over a servo. For instance for the continuous rotation of say a wind mill model. Or with applications like a turn table, a linear shift table or an elevator, a stepper motor can be of great help thanks to the accurate positioning that is possible. In this video we connect a very cheap (less than $2,-) toy motor to our Arduino and run it. In the coming videos we'll look at features like change directon, speed control and accurate positioning, and we'll look at more powerful motors and drivers. Link to Fun with Arduino 31 Stepper Motor with 4 Pulse Driver 2 Link to comment Share on other sites More sharing options...
RudyB Posted May 31, 2019 Author Share Posted May 31, 2019 Fun with Arduino 32 Stepper Motor Change Direction and Control Speed In the previous video we made the stepper motor run. In this video we'll add 2 functions: change direction and control speed. Link to Fun with Arduino 32 Stepper Motor Change Direction and Control Speed 1 Link to comment Share on other sites More sharing options...
RudyB Posted June 6, 2019 Author Share Posted June 6, 2019 Fun with Arduino 33 Find Zero Switch or Sensor A stepper motor does not know where it is after power up. If we want to use a stepper for accurate positioning, we first have to define its ‘zero’ point. This can be done by slowly rotating the motor until a sensor or a micro switch is activated. In this video we'll add a zero find routine as a preparation to the following vodeo where we will accurately position the motor. The video after that we will build a complete turn table control. Link to Fun with Arduino 33 Find Zero Switch or Sensor 3 Link to comment Share on other sites More sharing options...
RudyB Posted June 13, 2019 Author Share Posted June 13, 2019 Fun with Arduino 34 Rotate an Exact Number of Steps Now that we can find the zero switch or -sensor, we can start to position our application by rotating the motor an exact number of steps. No matter if the motor has to make 97 steps or maybe 144668 ... as long as the motor torque and the driver electronics voltage and current suffice in order to not lose steps on the way, we can position the motor with 1 step accuracy. Fun with Arduino 34 Rotate an Exact Number of Steps Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now