Quantcast
Channel: MEL PICBASIC Forum
Viewing all articles
Browse latest Browse all 4745

Trying to measure TACH pulses.

$
0
0
I'm using a PIC18F67K40 on PBP gold at 64Mhz and I am trying to measure "TACH" pulses on PORTB.0 that are being simulated from a signal generator. I'm trying three different methods just to see how things work. I am thinking that once I can be assured that the pulses are being recognized by PORTB.0 in any form or fashion then I can proceed with actual circuitry work out my permanent code to recognize and report true RPM. Problem is that I can't seem to get PORTB.0 (or PORTB.1, etc..) to recognize the signal from the signal generator.
Currently using 60-200 Hz at 5 volts from the signal generator in square wave ( with varying duty cycles, but I've tried sine, sawtooth, and various pulses types).

My test code is basically:

Do_Tach:
COUNT PORTB.0, 1000, RPM ' to count number of pulses in 1 second and store in word RPM
RPM = RPM * 60
serout LCD_out,6,[017,0,0," RPM: ", #RPM," "] ' print out to my LCD on line 0.
return
Do_Count:
COUNT PORTB.0, 1000, PCount' to count number of pulses in 1 second and store in word PCount
serout LCD_out,6,[017,0,1,"COUNT: ",#PCount, "cnts/sec "] ' print out on my LCD line 1
return
Do_Pulse:
PULSEIN PORTB.0, 1, TPulse ' read pulse on PORTB.0 and store result in word TPulse.
serout LCD_out,6,[017,0,2,"PULSE TIME: "] ' print out on my LCD line 2
return

Thus runs as a loop with a loop counter and the loop count is displayed on my LCD line 3 (code not shown)

I can see the generated signals at my board with my scope.
I can see the loops being counted on my LCD.
I get no response from PORTB.0 or PORTB.1

Before I build a new board I thought it would be best to check with the forum to see if I have missed something, done something stupid or whatever. I have not tried interrupts on this but can see where it might be needed for the PULSEIN statement.
I thought about doing an interrupt on a PORTB.0 change to read the system clock and compare it to the last interrupt time, but can't remember how to read the clock.

Open to any criticism that would help.

Viewing all articles
Browse latest Browse all 4745

Trending Articles