Arduino Stepper Motor Fritzing

Hi
Can someone help this aged challenged old man (77)

Can you give me a link to a stepper project that is for a stepper motor to have 4 steps (positions) to move a carriage between them. For a transfer table for a model railway, a small section of track moves sideways (driven by stepper motor) to each position.
Motor speed always the same. Distance between stops the same. Four buttons on ‘in’ side to select the right stop. At the moment just want to push button on and motor goes to next set stop. Will get more complicated than that (with reverse direction and selection of non sequential button) but at the moment just get it to go to next stop.
Using Arduino UNO and L298(293?)
Using vs 8.5 on Linux Mint.
If the project url could show how to set up motor speed (always the same) set the stops, set the distance between stops.
That will get me a long way and a lot more knowledgable .
Once set up on Fritzing can I check somehow to see if it works, just on Fritzing or ? So I can then proceed to the physical Arduino etc.
Thakyou

A google search for “stepper motor for model train” shows some hits, but not I think what you are describing. I expect the mechanics of this and the accuracy required are going to be the problems. I would guess that the tracks need to line up (perhaps to a quite accurate tolerance) for this to work, and depending on the weight being moved, a fair amount of torque may be required. There are cheap stepper motors (for moving air conditioning vents) such as this one on ebay

https://www.ebay.ca/itm/192446111209?hash=item2cceae9de9:g:9N8AAOSwY7taVzyf

which has the typical 1/64 gearing. The question will be if it has enough accuracy to do what you need. As well you need a mechanical method (a lead screw would be the usual choice) to change the rotary motion in to linear motion. It may be your best bet would be to use an old floppy drive stepper and lead screw to do what you want. They need to move the heads quite accurately and repeatably. There are tutorials on using motors like the ebay one with an Arduino on the net, but I expect your best bet would be the model railroad forums to find a project where someone has done something similar to what you want to do.

Probably not, Fritzing doesn’t currently have simulation so you need to use real hardware to test this. In theory this project should be fairly easy, a stepper motor moves in fixed steps (hence the name :slight_smile: .) The one in the ebay post moves 5.625° /64 (the motor itself move 5.625 degrees per step but the gear train divides that by 64.) With the gear train, I’m not sure how repeatable the steps are, so moving 10 steps right and then 10 steps left may not get you back to exactly the same place you started. If you are trying to align tracks after the move (which I expect you are) you may need fairly high accuracy and repeatability and that may not be easy to achieve. Once you have the mechanical stuff worked out then the coding is fairly easy, you just tell the motor to step the appropriate number of steps to get where you need to go. The exciting part is likely getting the accuracy you need to do that.

Peter

Hi Vanepp
Thanks very much for your great response and info and also the links.
But… ooops, I forgot to mention that I have already a commercial built transfer table with the motor and all the gears etc. See this link https://www.hattons.co.uk/stocklistdatabase/23766/heljan_89021_operating_transfer_table_traverser_for_ho_and_oo_scales_/stockdetail.aspx

However these were manufactured over 10 years ago and were very unreliable from the start. The unrreliable bit was the software. s. Used a menu system and very awkward to use, with bad result Mechanics seem ok.

So what I am doing is basically throwing all the control box and software away and doing the Arduino stepper exercise. Apologies for not making this clear earlier.

At this point your comments in terms of setting up a Arduino stepper motor to work with the original physical device. I can use the existing cables etc and the small motor is stepper.
Thankyou and regards
Charles

That makes your life a lot easier. Assuming you can drive the stepper from an Arduino this should be reasonably easy I think. Basically you need to figure out how many steps the stepper needs to take to get between positions. I expect a tutorial like this one from Adafruit should get you going

The Arduino code included in there lets you enter the number of steps from the serial console to control the stepper. Once you determine the number of steps between positions, then you can create the code to move to that position when a button is pressed. You likely need to know where the table is now and therefore how many steps and in which direction it needs to go to get to the new position then feed that number of steps to the stepper motor. If you are using the current hardware, you will need to figure out what I/O pins the stepper controller uses and probably modify the Arduino code to make their I/O pins match the ones your controller is using.

edit: A late thought, check if the unit has limit switches to prevent the table from going to far! It is easy to make a mistake in software and tell the stepper to go to far. Without a limit switch you may damage the table. If there aren’t limit switches already installed, I would advise adding two of these

capture

The power to the stepper motor connects to the NC (normally closed) contact. If the table gets too near the edge due to a software error, the switch will trip and remove the power from the stepper to prevent damage to the table.

Peter

Hi Peter I will follow up your links and do some learning. There are so many articles that I get confused with them all, but I will now use your recommended articles etc. I live here in New Zealand and it 9.15 am approx on Sunday.
Thanks (will probably return with some more questions!!)

Charles

I’m on the west coast of Canada so it is Saturday afternoon here. If you can get one easily, one of the stepper motor/driver boards such as the one in the ebay post may be a good investment. They are only a couple of bucks on ebay (but delivery is usually a month or more here.) There may be a local store near you that has them at higher cost but shorter delivery time. That would give you a test platform to figure out about driving stepper motors without risking the (probably expensive!) transfer table and experiment with limit switches which are good insurance in any case. By all means if you have questions feel free to ask.

Peter