• Welcome to 009 Society Members Forum.

Arduino Projects

Started by Neil McGrath, November 29, 2018, 21:36

Previous topic - Next topic

Tom Haythornthwaite

This is primarily addressed to Steve Lomax who wrote "I have 1 arduino controlling a stepper motor turntable" but I hope it (or his answer!) is of interest to all.

Steve - I also want to run a turntable with an Arduino and I am also working on a (non-scenic) train lift that will be run with an Arudino - both using stepper motors.  I have been sold an A4988 driver and a Rev 3 Motor Shield but I'm confused because I've found some advice on using just one, some on using just the other, and some on using both.  What are the reasons for these three permutations and what did you do?
Haythornthwaite & Westby Tea Railway
OO9 Society Diary Manager.  Please send event information to diary@009society.com.
(If you send them to dairy@009society.com there will be no use crying about it.)

Steve Lomax

Hi Tom;

Stepper motor windings come in 2 flavours, Bipolar (4 wires)  and Unipolar (5 wires).

I use this motor
https://www.ebay.co.uk/itm/ULN2003-Stepper-Motor-Driver-Module-for-Arduino-DC-5V-Stepper-Motor-28BYJ-48/163874356420?hash=item2627ac3cc4:m:mi1fs91xBFn6GrL540-Bo5w
It's a 5 wire Unipolar which works with the arduino examples and is very cheap and massively geared down.
The driver board chip just contains 7 darlington transistors; 4 of which are used to boost the microcontroller output current. The Bipolar nature means that it's just a matter of switching the coils in the motor on and off and this is handled by the Arduino stepper motor library. The driver you have is for a Unipolar stepper motor where the coil voltage needs to be switched on, off AND reversed. Arduino cannot reverse directly so the driver is needed. The arduino will talk to the driver, I'm sure it will work - but I've never used one in a project.  If you are new to this I find the best way is to open up the Arduino program on PC, plug in the Arduino to USB and get them talking. There's loads of tutorials on youtube to do this.   Then load an example file from the library and get the moto just doing something on that example. Then edit the code little by little to get it to do what you want.    Take a look at this: 
https://www.youtube.com/watch?v=GgfgWU0bpHk
As I recall, the output wiring order is not as one would expect. (1 to 1, 2 to 2, etc) I seem to recall 2 and 3 need swapping. I can't remember, use trial and error.
The rev3 Motor Shield can also be used to drive a stepper, but I don't think you will need both drivers. The 'rev3' Arduino is the up to date revision (as of Dec 2019). I would try the A4988 first.
As far as stepper motor turntable, here are some issues I discovered.
A stepper motor does not 'know' where it is (unlike a servo) . Some means of 'homing' the motor is required each time it is powered on. This could be a physical stop pin which forces the motor to stall or skip for a revolution and then it can start counting steps from that position. A microswitch could be used that switches when the turntable is in the home (0) position. The stop or switch position does not need to be anywhere in particular - as long as it is a known and repeatable start position. The gearing on the above stepper motor has some slop in it. I always set my turntable positions to end in a clockwise movement.
It's really hard to get tracks to line up exactly, especially it the turntable is on a bend or slope.
I made some mistakes:
I had track bends too close to the turntable. Next time I will ensure that all ray exits are on straight track.
I thought it wouldn't matter if the turntable track bed gauge was 0.4mm too narrow. It does.
It is important to get smooth rotation and smooth electrical contact transition. It is easy for a brief jamb to cause motor step skips.   
I relied on the contact springs against adjustment screws to get the track bed level. This doesn't work. Use a smooth float running surface.
   
Incidentally , you have everything you need to make a DCC system if you want to experiment with JMRI software. ( search DCC++ and JMRI).
If you have any problems I would be delighted to help if I can.
Steve





Steve Lomax

Neil

