Test & Debug - Code profiling

Please add any feature requests for Flowcode version 7 here

Moderator: Benj

Post Reply
johnsondav
Posts: 188
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Has thanked: 86 times
Been thanked: 186 times
Contact:

Test & Debug - Code profiling

Post by johnsondav »

Hi Guys

I am trying to go through the final stages of testing a PID controller using the Code profiling feature. However, the program relies upon an interrupt every 10ms for correct program execution. During simulation it hags at the interrupt input. Is there a way of simulating an interrupt? I have tried putting a switch to act an input, but this would require a component marco for switch input which I do not want. Any help/suggestion would be appreciated. If not, would this idea qualify for a future addition to debugging?

The actual controller appears to be working as expected using the interrupt.

Best regards
Dave

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Test & Debug - Code profiling

Post by medelec35 »

Hi Dave,
One way around this without adding any extra components is by adding a test variable with the initial value being 0.
Then add a branch to call the interrupt macro which branches only when the test variable is say 100.
You can setup key mapping so when you press a key of your choice, it assigns the test variable with 100.
Therefore after pressing the key of your choice the branch calling interrupt macro will alway be true.
However when run on hardware the interrupt macro will only ever be accessed when interrupt has been triggered.

If you get stuck trying that, if you post flwochart I will set it up for you.

Martin
Martin

johnsondav
Posts: 188
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Has thanked: 86 times
Been thanked: 186 times
Contact:

Re: Test & Debug - Code profiling

Post by johnsondav »

Hi Martin

Thanks ever so much for your help. Yes, it work brilliantly. Couldn't get my head around what I was supposed to do but this is what I ended up doing to get it to work:
Key Mappings FC7
Key Mappings FC7
KeyMappings.jpg (47.02 KiB) Viewed 7255 times
However, I still needed to do what you had suggested to get it to recognise the port interrupt by 'Reading' to port via a switch added to the panel and setting up a macro to Read it's state. Work like a charm.
Macro added
Macro added
Interupt Read State added.jpg (38.13 KiB) Viewed 7255 times
I am now able to fully 'Debug' using simulation.

Regards
Dave

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Test & Debug - Code profiling

Post by medelec35 »

Hi Dave,
Your welcome.
I have created an example for you.
Not sure if it's entirely what you're after?
There is a switch connected to activate port B IOC.
If you run the flowchart simulation then:
Click on the switch to trigger port IOC so LCD increases on each switch press and release.
Or
Make sure you click anywhere on the flowchart then press g to keep triggering port B IOC ISR
Press s to stop triggering port B IOC ISR, so relying on the switch again.

If compiled to hardware then decision branch and call IOCB macro should be ignored and just allow the switch to work as normal:
Key Mapping1.png
(56.32 KiB) Downloaded 4824 times

Martin
Attachments
Key Mapped Simulation .fcfx
(8.17 KiB) Downloaded 297 times
Martin

johnsondav
Posts: 188
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Has thanked: 86 times
Been thanked: 186 times
Contact:

Re: Test & Debug - Code profiling

Post by johnsondav »

Hi Martin

That's is cleaver, I would never have thought about doing it that way, but yes, you're right. I can now implement the trigger to run continuously without me constantly pressing the keyboard. This will allow me to concentrate upon the part of the code I am investigating for any errors/bugs.

Thank you ever so much.

Regards
Dave

johnsondav
Posts: 188
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Has thanked: 86 times
Been thanked: 186 times
Contact:

Re: Test & Debug - Code profiling

Post by johnsondav »

Hi Martin

That works great. I am making good progress now with the de-bugging. I really do like the Profiling feature with the percentage use label. I can see if the features such as fuzzy logic is working as expected.

Brilliant.

Regards
Dave

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Test & Debug - Code profiling

Post by medelec35 »

Hi Dave,
glad its working out well for you.
Thanks for keeping us updated. :)

Martin
Martin

johnsondav
Posts: 188
Joined: Thu Jun 28, 2012 7:29 pm
Location: Durham
Has thanked: 86 times
Been thanked: 186 times
Contact:

Re: Test & Debug - Code profiling

Post by johnsondav »

Hi Martin

Core Profiling works extremely well, I have found a bit of redundant code using 'Code profiling' feature. The percentage output control logic for the TRIAC controller, using the fuzzy logic to check percentage output for each state is never triggered at this point. Why this is happening, well I am now able to investigate my train of thought before testing in the field. this branch of code would probably have never shown up without the profiling feature.
Code profile Redundant Code.jpg
(131.04 KiB) Downloaded 1210 times
I really do like this even more every time I use it.


Happy Chap am I! :D

Post Reply