Anybody knows how to write a code for PIC microcontroller that can read/capture pwm signal and give output according to the pwm ?
The pwm signal is coming from a sensor. I want to program the PIC microcontroller to read this pwm signal and will give the output to other circuitry based on the pwm signal.
In order to do that you must use a timer\counter module in the microcontroller
measure the Ton and the Toff
Set a timer to inc every 5 Usec and trigger it from the signal raise edge and shut it down when the signal fall - look at the register of the counter and you have your time priod measurement.
If you can switch to MSP430 Ti supply a code in assembly & C language
Yes You can use microcntroller in capturing PWM signals trough a sensors.
You can just use a built in timer or a pre program code and compare it to a signal occuring in the input
or to suggest you better use a PSoC Cypress Basic Stamp USB dongle.
"
amplifiers, ADCs, DACs, filters and comparators and digital functions such as timers, counters, PWMs, SPI and UARTs. "
so what are you waiting for..PSoC CY8C27xxx device
You can better measure a PWM signal with capture/compare feature of a Timer.
For this
1. The signal is to be connected to a pin (associated with a timer) which can generate a capture interrupt.
2. Enable capture on both edges (raising, falling)
3. With this you can easily measure OnTime and OffTimeof PWM.
at this moment I'm looking at PIC microcontroller solutions since the projects involve several other modules that use this microcontroller. I'll try the other options after the PIC.