DSP Component
Moderator: Benj
DSP Component
Dear Ben.
Please help the old man ,
I am using the DSP Component to do a PID and it is working I get the Control output as expected according to the error between the
Input and the Feedback.However it seems to me that the control output does never increase if the error is kept constant as I would expect
the integral part should increase the output if the error remains constant,
(I force a constant error by setting the set point and not allowing the plant to move so error stays constant)
I have use the component in another project some time ago with FC 7 and I some how recall that it did exactly this in FC 7
Please can you check my setup of the Component may be you spot my error or what I am doing wrong
I will be very happy if you can help me
Please help the old man ,
I am using the DSP Component to do a PID and it is working I get the Control output as expected according to the error between the
Input and the Feedback.However it seems to me that the control output does never increase if the error is kept constant as I would expect
the integral part should increase the output if the error remains constant,
(I force a constant error by setting the set point and not allowing the plant to move so error stays constant)
I have use the component in another project some time ago with FC 7 and I some how recall that it did exactly this in FC 7
Please can you check my setup of the Component may be you spot my error or what I am doing wrong
I will be very happy if you can help me
 Attachments

 PIC16F1938eWG.rar
 (183.91 KiB) Downloaded 67 times
Re: DSP Component
Hi Peter,
I think intergral needs to be a value less than 1 to make a significant difference.
Maybe try these coefficients and see how you get on. We use these for the motor control solution and they work great with that.
P = 4.0
I = 0.3
D = 0.5
I think intergral needs to be a value less than 1 to make a significant difference.
Maybe try these coefficients and see how you get on. We use these for the motor control solution and they work great with that.
P = 4.0
I = 0.3
D = 0.5
Regards Ben Rowland  MatrixTSL
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Re: DSP Component
Hi Ben
Thanks for the info in the mean time I did play with this and noticed an integral of less than 1 seems to improve things
however this confuse me if I reach 0 in tuning should I go negative values ,my math do not add up on this ,can you explain the math behind this a bit for understanding
I have done PID myself in C code in my younger day and this seems strange
Thank again
Thanks for the info in the mean time I did play with this and noticed an integral of less than 1 seems to improve things
however this confuse me if I reach 0 in tuning should I go negative values ,my math do not add up on this ,can you explain the math behind this a bit for understanding
I have done PID myself in C code in my younger day and this seems strange
Thank again
Re: DSP Component
Hi Peter,
The maths for the PID is available here.
https://www.matrixtsl.com/wiki/index.ph ... ve_Control
It's a formula I boiled down at University which I have used multiple times since and I know embedded lecturers who actively use it. However if you feel the maths is wrong then let me know and I'll investigate
The maths for the PID is available here.
https://www.matrixtsl.com/wiki/index.ph ... ve_Control
It's a formula I boiled down at University which I have used multiple times since and I know embedded lecturers who actively use it. However if you feel the maths is wrong then let me know and I'll investigate
Regards Ben Rowland  MatrixTSL
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Re: DSP Component
Ben
I am not feeling the math is wrong I am just interested to understand how we get to go to smaller numbers as 1 for the integral
you are much smarter than me thanks for the link I will try to understand your method
Thanks Ben
I am not feeling the math is wrong I am just interested to understand how we get to go to smaller numbers as 1 for the integral
you are much smarter than me thanks for the link I will try to understand your method
Thanks Ben
Re: DSP Component
Hi Peter,
I took the maths from what my lecturers at Uni gave me and translated from integral type notation to an equation you can implement in code. I used it again in my masters and have published it in the Matrix DSP manual and it's never been questioned so hopefully it's on the money. As I say it does work very well when tuned.
The larger the integral parameter the smaller the intergral step as you divide the error by the I parameter.
For real number systems this works so say the error is 2 and the I param is 4 the intergral step would be 0.5.
We are using an integer based system for speed and efficiency and so any value for the integral step less then 1.0 will be read as 0 and therefore have no effect.
I think this is what's happening but I'll investigate. It's strange that a value above 1 is having no effect even with large numbers e.g. an error of 100 would be a step of 20 even with an I parameter of 5. Maybe the effect is there when the error is large but is slugged as the error gets smaller?
I'm currently revisiting the DSP components for the next version of FC and was considering adding float as a variable type. Also long and ulong are on the list as considerations. I've currently dropped the signed byte buffer type.
My main task is currently removing the need for the DSP system component and the associated buffer cap which has now been done and is being rolled out to the current components. Instead of the DSP system component each DSP component with an output will host its own buffer.
I'm also thinking about a DSP Analog Input component and maybe a DAC / PWM Analog Output component. File I/O and Fuzzy components are also a possibility. Completing the long awaited Kalman filter is also on the list but I first need to better understand the maths behind this.
What do you think? Is there anything you would like to see?
I'm hoping the maths is right but I'm certainly open to the possibility that it's not.I am not feeling the math is wrong
I took the maths from what my lecturers at Uni gave me and translated from integral type notation to an equation you can implement in code. I used it again in my masters and have published it in the Matrix DSP manual and it's never been questioned so hopefully it's on the money. As I say it does work very well when tuned.
The larger the integral parameter the smaller the intergral step as you divide the error by the I parameter.
For real number systems this works so say the error is 2 and the I param is 4 the intergral step would be 0.5.
We are using an integer based system for speed and efficiency and so any value for the integral step less then 1.0 will be read as 0 and therefore have no effect.
I think this is what's happening but I'll investigate. It's strange that a value above 1 is having no effect even with large numbers e.g. an error of 100 would be a step of 20 even with an I parameter of 5. Maybe the effect is there when the error is large but is slugged as the error gets smaller?
I'm currently revisiting the DSP components for the next version of FC and was considering adding float as a variable type. Also long and ulong are on the list as considerations. I've currently dropped the signed byte buffer type.
My main task is currently removing the need for the DSP system component and the associated buffer cap which has now been done and is being rolled out to the current components. Instead of the DSP system component each DSP component with an output will host its own buffer.
I'm also thinking about a DSP Analog Input component and maybe a DAC / PWM Analog Output component. File I/O and Fuzzy components are also a possibility. Completing the long awaited Kalman filter is also on the list but I first need to better understand the maths behind this.
What do you think? Is there anything you would like to see?
Regards Ben Rowland  MatrixTSL
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Re: DSP Component
I've dug this out which provides a lot of the basis of the maths.
Here the I parameter is 4.7 but the setpoint is only 1.0 so this makes sense for the integral step to be less than 1.0.
Here the I parameter is 4.7 but the setpoint is only 1.0 so this makes sense for the integral step to be less than 1.0.
Regards Ben Rowland  MatrixTSL
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Re: DSP Component
Hello Ben.
Thank you for your valuable info and comments
I have used the component on a few projects and it works really well , however in these project the tuning always ended in a smaller then 1.0 I part
till last Wednesday then I noticed that I values of bigger than 1.0 had no effect on the output .may be it is my combination of error setpoint and I that cause this .
but I think a bit heavy for 8 bit cpu's but surly the dsPIC and 32 bit ARM's and PIC32 it would benefit from it huge
besides the DSP components I really would love to see a component for using the microchip MCP3008 and MCP3004 and similar ADC's
Again I will work through your attached info to help me work with the DSP component in a good way,
Have great weekend
Thank you for your valuable info and comments
I have used the component on a few projects and it works really well , however in these project the tuning always ended in a smaller then 1.0 I part
till last Wednesday then I noticed that I values of bigger than 1.0 had no effect on the output .may be it is my combination of error setpoint and I that cause this .
My error was 1900 + and forced to stay constant and by writing the output to UART it stay the same as if P = 1, I= 1 ,D = 1 and the I did not change noticeable Ben Please investigate thisI think this is what's happening but I'll investigate. It's strange that a value above 1 is having no effect even with large numbers e.g. an error of 100 would be a step of 20 even with an I parameter of 5
I would have loved float in the variable types specially in this project but then again in a last project the sign variables was ideal, I think it a mistake to leave them out, in my last project the signals was swinging between negative and positive numbers (16bit) and I used thhe ADC directly only changed the sign in certain conditions it was fast and easy and neat solutionPlease rethink to leave the signed numbers.I'm currently revisiting the DSP components for the next version of FC and was considering adding float as a variable type. Also long and ulong are on the list as considerations. I've currently dropped the signed byte buffer type.
This make a lot of sense specially on PIC16 and 18We are using an integer based system for speed and efficiency
This will be nice I like that reallyMy main task is currently removing the need for the DSP system component and the associated buffer cap which has now been done and is being rolled out to the current components. Instead of the DSP system component each DSP component with an output will host its own buffer.
Please this will be a great help and feature Kalman filter will be a great feature to have specially for predicting where the system is going tooI'm also thinking about a DSP Analog Input component and maybe a DAC / PWM Analog Output component. File I/O and Fuzzy components are also a possibility. Completing the long awaited Kalman filter is also on the list but I first need to better understand the maths behind this.
but I think a bit heavy for 8 bit cpu's but surly the dsPIC and 32 bit ARM's and PIC32 it would benefit from it huge
besides the DSP components I really would love to see a component for using the microchip MCP3008 and MCP3004 and similar ADC's
Again I will work through your attached info to help me work with the DSP component in a good way,
Have great weekend
Re: DSP Component
Hi Peter,
My current plan is to keep the signed 16bit type but remove the signed 8bit type as there is no way currently in Flowcode to nicely generate this data.I think it a mistake to leave them out, in my last project the signals was swinging between negative and positive numbers (16bit) and I used thhe ADC directly only changed the sign in certain conditions it was fast and easy and neat solutionPlease rethink to leave the signed numbers.
Regards Ben Rowland  MatrixTSL
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Re: DSP Component
Hi Ben,
I agree signed 8 bit can go the range is too small for any decent control
Have nice time
I agree signed 8 bit can go the range is too small for any decent control
Have nice time
Re: DSP Component
Hi Peter,
Futher on this do you make use of the DSP Control component?
I'm thinking of changing things so that the setpoint is no longer passed into the function as a parameter and instead is a seperate DSP buffer input. This way you can take a reading direct from an analogue input using the new DSP Input Analog component and you can optionally do additional things such as filtering or averaging on the setpoint which would have been awkward before.
Futher on this do you make use of the DSP Control component?
I'm thinking of changing things so that the setpoint is no longer passed into the function as a parameter and instead is a seperate DSP buffer input. This way you can take a reading direct from an analogue input using the new DSP Input Analog component and you can optionally do additional things such as filtering or averaging on the setpoint which would have been awkward before.
Regards Ben Rowland  MatrixTSL
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Re: DSP Component
Hi Ben.
Thanks so much for looking into all these nice things
Yes this is the component I am using each and every time.DSP Control component
This will be great and will make life easier with the controls looking forward to this Ben, I am currently and in future will use this DSP Control Component quite a lot as I am working on an Automotive VGT Turbo system and waste gate control for/ with an OEMThis way you can take a reading direct from an analogue input using the new DSP Input Analog component and you can optionally do additional things such as filtering or averaging on the setpoint which would have been awkward before.
Thanks so much for looking into all these nice things
Re: DSP Component
HI Ben.
Just a small info for you.
We commissioned the controller using the PID/DSP Component on a 700 HP Porsche Engine (it is controlling the waste gate actuator/ Boost Pressure )
Again the PID showed as in the past that it works well and relatively easy to tune however as discussed above when we are using I values of less than 1.0
looking forward to the new modifications.
Have good one
Just a small info for you.
We commissioned the controller using the PID/DSP Component on a 700 HP Porsche Engine (it is controlling the waste gate actuator/ Boost Pressure )
Again the PID showed as in the past that it works well and relatively easy to tune however as discussed above when we are using I values of less than 1.0
looking forward to the new modifications.
Have good one
Re: DSP Component
Hi Peter,
That sounds very interesting and like a very good project. Any chance of some photos we can use for marketing purposes?
That sounds very interesting and like a very good project. Any chance of some photos we can use for marketing purposes?
Regards Ben Rowland  MatrixTSL
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Re: DSP Component
HI Ben,
I will ask the Project Manager and let you know
I will ask the Project Manager and let you know
Re: DSP Component
Hi Ben
Just checking any news regarding the planned changes to the DSP Component ? Just curious
Just checking any news regarding the planned changes to the DSP Component ? Just curious
Re: DSP Component
Hi Peter,
Here is the current list of new DSP components.
There should also be an Input CSV component which seems to be missing atm.
In summation,
Got rid of the DSP system component, each component now controls it's own output buffer.
The Tick and NoneTick macros have been renamed to Function and FunctionArray to make them more obvious.
Each component now has two main macros, functionality such as add/divide etc is now controlled via a property and the icon on the panel changes to suit. This should make it easier to see what's going on just by looking at the DSP chain.
Some components have been split up into new components to help make it more obvious what they do.
Math has been updated to include things like Power, Mod, Sin, Cos, Tan etc.
Lots of new features and functionality.
We want a scheduler component too so this can call the various DSP components in the correct order but this may come later as core exe changes are required for this.
Here is the current list of new DSP components.
There should also be an Input CSV component which seems to be missing atm.
In summation,
Got rid of the DSP system component, each component now controls it's own output buffer.
The Tick and NoneTick macros have been renamed to Function and FunctionArray to make them more obvious.
Each component now has two main macros, functionality such as add/divide etc is now controlled via a property and the icon on the panel changes to suit. This should make it easier to see what's going on just by looking at the DSP chain.
Some components have been split up into new components to help make it more obvious what they do.
Math has been updated to include things like Power, Mod, Sin, Cos, Tan etc.
Lots of new features and functionality.
We want a scheduler component too so this can call the various DSP components in the correct order but this may come later as core exe changes are required for this.
Regards Ben Rowland  MatrixTSL
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Flowcode Product Page  Flowcode Help Wiki  Flowcode Examples  Flowcode Blog  Flowcode Course  My YouTube Channel
Re: DSP Component
Hi Ben.
Wow this looks great
When do you expect to release it I assume it is still not available at this point in time
Many thanks for all these new features wow I am really happy
Wow this looks great
When do you expect to release it I assume it is still not available at this point in time
Many thanks for all these new features wow I am really happy
Re: DSP Component
I agree that looks great. There are several things I want to try with the pic 32.
Looks like I need to get the dsp pac..
Chad
Looks like I need to get the dsp pac..
Chad
Re: DSP Component
Hello!
I need some pointer/help on using DSP, I still do not understand how to use that after reading the post, rather I am getting confused for the moment, can someone help me little bit from the basic if possible, it will help me to understand better, may be I should brief what I am willing to do.
My purpose is to control the output frequency of the VFD (frequency drive) between 30Hz and 50Hz and achieve the set pressure, the DAC of the PIC (05V converted to 010V or 420mA) will be feed to the analog input of the VFD to control the output frequency. Once the set pressure is achieved the output frequency of the VFD will be reduced to 30Hz and eventually to 0Hz after a time delay if pressure do not drop again.
The pressure is sensed using a pressure transmitter (the output of the transmitter could be 420mA or 010V) which will be converted to 05V to feed the analog input of the PIC.
One of my friend who is using a PLC for such application suggested me that I need to use PI to achieve what I am willing to do, I do not understand where to begin.
I am thinking to use a PIC18F46K22, is this the correct chip or I need to order some other.
Kindly excuse if I have posted under a wrong heading.
Thank you.
Regards
Abhi
I need some pointer/help on using DSP, I still do not understand how to use that after reading the post, rather I am getting confused for the moment, can someone help me little bit from the basic if possible, it will help me to understand better, may be I should brief what I am willing to do.
My purpose is to control the output frequency of the VFD (frequency drive) between 30Hz and 50Hz and achieve the set pressure, the DAC of the PIC (05V converted to 010V or 420mA) will be feed to the analog input of the VFD to control the output frequency. Once the set pressure is achieved the output frequency of the VFD will be reduced to 30Hz and eventually to 0Hz after a time delay if pressure do not drop again.
The pressure is sensed using a pressure transmitter (the output of the transmitter could be 420mA or 010V) which will be converted to 05V to feed the analog input of the PIC.
One of my friend who is using a PLC for such application suggested me that I need to use PI to achieve what I am willing to do, I do not understand where to begin.
I am thinking to use a PIC18F46K22, is this the correct chip or I need to order some other.
Kindly excuse if I have posted under a wrong heading.
Thank you.
Regards
Abhi
Re: DSP Component
Hi.
In my humble opinion your friend gave you good advice a PI Controller for a electromechanical drive is a good starting point,
In theory you need to do as shown in the sketch below which is a PI controller normally a person needs to do this by C code in your program however FC makes it easy as all the functions for PPI PID controllers is ready for you in the dsp component ,you just need to feed your Set Value(in your case the pressure you want) and also the feedback signal(in your case the actual pressure.
and of course depending if you use ADC values or Pressure values the appropriate scaling/conversion needs to be done.
You can start a new topic and as you go with your project and have problems you can post your FC chart and we can try to help you
The sketch shows the DSP Component inside the red block
In my humble opinion your friend gave you good advice a PI Controller for a electromechanical drive is a good starting point,
In theory you need to do as shown in the sketch below which is a PI controller normally a person needs to do this by C code in your program however FC makes it easy as all the functions for PPI PID controllers is ready for you in the dsp component ,you just need to feed your Set Value(in your case the pressure you want) and also the feedback signal(in your case the actual pressure.
and of course depending if you use ADC values or Pressure values the appropriate scaling/conversion needs to be done.
You can start a new topic and as you go with your project and have problems you can post your FC chart and we can try to help you
The sketch shows the DSP Component inside the red block
It is a good chip however a dsPIC33 is better if doing a lot of Floating point maths if you use fix point maths it will help with the PIC18 performance wiseI am thinking to use a PIC18F46K22, is this the correct chip or I need to order some other.
Re: DSP Component
Hello! Peter
Many many thanks to write and all the efforts you took to explain, I desperately needed some starting point, humbly thank you again.
I shall start the project and soon revert back with the progress.
Regards
Abhi
Many many thanks to write and all the efforts you took to explain, I desperately needed some starting point, humbly thank you again.
I shall start the project and soon revert back with the progress.
Regards
Abhi
Re: DSP Component
Hi Abhi
You are welcome let us know how you get along
You are welcome let us know how you get along