cc1984
- 29th November 2011, 20:25
Might anyone be familiar enough with the PULSIN command to know the voltage level a "logic High" starts? Looking at the PIC documentation (18F4520) there are several levels listed for "Input High Voltage". In particular I am trying to see what effects signal rise and fall times are having on my measurements.
For example,
I am running at 32 MHz, therefore I expect the resolution of the PULSIN command to be around 1.25 usec. Looking at the pulse on the oscope, the positive pulse width is 6 usec. I take 100 PULSIN samples and then divide the result by 100 to get an average, as follows:
TRIGGER VAR PORTA.2
TRIG_FREQH VAR LONG
TRIG_FREQHA VAR LONG
For I=1 to 100
TRIG_FREQH=0
WHILE TRIGGER=1:WEND 'MAKE SURE I DON'T START IN THE MIDDLE OF A PULSE
PULSIN TRIGGER,1,TRIG_FREQH
TRIG_FREQHA=TRIG_FREQHA+TRIG_FREQH
Next I
TRIG_FREQHA=TRIG_FREQHA/100 'AVERAGE NUMBER OF HIGH COUNTS
TRIG_FREQHA=125*TRIG_FREQHA/100 'CHANGE TO USECs 1.25 USEC/CNT
The value I am getting is around 3, which makes we wonder if since this is a pretty small pulse width rise/fall times might have become an issue???? If it makes a difference, the pulse low time is 4995 usec which I seem to be measuring accurately using the same method.
If anyone can help, it would be greatly appreciated. CC
For example,
I am running at 32 MHz, therefore I expect the resolution of the PULSIN command to be around 1.25 usec. Looking at the pulse on the oscope, the positive pulse width is 6 usec. I take 100 PULSIN samples and then divide the result by 100 to get an average, as follows:
TRIGGER VAR PORTA.2
TRIG_FREQH VAR LONG
TRIG_FREQHA VAR LONG
For I=1 to 100
TRIG_FREQH=0
WHILE TRIGGER=1:WEND 'MAKE SURE I DON'T START IN THE MIDDLE OF A PULSE
PULSIN TRIGGER,1,TRIG_FREQH
TRIG_FREQHA=TRIG_FREQHA+TRIG_FREQH
Next I
TRIG_FREQHA=TRIG_FREQHA/100 'AVERAGE NUMBER OF HIGH COUNTS
TRIG_FREQHA=125*TRIG_FREQHA/100 'CHANGE TO USECs 1.25 USEC/CNT
The value I am getting is around 3, which makes we wonder if since this is a pretty small pulse width rise/fall times might have become an issue???? If it makes a difference, the pulse low time is 4995 usec which I seem to be measuring accurately using the same method.
If anyone can help, it would be greatly appreciated. CC