Nonlinear PWM

More
12 Jan 2014 16:58 #42638 by eslavko
Nonlinear PWM was created by eslavko
Hello...

I have little problem as my PWM to spindleRPM interface is nonlinear. I look into documentation but I don't find any solution.
In one of My old controller I have simple lookup table with (I think) 8 points in LUT and do interpolation between.
Is it possible to make similar in linuxcnc?
For example I measure the PWM rate at 5, 10, 15, 20, 25, 30 x1000 RPM and store PWM result in table so the PID and PWM can work to close loop?

Please Log in or Create an account to join the conversation.

More
12 Jan 2014 18:15 #42640 by emcPT
Replied by emcPT on topic Nonlinear PWM
If you control the spindle with a standard VFD, the VFD itself can do that and it can be a solution.
At least all the modern VFD that I worked on can adjust the input vs the output.

Please Log in or Create an account to join the conversation.

More
12 Jan 2014 23:37 #42656 by PCW
Replied by PCW on topic Nonlinear PWM
Take a look at the lincurve component Andy Pugh added
recently to master.

it looks like just what is needed

Please Log in or Create an account to join the conversation.

More
12 Jan 2014 23:42 #42657 by eslavko
Replied by eslavko on topic Nonlinear PWM
No, it's not VFD.
Just woodworking router with triac regulation.
I tided photoresistor instead potentiometer in woodworking spindle, and lit LED with pwm on it.
It works nice, just the ramp is not linear. Seems like to be logharitmic.
The PID works nice up to around 20000RPM, after that doesn't work as it take loooong time to reach speed. If I make PidI bigger then works little better but start to oscillate with low rpm. I will try to make regulation up to 20000 RPM with one set of parameters P.I.D, and over 20000RPM with other set of P.I.D parameters. Swiching parameters with mux should be easy. But if I need more "ranges" then this solution is not so good....

Will try...

Please Log in or Create an account to join the conversation.

More
13 Jan 2014 05:47 #42675 by andypugh
Replied by andypugh on topic Nonlinear PWM

The PID works nice up to around 20000RPM, after that doesn't work as it take loooong time to reach speed. If I make PidI bigger then works little better but start to oscillate with low rpm. I will try to make regulation up to 20000 RPM with one set of parameters P.I.D, and over 20000RPM with other set of P.I.D parameters. Swiching parameters with mux should be easy. But if I need more "ranges" then this solution is not so good.....


Changing PID with speed (etc) was exactly what "lincurve" was written for, but it might be easier to linearise the PWM using the same function.

Please Log in or Create an account to join the conversation.

More
13 Jan 2014 19:55 #42695 by eslavko
Replied by eslavko on topic Nonlinear PWM
I don't have branch with lincurve installed. But looking in manual I don't understand how it works?

For example if I setup this:

loadrt lincurve count=1 personality=3
setp lincurve.0.x-val-00 0
setp lincurve.0.x-val-01 10
setp lincurve.0.x-val-02 20

setp lincurve.0.y-val-00 0
setp lincurve.0.y-val-01 10
setp lincurve.0.y-val-02 100


What y I got for X=5? (0 or 5?)

What y I got for X=15? (10 or 45?)

If value is interpolated then it's ok for me. But in docs seems that it isn't?

Slavko.

Please Log in or Create an account to join the conversation.

More
13 Jan 2014 20:04 #42697 by andypugh
Replied by andypugh on topic Nonlinear PWM

If value is interpolated then it's ok for me.


It is interpolated.

If you need it then it should be relatively easy to get the file from git.linuxcnc.org and install it on your system with comp --install

Please Log in or Create an account to join the conversation.

More
13 Jan 2014 22:55 #42701 by eslavko
Replied by eslavko on topic Nonlinear PWM
Ahh I forget that there is comp install, and I install (in place) the 2.6~pre. (will probably try comp as hate new axis gui, and there are missing spindle -+ buttons.)

for lincurve I missread that interpolation is done betwen range but not if input is outside of parameter.
.. now tryyng to make it work.

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 05:21 #42719 by eslavko
Replied by eslavko on topic Nonlinear PWM
I managed to setup lincurve.

I do linearize the signal just before entering PWM. With personality=7 I can achive pretty precise open loop spindle speed.

But untill now I never used PID on linuxcnc, and something is strange there. (at least something I dont expect)

For example when I put number 500 to PWM (lincurve before pwm) the spindle run around 30000 RPM (500 RPS), and I have pid.command=500 and pid.feedback=500 too. But the output is not 500 but 0!
Test done with d P=1, I=0, D=0. If I change feedback to 499 I got output of 1. So PID output is only the error factors.

So if I assume correct I need to add command and error (the pid output) together and feed to pwm.
I suppose that connecting pid.N.bias and pid.N.command together is the right way?

...Or I make something wrong elsewhere?

Slavko

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 05:30 #42720 by andypugh
Replied by andypugh on topic Nonlinear PWM

With personality=7 I can achive pretty precise open loop spindle speed.

That might be good enough. My mill runs open-loop with automatic gear detection (described elsewhere in the forum) and I am perfectly happy with it.

For example when I put number 500 to PWM (lincurve before pwm) the spindle run around 30000 RPM (500 RPS), and I have pid.command=500 and pid.feedback=500 too. But the output is not 500 but 0!

That is exactly how PID works. :-) Output is proportional to error. With no error, there is no output with a purely P-based setup.

So if I assume correct I need to add command and error (the pid output) together and feed to pwm.

That would work, but there is a built-in feature of PID for this situation. Connect your command signal to the FF0 pin, and the command is added to the output.
You will probably get the best results with FF0 connected, and using only I-gain to do most of the work, and just a hint of P to get it there faster.

Please Log in or Create an account to join the conversation.

Time to create page: 0.117 seconds
Powered by Kunena Forum