Unstable PWM motor control issue
- F4br1c4t3D
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 51
- Thank you received: 1
15 Apr 2019 21:04 #130927
by F4br1c4t3D
I rarely treat my confectionery with such lavish gifts!
Probably a bit overkill for a Chinese mini-lathe CNC conversion. I just want to be able to make fancy cylinders not create the worlds first sentient lathe!
Replied by F4br1c4t3D on topic Unstable PWM motor control issue
Steven,
Your lollipop can consider Ethercat.
This is the fasted lollipop on Earth at the moment....
I rarely treat my confectionery with such lavish gifts!
Probably a bit overkill for a Chinese mini-lathe CNC conversion. I just want to be able to make fancy cylinders not create the worlds first sentient lathe!
Please Log in or Create an account to join the conversation.
15 Apr 2019 21:26 - 15 Apr 2019 21:27 #130929
by Grotius
Replied by Grotius on topic Unstable PWM motor control issue
Attachments:
Last edit: 15 Apr 2019 21:27 by Grotius.
Please Log in or Create an account to join the conversation.
- F4br1c4t3D
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 51
- Thank you received: 1
15 Apr 2019 21:43 #130935
by F4br1c4t3D
I think I actually preferred it before the gigantic lolly "upgrade".
What will I do about my motor control though?
Replied by F4br1c4t3D on topic Unstable PWM motor control issue
When your dream's come true ....
I think I actually preferred it before the gigantic lolly "upgrade".
What will I do about my motor control though?
Please Log in or Create an account to join the conversation.
15 Apr 2019 22:21 #130941
by Grotius
Replied by Grotius on topic Unstable PWM motor control issue
You ordered a mesa i see.
i can only say. If you want to be happy keep up the good work !!
The 0 to 10 volt bob control has various settings. If you want to try another setting pm me.
I only hope that you are going the good direction to start with....
i.ytimg.com/vi/nIFwFKh30j4/maxresdefault.jpg
i can only say. If you want to be happy keep up the good work !!
The 0 to 10 volt bob control has various settings. If you want to try another setting pm me.
I only hope that you are going the good direction to start with....
i.ytimg.com/vi/nIFwFKh30j4/maxresdefault.jpg
Please Log in or Create an account to join the conversation.
- F4br1c4t3D
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 51
- Thank you received: 1
22 Apr 2019 23:11 #131570
by F4br1c4t3D
Replied by F4br1c4t3D on topic Unstable PWM motor control issue
Well i managed to sort this out in the end.I changed the PWM that LinuxCNC was outputting to use the full duty cycle range I then used an Arduino nano to read the PWM from LinuxCNC, apply smoothing with a software filter and used the servo.h library to send the smoothed input to my ESC in the PWM format that it understands. The result is a much more stable motor speed. +/- ~5rpm when a static speed is commanded; according to my handheld IR tachometer. I get within 30rpm of the commanded speed over the full speed range most of the tested speeds were within 5rpm of the commanded speed. Considering I've not implemented any PID loop for speed control I'm reasonably happy.
Which leads me onto my next question. How do I implement the PID feedback for spindle speed?
The .hal file generated by stepconf has many references to the spindle feedback but it's not set up to adjust for any error using PID. I tried following this example but it wont work as I end up with conflicts as things are already assigned elsewhere. I'm not sure what I need to remove/add/reconnect to have a PID modify my pwm based on the measured speed.
I'm not sure as I've not tested but I should have everything in place for spindle sync. and spindle at speed.
I've attached my .hal and .ini files, where would I start adding the code for the PID? what do I need to manipulate in my existing setup to allow me to integrate the above example into my configuration?
Which leads me onto my next question. How do I implement the PID feedback for spindle speed?
The .hal file generated by stepconf has many references to the spindle feedback but it's not set up to adjust for any error using PID. I tried following this example but it wont work as I end up with conflicts as things are already assigned elsewhere. I'm not sure what I need to remove/add/reconnect to have a PID modify my pwm based on the measured speed.
I'm not sure as I've not tested but I should have everything in place for spindle sync. and spindle at speed.
I've attached my .hal and .ini files, where would I start adding the code for the PID? what do I need to manipulate in my existing setup to allow me to integrate the above example into my configuration?
Please Log in or Create an account to join the conversation.
23 Apr 2019 22:14 #131701
by andypugh
Replied by andypugh on topic Unstable PWM motor control issue
Because the velocity feedback is revs-per-second then you should rps for the PID.
So, delete
A PID needs a command and a feed back as inputs and has one output.
You then need a set of "setp" commands to set the PID parameters, I would start with P, I and D as zero and adjust FF0 until the speed is right at one setpoint, then increase I until it becomes right at all setpoints, then perhaps add some P to make it settle faster.
So, delete
net spindle-cmd-rpm => pwmgen.0.value
A PID needs a command and a feed back as inputs and has one output.
#this signal already exists so re-use it
net spindle-cmd-rps pid.0.command
#this signal also already exists, so re-use it
net spindle-velocity-feedback-rps pid.0.feedback
#now connect the pid output to the pwm generator using a new signal
net spindle-pid-output pid.0.out => pwmgen.0.value
# and the pid enable, also a pre-existing signal
net spindle-on pid.0.eable
The following user(s) said Thank You: F4br1c4t3D
Please Log in or Create an account to join the conversation.
- F4br1c4t3D
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 51
- Thank you received: 1
23 Apr 2019 23:08 #131712
by F4br1c4t3D
Replied by F4br1c4t3D on topic Unstable PWM motor control issue
Hi Andy,
Thanks a lot for your input. I've now adjusted my config since posting the above files. and started a new thread here since this isn't really about the PWM issue anymore. I believe I have now made the correct connections, the loop isn't stabilising the speed but rather causing the motor to grind to a halt immediately after starting. PCW had already given me similar advice on that thread regarding setting ff0 first, then introducing some the other terms. you're saying start with I to rein in any outlying speeds then a touch of P to increase responsiveness. Got it! Thanks very much for the advice.
Cheers,
Steve
Thanks a lot for your input. I've now adjusted my config since posting the above files. and started a new thread here since this isn't really about the PWM issue anymore. I believe I have now made the correct connections, the loop isn't stabilising the speed but rather causing the motor to grind to a halt immediately after starting. PCW had already given me similar advice on that thread regarding setting ff0 first, then introducing some the other terms. you're saying start with I to rein in any outlying speeds then a touch of P to increase responsiveness. Got it! Thanks very much for the advice.
Cheers,
Steve
Please Log in or Create an account to join the conversation.
- F4br1c4t3D
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 51
- Thank you received: 1
24 Apr 2019 18:29 #131782
by F4br1c4t3D
Replied by F4br1c4t3D on topic Unstable PWM motor control issue
Hi Andy,
Well I tried what you suggested above and it didn't work out.
I removed the line you suggested
It seems though, without this line, the spindle won't spin up at all, even though we're reconnecting the pwmgen.0.value to the output of the pid. What gives?
Here's what I added:
Also attached is the rest of the .hal as it currently stands, as I'm guessing I'm missing something else.
Well I tried what you suggested above and it didn't work out.
I removed the line you suggested
net spindle-cmd-rpm => pwmgen.0.value
It seems though, without this line, the spindle won't spin up at all, even though we're reconnecting the pwmgen.0.value to the output of the pid. What gives?
Here's what I added:
setp pid.0.Pgain 0
setp pid.0.Igain 0
setp pid.0.Dgain 0
setp pid.0.FF0 1
net spindle-cmd-rps pid.0.command
net spindle-velocity-feedback-rps pid.0.feedback
net spindle-pid-out pid.0.output => pwmgen.0.value
net spindle-on pid.0.enable
Also attached is the rest of the .hal as it currently stands, as I'm guessing I'm missing something else.
Please Log in or Create an account to join the conversation.
24 Apr 2019 19:02 #131784
by andypugh
Replied by andypugh on topic Unstable PWM motor control issue
Use halshow to work out where the signals are getting confused.
(machine -> show hal configuration if using the Axis interface)
(machine -> show hal configuration if using the Axis interface)
Please Log in or Create an account to join the conversation.
24 Apr 2019 19:07 - 24 Apr 2019 19:10 #131785
by PCW
Replied by PCW on topic Unstable PWM motor control issue
Did you re-scale the PWM for RPS?
( actually I think it would be an improvement in LinuxCNC for the encoder module to have a RPM velocity pin )
( actually I think it would be an improvement in LinuxCNC for the encoder module to have a RPM velocity pin )
Last edit: 24 Apr 2019 19:10 by PCW.
Please Log in or Create an account to join the conversation.
Time to create page: 0.164 seconds