RE: Fun with Arduino - a Series of Introductory Videos

#26 von RudyB , 29.03.2019 12:10

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



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#27 von RudyB , 05.04.2019 14:44

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



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#28 von RudyB , 11.04.2019 11:36

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



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#29 von RudyB , 18.04.2019 11:02

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.

Fun with Arduino 27 Rotary Encoder Slow / Fast Recognition



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#30 von RudyB , 25.04.2019 11:58

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++



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#31 von RudyB , 06.05.2019 12:26

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



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#32 von RudyB , 13.05.2019 12:04

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



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#33 von RudyB , 23.05.2019 12:34

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



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#34 von RudyB , 31.05.2019 11:34

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



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#35 von RudyB , 06.06.2019 11:17

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



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#36 von RudyB , 13.06.2019 11:54

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



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#37 von RudyB , 17.06.2019 13:05

Now that we can find the zero switch or -sensor, and we know how to position our application by rotating an exact number of steps, we have all ingredients to build say a turn table, or a translating table or an elevator.

We use a Tuning sketch to determine the number of steps for every stop position, counting from the zero position. The numbers are entered into the Turntable Control sketch. Digital inputs are used to tell the Arduino to which position we want to move.

Link to Fun with Arduino 35 Turn Table Control with a Stepper Motor



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#38 von RudyB , 01.07.2019 11:21

Because a stepper motor does not know where it is after startup, we need a way to find out where it is. We used a zero find routine to rotate the motor until a sensor is triggered. But suppose we were able to store the last position we moved to in memory and read it our after startup?

The good news is: this is possible. The Arduino has 1024 bytes of non volatile EEPROM memory on board. The video shows how we can write data to memory and how we can read it out at startup such that we can start to use our turntable immediately after starup, without the need to find zero first.

Link to Fun with Arduino 36 Store Data in Non Volatile Memory EEPROM



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#39 von RudyB , 08.07.2019 14:35

Several driver circuits are available to control a more powerful stepper motor like a NEMA 17. In this video the EasyDriver is used, but the software is applicable to any driver with Enable, Direction and Step inputs.

Link to Fun with Arduino 37 Control a NEMA 17 Stepper Motor with Easy Driver



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#40 von RudyB , 19.08.2019 12:08

The HC-SR04 is a sensor that has a little loudspeaker and a little microphone via which the distance to an object can be measured. It's ultrasonic, humans can not hear it.

Don't expect super high accuracy of this less than $1,- costing device, yet I was pleasantly surprised to see that measurements with an accuracy of a couple of mm are very well possible.

Link to Fun with Arduino 38 - Ultrasonic Distance Measurement HC-SR04



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#41 von RudyB , 09.09.2019 11:59

We're going to add an OLED display to the ultrasonic distance measurement of the previous video. Together with a battery it now becomes a fully handheld portable device. This is just for fun, the actual purpose is to introduce the OLED display ... once we have that up and running there's a whole lot of fun and useful applications where they can be applied.

Link to Fun with Arduino 39 - OLED dDisplay SSD1306



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#42 von RudyB , 23.09.2019 11:57

In the previous video we attached an OLED and we saw how to display a text and some lines. In this video we take this a step further, we'll make a station platform train departure sign with a working analog clock.

Via digital inputs a selection can be made of 6 different messages to display. This can be controlled via push buttons or via a DCC decoder.

The clock starts at a random time, this requires no other hardware than the Arduino and the OLED. In the next video we'll add a Real Time Clock module to make the clock run on actual time.

Link to Fun with Arduino 40 Station Platform Departure Display with Analog Clock



Youtube channel on Model Railway, Traincontroller, Arduino and more


RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


RE: Fun with Arduino - a Series of Introductory Videos

#43 von VT601 , 21.10.2019 09:46

Hallo MoBaner,

letztes Wochende hatte ich Gelegenheit die Sketch von Rudy (#40 - Platform Display) mal aus zu probieren und het hat letztenlich auch richtig geklappt.
Naturlich smeckt sowas nach mehr, z.B. gesonderte Angabe der Zugart oder mehrere End- und Zwischenstationen. (Vielleicht mit Arrays o.Ä.)

Ich werde zunächst mal erwarten was Ausgabe #41 nog bringen wird.

Aber für Rudy ein grosses Lob

John


Fahre Märklin-system, unter Nutzung von CS3+ und IB-Basic und PC-Steuerung über Rocrail.
Mitglied des 3railforum.nl und die M-Track Gruppe NL (www.mtrack-org)
Lese und schreibe Niederländisch, Deutsch und Englisch.
YouTubekanal: VT601


 
VT601
InterRegio (IR)
Beiträge: 218
Registriert am: 22.03.2017
Ort: NL-Gouda
Gleise K-Gleis und C-Gleis
Spurweite H0
Steuerung CS3+, IB-Basic
Stromart AC, Digital


RE: Fun with Arduino - a Series of Introductory Videos

#44 von RudyB , 24.02.2020 12:20

The station platform clock of the previous video runs, but it shows a random time. We can add a Real Time Clock module to have it show the current time. Several versions of Real Time Clock modules are available. This video is about the DS1307 RTC, which can be had for under $1,-.

Link to Fun with Arduino 41 Real Time Clock DS1307



Youtube channel on Model Railway, Traincontroller, Arduino and more


fbstr hat sich bedankt!
RudyB  
RudyB
InterRegioExpress (IRE)
Beiträge: 268
Registriert am: 20.09.2014
Homepage: Link
Gleise Peco 75
Spurweite H0
Steuerung TrainController
Stromart Digital


   


  • Ähnliche Themen
    Antworten
    Zugriffe
    Letzter Beitrag
Xobor Einfach ein eigenes Forum erstellen
Datenschutz