DSP Component

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

Moderator: Benj

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1161
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 573 times
Contact:

DSP Component

Postby QMESAR » Fri Sep 27, 2019 11:44 am

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.92 KiB) Downloaded 22 times

User avatar
Benj
Matrix Staff
Posts: 14374
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4448 times
Been thanked: 4151 times
Contact:

Re: DSP Component

Postby Benj » Fri Sep 27, 2019 5:07 pm

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: 1161
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 573 times
Contact:

Re: DSP Component

Postby QMESAR » Fri Sep 27, 2019 5:12 pm

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: 14374
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4448 times
Been thanked: 4151 times
Contact:

Re: DSP Component

Postby Benj » Fri Sep 27, 2019 5:21 pm

Hi Peter,

The maths for the PID is available here.
https://www.matrixtsl.com/wiki/index.php?title=Component:_Control_(DSP)#Proportional.2C_Integral_.26_Derivative_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
These users thanked the author Benj for the post:
QMESAR (Fri Sep 27, 2019 5:26 pm)
Rating: 5.26%
 

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1161
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 573 times
Contact:

Re: DSP Component

Postby QMESAR » Fri Sep 27, 2019 5:24 pm

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
These users thanked the author QMESAR for the post:
Benj (Fri Sep 27, 2019 8:35 pm)
Rating: 5.26%
 

User avatar
Benj
Matrix Staff
Posts: 14374
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4448 times
Been thanked: 4151 times
Contact:

Re: DSP Component

Postby Benj » Fri Sep 27, 2019 8:34 pm

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?
These users thanked the author Benj for the post:
QMESAR (Sat Sep 28, 2019 5:26 am)
Rating: 5.26%
 

User avatar
Benj
Matrix Staff
Posts: 14374
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4448 times
Been thanked: 4151 times
Contact:

Re: DSP Component

Postby Benj » Fri Sep 27, 2019 8:43 pm

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 39 times
These users thanked the author Benj for the post (total 2):
QMESAR (Sat Sep 28, 2019 5:26 am) • AbhijitR (Sat Sep 28, 2019 6:58 am)
Rating: 10.53%
 

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1161
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 573 times
Contact:

Re: DSP Component

Postby QMESAR » Sat Sep 28, 2019 4:57 am

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
These users thanked the author QMESAR for the post:
Benj (Mon Sep 30, 2019 10:02 am)
Rating: 5.26%
 

User avatar
Benj
Matrix Staff
Posts: 14374
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4448 times
Been thanked: 4151 times
Contact:

Re: DSP Component

Postby Benj » Mon Sep 30, 2019 10:03 am

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.
These users thanked the author Benj for the post:
QMESAR (Mon Sep 30, 2019 12:39 pm)
Rating: 5.26%
 

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1161
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 573 times
Contact:

Re: DSP Component

Postby QMESAR » Mon Sep 30, 2019 12:38 pm

Hi Ben,

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

Have nice time
These users thanked the author QMESAR for the post:
Benj (Tue Oct 01, 2019 2:00 pm)
Rating: 5.26%
 

User avatar
Benj
Matrix Staff
Posts: 14374
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4448 times
Been thanked: 4151 times
Contact:

Re: DSP Component

Postby Benj » Fri Oct 04, 2019 3:35 pm

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 1064 times
These users thanked the author Benj for the post:
QMESAR (Sat Oct 05, 2019 6:41 pm)
Rating: 5.26%
 

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1161
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 573 times
Contact:

Re: DSP Component

Postby QMESAR » Sat Oct 05, 2019 6:40 pm

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: 1161
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 573 times
Contact:

Re: DSP Component

Postby QMESAR » Wed Oct 09, 2019 6:42 am

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
These users thanked the author QMESAR for the post:
Benj (Wed Oct 09, 2019 10:36 am)
Rating: 5.26%
 

User avatar
Benj
Matrix Staff
Posts: 14374
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4448 times
Been thanked: 4151 times
Contact:

Re: DSP Component

Postby Benj » Wed Oct 09, 2019 10:37 am

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: 1161
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 573 times
Contact:

Re: DSP Component

Postby QMESAR » Wed Oct 09, 2019 1:42 pm

HI Ben,
I will ask the Project Manager and let you know :D
These users thanked the author QMESAR for the post:
Benj (Wed Oct 09, 2019 4:50 pm)
Rating: 5.26%
 

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1161
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 573 times
Contact:

Re: DSP Component

Postby QMESAR » Mon Oct 28, 2019 5:32 pm

Hi Ben

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

User avatar
Benj
Matrix Staff
Posts: 14374
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4448 times
Been thanked: 4151 times
Contact:

Re: DSP Component

Postby Benj » Mon Oct 28, 2019 6:13 pm

Hi Peter,

Here is the current list of new DSP components.

DSP.jpg
DSP.jpg (37.99 KiB) Viewed 629 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: 1161
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 357 times
Been thanked: 573 times
Contact:

Re: DSP Component

Postby QMESAR » Mon Oct 28, 2019 6:31 pm

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: 147
Joined: Sun Nov 04, 2018 7:13 pm
Has thanked: 26 times
Been thanked: 31 times
Contact:

Re: DSP Component

Postby chad » Mon Oct 28, 2019 9:20 pm

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
These users thanked the author chad for the post:
QMESAR (Tue Oct 29, 2019 1:27 pm)
Rating: 5.26%