DSP component PI, PID issues

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

Moderator: Benj

Post Reply
User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

DSP component PI, PID issues

Post by STibor »

Hi!

I guess the experiment Flowvcode V6 PID Help / Example program.
It works well.
How to change this program, the P, I and D floating-point variables?
How do I assign a variable?

http://www.matrixtsl.com/wiki/index.php ... _component

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

Re: DSP component PI, PID issues

Post by Benj »

Hello,

Currently the PI and D values are fixed via the property settings and cannot be altered during runtime. We might be able to add in an option to allow for changes on the fly so I will look into this for you and see how easy it would be.

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

Re: DSP component PI, PID issues

Post by STibor »

Hi!
Thank you!

It would be very nice if you could use the external variable.
Now I make a motor controller, and so the development is very slow.

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

Re: DSP component PI, PID issues

Post by Benj »

Hello,

Right I've had a bit of a go at allowing the PID parameters to be controlled on the fly during program execution.

I've not tested it but I think sim and download should both work ok with the new ChangePID macro.
DSPControl.fcpx
(22.86 KiB) Downloaded 252 times
Let me know how you get on.

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

Re: DSP component PI, PID issues

Post by STibor »

Thanks for your help!

Unfortunately we could not compile the program.

Added to the error message and the program.
Attachments
PI_Control_default.fcfx
(18.31 KiB) Downloaded 233 times
PID.jpg
PID.jpg (59.05 KiB) Viewed 7869 times

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

Re: DSP component PI, PID issues

Post by Benj »

Hello,

Thanks for letting me know. I think I have now fixed the bug causing the compilation error.
DSPControl.fcpx
(22.86 KiB) Downloaded 254 times
Let me know how you get on.

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

Re: DSP component PI, PID issues

Post by STibor »

Hi!

Thank you, it works.

I found some interesting problems in this project.
Main Programme float variable
-define as
-modify value
-converted to use a string variable

ADC voltage reading on the float variable
or
-Float converters use a string variable
-byte integer variable or string literals be converted
Stack overflow occurs.
The microcontroller reset constantly.

If timer interrupts do the above programs are good.
Why do you point the main program stack overflow?

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

Re: DSP component PI, PID issues

Post by Benj »

Hello,

Are you getting any warnings when you compile your project? Also can you post the project so we can have a look and suggest different ways to proceed?

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

Re: DSP component PI, PID issues

Post by STibor »

Hello!

I get an error message.
Added to the modified example program.
Attachments
PID_Control_x.fcfx
(18.62 KiB) Downloaded 213 times
PID_WARNING.jpg
PID_WARNING.jpg (145.13 KiB) Viewed 7803 times

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

Re: DSP component PI, PID issues

Post by Benj »

Hello,

As you are compiling using an 8-bit PIC this uses the BoostC compiler which has issues surrounding float variables. They are handled using functions rather than natively via the language and so cannot be re-entered in the main and again via an interrupt.

To get around the problem can you move the GetVoltage and FloatToString function into the interrupt.

Or you could move all the interrupt code into main and use the trigger functionality to control the calling of the DSP chain.

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

Re: DSP component PI, PID issues

Post by STibor »

Hello!

I want to use PID control example.

I looked at the simulator, but not control.
Only 50% duty square wave is the PWM output.
8bit controller 18F452 temperature control would be a problem.
Even the Simulator Flowcode not change the duty.
If the adc adc feedback or setpoint change, the need to change the PWM duty cycle as well.
This does not happen.
It is also possible to use the timer tick timer macros without interruption?

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

Re: DSP component PI, PID issues

Post by Benj »

Hello,

Can you post your program so we can try and see the issue.
It is also possible to use the timer tick timer macros without interruption?
Yes this is possible, no interrupt is strictly required. The tick macros process one value in the buffers, the none tick functions will loop through and will process all values in the buffers in one operation.

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

Re: DSP component PI, PID issues

Post by STibor »

Hello!

This sample program can be downloaded from the DSP.
Interruption is due to stack overflow.
Serious Warning: Possible sw stack corruption, function 'FC_CAL_ADC_Disable' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'FC_CAL_ADC_Enable' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'FC_CAL_ADC_Sample' called by more than one asynchronous thread (main/Task, interrupt, interrupt low)
Attachments
pid_ex_default.fcfx
(16.41 KiB) Downloaded 149 times

User avatar
STibor
Posts: 263
Joined: Fri Dec 16, 2011 3:20 pm
Has thanked: 116 times
Been thanked: 113 times
Contact:

Re: DSP component PI, PID issues

Post by STibor »

Hi

The help menu DSP example is not the same as the download site matrixtsl DSP examples.
Inserts the Help menu adapted modified for example program.
Will be so good?
Attachments
PID_Control_help_example.fcfx
(17.27 KiB) Downloaded 164 times

Post Reply