Arduino Uno Question

gunrunnerjohn posted:

Can we say stepper motor?

Now you've done it, John! I believe that the CRS (constant rotation servos) grew out of the R/C hobbyists who just wanted drive wheels for their robots. I'm not sure why? You would think that driving a robot around would require more positional feedback than ever. Maybe costs were lower or they just didn't want to mess with the stepper motor driver boards. But whatever the motivation, people have been "modifying" standard servos into CRS for a while.

I'm not experienced on stepper motors either but I do think it takes some additional hardware to drive them properly. Motor control and H-bridge controls are not generally done in software as far as I know.

Having watched a couple of videos on the Arduino running stepper motors, I take back what I said last time about not using software to control them. Although they do use additional hardware to drive the motor, the programs tell them when to take each step and how long to wait before taking another one. The delay determines the speed. These methods simply involve regular digital I/O pins to generate the pulses for the stepper motor.

A cursory look at my favorite auction site yields prices and varieties on a par with servo motors. Apparently they are often used with the mechanisms for 3D printers. Mounting brackets are generally more expensive than the stepper motors that they are meant to hold.

And so, stepper motors would seem to be a valid alternative to continuous rotation servos and may be more scalable (they can do some heavy lifting with the proper driving hardware). However, the driving hardware, though simple and available, adds to the overall cost.

Unless you're building a hundred of these, the cost of a few bucks between servos and steppers isn't exactly a killer I would imagine.  I just figured it's another option that's worth considering.

79 cents for this one. 



Photos (2)
gunrunnerjohn posted:

I just figured it's another option that's worth considering.

GRJ: Options are always a good thing. I admire it when people come up with different approaches to problem solving. Your experience in the aerospace field and flight instrumentation is not wasted on us. Folks on the Electrical Forum are always watching for your input to back up their pursuits. I personally give you high marks for much of your advice and direction. Keep it up.

rtr12 posted:

Oh my, you guys are already on stepper motors and I still have a few hundred thousand servos left to look at!

RTR12: Don't worry! You're abbreviation guide has given you a special exemption because of the number of forumites (including me) that it has helped. So if you have fallen behind on stepper motors, that's OK (okie-dokie). They're just motors that are used for more precise movements due to their design. You'll be fine.

This might be off topic, but related. I have been designing a model railroad layout and using a PLC to control it. I am mainly doing this as a learning tool to teach myself PLC programming. I have not posted about this mainly because its impractical and probably would not be of interest to most. I have never used the Adriano, but I would think programming it may have some similarities to ladder logic and I might be able to help.




Photos (3)
mikeexplorer posted:

I would think programming it may have some similarities to ladder logic and I might be able to help.

Mike: Ladder logic is an old school method of industrial programming with relays; 2 in series for AND, 2 in parallel for OR. I realize that they still use ladder logic for modern PLC (programmable logic controllers) systems but that's because they didn't want to have to change things over when they had so much invested in the older technology. That and the fact that the transition most likely involved both older equipment along with the new. It's odd that ladder logic is still used in industrial control environments.

The Arduino (pronounced: ard - as in aardvark, ui - as in ween from Haloween, and no - as in no meaning negative) is much less restrictive. Of course it does involve logic but the mechanisms of the programming language are much more open.

The Arduino uses a version of the "C++" programming language that came from the older "C" language developed at Bell Labs. C++ is an object oriented language that allows for the creation of new entities that have common functionality. For example: you can create an LED object that can have methods to change its state like so:

#define LED_PIN 13


These objects in the Arduino world are refered to as a "library". There are a number of libraries already available for the Arduino including a Servo library (as described here).

There's a lot more to it but I think you've got the idea. There are plenty of books, videos, etc about the Arduino platform as well as the C++ programming language. You might want to give them a try.

  -- Leo

It seems to me the take-away of this discussion is the use of the servo.write functions to easily get up and running with an Arduino and a servo.   The servo has 3-wires going to it.  2 are just the +5V power and ground that the Arduino has anyway.  The 3rd is a single digital output pin.  The single servo.write(0) command sends the servo to one end, the single servo.write (180) sends it to the other end.  And arguments in-between send the servo to some angle in-between.  Easy.

