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
Pules Calculation
-
- Posts: 52
- http://meble-kuchenne.info.pl
- Joined: Wed Jan 12, 2022 8:25 am
- Has thanked: 10 times
- Been thanked: 1 time
-
- Valued Contributor
- Posts: 1626
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 142 times
- Been thanked: 757 times
Re: Pules Calculation
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
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
-
- Matrix Staff
- Posts: 2076
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 638 times
- Been thanked: 697 times
Re: Pules Calculation
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 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
-
- Posts: 52
- Joined: Wed Jan 12, 2022 8:25 am
- Has thanked: 10 times
- Been thanked: 1 time
Re: Pules Calculation
Dear Martin,mnfisher wrote: ↑Tue Aug 05, 2025 4:57 pmThere 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
Thank you for patiently explaining, you have shown me the clear direction. I believe I can make it.
Best wishes!
Deqiang
-
- Posts: 52
- Joined: Wed Jan 12, 2022 8:25 am
- Has thanked: 10 times
- Been thanked: 1 time
Re: Pules Calculation
Hellomedelec35 wrote: ↑Tue Aug 05, 2025 5:10 pmHello.
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.
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