Page 1 of 1

What is the best solution to design a Timer ?

Posted: Thu Feb 27, 2025 1:41 pm
by Nico595
Hello,

I progress good with PC App, I use function per button to drive my device, exactly like with a programmable remote control software. Work fine but I want also add function with event timer in background of the software. I tried 3 methods and the result is very strange. I use a button to start the timer with debug window to see the values of counters in real time.

The first method use a 500ms delay with a counter. With this counter I designed two timer: per 1 second and per 10 seconds.
Work fine but this timer is stopped when I push on a other button. It's the best method I find, the timer is stopped but the button function work fine and the timer restart after the button code is sent.

The second method use interrupt per 0.5Hz. Interrupt have not priority level parameter and is stopped when I push on a other button and create bug.

The third method use Trigger component with 1 second. When I push button the trigger event macro stop the function of the other buttons and create bug.

When I push button, I also need a long touch function, if it's possible without stop the timer in background.

Have you advice ?
Thank you so much.

Re: What is the best solution to design a Timer ?

Posted: Thu Feb 27, 2025 3:49 pm
by Nico595
I maybe find a very good method with anti-bounce timing in the timer. So the first method is very good if the anti-bounce is integrated and synchronised with the main timer. I will check with button with more long time process.

I use also FATScadaFile Component. I hope this method work fine with the fill_up_back_up_buffer macro.

Interrupt level priority is welcome.

Re: What is the best solution to design a Timer ?

Posted: Thu Feb 27, 2025 4:15 pm
by medelec35
Hello.
We can't instigate as you have not posted a project that has the issue.

If you post your project, we will investigate further.

Re: What is the best solution to design a Timer ?

Posted: Thu Feb 27, 2025 4:47 pm
by Nico595
Hi Martin,

Thank you for your answer.

I will share file project of the main timer with delay. It's a very good solution to respect the timing in background and a function running by a other button.

However, without the device you can't test this solution in real condition. When you push on some button you have this process: send value - receive value of the device - answer ok to end the transmit process.

But this solution can be used by other FC10 user.

Now, I will found a solution to use the FATScadaFile component with timer in the background.
I must also found a method to obtain repeat increment when I have a long time push button.
I tried "getvalue" from the button in the main macro of FC10. Work fine but no priority. Interrupt without priority level is a problem to design a complex PC App project.

Re: What is the best solution to design a Timer ?

Posted: Thu Feb 27, 2025 8:10 pm
by medelec35
Matrix staff advice for using timed interrupts within PC Developer or embedded is to use the Timed event trigger component as that is easy to set up and works great for both embedded and PC developer.
To find it, you can select the Components Libraries ribbon, search magnifying glass and enter timed event
Timed Event Component.png
Timed Event Component.png (17.07 KiB) Viewed 3900 times

Re: What is the best solution to design a Timer ?

Posted: Thu Feb 27, 2025 8:42 pm
by Nico595
Thank Martin

I tried this method, it's the third method with 1 second. But with this method the trigger event macro stop the process of my button macros when I push a new transmit / receive data button. I saw your example with graph and slider in the Flowcode Wiki. The Flowcode Wiki is great and perfect to start with the FC10.

I will check again with this component even if the minimum time with the trigger is 1 second, I need 500ms.
I will send you soon this 3 projects with this 3 methods.


Thank you.