DSP Component

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

DSP Component

Post by QMESAR »

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 :D
Attachments
PIC16F1938-eWG.rar
(183.91 KiB) Downloaded 67 times

User avatar
Benj
Matrix Staff
Posts: 14848
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: DSP Component

Post by Benj »

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

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: DSP Component

Post by QMESAR »

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 :D

Thank again

User avatar
Benj
Matrix Staff
Posts: 14848
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: DSP Component

Post by Benj »

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 :D

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: DSP Component

Post by QMESAR »

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 :D

you are much smarter than me thanks for the link I will try to understand your method
Thanks Ben

User avatar
Benj
Matrix Staff
Posts: 14848
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: DSP Component

Post by Benj »

Hi Peter,
I am not feeling the math is wrong
I'm hoping the maths is right but I'm certainly open to the possibility that it's not. :D

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?

User avatar
Benj
Matrix Staff
Posts: 14848
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: DSP Component

Post by Benj »

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.
PID Coursework.XLS
(44.5 KiB) Downloaded 86 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: DSP Component

Post by QMESAR »

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 .
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
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 this
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.
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 solution-Please rethink to leave the signed numbers.
We are using an integer based system for speed and efficiency
This make a lot of sense specially on PIC16 and 18 :D
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.
This will be nice I like that really
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.
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 too
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

User avatar
Benj
Matrix Staff
Posts: 14848
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: DSP Component

Post by Benj »

Hi Peter,
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 solution-Please rethink to leave the signed numbers.
My current plan is to keep the signed 16-bit type but remove the signed 8-bit type as there is no way currently in Flowcode to nicely generate this data.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: DSP Component

Post by QMESAR »

Hi Ben,

I agree signed 8 bit can go :D the range is too small for any decent control

Have nice time

User avatar
Benj
Matrix Staff
Posts: 14848
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: DSP Component

Post by Benj »

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.
Control.jpg
Control.jpg (7.07 KiB) Viewed 2639 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: DSP Component

Post by QMESAR »

Hi Ben.
DSP Control component
Yes this is the component I am using each and every time.
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.
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 OEM

Thanks so much for looking into all these nice things

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: DSP Component

Post by QMESAR »

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 :D however as discussed above when we are using I values of less than 1.0 :D
looking forward to the new modifications.

Have good one

User avatar
Benj
Matrix Staff
Posts: 14848
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: DSP Component

Post by Benj »

Hi Peter,

That sounds very interesting and like a very good project. Any chance of some photos we can use for marketing purposes? :D

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: DSP Component

Post by QMESAR »

HI Ben,
I will ask the Project Manager and let you know :D

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: DSP Component

Post by QMESAR »

Hi Ben

Just checking any news regarding the planned changes to the DSP Component ? Just curious :D

User avatar
Benj
Matrix Staff
Posts: 14848
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Re: DSP Component

Post by Benj »

Hi Peter,

Here is the current list of new DSP components.
DSP.jpg
DSP.jpg (37.99 KiB) Viewed 2204 times
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.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: DSP Component

Post by QMESAR »

Hi Ben.

Wow this looks great :D
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

chad
Posts: 154
Joined: Sun Nov 04, 2018 7:13 pm
Contact:

Re: DSP Component

Post by chad »

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

User avatar
AbhijitR
Posts: 134
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Contact:

Re: DSP Component

Post by AbhijitR »

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 (0-5V converted to 0-10V or 4-20mA) 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 4-20mA or 0-10V) which will be converted to 0-5V 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

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: DSP Component

Post by QMESAR »

Hi.
In my humble opinion your friend gave you good advice a PI Controller for a electro-mechanical 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 P-PI -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
SCG-1.JPG
SCG-1.JPG (22.88 KiB) Viewed 1153 times
The sketch shows the DSP Component inside the red block
SCH2.JPG
SCH2.JPG (33.49 KiB) Viewed 1153 times
I am thinking to use a PIC18F46K22, is this the correct chip or I need to order some other.
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 wise

User avatar
AbhijitR
Posts: 134
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Contact:

Re: DSP Component

Post by AbhijitR »

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

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Contact:

Re: DSP Component

Post by QMESAR »

Hi Abhi

You are welcome let us know how you get along :D

Post Reply