Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

i have a lot of ope loop stepper motor drivers with step/dir control interface. these drivers have curret adjust and step resolution swithches. i have a lot of cwd556 dm860 r60 model stepper motor drivers.
i want to make them closed loop stepper motor drivers by adding a bluepill and three opto couplers. we must use bluepills timer 2 as encoder interface. we need to integrate a step dir motor driver code and encoder interface in a bluepill code.
how can we use simple foc with step dir motor driver and optical incremental A/B/I encoders?

You must be logged in to vote

Replies: 2 comments · 4 replies

Comment options

Hi @phpkadir,

You can also use our forums at https://community.simplefoc.com to ask questions... I think more people read the questions there...

SimpleFOC has support for encoders via the Encoder class, and on some STM32 MCUs there is also the STM32HardwareEncoder in our drivers repository, which uses the encoder mode of STM32 timers.
So running the encoders is no problem.

However, controlling the steppers via the microstepping drivers is not something we support. SimpleFOC is intended to control BLDCs and also Stepper motors using field-oriented control (FOC). This means SimpleFOC needs to control the phase voltages/currents of the motor directly, not via a micro stepping driver. To use SimpleFOC with the steppers you will need a simpler half-bridge driver for each motor phase.

You must be logged in to vote
4 replies
@phpkadir
Comment options

adding a pid controller with position loop and speed loop to simpleFOC library will make a mega earthquake on market.
we should make a better library to use open loop stepper motor drivers with stepper motors with encoders. soon we can provide cheap closed loop stepper motor drivers. people can use external hardware encoders and their regular stepper motors.
we should add a code block to stepper motor driver class. a PID stepper motor controller with step/dir buffer and speed loop+ position loop.

@runger1101001
Comment options

Hi @phpkadir ,

But we already have a PID position loop and velocity loop... SimpleFOC is all about closed loop control, really. With the normal library, you can drive steppers in closed loop position control or closed loop velocity control, using simple half-bridge drivers with PWM control, and an encoder or magnetic sensor for position feedback.

Or do you mean supporting PID control of StepDir type drivers? We can support position and velocity control via PID for many other kinds of drivers using our new DC motor library. This is not FOC (field oriented control) but rather just PID control over the position/velocity.
This is also implemented, in our SimpleDC motor library... it is being tested, and will be released soon. In the meantime, you can find the code (in development) here: https://github.com/runger1101001/Arduino-FOC-dcmotor

@phpkadir
Comment options

i mean adding a buffer simplefoc programmed microcontroller for PID control of StepDir type drivers. https://github.com/runger1101001/Arduino-FOC-dcmotor/blob/main/src/drivers/DCDriverSpeedDir.cpp) awesome effort. thank you for this improvement. i want to make a pure stm32 cube HAL fork of Arduino-FOC-dcmotor.

@runger1101001
Comment options

Ok, I understand!

May I ask why not do FOC control of the stepper, and also get the advantages on the electrical level?

Looking more at what would be necessary for your use-case:

  • I guess we would need a new type of driver in the DC motor library, for emitting the pulses expected by the StepDir interface.
  • We would treat the stepper like a DC motor in this case, sending pulses at a constant speed for a given "DC voltage" computed by the algorithm
  • You could then run the motor in torque-voltage mode, as well as velocity and position modes after tuning the PIDs.
  • Where I have some doubts regarding this scheme is if you want to do "single stepping" type operations, e.g. controlling the motor at the very limit of its step resolution - this would correspond to computing very low voltages (or small voltage variations) resulting in very low "pulse frequencies" - I suspect there will be problems when the computed pulse frequencies enter into the same time-scales as the rate of change of control commands...

In any case, there would be still a bit of work to get this running, as we currently don't have a driver for this frequency type of control. I was a bit optimistic in my last posting there :-) as I think about it more now, I realise we're still missing that part of the code.

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
💡
Ideas
Labels
None yet
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.