Jump to content
 

Fun with Arduino - how to get started, and more


RudyB
 Share

Recommended Posts

Fun with Arduino 35 Turn Table Control with a Stepper Motor

 

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


36033228kx.jpg

  • Like 1
Link to post
Share on other sites

  • 2 weeks later...

Fun with Arduino 36 Store Data in Non Volatile Memory EEPROM

 

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


36151676ta.jpgvv

  • Like 2
Link to post
Share on other sites

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

 

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


36205987bk.jpg

  • Like 3
Link to post
Share on other sites

  • 1 month later...

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

 

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


36544908fy.jpg

  • Like 2
  • Informative/Useful 1
Link to post
Share on other sites

  • 3 weeks later...

Fun with Arduino 39 - OLED display SSD1306

 

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 Display SSD1306


36717754og.jpg

Edited by RudyB
  • Like 2
Link to post
Share on other sites

  • 2 weeks later...

Fun with Arduino 40 - Station Platform Departure Display with Analog Clock

 

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


36827560uc.jpg

  • Like 3
Link to post
Share on other sites

  • 1 month later...
  • 3 weeks later...
  • 2 months later...

Fun with Arduino 41 Real Time Clock DS1307

 

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

 


37939342lr.jpg

  • Like 3
Link to post
Share on other sites

  • 1 month later...

So glad I found this thread. It had one sketch that I was really interested in - #23 - Neopixel addressable LEDs. Just what I was after for my terraced houses. They are low relief with an upstairs front room, a downstairs front room and a fireplace. Thanks Rudy - fantastic thread and I have now started following your blog.

Link to post
Share on other sites

  • 2 months later...
  • RMweb Premium

I have a persisting idea, to semi-automate some of the points on my layout.

 

What I want to do is to optically detect any train (loco, wagon, whatever) approaching points from the trailing direction, and then (if necessary) have the blades move to the favourable location. So I eliminate a lot of short circuits in live frogs. A sort of emulation of a "lazy shunter" who only manages to operate the points for trailing movements. Or, if you prefer, a version of hand-operated points where full-size trains bounce their way through the blades, but leaving the blades where the train has put them.

 

I envisage a momentary push button to let me move the points (press and release to change direction), and two infra-red sensors to let the train trip the points.

 

I have a Megapoints servo controller board and an Arduino starter kit. Communications between the two will be a serial interface, and the message protocol is simple - 12 bits sent in two bytes to set up to twelve servos.

 

I wonder if anyone could post me any pointers on where to look for ideas for the Arduino side of things? Many thanks.

 

- Richard.

Link to post
Share on other sites

  • RMweb Premium
7 minutes ago, melmerby said:

You can control servos directly with an Arduino or with an add on servo controller shield.

So I don't see why you would need the Megapoints unit.

 

So I can guarantee myself something which works, for example with local toggle switches, and I have a path for future expansion.

 

- Richard.

Link to post
Share on other sites

Have a look at www.arcomora.com and download the software. With the free Mardec software you can control servos either via DCC or via an input signal from a push button or a sensor. The whole software can be configured via PC and also the angles needed for open or close of the turnout can be tuned via PC.

  • Agree 1
  • Thanks 1
Link to post
Share on other sites

10 hours ago, 47137 said:

I have a Megapoints servo controller board and an Arduino starter kit. Communications between the two will be a serial interface, and the message protocol is simple - 12 bits sent in two bytes to set up to twelve servos.

If you do decide to use your Arduino to control the Megapoints board you need to use I2C to communicate with it. The Megapoints website has some example Arduino code.

 

However I agree with others that you can control servos directly with an Arduino.

 

I use Light Dependent Resistors set between the sleepers to detect trains. Megapoints seem to have good value in IR detectors - but they are more expensive and bigger than LDRs.

 

...R

  • Thanks 1
Link to post
Share on other sites

  • RMweb Premium
27 minutes ago, Robin2 said:

If you do decide to use your Arduino to control the Megapoints board you need to use I2C to communicate with it. The Megapoints website has some example Arduino code.

 

However I agree with others that you can control servos directly with an Arduino.

 

I use Light Dependent Resistors set between the sleepers to detect trains. Megapoints seem to have good value in IR detectors - but they are more expensive and bigger than LDRs.

 

...R

Buy your own IR detectors directly, then they will be cheaper and smaller than LDRs

 

You could also use an IR receiver connected to an Arduino then use it to operate things (e.g. servos) by using a TV remote control (there is an Arduino TV remote code library)

