Timer Counter in Sim

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

Moderator: Benj

Post Reply
alanwms
Posts: 67
Joined: Tue Sep 16, 2008 2:09 pm
Location: Minnesota USA
Has thanked: 4 times
Been thanked: 17 times
Contact:

Timer Counter in Sim

Post by alanwms »

Hello Ben - Just doing a simple test to understand the timer capabilities, and can't get the Ulong_timer variable to update. It's always at zero- am I missing something?
I did try enabling the timer interrupt to no avail.
Attachments
Timer.jpg
Timer.jpg (21.43 KiB) Viewed 5600 times

chipfryer27
Valued Contributor
Valued Contributor
Posts: 617
Joined: Fri Jun 06, 2014 3:53 pm
Has thanked: 184 times
Been thanked: 195 times
Contact:

Re: Timer Counter in Sim

Post by chipfryer27 »

Hi

Have you had a look here?

https://www.matrixtsl.com/wiki/index.ph ... Properties

Each properties box in FC has a little help icon in bottom left that leads to their wiki which is usually very helpful.

The timer interrupt will generate an interrupt at whatever frequency you have set (say for example 2000Hz). So 2000 times a second it will automatically call whatever Macro you have set in the properties box of the Enable Interrupt icon. You do not need any further call to such.

In the "Interrupt Macro" that you create and call via the Interrup, have a calculation box that increments your variable (e.g. count = count + 1), then in your main program you could have a decision / action based on count, perhaps zeroing count after action completes e.g. :-

if count >= 2000 then "xyz"
count = 0

would call / do "xyz" every second.

Hope this helps.

Regards

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: Timer Counter in Sim

Post by medelec35 »

I would never recommend screen captures.
We can't get the full picture from them.
can you post flowchart please.
Martin

alanwms
Posts: 67
Joined: Tue Sep 16, 2008 2:09 pm
Location: Minnesota USA
Has thanked: 4 times
Been thanked: 17 times
Contact:

Re: Timer Counter in Sim

Post by alanwms »

Thanks - I do understand interrupts. What I am attempting to do is count hardware pulses into the timer. I'm not sure how to do that in sim. I have:
1. Attempted to setup the timer 0 interrupt with a transition on T0CK1 pin and connect a simulator switch to that pin. Regardless, the interrupt happens in sim no matter the clock source select setting.
2. The interrupt properties dialog box indicates a clock speed and interrupt frequency even after I select a hardware input transition (Interrupt frequency is hardware dependent of course). That issue is a Flowcode issue and I understand that it has no bearing on the frequency if interruption

I guess my question is - Can I simulate a counter counting with a simulated hardware switch?

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: Timer Counter in Sim

Post by medelec35 »

Hi alanwms,
Timer 0 will not simulate external input using T0CKI
Also Timer 1 will not simulate external input using T1CKI
Simulation only, whether T0CKI, T1CKI or internal is selected, Flowcode will treat the interrupt as internal and will continue to count.
Should work OK on hardware.
Timer component (within data menu) simulates for me OK.
If you want to see the value changing, then you will need to slow the simulation down.
50Hz should be fine.
Martin

alanwms
Posts: 67
Joined: Tue Sep 16, 2008 2:09 pm
Location: Minnesota USA
Has thanked: 4 times
Been thanked: 17 times
Contact:

Re: Timer Counter in Sim

Post by alanwms »

Thanks - That helps a lot.

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: Timer Counter in Sim

Post by medelec35 »

You're welcome.
Thanks for letting us know.
Martin

Post Reply