Jump to content
 

NinOz

Members
  • Posts

    105
  • Joined

  • Last visited

Posts posted by NinOz

  1.  

    I call up  more than just "step".  There are commands in the library that  allow different math operations to occur.  that may be where your error is introduced.   I use the following in my code (from the original code on this forum): 

     

    stepper2.moveTo(VALUE);       moves the step number (Value) 0 to 3200 for microstep.

    stepper2.move(VALUE);          the stepper moves the value input: + or -. for the total number of steps in (VALUE)

     

    stepper2.distanceToGo();        returns the data from the library code (helpful for troubleshooting in serial monitor)

    stepper2.targetPosition();        returns the target position from the library

    stepper2.currentPosition();      returns what the library thinks the current position is from the library

    stepper2.setCurrentPosition(VALUE);  This sets the position value to the integer you put in the (). 

                                                          Useful to re-zero after going around zero- other wise it "unwinds" to get back to the other number.

    stepper2.speed();                    returns the speed value from the library. 

     

    -Eric

    These functions must be in the AccelStepper library (which I am not using) as I can't find them in the motorshield library.

     

    I have submitted an "issue" note so it is in Ardafruit's hands.  My code seems to work ok with the routine deleted so it is forward to writing the last couple of functions and then trying to stop the lurch on stepper reattachment.

     

    Something to keep the old brain cells active.

     

    Regards,

    CFJ

  2. CFJ-

     

    I have not had any problems with my AdaFruit V2 code.  Check out the topic on DCC Controlled Peco Turntable. 

    http://www.rmweb.co.uk/community/index.php?/topic/78578-dcc-controlled-peco-turntable-project/

     

    The change I made to my table was to put in a 50:1 gearbox to get more torque, but the resolution is great.  I have run the table for hours with multiple operators and the resolution stays 1:1.  Check out my code.  I did switch from microstep to interleave as I didn't need that many steps.  The acceleration and speed controls are great, the torque is fine and I am very happy with the result.  Perhaps your code is calling the target position more than once or you are calling "go to" rather than "target".

     

    -Eric

    I didn't have any problems either just shuffling back and forth between fixed points (errors would mostly cancel) until I wrote some code to "teach" the unit where a track was by stepping from the home (zero) position to the track location and using microstepping to smooth out movement.  Then all went pear shaped.

    I spent a couple of hours tracing the library code to find where the problem was.  Blow away a chunk of code and all works ok.  The "problem" is in a bit of code that does microstepping so not executed if you use step, doublestep or interleaved.  Also with a 50:1 gearbox you wouldn't notice an error of two steps.

     

    This bit:

    if (style == MICROSTEP) {

        while ((ret != 0) && (ret != MICROSTEPS)) {

          ret = onestep(dir, style);

          delay(uspers/1000); // in ms

          steppingcounter += (uspers % 1000);

          if (steppingcounter >= 1000) {

        delay(1);

        steppingcounter -= 1000;

          }

        }

      }

     

    More specifically the effect of this statement:  while ((ret != 0) && (ret != MICROSTEPS))

    I have written a bug report and will submit to github this week.

     

    Now I just need to figure out how to stop the table from occasionally lurching when woken from the released state.

    Well at least I now have a better idea on how the library code works. :scratchhead:

     

    Not sure what you mean by "go to" or "target", the library code only has a step function.

     

    CFJ

  3. Currently working on my turntable code.

    I have a problem in the Ardafruit motor library code for V2 motor shield.

    Problem is related to using microstepping and errors in positioning depending on how many full steps are requested.  The worst case is trying for a full rotation, for my 200 step motor calling 1 * 200 steps results in one very accurate rotation but if I do it as 200 * 1step I get 2 complete rotations.  4 * 90degree (50 steps) rotations returns 208 steps, an 8 step overshoot.

    If the number of steps requested is a multiple of 4 (200,100,80,....4) then all is ok.  Any other numbers of steps and you get a bonus of 1 to 2 steps for each call.

     

    Anyone else getting the same effect?

     

    Delete the problem bit of library code and it seems to work perfectly.  A call of 200 * 1step now gives a single accurate rotation. Can't see any use for the problem bit of code; seems to be trying to capture an impossible error (badly).

     

    Regards,

    CFJ

  4. Hi to everybody, I was recently pointed to this forum by another member. I have been playing around with the Arduino & stepper motors for a while now, and recently purchased a Walthers 90' TT, non motorized, with the intention of DCC control via Arduino & stepper motor; so this thread has been very, very helpful. I am using the large gear supplied with the TT, as I am using a miniature 12 wire slip ring to supply power/control to the bridge. The main reason I am posting, is that I have a Digitrax system, and would like to use that as the connection to the "DCC - Arduino Turntable Interface" diagram from post #8. I would be very grateful if someone could tell/show me what needs to be changed to allow connection to the Loconet bus.

     

    Thanks in advance,

    Barry from Goolwa

    South Australia

    If you don't want to do peer to peer over the loconet then you can use the railsync lines as the DCC input to the opto-coupler in post 8, no changes needed.

    If you want to do some reporting or status over the loconet then you would need to feed the data lines into the opto-coupler and will also need to add a bit of circuitry to send loconet messages, fairly simple just a resistor, fast transistor and a pin on the arduino.

     

    See the bits connected to pin 2 of schematic in http://www.locobuffer.com/LocoIO/LocoIO.pdfas example of Tx from the cpu.

  5. I have nearly finished my first Arduino project :yahoo: , not counting the many, many tutorials with blinking LEDs.

    It is a train speed measuring unit.  Yes, I know there are several of these available but it is just a simple project to see how I go.

    Just need to make a couple of mounts for the detectors.

     

    Uses IR reflection as detectors/sensors, a pro mini as the CPU, 2 line LCD for output and a 5V regulator.  Development was done with a Uno.

    Truely thankful for the cheap electronic modules available from China as it certainly speeds up construction and of course keeps the cost down.  I spent more on the hardware side (plastic case, power connectors, sensor connectors) than the electronics stuff.  The raw cost would be about 10 quid for the major items.  Making it pretty would be at least the same again.

     

    Used EEPROM CVs to store the scale (max 1:500), distance between detectors (max 2000mm) and output units (kph or mph).  These can be changed at any idle time using a few push buttons.  Max values can be easily changed in code.  The unit can work from either direction through the IR gates.

     

    Was enjoyable, mostly, as I came to terms with the requirements for LCD, strings and C++ math.  The math and units seem rather clumsy.

     

    Now am onto making my PECO turntable operational.  Most of the code written, just into debugging.  Using some of the coding I made for the speed unit, especially for editing CVs, adding editing and deleting tracks.  For this project I am going to use a 4 line LCD on I2C, what a struggle to get the right setup for the interface, and an Adafruit motor shield for the stepper motor.

    Algorithm for selecting which direction to turn and then how far to move was a right pain, kept making small mistakes (really a bummer getting senile).

    After the code, comes the mechanics. :O

     

    Regards,

    CFJ

    • Like 2
×
×
  • Create New...