Timer Reading Value?

For general Flowcode discussion that does not belong in the other sections.
Post Reply
seokgi
Posts: 217
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 1:43 pm
Has thanked: 6 times
Been thanked: 7 times

Timer Reading Value?

Post by seokgi »

Good morning.
I use the PIC18F47Q10.
I would like to use a 16 bit timer in my program.
So I use Timer5.
It reads the values in milliseconds or Second comes a different value.

If there is an example, can I see it?

Thank you.

BenR
Matrix Staff
Posts: 1952
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 510 times
Been thanked: 698 times

Re: Timer Reading Value?

Post by BenR »

Hello,

I've added an example here for you which should show the basics of the timer component.

https://www.flowcode.co.uk/wiki/index.p ... )#Examples

seokgi
Posts: 217
Joined: Thu Dec 03, 2020 1:43 pm
Has thanked: 6 times
Been thanked: 7 times

Re: Timer Reading Value?

Post by seokgi »

Thank you for the example program.
After the timer stops, the value is read.
I want to read the value before the timer stops and use that value to stop the timer and use the read value. is it possible? Or is there a way to use that value after a certain amount of time has passed?
For example, a 500ms timer and a 1 second timer.

please answer me.
Thank you.

alanwms
Posts: 145
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 7 times

Re: Timer Reading Value?

Post by alanwms »

Possibly use an interrupt for the timer, and increment a variable inside the interrupt. Then outside of the interrupt, simply test the variable for the value you are wishing to stop at.

seokgi
Posts: 217
Joined: Thu Dec 03, 2020 1:43 pm
Has thanked: 6 times
Been thanked: 7 times

Re: Timer Reading Value?

Post by seokgi »

Thank you for answer.
But I don't understand it very well.
Sorry, but could you post a simple example.

Thank you.

alanwms
Posts: 145
Joined: Fri Dec 04, 2020 2:29 pm
Has thanked: 26 times
Been thanked: 7 times

Re: Timer Reading Value?

Post by alanwms »

Just insert an interrupt icon into the beginning of the program. The timer you use will dictate how often the interrupt happens.

When the interrupt happens, the macro (of your choice) will be run. In that macro, you simply add +1 to a variable That's it.

That accomplishes nothing except incrementing a variable - But in your regular program, you can now test the variable for compliance with your requirements.

The timer speed will be set when you insert the interrupt. That number will dictate how many times per minute that the interrupt will run.

Simply calculate how many times it will run to determine your variable test number for one second or millisecond.

Post Reply