stepper motor speed and position control

Motion
2020-05-09
2020-07-24
  • juancodesys

    juancodesys - 2020-05-09

    Good afternoon, I take this opportunity to introduce myself, my name is Juan, and although it is the first time I ask, I have been following some topics on this forum for quite some time.
    Due to my work I have a little experience at Codesys, although he acknowledges that we have only carried out a few projects with this software.
    My desire to learn and play led me to install the code at home to carry out some projects on a personal level using a Raspberry Pi3 as a PLC.
    I have been trying for several weeks to collect information on the subjects that will be recorded after my presentation and I really cannot find what I am looking for.
    I don't know the best way to control a stepper motor with a raspberry, I count my tests and then we talk about the hardware you may need.
    He made a simple program to test a stepper motor, in this case a Nema17 connected to its corresponding controller. The controller is set to 200 pulses per revolution, since in this case I am looking for a higher speed. Before creating confusion, I am aware that this is not the correct way to carry out this process, but at the moment, and because I do not have any specific board, you used the change of one of the GPIO outputs to try to simulate a pulse train As simple as changing the state of the output in each scan cycle. Setting the task as cyclical and varying this time, it got 300 rpm. He carried out several tests that varied the execution time from 5ms to 0.5ms and with it, they obtained a speed, which a priori, with the help of an encoder and a mega arduino, seems constant. Below 0.5 ms per cycle, the motor does not start. This means that my motor does not allow a time between pulses of less than 1 ms. It should be noted that I cannot apply any type of ramp in these tests.
    I know that there are many communication protocols that connect a specific module to the Raspberry to control these types of motors.
    My doubts will be at this time, and I hope they can be resolved.
    1: PWM. Using PWM I understand that I could control the speed of the pulse train. But, I don't know if I could perform a position control, that is, I need to know if this same board allows me to move at a certain speed to a limited position.
    2: Type of "field bus" to use. I have doubts about what would be the most optimal to perform movements with these nema17 motors. The state reading that modules like Modbus or I2C have a too slow response time to perform real-time axis control.
    3: Sofmotion. I understand that with the Raspberry Pi you can use the softmotion libraries for free. I don't know if this is true
    4: specific plate to acquire. Once I have specified whether or not a PWM board works for me or if I should buy another type of board, and knowing the type of protocol to use, I would like to know what would be the best option that I would recommend to perform axis control with this type of motor. domestic.
    5: Encoder. I am sure that just as there is some specific protection to control a stepper motor, there is also the possibility of acquiring a specific board for connecting an encoder to a Raspberry Pi. I don't know if any input can be configured as an interrupt or quick contact input. If it is a specific board, how can I read the data, how can I know the PDO to use? I would like to do a closed loop with the stepper motor and an additional encoder.
    6: Another question that arises to me, is if there is the possibility of using external periphery using a CanOpen bus. If so, I would like to know the way to connect a Wago 750-337 header to Raspberry pi with Codesys. And in turn, since I can't find it anywhere, thank me you can provide the package manager for this device.
    Thank you very much in advance, and I hope you can help.

     
    • tschroeder

      tschroeder - 2020-07-24

      Hi Juan,
      there is a position controlled SoftMotion driver for this use. You can connect the stepper to the GPIOs of your Raspi. It just needs a motordriver like a L298, a Raspberry Pi as PLC and the stepper motor.
      You will find a detailed description of the driver, how to use it and how it works here:
      https://forge.codesys.com/drv/sm3raspistepper/home/Home/

       
      👍
      1
  • Morberis

    Morberis - 2020-07-10

    I think if you do a few searches on this forum you'll find a lot of answers.

    Starting with version 3.5.15.0 the softmotion license is only available as a seperate product that you need to pay for. If you want to use it for free you'll be restricted to version 3.5.14.40 of the library.

    The only PWM boards I know of with easy control from the Pi use I2C. You'd need to write something for a board that uses SPI if I2C won't be fast enough.

    The GPIO can not be configured as an interrupt. From what I've seen recommended it's best if your stepper control board has the encoder connections.

     

Log in to post a comment.