Forum Rule: Always post complete source code & details to reproduce any issue!
Page 5 of 5 FirstFirst ... 3 4 5
Results 101 to 116 of 116

Thread: New Stepper Motor Library

  1. #101
    Junior Member
    Join Date
    Jan 2020
    Posts
    2

    New Stepper Motor Library

    by reading this thread I did not really understand what Devs have done.

    Have they just added the 15min internal cooldown for using RDF which is blizzlike or they have made some custom change ?

  2. #102
    Junior Member
    Join Date
    Mar 2020
    Posts
    1
    Hello dear Luni!
    I use StepControl to move to the desired position. But I need the ability to change speed on the fly. How can i do this?

  3. #103
    Junior Member
    Join Date
    Feb 2020
    Posts
    17
    I did not want to wait for the Teensy 4 port to be done properly, and did not want to read any datasheets, so I made a hacky port (https://github.com/bondus/TeensyStep) to Teensy 4 using ChibiOS timers (https://github.com/greiman/ChRt)

    It might hang, crash and burn, and be very slow. I have only done some very basic testing.

    The pin manipulation of DIR/STEP pins did not work on Teensy 4, and the code did now allow for <Arduino.h> to be included, so you have to implement a little function somewhere:
    Code:
    void doPin(int pin, int state) {
        digitalWriteFast(pin, state);
    }
    A very hacky implementation indeed, but it works.

    I'll hook it up to my little 3-stepper robot and give it a better spin...

  4. #104
    I've used this library in the past with a Teensy 3.5 and had great success with the project. Any update on compatibility with Teensy 4.1? It would be great to have the additional processor speed combined with the on-board Ethernet functionality.

  5. #105
    O0ops. I posted in the wrong thread https://forum.pjrc.com/threads/59112...l=1#post269844

    @luni My problem is that is a custom PCB and all the pins I can use are on FTM0 :-(
    Is there no workaround for this timer shortage?

    J
    Last edited by jensa; 02-10-2021 at 04:52 PM.

  6. #106
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,450
    No, there are only two timer channels on FTM1/2 :-(

    However, if you don't need the controllers at the same time it should work. The controllers are supposed to release the timers after the movement. So, if you use one after the other, the two FTMs should be sufficient.

  7. #107
    Junior Member
    Join Date
    Nov 2020
    Posts
    3
    Works great. Love the library!
    Is it possible to set the motor deceleration different than the acceleration? I can't figure out how to do this, as a single number controls both.
    In my application, the motors are capable of decelerating much more quickly than they can accelerate, (as is the case in many applications.)

  8. #108
    Senior Member
    Join Date
    Jul 2020
    Posts
    984
    For steppers the acceleration and deceleration miss-step thresholds are similar as they depend on the inertial torque
    compared to the dynamic torque available. If you add a braking mechanism to a stepper system it may lose
    position whenever you brake. Normally this means brakes are only for emergency-stop, otherwise the steppers
    should have full control authority for reliable operation.

  9. #109
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,450
    Is it possible to set the motor deceleration different than the acceleration?
    I second MarkT's remarks above and the currently implemented accelerators do not provide this.

    However, if for some reasons you want to change the acceleration behavior, the library is prepared to use custom accelerators. With a custom accelerator you can implement whatever acceleration scheme you need. See here https://github.com/luni64/TeensyStep...c/accelerators for the standard accelerators. You can then simply typedef a custom controller which uses your custom accelerator. See here for the standard controllers https://github.com/luni64/TeensyStep...ensyStep.h#L38

    Please note that all of this can be done in your sketch without touching the library code.

  10. #110
    Junior Member
    Join Date
    Nov 2020
    Posts
    3
    Quote Originally Posted by luni View Post
    I second MarkT's remarks above and the currently implemented accelerators do not provide this.

    However, if for some reasons you want to change the acceleration behavior, the library is prepared to use custom accelerators.

    Please note that all of this can be done in your sketch without touching the library code.
    I am afraid that it is far beyond my "pay grade" to modify the library code. :-) I have no issue modifying my sketch, however.

    I am controlling the speed of a rather large spool that is winding up 3D printing filament, and gaining weight as it is doing so. The spool speed is controlled by a filament tension arm with a corresponding PID loop. The tension decreases, the arm moves up, the spool speed is increased to restore the arm position. The tension increases, the arm moves down.......

    I suppose I could add an acceleration override to alter the acceleration/deceleration depending on the sign of the derivative of the control loop output. An increasing (positive) control output change would select an appropriate acceleration, while a decreasing (negative) control output change would select a different deceleration.

    Is this what you suggest?

  11. #111
    Junior Member
    Join Date
    Apr 2021
    Posts
    3
    Quote Originally Posted by scaraman View Post
    The pin manipulation of DIR/STEP pins did not work on Teensy 4, and the code did now allow for <Arduino.h> to be included, so you have to implement a little function somewhere:
    Code:
    void doPin(int pin, int state) {
        digitalWriteFast(pin, state);
    }
    Thank you for your (wacky?) implementation.
    However, I don't understand what you mean by implementing the little function.
    Can you explain further or post an example ?
    Thanks a lot

    @luni, any plan for an official support of Teensy 4.x ?

  12. #112
    Junior Member
    Join Date
    Apr 2021
    Posts
    3
    Quote Originally Posted by killacycle View Post
    Is it possible to set the motor deceleration different than the acceleration?
    I second this request with even a more complex solution for me.

    My axis are vertical with some weight on.
    So going down the acceleration could be faster.
    But the deceleration must be slower.
    While going up the acceleration must be slower.
    But the deceleration could be faster.

    Any thought on how to implement that?
    Thank you everyone

  13. #113
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,450
    @luni, any plan for an official support of Teensy 4.x ?
    Actually, I'm currently working on it.

    My axis are vertical with some weight on.
    So going down the acceleration could be faster.
    But the deceleration must be slower.
    While going up the acceleration must be slower.
    But the deceleration could be faster.
    I don't know your mechanical setup but one often underestimates moment of inertia of the lead screw and motor anchor as limiting factors to the acceleration/deceleration. Some yeas ago I did a spreadsheet to calculate those effects (attached). It is in German, but mathematics should be easy to translate :-)

    Anyway, I'll try to make the acceleration settings more flexible.
    Attached Files Attached Files

  14. #114
    Junior Member
    Join Date
    Apr 2021
    Posts
    3
    Quote Originally Posted by luni View Post
    Actually, I'm currently working on it.
    Fantastic news!!!
    Do you need beta testers?

    Quote Originally Posted by luni View Post
    I don't know your mechanical setup but one often underestimates moment of inertia of the lead screw and motor anchor as limiting factors to the acceleration/deceleration. Some yeas ago I did a spreadsheet to calculate those effects (attached). It is in German, but mathematics should be easy to translate :-)
    Our project is an art installation.
    The goal is to lift a ring of light on a pillar. Each motor should lift about 2kg including the 1kg of the NEMA23 motor itself.
    Our first prototype will be using 3GT belts on an Everman belt drive system. No idea if it will work...
    As for the file, I will read it after work. That you.

    Quote Originally Posted by luni View Post
    Anyway, I'll try to make the acceleration settings more flexible.
    Thank you.
    My personal priority is still on the Teensy 4.1

  15. #115
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    203
    Here is the file translated to english...thanks google translate.Torque Screw Drive v2.zip

  16. #116
    Hi,

    I'm using the teensystep to control a servo which works great!
    but the issue is, once i've added the library i have a strange behavior.

    I have also a DC motor that i contorl with a DC motor shield, which is controlling the speed of the motor by send PWM signal. i'm doing it via pin 5 of the teensy.

    I can control the DC motor IF i'm not using the teensystep commands.
    Once I turn on the stepper motor, the DC motor is not responding any more...
    What could be the issue?

    Here's the code:

    Code:
    #include <TeensyStep.h>
    
    #define PUL 30
    #define DIR 31
    #define EN 32
    
    #define steps_per_rev 3200
    #define rpm 120
    
    Stepper stepper_pump(PUL,DIR);
    RotateControl controller;
    
    void setup_stepper()
    {
      pinMode(EN, OUTPUT);
      digitalWrite(EN, LOW);
    
      
      stepper_pump.setMaxSpeed(steps_per_rev*rpm /60);  
      stepper_pump.setAcceleration(10*steps_per_rev*rpm /60);
    
      //controller.rotateAsync(stepper_pump);
    //  controller.overrideSpeed(0);
    }
    
    
    void spin_stepper(bool spin)
    {
      if(spin)
      {
        digitalWrite(EN, HIGH);
        controller.rotateAsync(stepper_pump);
      }
      else
      {
        controller.stopAsync();
        digitalWrite(EN, LOW);
      }
    }
    
    void steering_wheel_jog(int percent)
    {
      float ratio = (float)percent / 100;
      
    //  Serial.println("SET SPEED: " + String(ratio));
      controller.overrideSpeed(ratio);
    
    }
    
    
    switch (char_from_serial)                     //decide what command was sent
        {
          case 't': //top motor
            tmotor_mode = !tmotor_mode; 
            Top_Mixer_Motor(tmotor_mode);
            if (!tmotor_mode){
              Serial.println ("Top motor off");
            }
            if (tmotor_mode){
              Serial.println ("Top motor on");
            }
            break;
    
    void Top_Mixer_Motor(int opmode1)
    {
      if (opmode1)
        analogWrite (Top_pwm,255);
      else 
        analogWrite (Top_pwm,0);
      
    }

    The definitions are in setup section:

    Code:
    #define  Top_Mixer 6
    #define  Top_Mixer2 7
    #define  Top_pwm 5
    
    //Define pins for 
      pinMode (Top_Mixer, OUTPUT);
      pinMode (Top_Mixer2, OUTPUT);
      pinMode (Top_pwm, OUTPUT);

Posting Permissions

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