Did anyone implement a controller in dsPIC by this toolbox?
Did anyone implement a controller in dsPIC by this toolbox?
Did anyone implement a controller in dsPIC by this toolbox? I was trying some times but still got some problems. I use dsPIC30f6014A device. If I use 'transfer function' block of Simulink simply or create a 'direct form' model for controllers, they don't work in practice.
Only when I use a simple P, PI or 1st order model, the controller works just OK in practice. Also error tracking is not good in this situation.
For all models, sample time was specified. The 'signal type' was setup as 'double precision', because there was a big number range from reference input to controller output in my case. I'm not sure above modelling and setups are exactly correct. Did anyone have related experiences? And Mr. Lubin, do you have any advice for implementing controller by your toolbox? Thanks for all!-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: Did anyone implement a controller in dsPIC by this toolbox?
Hello,
Thanks for the images.
I made many controllers (PID or state space model) that work.
Try to:
- show sample time of each block (use sample time color).
- Check that 1/Z works at the right sample time (should be -1 for inherited or you simulink sample time value) default value is 1 (for 1 second) and is a cause of error!
- Also, note that double are implemented as single in the dsPIC except if you add the block "Compiler Configuration" from the dsPIC blockset and check the box to implement Double in 64bits instead of 32. (But I do not think that is the error, and I would advise to keep 32 bits)
If it did not solved the problem, could you upload the simulink files for theses model?
Lubin
Thanks for the images.
I made many controllers (PID or state space model) that work.
Try to:
- show sample time of each block (use sample time color).
- Check that 1/Z works at the right sample time (should be -1 for inherited or you simulink sample time value) default value is 1 (for 1 second) and is a cause of error!
- Also, note that double are implemented as single in the dsPIC except if you add the block "Compiler Configuration" from the dsPIC blockset and check the box to implement Double in 64bits instead of 32. (But I do not think that is the error, and I would advise to keep 32 bits)
If it did not solved the problem, could you upload the simulink files for theses model?
Lubin
Re: Did anyone implement a controller in dsPIC by this toolbox?
Hi Lubin,
I think I have done the same setup for my models. It's better to upload the model, but always errors occur when I upload a .mdl
file. Anyway, I have sent the model to you by email-lubin@kerhuel.eu, please take a look if possible.
cheers,
gladiac
I think I have done the same setup for my models. It's better to upload the model, but always errors occur when I upload a .mdl
file. Anyway, I have sent the model to you by email-lubin@kerhuel.eu, please take a look if possible.
cheers,
gladiac
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: Did anyone implement a controller in dsPIC by this toolbox?
Hi Gladiac,
I did not see obvious error the simulink file you sent.
But I could perhaps help anyway. First of all, I will not check the controller stability and so on... I supposed that it is Ok.
I have two remarks:
First, on the use of data type double: despite it is easier to use than fixed point calculation, strange behavior may appears when calculation involving both very large value with very low value appears.
Then, a second remark: the PID implemented has no reset or saturation limits (or anti windup) on the 'I' term. As soon as the controller is switch off (See switch on the model), I supposed that the integrator reach a very high value. Cf to remark 1, you may get into trouble then.
If your electronic board has an UART that you can connect to your PC, I would suggest using the Tx-Matlab block to see what happen on several variables at the same time. (Convert value into int16 data type before sending through UART. Lubin
I did not see obvious error the simulink file you sent.
But I could perhaps help anyway. First of all, I will not check the controller stability and so on... I supposed that it is Ok.
I have two remarks:
First, on the use of data type double: despite it is easier to use than fixed point calculation, strange behavior may appears when calculation involving both very large value with very low value appears.
Then, a second remark: the PID implemented has no reset or saturation limits (or anti windup) on the 'I' term. As soon as the controller is switch off (See switch on the model), I supposed that the integrator reach a very high value. Cf to remark 1, you may get into trouble then.
If your electronic board has an UART that you can connect to your PC, I would suggest using the Tx-Matlab block to see what happen on several variables at the same time. (Convert value into int16 data type before sending through UART. Lubin
- Attachments
-
- controller.mdl
- Simulink Model file from Gladiac
- (42.31 KiB) Downloaded 878 times
Re: Did anyone implement a controller in dsPIC by this toolbox?
Thank you very much, Lubin! I will try it tomorrow and let you know the result.
Re: Did anyone implement a controller in dsPIC by this toolbox?
Hi Lubin,
I have tried the dsPIC again. First, my controller worked OK on dSPACE before.So the cotnroller should be OK. Second,if I remove the 'saturation' block in model, output signal looks fine on oscilloscope. But on real testing, behaviour is still bad. I'm sitll checking problem include the hardware.
cheers,
gladiac
I have tried the dsPIC again. First, my controller worked OK on dSPACE before.So the cotnroller should be OK. Second,if I remove the 'saturation' block in model, output signal looks fine on oscilloscope. But on real testing, behaviour is still bad. I'm sitll checking problem include the hardware.
cheers,
gladiac
Re: Did anyone implement a controller in dsPIC by this toolbox?
Hi Lubin,
The low order controller works OK when using the update version toolbox.The high order one doesn't work. Still trying.
The low order controller works OK when using the update version toolbox.The high order one doesn't work. Still trying.
Re: Did anyone implement a controller in dsPIC by this toolbox?
Dear Lubin,
Unfortunately, my dsPIC was broken two weeks ago and the new one just come a few days ago. So the problem has been delayed for a long time. Now I use the 'zpk(zeros-poles-gain)' block to implement the high order controller, and that works OK in real testing. Also I tried the 'state-space' block, it performaned like the general 'tf' blcok which doesn't work. Do you have any idea for that phenomenon and What's the difference between 'zpk','ss'and 'tf' block in implementation?
Cheers,
Gladiac
Unfortunately, my dsPIC was broken two weeks ago and the new one just come a few days ago. So the problem has been delayed for a long time. Now I use the 'zpk(zeros-poles-gain)' block to implement the high order controller, and that works OK in real testing. Also I tried the 'state-space' block, it performaned like the general 'tf' blcok which doesn't work. Do you have any idea for that phenomenon and What's the difference between 'zpk','ss'and 'tf' block in implementation?
Cheers,
Gladiac
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: Did anyone implement a controller in dsPIC by this toolbox?
Hi Gladiac
Lubin
I did not compared the C implementation of theses block yet. That would be interresting. Could you upload a model with your corrector as starting point to compare ?gladiac wrote:What's the difference between 'zpk','ss'and 'tf' block in implementation?
Lubin
Re: Did anyone implement a controller in dsPIC by this toolbox?
Hi Lubin,
The file attached is the model of the controller. I put three different blocks with same one controller in it.
Cheers
Gladiac
The file attached is the model of the controller. I put three different blocks with same one controller in it.
Cheers
Gladiac
- Attachments
-
- controller.mdl
- (38.02 KiB) Downloaded 844 times
Re: Did anyone implement a controller in dsPIC by this toolbox?
Hello Lubin,
This seems to be quite an interesting comparison, would you post your results if/when you have them to see which is more efficient?
Thanks
This seems to be quite an interesting comparison, would you post your results if/when you have them to see which is more efficient?
Thanks
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: Did anyone implement a controller in dsPIC by this toolbox?
Hello Gladiac, Mariano,
I'am quite overloaded (Working on both the next blockset version and my PhD ...) forgot this thread. Sorry about that.
Thanks Gladiac for the last model you posted. I'll try to have a look next week. (it is not urgent for anybody? )
I'll report results If it is not already done by someone.
As an interresting subject, that could be a case study to add in the wiki pages...
Cheers
Lubin
I'am quite overloaded (Working on both the next blockset version and my PhD ...) forgot this thread. Sorry about that.
Thanks Gladiac for the last model you posted. I'll try to have a look next week. (it is not urgent for anybody? )
I'll report results If it is not already done by someone.
As an interresting subject, that could be a case study to add in the wiki pages...
Cheers
Lubin
Re: Did anyone implement a controller in dsPIC by this toolbox?
The controller model presented has problem with the Gain 3; It must be negative...
Gain 3 and Gain 2 MUST be negative...
...and do not try any positive feedback design in your systems unlesss you are designing Variable Structure System Design...
Todor
Gain 3 and Gain 2 MUST be negative...
...and do not try any positive feedback design in your systems unlesss you are designing Variable Structure System Design...
Todor
Re: Did anyone implement a controller in dsPIC by this toolbox?
This Gain -koefficient in the first intrgrator feed back must be negative.
...in both the Plant and the controller.
The controller presented is not performing PI.
If the Gain is negative then we have a first order filter responce added to Proportional K...
Ones you have negative gain ofcourse.
Then you will have an "I" component to "P", which will be working for 0.63 of the Time Cte for this First order structure. And no MORE...
After that - in study State...this 1 Order will add extra proportional actuating...
You will miss the "I" Integral component in PI...therefore, a big Static Error (studyState...Tracking...error.) will never be compensated to be ZERO.
Back to Simulink...
Lubin is right about using Integrators...always limit them...and be ready to reset the Initial Conditions !!!!!
Happy Simulating,
Todor
...in both the Plant and the controller.
The controller presented is not performing PI.
If the Gain is negative then we have a first order filter responce added to Proportional K...
Ones you have negative gain ofcourse.
Then you will have an "I" component to "P", which will be working for 0.63 of the Time Cte for this First order structure. And no MORE...
After that - in study State...this 1 Order will add extra proportional actuating...
You will miss the "I" Integral component in PI...therefore, a big Static Error (studyState...Tracking...error.) will never be compensated to be ZERO.
Back to Simulink...
Lubin is right about using Integrators...always limit them...and be ready to reset the Initial Conditions !!!!!
Happy Simulating,
Todor
Re: Did anyone implement a controller in dsPIC by this toolbox?
Tchangov wrote: I have just derived the controller: It present a Proportional Derivative dynamics.
This Gain -koefficient in the first intrgrator feed back must be negative.
...in both the Plant and the controller.
The controller presented is not performing PI.
If the Gain is negative then we have a first order filter responce added to Proportional K...
Ones you have negative gain ofcourse.
Then you will have an "I" component to "P", which will be working for 0.63 of the Time Cte for this First order structure. And no MORE...
After that - in study State...this 1 Order will add extra proportional actuating...
You will miss the "I" Integral component in PI...therefore, a big Static Error (studyState...Tracking...error.) will never be compensated to be ZERO.
Back to Simulink...
Lubin is right about using Integrators...always limit them...and be ready to reset the Initial Conditions !!!!!
Happy Simulating,
Todor
Re: Did anyone implement a controller in dsPIC by this toolbox?
Hi Lubin,
Thanks for your continuing attention.
And Todor,
Your explanation is right. But I don't think it will cause the problem, feedback loop of 'direct form' still can be negative. As 'sign' can be changed straight in 'gain' block. Actually, I put the negative cofficients in 'gain' blocks directly. The problem for the model first uploaded is not the compensator. The reason is my hardware is not supported by Lubin's blockset initially, when Lubin upgrade the blockset for me, the problem was solved. The controller with dsPIC woked fine in real machine testing.
Cheers
Gladiac
Thanks for your continuing attention.
And Todor,
Your explanation is right. But I don't think it will cause the problem, feedback loop of 'direct form' still can be negative. As 'sign' can be changed straight in 'gain' block. Actually, I put the negative cofficients in 'gain' blocks directly. The problem for the model first uploaded is not the compensator. The reason is my hardware is not supported by Lubin's blockset initially, when Lubin upgrade the blockset for me, the problem was solved. The controller with dsPIC woked fine in real machine testing.
Cheers
Gladiac
Who is online
Users browsing this forum: No registered users and 71 guests