There are many variants of Arduino:
Arduino "Uno" is the original from which all others are based or influenced. It has a removable chip and a USB connector for talking to PCs. It has experimental header sockets for wire jumpers and for a multitude of "shields" that add ancillary components and connectivity to a UNO in a 'Lego' style simple building brick system.
"Genuino" is a EU trade name that went horribly wrong but it's identical to Arduino in every way
"Arduino" is open source. Anyone is allowed to make and sell them and there are loads of other manufacturers (mostly Chinese)  that make their own direct copies and variants.
There are a few commonly used Arduino variants: "MEGA256" is a larger version with more power ports, memory etc,  "Nano" is a miniaturized version also with USB connectivity  "Pro Mini" is a postage stamp sized version but needs a seperate USB - serial module (eg FTDI) to talk to a PC. I use these all the time and can be picked up for less than £2 each. Most Arduino variants are 5V, some are 3.3V. The ESP32 or ESP8266, behave as Arduinos but also have wifi connectivity. (this is an example of the IOT or 'Internet of things' you may have heard about). Although it is a few pence more expensive I recommend always sticking with the '5v mega328P 16Mhz' version and not the 'mega168 8Mhz' unless there is a reason for doing so. Arduino is not the best microcontroller, but it is the most well documented and supported. I have used PIC and found it to be more powerful but Arduino is far more user friendly for beginners; and the onset of ESP devices will probably be a game changer in coming years anyhow. 'Adafruit' is a USA manufacturer (Lady ADA) that offers lots of support, however, many of her products are 'improved' variants which sometimes require specific Adafruit library support and most of her products are slightly more expensive than others.  DF Robot (China) have their own range too. Most are generic unbranded. Of course, buying genuine Arduino helps to keep the parent company alive.  There is a thriving Arduino support community at https://forum.arduino.cc/
 




   

Stephen Rainsbury

I agree with
Quote from: Steve Lomax on December 10, 2019, 15:32
I have used PIC and found it to be more powerful but Arduino is far more user friendly for beginners
I agree about PIC being more powerful, and they are still my favourite range to work with, but for my purposes the hardware support has not been as comprehensive as arduino and can work out quite a bit more expensive  unless you are prepared to roll you own.

For people starting out I still recommend Arduino as they at least know they are starting with working hardware and there is loads of support for beginners.

I use arduinos where buying a cheap shield can save me time, but if that isn't an issue until a few years ago I would have used PIC, but now I want to get into low power Raspberry Pis (under £10 + £5 for USB development pod) and just need a decent project to force me to learn :)


---
Stephen

Graeme Dunbar

I'd qualify that by saying some PICs are more powerful than some Arduinos. There are 8, 16 and 32-bit PICs and Arduinos using 8-bit and 32-bit processors.

It is a bit of a skewed comparison in that PIC is the name of the microcontrollers manufactured by the semiconductor company Microchip and Arduino is a combination of a software development system, microcontroller circuit board format and standard for input and output hardware or "Shields". A more direct comparison would be between Arduino, PICaxe, OOPIC, BASICstamp and so on and Arduino is almost certainly the most popular one now. There was at one time even an Arduino look-alike (Pinguino) that used a PIC microcontroller.

I think the Arduino is the best option for a beginner too. The software is quite easy to install and get a simple program up and running. The online manual, references and examples are pretty easy to navigate and there are a wide range of beginner kits and add-on input-output "Shields" available. There a plenty of example Sketches in the Arduino software to try out different facilities and the online language reference generally has good beginner's examples  (e.g. "how does an if() statement work" - including help on common "gotchas" that often trip up beginners.) There is a lot of YouTube video "walk through" examples too (from excellent to dreadful).

A very big plus for Arduinos is for experimenting and "rapid prototyping" of projects. In many cases ideas can be developed on the "standard" Uno version and protoboard components and then rebuilt on a smaller and less expensive Nano, Nano clone, or similar, on stripboard. Likewise, if the Uno turns out not to have enough capability the software can be loaded onto a bigger version.
Graeme Dunbar - 4441

Steve Lomax

Quote[ but now I want to get into low power Raspberry Pis (under £10 + £5 for USB development pod) and just need a decent project to force me to learn :)/quote]
I bumped into someone who was running a DCC layout using a raspberry pi and JMRI (Java).  I would love to hear what you end up working on. It's one of those fantastically powerful bits of kit which at first glance seems the best thing since sliced bread but I found it hard to find an application (other than video) that, as a  beginner  I think I could not achieve on the platform I already use. - I suppose its a case of 'you don't know what you don't know' :)

Graeme Dunbar

Quote from: Steve Lomax on December 11, 2019, 11:16
Quote[ but now I want to get into low power Raspberry Pis (under £10 + £5 for USB development pod) and just need a decent project to force me to learn :)/quote]
I bumped into someone who was running a DCC layout using a raspberry pi and JMRI (Java).  I would love to hear what you end up working on. It's one of those fantastically powerful bits of kit which at first glance seems the best thing since sliced bread but I found it hard to find an application (other than video) that, as a  beginner  I think I could not achieve on the platform I already use. - I suppose its a case of 'you don't know what you don't know' :)

SPROG is well established in this respect https://www.sprog-dcc.co.uk/ I have a very old version and I'm tempted by the Raspberry Pi variant, but must avoid going off down another side alley!

