Trains.com

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

turntable stepper motor step size?

5128 views
14 replies
1 rating 2 rating 3 rating 4 rating 5 rating
  • Member since
    July 2009
  • From: lavale, md
  • 4,678 posts
Posted by gregc on Sunday, December 23, 2018 3:40 PM

anyone have experience using an encoder to control a motor's position?   what algorithms used to deal with motor momentum?   how would PID be applied?

greg - Philadelphia & Reading / Reading

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Wednesday, December 19, 2018 8:50 PM

 If you look at the code for my turnout controller, you can see the functions that write the current position of each turnout.

 The 'data' is 2 bytes, one is the counter for how many times that data location has been written, 0-255. The other byte is the actual data, 4 possible values for the 2 turnouts: 00, 0F, F0, or FF. Each time the position changes, the counter increments and is also written. When it rolls over past 255 and back to 0, the pointer is incremented by 2 and written. Then it repeats. 256 writes, then on to the next pair of locations, another 256 writes, etc.

 And yes, Flash. The stuff built in to the micros is fairly low endurance at 10K cycles ( though that's the guaranteed level, not absolute maximum, as some have gotten WAY more in a test environment by doing continuous read/write/compare to see how long it would go until an error showed up). Some of the external serial chips are rated to 100k writes, plus are typically larger than the built in flash space, so not only can each cell take more writing, there are more of them for the pointer to range over. Suffice to say, you cna store the position millions of times before hotting the endurance limits, especially if you only write the position when you are sure the operation is complete - for example, in my turnout controller, if you start one servo moving to the reverse positon but then press the normal button before the movement completes, the servo will retuen to the normal position. It will never have written that it was set to reverse - it only updates the flash when movement has stopped AND it is at one position or the other. Also why the code has to be non-blocking - if turnout 1 is in the middle of a movement and you also need to operate turnout 2, it will respond immediately, not wait until turnout 1 finishes moving. This is the issue that makes the otherwise inexpensive Lenz LS150 turnout decoder unsuitable for any sort of slow motion motors - once one of the outputs has been commanded to change state, it ignores DCC commands to change any others until the operation is complete. Not a big deal for solenoids which change almost instantly, but for slow motion machines that take a few seconds, that's a few seconds the decoder just ignors commands. For a turntable, you would do similar - only write the position when motion stops. That way if you are halfway between tracks 1 and 8, and decode you actually wanted track 6, you hit 6, and only after the bridge stops at track 6 does it write track 6 as the current location. Versus writing the position as soon as the button is pressed.

                                                --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    July 2009
  • From: lavale, md
  • 4,678 posts
Posted by gregc on Wednesday, December 19, 2018 4:20 PM

rrinker
For every 256 writes to the pointer locations (out of the 10K lifetime), you get 256x256 stores to each pair of storage locations, so 65536 saves of whatever data you are saving.  To get to 10K writes to the pointer, that's 39 passes (at 256 writes per pass). Since each pass through all 256 pointer values is 65536 writes, you get 39x that total writes, over 2.5 million.

having a hard time following this, and there are other requirements for the EEPROM

may be less of an issue.  The 1k EEPROM (not flash) is rated at 100,000 write/erase cycles

sounds like ...  you have 3 memory locations: one is the position and 2 3 bytes the number of writes.   You use these until the count reaches the limit, 100k.   You then use the next 3 4 locations. 

At some point (unlikely), there i no additional storage.   If you reach this point, you could potentially increase the limit.   Maybe a readback test after each write to mark the space unusable

greg - Philadelphia & Reading / Reading

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Wednesday, December 19, 2018 3:18 PM

 One (or 2) locations store a pointer. The location that the pointer points to is a counter, and the locatioon after that is the actual data. So for every update to the pointer, you get 256 writes to the data, then the pointer updates, and you get 256 writes to the next location for data, and so on. Say you have 256 pairs of addresses available (so the micro has more than 512 bytes of EEPROM - and I'm using easy numbers for reference). For every 256 writes to the pointer locations (out of the 10K lifetime), you get 256x256 stores to each pair of storage locations, so 65536 saves of whatever data you are saving.  To get to 10K writes to the pointer, that's 39 passes (at 256 writes per pass). Since each pass through all 256 pointer values is 65536 writes, you get 39x that total writes, over 2.5 million. With no location exceeding 10K writes. The pointer hits the limit before the actual storage locations do. So another layer could be added to get more. If you are using a micro with 1K of EEPROM, you can (jusr rounding) get 500x256 stores per pass, for the same 39 passes. which is almost 5 million stores. (1024 bytes, less 2 bytes for the pointer, less a couple of bytes for an initialization string so your code can determine if it needs to start with the pointer at the first block or read the existing pointer to retrieve data - can't rely on a freshly programmed chip having all 0's or anything - divided by 2, for the 0-255 counter byte and the actual data byte).

                                      --Randy


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    July 2009
  • From: lavale, md
  • 4,678 posts
Posted by gregc on Wednesday, December 19, 2018 2:21 PM

rrinker
you get 10K writes spread out across 256 or 1024 locations.

how do you keep track of which location is current?   and don't you need to keep track of the number of writes in each location

greg - Philadelphia & Reading / Reading

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Wednesday, December 19, 2018 2:00 PM

 You could so something liek what I'm doing with my turnout controller to roll the storage location in EEPROM, so you get 10K writes spread out across 256 or 1024 locations. It will take a long time to accumulate 10 million moves of the turntable.

 Or same technique but use an external serial EEPROM, most of them are rated for 100K writes instead of just 10K of the microcontroller. Combine techniques (micro holds the address of the external EEPROM being used) and use say a 4K EEPROM - that's over 400 million 'saves' before hitting the endurance rating. If you moved the turntable 5 times a minute, 24 hours a day, 7 days a week, that's over 2.5 years of continuous operation. I think it should be fine. And one byte is plenty, since you'd never be able to have 255 tracks on one turntable anyway.

                              --Randy


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    July 2009
  • From: lavale, md
  • 4,678 posts
Posted by gregc on Wednesday, December 19, 2018 1:48 PM

i'm guessing that the position, geared step #, is saved in eeprom after every movement, otherwise it needs to be realigned whenever turned on.   I'm guessing this would be a reasonable number of writes to EEPROM (10k write lifetime)?

would you think there is an automatic position reset whenever the turntable passes the alignment point (led in wall)?

wondering how complicated a controller would be after getting past the mechanical setup

greg - Philadelphia & Reading / Reading

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Wednesday, December 19, 2018 12:55 PM

Greg
 
When I bought my CMR Turntable Kit about 20 years ago it came with a direct drive 12 volt gear motor, Dayton 2L003, RPM.5, Torque 50.0 in.-lb., gear ratio 7189:1.  The gear motor will turn my 19” bridge at 5.5 volts at about .2RPM, normal operation is 11 volts.  It has so much power that it requires a slip clutch to prevent damage should something stop the bridge from moving.  Without a slip clutch type connector between the gear motor and the bridge stopping it would do some serious damage, it could toss a 3 pound locomotive across the room into a wall.
 
That being said I made my own indexing system using IR detection.  I placed an IR emitter behind a 1/16” hole in the wall of the pit under each track.  I used a pair of IR detectors one under each end of the bridge.  For the extra wires from the bridge I made a 4 contact slip ring, one common, one for the bridge lighting and two for the LED IR detectors.
 
 
The track power is one rail from the gear motor shaft and the other rail is from the bridge power drop.  I don't use the pit rail for power, too many problems.
 
 
I bought a 2P24T rotary switch (24T for the 15° spacing, I only have 7 tracks) to turn on the proper Emitter to stop the bridge. 
 
 
I used a DPDT relay to power the gear motor and wired it to short the motor using the short as a dynamic brake.  The bridge stops instantly well within 1/64” for perfect track alignment from either direction every time.
 
 
Super simple, no programming, no processor, I just turn the switch to the proper track and flip a momentary toggle.
 
Mel
 
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Wednesday, December 19, 2018 12:21 PM

 Especially if you have some rather expensive brass locoos - I'd say there should be at least 2 safety mechanism. One can detect motor current and stoop the step signal if it is too great, and as a last resort, the mechanical coupling somewhere should allow for slip.

 There definitely are stepper motors plenty powerful enough to be direct drive.

 Another option is what in referred to as servos - not the ones like in model airplanes, but a high torque motor with a precision encoder wheel on the shaft, rather than have some absolute number of steps between tracks, you have a number of counts on the encoder wheel. These things are extremely precise, more accurate than a typical stepper. This is the mechanism used on precision CNC machine tools. The cheap DIY ones use steppers. Downside is, they are not nearly as cheap as a stepper. And probbaly a lot more accurate than is really needed to line a turntable bridge - the stepper is going to be close enough, as there is no need to line the rails to within the nearest tenth. Cut a piece of straight track and the ends won't be aligned to those tolerances anyway. 

                                  --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    July 2009
  • From: lavale, md
  • 4,678 posts
Posted by gregc on Wednesday, December 19, 2018 11:49 AM

yesterday the turntable bridge I was operating caught on the coupler of a loco a little to close.   This prevented the bridge from moving and doing any damage

it didn't knock the loco off  the track, which i think suggests how little force is needed to stop the bridge, as well as move it

and that you wouldn't want the motor to be so powerful that it can do damage -- it simply slipped on the rod.  (yes, it needed to be re-calibrated, re-aligned with a known position).

greg - Philadelphia & Reading / Reading

  • Member since
    August 2003
  • From: Collinwood, Ohio, USA
  • 16,367 posts
Posted by gmpullman on Wednesday, December 19, 2018 11:24 AM

gregc
is that a good thing?

I never dared try to stall it. When there is a locomotive weighing close to two pounds on the bridge you certainly need some torque there. I suppose a shear pin or slip clutch might make a "safety valve" but, in twenty-five years operation I've never had anything jam the bridge. Keep the pit clean and obstructions clear before operating the turntable.

Cheers, Ed

  • Member since
    July 2007
  • From: Yorkton, Sk, Cnd
  • 441 posts
Posted by wvg_ca on Wednesday, December 19, 2018 11:18 AM

as far as i know, they are all geared, stepper or otherwise..

direct coupled motors would have to be relatively large to generate needed torque i think

  • Member since
    July 2009
  • From: lavale, md
  • 4,678 posts
Posted by gregc on Wednesday, December 19, 2018 11:03 AM

thanks

gmpullman
very powerful.

is that a good thing?   

greg - Philadelphia & Reading / Reading

  • Member since
    August 2003
  • From: Collinwood, Ohio, USA
  • 16,367 posts
Posted by gmpullman on Wednesday, December 19, 2018 10:04 AM

I use the system provided by New York Railway Supply. The stepper motor is definitely geared. Step angle is .025°. I could look later to see what make/model it is.

 IMG_5885 by Edmund, on Flickr

I don't believe a direct drive stepper motor would have the torque needed to turn the bridge.

I don't know the ratio of the gearcase but the result is a nice slow movement and very powerful. 10:1 maybe?

 IMG_5883 by Edmund, on Flickr

Good Luck, Ed

  • Member since
    July 2009
  • From: lavale, md
  • 4,678 posts
turntable stepper motor step size?
Posted by gregc on Wednesday, December 19, 2018 9:55 AM

i see that the Nema stepper motors have a 1.8 deg step size.

for a 10" turntable, i calculate that this is ~0.2" arc at the edge of the bridge, which seems large to me for aligning rails within a rail thickness

are stepper motors w/ 1.8 deg step size typically directly coupled to turntable bridges or are they geared some how?

i see geared stepper motors on ebay  (1:63, step size 18 deg, ~0.02")

seems that there are lots of articles on the use of stepper motors, but they are focused on the software.

greg - Philadelphia & Reading / Reading

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Users Online

There are no community member online

Search the Community

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
Model Railroader Newsletter See all
Sign up for our FREE e-newsletter and get model railroad news in your inbox!