cancel
Showing results for 
Search instead for 
Did you mean: 

Handling an input signal within 1 ms

mids400
Associate III

Hello,

I have to measure the pulse width and the period of Fiber-Optical Signal with STM32F469 Discovery board and view the values on the display using TouchGFX Design.

I have no problem to blocking the display for a while (max. 2s) to read a pulse width that maybe between (1us - 1000us) and the period (10 - 100ms) but i should also ignore some pulses (for data transfer) which they comming within 10ms..

I am using Input capture mode on the input pin and thought to call HAL_GetTick which returns microseconds value of InitTick to be able to ignoring some pulses and to make a global timer then i know where i am but i think all the interrupts will be suspended when the IC called even that for GetTick!

Hier is the signal that i should handle.

signal.png

I have wrote my code in Model part of TouchGFX thats way i could after that pushing the values directly to View.

It is very critical and i don't know if it will work by the way. I need to get some ideas also .

Thanks

8 REPLIES 8

Perhaps have a TIM running in a maximal count mode, time stamp edges on TIM_CHx pins with CCRx registers

Perhaps use EXTI and read micro-second, or sub-millisecond count from TIM CNT

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

Hi,

With the values you specified, i think, its impossible.

To capture pulses with a timer is not so difficult, thats not the big problem, but to "sync" to the unknown signal, seem impossible : the puls-pause can be 10..100ms , but the "ignore time" is also 10ms , and next pulse can be 0,001ms - so i see no way, to find a good "sync" to differentiate "main sync" puls and any pulses that can be there.

So there should be a clear window: first pulse raising to last possible "any pulse" is 11ms , then a gap of minimum 4ms without any pulse ; so it should be possible, to get this "minimum 4 ms no pulse" gap, to find reliable the next "main sync pulse".

If you feel a post has answered your question, please click "Accept as Solution".
MM..1
Chief II

Your image show two amplitude signal ... idea detect it as logical signal is ...

Why you dont use ADC +TIM + DMA perfectly hw mode scope ???

@Tesla DeLorean  You mean to calculate the time in us or ms from the counter register of the specific TIMx using EXTI option? And that option not possible with IC mode?

@AScha.3 I thougt firstly to enter in capture mode or enable the timer only when i click a button on the display and then should i wait 11ms after the first pulse in this case i will be absoloutly in the right point to get the next correct pulse cause (the pulse is 1ms of period maybe 10 or 20.. 100ms and what i need to ignore ist only 10ms then 10ms + 1ms = 11ms) and the problem is how i can excute this delay within the interrupt that it seems impossible.

@MM..1  Why should i use ADC? what is the feature of using DMA here?

Thanks

 

How many pulses can be in the "packet" and what the puls/pause here ?

Because my idea is: let the timer capture every puls/pause , easy to add them (until > 10ms sum) and get the full time until the next "sync" pulse .

This way i receive the IR-remote pulse sequence, the time in INT with some simple math is about 1,3 us (at 200MHz cpu clock), so way fast enough for your signal also. 

If you feel a post has answered your question, please click "Accept as Solution".

@AScha.3 I have seen the signal on the oscilloscope and it seems infinity pulses (like the photo above) ..

First pulse is (1us.. 1ms that muss be catching and displayed after that comes some noisy pulses for max. 10ms that should be ignored and after that comes the second real pulse regulary with the same procedure, the period of the signal is 10ms ... 100ms.

I suppose your idea would be very helpful, but still needs more explain.

One could use IC (Input Capture) from a TIMx_CCRx into a time stamp buffer managed by DMA. Could perhaps cultivate that list in the 1ms (1KHz) SysTick (could be faster)

With EXTI you'd have to time stamp Interrupt arrival via some time base counter, at a resolution you determine.

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

Simply you create buffer for 1sec scoped signal . ADC DMA record it ofloaded MCU (you can do in code other thing)

DMA complete interrupt start your signal analyse  , any filtering etc... With double buffer mode your signal can be monitored continuos...

But for ! between (1us-  ! you require high ADC sampling rate max 0,5us = 2MHz. With this 1sec buffer is little big.

Here is better short time (120ms) based on your data, and trigered ADC start...

Ofcourse if your pulses is clean and logic level based you can use timer capture plus DMA etc.

But right way is do this all outside TouchGFX thread and send results to GUI over shared memory or RTOS messages.