You could then control your points remotely with the handset.

Link to post
Share on other sites

  • RMweb Premium

Thanks for the ideas, well most of them :-).

 

Control of the points would be by momentary push buttons, supplemented by the train detectors.

 

I am doubtful about the Arcomara system because it seems to commit me to having a DCC controller. I run analogue as well as DCC.

 

The use of the Megapoints servo controller gives me a single-board solution to run all of the servos on the layout, and the I2C bus seems an elegant way to get commands into this - commands from eight buttons for the points, and up to sixteen optical sensors. The board also sorts out the wiring for the servos.

 

I think, I have two tasks:

1) work out how to connect the buttons and sensors to my Arduino Uno.

2) devise some code to poll these inputs and instruct the servo controller to set the points to suit.

 

If I can pull this off, there is scope for the event of a train tripping one point to trip one or more others, to make for simple route-setting.

 

I don't want to sound too solution-oriented, but if I need more than one Arduino to do this I'll be sure I'm doing it wrong. I may well run out of hardware inputs on the Arduino, so I'll look for some hardware to add inputs.

 

My greatest unknowns are:

a) Whether I could use other products from Megapoints, such as their Multipanel, to control the same servo controller board at the same time as the Arduino. It's a wall-hugging layout and control from a second location would have merits.

b) How many of my eight points really need sensors for normal operations. 

c) Whether I can prototype something reliable enough to be worth building.

 

Thanks for the suggestion on a TV-style remote control but I have found I am only really happy with a hardware control panel. Most likely because one hand is usually holding the DCC controller or analogue throttle.

 

- Richard.

Link to post
Share on other sites

Staying with your stated aim of keeping the Megapoints control boards.

 

You need to use IC2 for that.   The number of Arduino's is, to my mind, irrelevant.  They're cheap, and you can use more than one on the IC2 bus if that's the way to go.    Or, if running out of inputs (or processing power), there is the option of the Arduino Mega, with many more inputs than the usual Uno. 
If you need distributed inputs (some on a remote panel, some on the layout), then I'd be looking to network things with multiple processors over the network (IC2 in this case), rather than a huge bundle of wires coming back to a large central processor.

 

If a MERG member, then Davy Dick published an article on "EzyBus" about six months ago.   This is an Arduino network to support panel input and servo control of turnouts/signals.   I think it covers most of the stuff you've mentioned.   You could dig out the article and the code to see how much could be repurposed for your own requirements. 

 

 

 

 

 

  • Informative/Useful 1
Link to post
Share on other sites

  • RMweb Premium
29 minutes ago, Robin2 said:

Have you a link to a supplier?

 

...R

 

I have just ordered up a pair of these:

https://www.ebay.co.uk/itm/131766882112

 

I will then have some representative hardware - an Arduino starter kit (I only uploaded my first sketch this week), switches, IR sensors, some wire to make the IC2 bus, and what is currently a fully-working Megapoints servo driver board and some sample code to drive it.

 

It would be a shame to clutter this excellent topic with discussions of preferences for particular hardware, and so I will report back after I have something which works or I have given up.

 

I would of course still welcome replies to my original question.

 

- Richard.

Edited by 47137
Link to post
Share on other sites

  • RMweb Premium
42 minutes ago, Robin2 said:

Have you a link to a supplier?

 

...R

AliExpress

Choose what you want from IR receivers & emitters.

17 minutes ago, 47137 said:

 

I have just ordered up a pair of these:

https://www.ebay.co.uk/itm/131766882112

 

 

Those IMHO are the same as the Megapoints ones

 Which are a little cheaper on Aliexpress but take longer to arrive:

https://www.aliexpress.com/item/4001131566729.html?spm=a2g0o.productlist.0.0.64f56666uUdpvz&algo_pvid=6a7df7b6-0899-4776-ac11-0f110aa4c97d&algo_expid=6a7df7b6-0899-4776-ac11-0f110aa4c97d-49&btsid=0b0a0ae215926424005675881e6197&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_

 

I would have bought individual components which can interface directly to the Arduino.

Link to post
Share on other sites

  • RMweb Premium
32 minutes ago, 47137 said:

 

 

 

It would be a shame to clutter this excellent topic with discussions of preferences for particular hardware, and so I will report back after I have something which works or I have given up.

 

I would of course still welcome replies to my original question.

 

- Richard.

Well the topic is "Fun with an Arduino" and an Arduino will do all you want without employing a Megapoints board.:jester:

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...