Hello,
I am trying to make a tachometer for my lathe and milling machines. I have joined M E Labs 7 segment example to some code I was experimenting with a year ago or so. The code does count and return a value, I have not attempted to make it return any useful numbers yet, as I am not at all satisfied with what it displays, 1: the portA.3 output is much brighter than the other 3, all switched with 2n3906 transistors, and the less bright displays are too dim. I decreased the initial pause directly after T1CON to increase the loop speed so as to make the display flash faster than my eyes can see,This makes the displays brighter too, I think however I will never be able to make enough pulses to use this as anything but an RF freq. counter with this setting. What I am contemplating is to add TTL latches to the ABCDEFG and DIG ports to freeze the LEDs on between cycles. Does anyone have better Ideas?
Thank You
Joe S.
oh BTW PIC 16F876A and 2" tall LED 7 Segment displays
Code:@ __config _HS_OSC & _WDT_OFF & _PWRTE_ON & _LVP_OFF & _BODEN_OFF define OSC 20 CMCON = 7 ADCON0 = 0 ADCON1 = 7 TrisA = %00000000 TrisB = %00000000 TrisC = %00000001 Segments Var PORTB Digits Var PORTA PORTC = %00000011 PAUSE 500 PORTC = %00000000 CounterTotal var word RPM VAR WORD i Var Byte n Var Byte RPM = 0 T1CON = %00000111 ' bits 0, 1, 2 set high, prescaler to 1:1 START: TMR1L = 0 TMR1H = 0 mainloop: counterTotal.lowbyte=TMR1L counterTotal.highbyte=TMR1H TMR1L = 0 TMR1H = 0 T1CON.0=1 pause 5 <font color = red>' the greater the delay the slower the display flashes</font color> rpm = (CounterTotal * 2) 'no attempt has been made here to get accurate numbers GoSub display ' Display the value T1CON.0=0 GoTo mainloop ' Do it forever ' Subroutine to send the number (0 - 9999) in Value to LEDs display: For i = 0 To 3 ' Loop through 4 digits n = RPM Dig i ' Get digit to display GoSub display1 ' Display the digit ' Leave it on 2 millisecondS Next i ' Do next digit Return ' Surboutine to display one digit on LED ' i = digit number ' n = number to display display1: 'Digits = $ff ' All digits off to prevent ghosting ' Convert binary number in n to segments for LED Lookup n, [$40, $79, $24, $30, $19, $12, $02, $78, $00, $18,$7f], Segments ' logic low complements ' Set digit pin i to 0 (on) and the rest of the pins to 1 (off) Digits = ~Dcd i Pause 2<font color = red> Increase to make digits brighter and flicker worse</font color> Return end


 
			 
			 
			 
					
					 LED Machine Tach For Tired Eyes
 LED Machine Tach For Tired Eyes
		 
				
				
				
				
			

Bookmarks