PDA

View Full Version : defining max pulsin time with duty cycle 100%



hkpatrice
- 5th April 2010, 10:27
Hello,

I have a problem with pulse width measurements. I am trying to measure pulse widths from a signal that has a duty cycle from 0%-100%. The problem I am facing is that the define pulsin max does not behave the way I had anticipated. For instance, the signal I am measuring has a period of about 9 ms. So, I was expecting that defining pulsin max at 900 would return a variable value of 900 when duty cycle was 100% (always high). However, the variable gets set at "0" instead.

My boards are already made and the pwm signal is already assigned to portc.2, so I cannot use the CCP module, or the interupts on change from portB.

Any suggestions for measuring this signal?

Or, Is there a way to modify the Pic basic command so that a 100% duty cycle would return the defined pulsin max value, instead of 0?

Thanks!

Acetronics2
- 5th April 2010, 10:58
Hi, Patrice

The problem is Pulsin needs a leading and a falling edge to work ... so 0 and 100 % do not trigger it ...

the way is test your input as soon as pulsin sends a zero ... ( after timeout, tho )

suppose pulse High :




Pulsin Portpin, 1 , result

IF result = 0 THEN
IF PortPin THEN
LCDOUT $FE,2 " Pulse > 900 "
ELSE
LCDOUT $FE,2 " No Pulse "
ENDIF
ENDIF



no need to tweak the Pulsin Command ... just use logics !

Alain