Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: TeensyStep Re-homing question

  1. #1

    TeensyStep Re-homing question

    Hi there! I have been using the fantastic teensystep for some time, and am just starting to tidy up my code and finalise it for use in my car dashboard project. The one remaining function I'm trying to implement is a re-zeroing function in the event that the steppers become out of alignment somehow.

    To do this, I look for a flag called resetsteppers being equal to 1. If I see it then I engage the code in line 345. This seems to work, and I see the steppers stop, return to where they think zero is, then they run against the stops to re-zero, but when the rotatecontrol takes back control from step control, I ask it to run to the desired step target but for some reason the steppers all jump to maximum steps and then back to their old incorrect positions. I can't work out why this is happening - how do I re-introduce the rotatecontroller with the steppers now at the zero position?

    Thank you!StepperDuinoNEW.ino

  2. #2
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,218
    I had a quick look at your code but unfortunately I can't compile it due to dependencies on other libraries. Can you please reduce this 620 lines sketch to a minimal example showing the problem and doesn't need additional libraries.
    Thanks a lot

  3. #3
    Stepperduino_Luni.ino

    Hi Lutz, I have added a cut down version of the code which should demonstrate the problem with all of the serial stuff removed and the analogue smoothing library. The steppers are driven from the 4 input signals - the speed & RPM come from a square wave pulse reading code and the fuel & temp are just driven by input potentiometers with an analogue read.

    While in normal operation the steppers will be in rotate control driven by the 4 input variables. The problem occurs when the variable "ResetSteppers" is raised from 0 to 1. This should trigger the steppers to stop, roll back against their stops (2 of them are clockwise, 2 anticlockwise hence why 2 are negative) and then return to where they should be based on the input signal and on rotate control once again.

    Currently the first part works and they stop and run against stops without an issue, but they then do not return to operation as expected. The way I usually trigger this process is by reading the serial monitor for a 1 second burst of a signal requesting for ResetSteppers to become 1 from another arduino (the burst in case a single message is missed). The code should see the request and trigger the reset from the first time it sees the message, but will ignore the rest of the burst. Once the burst is complete then ResetSteppers returns to 0.

  4. #4
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,218
    Looks like you have 4 instances of RotateControl and one StepControl. Each one of those uses a Intervaltimer. Since there are only 4 Interval timers, this can get complicated. Older versions of TeensyStep allocated the timers in their constructors and simply kept them. -> won't work. The latest released version of the lib allocates the timers only when they are really used. Particularly, the controllers release the timers after stopping. (Please note that you really have to stop them. Just overriding the speed to 0 does not release the timers).

    Do you use the current Version (2.1)?

    Your sketch is still to complicated for me to do some real debugging. If you want me to dig deeper into the problem I would appreciate a sketch which just shows the problem. Best to strip it further down, or better start a new one. Only allocate your controllers and steppers and do two or three simple functions demonstrating the issue. Don't misunderstand me, I don't want to be offensive but I'm currently too busy to spend the two or three hours needed to understand your sketch.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •