Process PWM-Signal

Firmware/software/electronics/mechanics
Post Reply
Che.
Member
Posts: 62
Joined: Tue Jul 28, 2015 1:47 pm
Location: Germany

Process PWM-Signal

Post by Che. »

Hi everyone,

does anybody have an approach to process a PWM-Signal from a sensor?

Mine looks like this at the moment:

Create 2 Tasks:

First one to poll the GPIO-Port which is connected to the PWM signal in 10µ-Second steps until end-condition is received, then suspend the task
Second one to wake first task in desired period time

I think getting an interrupt from the GPIO would be much more favorable.

Greets
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Process PWM-Signal

Post by tobias »

Maybe the CPPM driver could give some ideas. It is using an input timer to take time stamps of GPIO transitions and then feeding that to a queue.
Che.
Member
Posts: 62
Joined: Tue Jul 28, 2015 1:47 pm
Location: Germany

Re: Process PWM-Signal

Post by Che. »

Thanks for your reply.

Could you explain to me, how the input timer works?

I've managed to catch an interrupt with the transition on my GPIO-Pin (IO_3 on board), but the system stops working at the moment the IRQ appears.
I think i am lacking of saving the context of FreeRTOS.

Unfortunately I did not completely understand your CPPM-Driver, but it seems, as you are skipping the part i tried to program.

How is it possible, to catch the Flanks directly and start the timers? I also think the timers are depending on which GPIO-Port one is using.
I couldnt figure out, with which timer i need to replace TIM14 in the code when using PB5 as input. Or should i just switch to PA7 (which i assume you use)?

Thanks in advance.


edit: Where can I find the define for NVIC_CPPM_PRI?

edit2: The code works. But i want to count from a falling edge to a rising edge. There are three modes, rising, falling and both. Is it possible in one interrupt to only count the low time of the pwm signal? or do i need two interrupts, one for starting the counter at falling edge and one stopping the counter at rising edge?

and the second problem is, that i get big noise problems. I attached a screenshot. before this measurement i selected falling edge mode.

edit3: selecting both edges on the interrupt capture did the trick. now i get proper distance reading from my sensor. but the peaks are still there. anyone has a clue?
Attachments
peaks_distance.jpg
Post Reply