Graeme Dunbar - 4441

Stephen Rainsbury

Quote from: Steve Lomax on December 11, 2019, 11:16
I would love to hear what you end up working on.
So far just a camera trap :-)

---
Stephen

Tom Haythornthwaite

Thanks Steve, that was very helpful.  And the video you linked is a lot clearer than many.  By the way I do use JMRI and will be integrating.  As I understand it, one day I will be 'throwing' 'point number 2xx' etc. to move my turntable.
Haythornthwaite & Westby Tea Railway
OO9 Society Diary Manager.  Please send event information to diary@009society.com.
(If you send them to dairy@009society.com there will be no use crying about it.)

Dave Cooper

Just in case anyone is looking for an Arduino "Starter Kit", I have been doing a bit of research :

Sparkfun - do a kit for about £80 but seems permanently 'out-of stock'. It's recommended in the book I have "Exploring Arduino" by Jeremy Blum.

Newark element14 - mentioned in the book as a recommended supplier. I just could not make sense of their website's ordering system. (especially for Edition 1 of the book).

Farnell - last time I looked said there was no 'European' ordering /shipping available.

I finally settled on "Elegoo" who do a very comprehensive kit for £29.99. Amazon will supply (which I thought made it easier for Xmas present buyers!).

There seems to be 2 different editions of Jeremy's book and, if you want to follow the book's build sequence, I think it would be best to get a kit for that edition. (some kits include the book as well).

You could, of course, just order up all the items separately from someone such as RS Components. The Elegoo kit comes with a CD giving code samples and it's own project list and seems to have everything included to get you quite deep into Arduino land...       

I'll let you know how I get on with the kit (assuming Santa is on-track with this) probably in the new year now.
Dave
"High Water" Diorama ("Dŵr Uchel")
- the inveterate tinkerer

andy1878

I got one of these elegoo starter kits last week, I consider it good value. I also went on ebay and for the princely sum of £4.89 purchased another Uno clone. (I have a specific project in mind, so one is a dedicated unit whilst the second is for experimenting, aka playing)

I would advise raw beginners to thoroughly  understand and modify the Blink lesson before moving on.



Andrew Woolass


Newby Conor - a 009 mircro layout

Graeme Dunbar

For UK sources, hobby robot shops  might be worth looking at. Many will use the same general components and it is often down to how good the book/booklet with it is.

https://www.robotshop.com/uk/arduino-kits.html

https://coolcomponents.co.uk/collections/arduino/arduino-kits?grid_list=grid-view

There is a fair chance that a booklet will be there to "fill out" the kit contents and it is worth considering a book if gleaning stuff from online does not appeal. The ".... for Dummies" series of books are generally pretty good as the publishers do seem to go for authors well up in their respective fields.

https://www.amazon.co.uk/Arduino-Dummies-Computer-Tech/dp/1119489547/ref=sr_1_3?keywords=arduino&qid=1576279350&s=books&sr=1-3

A look at the contents page and index does suggest it is comprehensive.


Graeme Dunbar - 4441

Stephen Rainsbury

The Elegoo kits are pretty good. I had two as presents a few years ago, and although you could buy the bits separately you wouldn't save a lot and it would be a lot of faff.

Their sensor kits are pretty good value too,  although they do not come on shields so it takes longer to set them up, but still a good way to learn.

I normally just buy Chinese clones from eBay for a few quid, but note they don't normally come with the correct USB lead or a power supply, unless you specifically buy a kit. So far I have only had one not work, and they just sent me a new one so no big loss really. Having said that I tend to use "official" ones for important projects.
---
Stephen

Dave Cooper

Does anyone know if the Arduino (and associated) chips are sensitive to static ?

I remember years ago having to wear a wrist-strap wired to a bench whilst working on Motorola 68xxx disk controllers...I understand that 'modern' chips are not so sensitive - just wondering.
Dave 
"High Water" Diorama ("Dŵr Uchel")
- the inveterate tinkerer

Retiarius

Quote from: Dave Cooper on December 14, 2019, 14:20
Does anyone know if the Arduino (and associated) chips are sensitive to static ?

I remember years ago having to wear a wrist-strap wired to a bench whilst working on Motorola 68xxx disk controllers...I understand that 'modern' chips are not so sensitive - just wondering.
Dave


Always a good idea to wear a grounding wrist strap when working with any IC.
A returnee to 009 modelling after 50+ years. Web site designer, former explosives engineer and general computer nerd.
Retiarius Internet Design