Pules Calculation

Use this section to discuss your embedded Flowcode projects.
Post Reply
liudeqiang_2008
Posts: 52
http://meble-kuchenne.info.pl
Joined: Wed Jan 12, 2022 8:25 am
Has thanked: 10 times
Been thanked: 1 time

Flowcode v10 Pules Calculation

Post by liudeqiang_2008 »

Hello,

I am design a FC program on stm32F303CB to calculate the speed pules within one second from the motor controller.
I need to keep calculating the pules every second, but other function(EXTI Interrupt, IO, USART...) need to work the same time, and will not be effected by it.

Is it possible to show me a example program about it?
I couldn't find a "pules calculate" component in the FC V10.

Very appreciate for your help.

Thanks.

Br, Deqiang

mnfisher
Valued Contributor
Posts: 1626
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 142 times
Been thanked: 757 times

Re: Pules Calculation

Post by mnfisher »

There are several approaches you can use.

For example:

One is to have two interrupts - one counting pulses on a pin (so the interrupt handler just does pulse_count = pulse_count + 1) and another timer interrupt that (ideally every second) does

pulses_per_second = pulse_count
pulse_count = 0

If the timer interrupt is less/more than 1 second you will need to do some calculation to calculate the pulses/second.

Alternatively you can use the 'input capture' unit interrupt to time individual or multiple pulses and calculate the speed from that. You'll need to use C Code blocks to enable and use this feature however (there are examples on the forum for PIC and AVR MCUs at least - and maybe others).

You can use the input to run a timer (see https://users.fmf.uni-lj.si/ponikvar/ST ... er%202.pdf for example)

There are surely other techniques - the first here is probably simplest?

Martin

medelec35
Matrix Staff
Posts: 2076
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 638 times
Been thanked: 697 times

Re: Pules Calculation

Post by medelec35 »

Hello.
Martin has beat me to it.
But I submit my post as there might be something you can learn from it .
To get you started.
If you click the Component Library tab, then select the Search magnifying glass.
Enter timer, and you will see different timers listed.
Right click on the Timer [2D] and select Help. You can then see a basic example of how to use it.
With Flowcode 10, as all components are free you can ignore Timer Free as that never used to be available to the public, so might not be updated to the latest version.
Martin

liudeqiang_2008
Posts: 52
Joined: Wed Jan 12, 2022 8:25 am
Has thanked: 10 times
Been thanked: 1 time

Re: Pules Calculation

Post by liudeqiang_2008 »

mnfisher wrote:
Tue Aug 05, 2025 4:57 pm
There are several approaches you can use.

For example:

One is to have two interrupts - one counting pulses on a pin (so the interrupt handler just does pulse_count = pulse_count + 1) and another timer interrupt that (ideally every second) does

pulses_per_second = pulse_count
pulse_count = 0

If the timer interrupt is less/more than 1 second you will need to do some calculation to calculate the pulses/second.

Alternatively you can use the 'input capture' unit interrupt to time individual or multiple pulses and calculate the speed from that. You'll need to use C Code blocks to enable and use this feature however (there are examples on the forum for PIC and AVR MCUs at least - and maybe others).

You can use the input to run a timer (see https://users.fmf.uni-lj.si/ponikvar/ST ... er%202.pdf for example)

There are surely other techniques - the first here is probably simplest?

Martin
Dear Martin,

Thank you for patiently explaining, you have shown me the clear direction. I believe I can make it.

Best wishes!

Deqiang

liudeqiang_2008
Posts: 52
Joined: Wed Jan 12, 2022 8:25 am
Has thanked: 10 times
Been thanked: 1 time

Re: Pules Calculation

Post by liudeqiang_2008 »

medelec35 wrote:
Tue Aug 05, 2025 5:10 pm
Hello.
Martin has beat me to it.
But I submit my post as there might be something you can learn from it .
To get you started.
If you click the Component Library tab, then select the Search magnifying glass.
Enter timer, and you will see different timers listed.
Right click on the Timer [2D] and select Help. You can then see a basic example of how to use it.
With Flowcode 10, as all components are free you can ignore Timer Free as that never used to be available to the public, so might not be updated to the latest version.
Hello

Yes you are right, I will look at the examples and have lots of things to learn about FC, it take times.
Thank you for support !

Best wishes!
Deqiang

Post Reply