Then build or buy a modified servo which has come to be known as a Continuous Rotation Servo and now the same commands send the mechanism spinning in one direction or the other direction and coming to a halt by sending the single servo.write(90) or mid-value command.  Easy.

If you are going to mess with servos, I highly recommend the $1 servo-tester you can get on eBay.  Simply apply 5V DC.  Attach 1 (or up to 3) servo mechanisms via the standard 3-wire connector.  Then by turning the knob on the exerciser, you effectively generate servo.write(x) commands so you can verify operation of your servo mechanism before writing a single line of Arduino code.   This development tool is obviously handy when mating your servo to your animation.

Again, I think the idea here is to get up and running quickly with minimal fuss.  That's what is interesting about the CRS since it accepts and interprets Arduino servo.write commands.  As I've already confessed, I was not aware of this development until Leo pointed it out.  Anyway, to further the discussion about using servos for layout animations, here are a couple more ideas that might help Arduino enthusiasts willing to modify (or pay a couple bucks extra to modify) a standard servo as is done with a Continuous Rotation Servo.

Watch the 4 mechanisms in action (one being an un-modified standard servo).

diy servo - position and continuous rotation

In photo (and video), I modified the "guts" of a standard servo to make a CRS.  As mentioned in a previous post, I then replaced the DC motor within the CRS with a cheap DC gearmotor.  In fact, I show two DC gearmotors being driven together by a single CRS.  The point here was a standard servo has pretty amazing current drive capability since it can spin the integral motor at whiplash like speeds.  But if you want to go slower as you might with many layout animations, there is plenty of current capability to drive a wide variety of DC motors.

Additionally, on the top, I show a "linear" servo which is an incredibly useful mechanism for layout animations.  Sometimes you just want something to go left-to-right rather than around-and-around.

DIY linear servo

Again, it's just a modified standard servo removing the electronic guts and attaching it to a linear volume control mechanism from a remote-control audio amplifier - you've seen them...when you adjust volume from the remote, the manual volume control knob slides (or rotates) by itself.  Or you can just go up to the amp and manually slide the volume control.  It's essentially a motor-driven potentiometer.  So the potentiometer provides the feedback to the servo electronics.   I buy these surplus for a few bucks.  Again, you have the standard 3-wire connector (+5V, ground, 1-pin Arduino output) so from the Arduino perspective, the single command servo.write(0) sends the slider to one end, servo.write(180) sends the slider to the other end, and value in between send the slide to the mid-point.  Easy.


Photos (2)
stan2004 posted:

It seems to me the take-away of this discussion is the use of the servo.write functions to easily get up and running with an Arduino and a servo.


Stan: Right, but more generally, that all kinds of automation are possible with a microprocessor. Add in cheap relay modules along with homemade train detection circuits and LEDs for trackside signals and now you can build some good stuff; a reactive layout. Not exactly a new idea but now with the costs at a level that makes it very practicable.

Think about how a conventional layout could be setup to use isolated blocks to control more than one train on the same track. You could follow each train around the layout through its own transformer. You could use large bridge rectifiers (diodes to reduce voltage) to slow down a train as it approaches a more restrictive signal; trains would maintain a safe stopping distance without any operator intervention. All made possible because of the simple but sophisticated microprocessor watching over the entire enterprise.

I imagine many Arduinos around the layout controlling turnouts, led signals, power districts, talking to each other, running switcher operations in the yard to build a consist; and that's just for conventional mode. TMCC, Legacy, DCS, DCC are all candidates for automated control as well.

Sounds like fun to me!

Stan: I also want to say that I am suitably impressed with your demonstration video. That little tester looks like it belongs on my workbench. You've created enough movement there to set an ocean hardened sailor out to look for the railing. Who needs animations when you can look at all that going on. Good job!

Add Reply

Likes (0)

OGR Publishing, Inc. PO Box 218, Hilliard, OH 43026 330-757-3020