cancel
Showing results for 
Search instead for 
Did you mean: 

3MHZ pulse counter with trigger output

Anas Nashawaty
Associate II
Posted on June 23, 2018 at 13:27

Hi, i'm totaly new to stm32 actually i have been looking for a solution to test some motion control output the case is:

i need to measure number of pulse that motion give it at speed of around 3mhz and when the number is equal to the set value that set to the stm32f4 it give a pulse out as a trigger without any latency , i don't have any board yet but i think 'discovery' stm32f4 could handle it, if there is any body have tried such idea or have any segregation or example code could help a lot thank you for reading my Post.

Anas

5 REPLIES 5
henry.dick
Senior II
Posted on June 24, 2018 at 21:30

easy:

1) set up a timer to count up an external input;

2) load up the timer value to -desired pulses;

3) set up interrupt on overflow;

4) in the isr, do things you want.

it can be done with a downcounter, or output compare as well.

Posted on June 24, 2018 at 22:29

thank you

henry.****

for your fast response,

could you please advice witch board could be powerful and good for starting? and please some sample code if possible for the case?, is it possible to use another input signal to save the count in so realtime without any latency, i mean save the count when exactly the input signal is acquire like ISR or so?

thank you again.

Anas

Posted on June 24, 2018 at 23:13

The use of '3 MHz' and  'without any latency' gets complicated.

You could have a TIM in external count mode and toggle another channel using the hardware. ie IF TIM2->CNT == TIM2->CCR1 THEN TIM2_CH1 ^= 1;

If you start involving interrupts you're going to hit a ceiling at a few hundred KHz

You might want to consider if your task lends itself to the use of a CPLD or FPGA, where you control the timing and the latency, and can support MHz repetition.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on June 26, 2018 at 08:09

thank you

Turvey.Clive.002

, the application is to count a control pulse for motor pulse command and the pulse is about 3MHz, so when the sensor read the mark we need a pulse registration when a mark

acquire

, is it possible for STM32 in such real time? or i should go to cpld/fpga as you mention? if that not possible with STM32 is there a suggestion board for cpld/fpga development board?.

Posted on June 26, 2018 at 14:08

I don't work with motors, and don't see any timing diagram suggesting phase/timing requirements of the pulse placement, or expected repetition rate. If the design can't handle any latency it suggests you need to use synchronous logic to keep things within +/-33ns, or whatever 'without any latency' means in this context.

Suggest you get a NUCLEO board and test a proof-of-concept, supplying the timers with equivalent signals expected from the motor.

You should discuss design choices with colleagues and supervisors.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..