PDA

View Full Version : LED Machine Tach For Tired Eyes



Archangel
- 18th June 2008, 01:56
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



@ __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

skimask
- 18th June 2008, 03:45
Feed your individual digits into a few 74LS373 (or 74LS573) latches, kicks the latch pin, have the output from the 393's drive ULM2803's which connect directly to your 7 segment LEDs. Or might not even need the ULN2803, could probably drive the LEDs directly from the '373...

Set everything up, set the output enables high, set the output latches high...

Pull the output enable pin on the first '373 high, put the first number for output on PortA, toggle the first '373 latch pin, pull the first '373 output enable pin low, leave it
Put the output enable pin on the second '373 high, put the second number for output on PortA, toggle the second '373 latch pin, pull the second '373 output enable pin low, leave it. Since you didn't trigger the latch enable pin on the 1st '373, it won't do squat but sit there and output for you...thereby stay sitting still.

Wash, lather, rinse, repeat, all the way down the line...


Or even easier, buy up one of those 'large-ish' backlit LCDs.

George
- 19th June 2008, 23:03
I did a similar counter several years back with some 4" tall digits I just over drive the LEDs, for example if you have 4 digits and each segment is 20mA, pump each segment to 80mA. I also found it necessary to put a resistor to each of the 7 outputs to the LED segments rather than just a common resistor - else I found that a 1 was much brighter than anything else - and of course the 8 was quite dim.

Darrel Taylor
- 20th June 2008, 00:23
Hi Joe,

I think the problem is in the pauses.
The first 3 digits are on for 2ms each, then the last digit is on for 7ms (2ms + 5ms in the main loop). So the dutycycles are around 15% for the 3 digits and over 50% for digit 4.

Removing the 5ms pause in the Mainloop should make them all the same brightness with 25% duty.

But you still need a Time Base if you want to read RPM, and you'll need to do some math to convert the result which will cause small variances in the brightness as the delays thru the loop change.

This sounds like the perfect job for Instant Interrupts.

I just happen to have some hardware available, that's hooked up the same way as the meLabs 7-segment demo.
http://www.picbasic.co.uk/forum/showthread.php?p=58076#58076

Feel like trying it a different way?
<br>

Archangel
- 20th June 2008, 00:42
Hi Joe,

I think the problem is in the pauses.
The first 3 digits are on for 2ms each, then the last digit is on for 7ms (2ms + 5ms in the main loop). So the dutycycles are around 15% for the 3 digits and over 50% for digit 4.

Removing the 5ms pause in the Mainloop should make them all the same brightness with 25% duty.
<br>
That answered a question I didn't exactly know how to ask.


But you still need a Time Base if you want to read RPM, and you'll need to do some math to convert the result which will cause small variances in the brightness as the delays thru the loop change.
<br>
I thought the pause was the time base! In the example it was 500.


This sounds like the perfect job for Instant Interrupts.

I just happen to have some hardware available, that's hooked up the same way as the meLabs 7-segment demo.
http://www.picbasic.co.uk/forum/showthread.php?p=58076#58076

Feel like trying it a different way?
<br>
OH HECK YES . . . :) I was getting ready to output BCD into some 4511s so as to have a latch to get brightness without flicker . . . In fact to that end I ordered some common cathode LEDs last night, I already have common anode ones here.<h2><b>LEAD THE WAY MASTER</h2></b>Thank You Darrel.

Archangel
- 21st June 2008, 10:21
Hello again,
M E Labs has a lot of code samples, many of you have examples there, and here is a sample from mister_e that I believe will do what I need without all the overhead associated to using latches. I am posting it here as the download from ME Labs has some cut paste errors, specificly duplicate IF THEN loop which upset my compiler's little tummy :) I modified mister_e's code only enough to port it to a 16F628A, . . . Great piece of work Steve ! Thank You !


' Pulse counter
' =============
'
' File name : Count_Display.bas
' Company : Mister E
' Programmer : Steve Monfette
' Date : 27/12/2004
' Device : PIC16F84A-20/P
'
'
' This program display to 3 x 7 segments dislay the result of
' pulses count on PORTA.4 pin/sec.
'
' Hardware connection :
' ---------------------
' 1. 3 X 7 segments display on PORTB<7:0>
' 2. 3 X PNP transistor on PORTA<3:0> to drive common anode
' of each 7 segments display
'
'
' Programming mode and PIC define
' -------------------------------
'
@ __config _HS_OSC & _WDT_ON & _PWRTE_ON & _LVP_OFF
CMCON=7 ' ADDED FOR PIC16F628A
DEFINE OSC 20 ' use 20 MHZ oscillator


' I/O Definition
' --------------
'
TRISA = %11111000 ' PORTA : <2:0> outputs to common Anode of 7 segment
' 1. PORTA.0 More significant
' 2. PORTA.2 Less significant
' : PORTA.4 input for signal
'
TRISB = 0 ' PORTB connected to 7 segments
' B0 : segment a
' B1 : segment b
' B2 : segment c
' B3 : segment d
' B4 : segment e
' B5 : segment f
' B6 : segment g
' B7 : segment decimal dot


' Internal EEPROM definition
' --------------------------
'
data @0,192,249,164,176,153,146,130,248,128,144 ' table to convert
' numbers to 7 segments
' pattern output when
' drive invert



' Interrupt and register definition
' ---------------------------------

OPTION_REG = %1111000 ' TMR0 clock source : RA4/T0CKI
' increment on low to high transition
' Prescaler assign to WDT
' WDT rate 1:1
'
INTCON = %10100000 ' Enable global interrupt
' Disable EE write interrupt
' Enable TMR0 overflow interrupt


' Variable definition
' -------------------
'
DisplayPort var PORTB ' Port for 7 Segments
ClockInput var PORTA.4 ' Input pin for signal
_7Seg1 con 14 ' enable more significant 7 segment display
_7Seg2 con 13 ' enable mid significant 7 segment display
_7Seg3 con 11 ' enable less significant 7 segment display
Digit_1 var byte ' Hundreds digit
Digit_2 var byte ' Tenth digit
Digit_3 var byte ' Unit digit
ToBeDisplay var word ' Result of count to be send to 7 segment display
Display var byte ' Temp variable
DisplayLoop var byte '
Delay var word ' Variable for Delay loop
OverFlowVar var word '
Thousands var bit ' Flag for count >= 1000 & < 10 000
TenThousands var bit ' Flag for count >= 10 000

' Variable and software initialisation
' ------------------------------------
'
tobedisplay = 0 ' set initial value of count
TMR0 = 0 ' reset prescaller
On interrupt GoTo SetVarToBeDisplay

MainLoop:

' MainLoop
' ---------
'
' 1. display the result of the count on RA4 pin
' 2. refresh display
' 3. reset Timer0
' 4. reload prescaler.
'
' Duration of the procedure : 1 sec
' fine tuned by DelayBetweenEachDisplay Sub
'
' Looping 1 sec and get results of the pulse count in
' TMR0 + OverFlowVar
'
DisplayRefresh:
'
' Testing amount of count
' -----------------------
'
' Get the result of count and place decimal point flag
' on the according 7 segments
'
If tobedisplay>= 1000 Then
tobedisplay = tobedisplay / 10
Else
tenthousands = 0
thousands = 1
EndIf

'
' convert digit to 7 segment output pattern
' -----------------------------------------
display=ToBeDisplay dig 2 ' Read hundreds digit
read display, digit_1 ' Convert hundreds
if thousands==1 then digit_1=digit_1 & $7F ' enable decimal dot
' by clearing PORTB.7

display=ToBeDisplay dig 1 ' Read tenths digit
read display, digit_2 ' Convert tens
if tenthousands==1 then digit_2=digit_2 & $7F ' enable decimal dot '
' by clearing PORTB.7

display=ToBeDisplay dig 0 ' Read units digit
read display, digit_3 ' Convert units
'
'
' Send digit to 7 segments
' ------------------------
For displayloop = 0 To 111 ' loop for about 1 sec

' display hundreds
' ----------------
PORTA=_7seg1 ' enable hundreds 7 segment
displayport = digit_1 ' display
GoSub DelayBetweenEachDigit

' display tenth
' -------------
PORTA=_7seg2 ' enable tenth 7 segment
displayport = digit_2 ' display
GoSub DelayBetweenEachDigit

' display units
' -------------
PORTA=_7seg3 ' enable unit 7 segment
displayport = digit_3 ' display
GoSub DelayBetweenEachDigit

Next
tobedisplay = OverFlowVar + TMR0
OverFlowVar = 0 ' Reset OverFlowVar
TMR0 = 0 ' reset prescaller
GoTo DisplayRefresh


DelayBetweenEachDigit:

' DelayBetweenEachDigit
' ---------------------
' Produce delay of about 3 mSec
'
' Fine tuned with MPLAB StopWatch to get MainLoop = 1 sec
'
For delay = 1 To 307
@ nop
Next
@ nop
@ nop
@ nop
@ nop
@ nop
@ nop
@ nop
Return


disable
SetVarToBeDisplay:
'
' SetVarToBeDisplay
' -----------------
' interrupt routine of TMR0 overflow
'
' Reset prescaller
' Reset overflow flag
'
OverFlowVar = OverFlowVar + 256
INTCON.2 = 0 ' clear overflow flag
TMR0 = 0 ' reload TMR0
Resume
enable

END

Darrel Taylor
- 21st June 2008, 10:48
That's a "Straw", I'm a "Camel", and my back is broken.

2 days of work, and as I'm posting it I see ... "Nevermind, I'll use mister-e's program".
Arrrrghhh.

Enjoy.

Archangel
- 21st June 2008, 11:19
That's a "Straw", I'm a "Camel", and my back is broken.

2 days of work, and as I'm posting it I see ... "Nevermind, I'll use mister-e's program".
Arrrrghhh.

Enjoy.

No NO NO NO Don't be that way Darrel, I really want to see what you have come up with! You and Mister_e, Melanie, and a few others all write really sweet code, and I am humbled, that you have made this effort. I thought you were standing by to see what I could come up with (I know, there I go thinkin' again). I just really thought this example needed to be "showcased"as a lot of NOOBS may have tried unsucessfuly to use it, due to aforementioned . . . misprint? For sure I have no intent to offend Professor Rex Nexus Taylor of the Crownhill University. I'm like an old hound dog with a bone, keep on shakin' it and shakin' it till I get the marrow out of it, now for steak . . . as for you being a Camel, yea like Secretariate was huh?

Archangel
- 20th October 2008, 00:41
Threads left open are useless to others, so I will post what I came up with.


@MyConfig = _HS_OSC & _LVP_OFF & _WDT_OFF & _CP_OFF
@MyConfig = MyConfig & _BODEN_OFF & _MCLRE_ON & _PWRTE_ON
@ __CONFIG MyConfig
'===================== Set Defines ===================================
'*
DEFINE OSC 20
'==================== Set up registers ===============================
'
INCLUDE "MODEDEFS.BAS"
CMCON = 7 ' Shut off comparators
TRISA = %00010000 ' Set PORTA to all outputs A.4
TRISB = %00000000 ' Set PORTB Outputs
PortA = $20 ' Set all Port A outputs low
PORTB = 0 ' Set all Port B outputs low
'
'=====================Set Constants ================================
'no constants as yet
'
'===================== Alias Ports =================================
'
TacInput var PORTA.4 ' Input pin for T0CKI - Tach In
'
SDO VAR PortB.0 ' 7 Segment Data Out
SCLK var PortB.1 ' 7 Segment Clock Out
DLE var portB.2 ' 7 Segment Latch Enable
'===================== Declare Variables =============================
Digit_1 var byte ' Thousands digit
Digit_2 var byte ' Hundreds digit
Digit_3 var byte ' Tens digit
Digit_4 var byte ' Units digit
DIGIT_OUTPUT VAR BYTE ' Storage for each digit before lookup
CounterTotal var word ' Someplace to count input pulses
Displays VAR WORD ' Storage while Countertotal gets cleared
'===================== Zero Digits ====================================
Digit_1 = 0
Digit_2 = 0
Digit_3 = 0
Digit_4 = 0
'===================== EEPROM DATA ===================================
DATA @ 0,126,48,109,121,51,91,95,112,127,123 'DIGITS WITHOUT DECIMAL

;DATA @ 10,254,176,237,249,179,219,223,240,255,243 'DIGITS WITH DECIMAL

'=========================== Main Loop ==============================
LOOP:
COUNT PortA.4,1000,CounterTotal
'
DISPLAYS=0
DISPLAYS=(DISPLAYS+CounterTotal) ' load OverflowTotal into displays

displays=(displays*60) ' change this formula to agree with encoder
' Formula is for 1 PPR, 30 for 2 PPR, 15 for 4 PPR
' 10 for 6 PPM, ET-AL, OR TURN THEM AROUND 2 FOR 30
' 3 for 20,4 for 15,5 for 12, 6 for 10
gosub Display
CounterTotal=0
'
GOTO LOOP
'
'=========================== Subroutines ============================
Display:
'
DIGIT_OUTPUT = DISPLAYS dig 0 ' Load Thousands Digit
READ DIGIT_OUTPUT, DIGIT_1 ' Convert and Load Thousands Variable
DIGIT_OUTPUT = DISPLAYS DIG 1 ' Load Hundreds Digit
READ DIGIT_OUTPUT, DIGIT_2 ' Convert and Load Hundreds Variable
DIGIT_OUTPUT = DISPLAYS DIG 2 ' Load Tens of Units Digit
READ DIGIT_OUTPUT, DIGIT_3 ' Convert and Load Tens Variable
DIGIT_OUTPUT = DISPLAYS dig 3 ' Load Ones of Units Digit
READ DIGIT_OUTPUT, DIGIT_4 ' Convert and Load Units Variable
'
shiftout SDO,SCLK,4,[DIGIT_1\8,DIGIT_2\8,DIGIT_3\8,DIGIT_4\8]
pulsout DLE, 500
pause 125
'
return
'
END

This Works on the bench , I have yet to try it on the machine as I am still making parts for it.

Archangel
- 20th October 2008, 00:45
A second more complicated unit using a bargraph in addition to numbers is posted in attachment below:

Acetronics2
- 20th October 2008, 09:08
Hi, Joe

from your program ... may I think you use "something like" a MAX 7219 Serial LedDriver ???

Alain

Archangel
- 20th October 2008, 09:35
Hi, Joe

from your program ... may I think you use "something like" a MAX 7219 Serial LedDriver ???

AlainHi Alain,
I used this: http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&rd=1&item=350111924254&ssPageName=STRK:MEWA:IT&ih=022
and this
http://cgi.ebay.com/40-segment-2-54mm-pitch-LED-Bar-Display-Board_W0QQitemZ230300229520QQcmdZViewItem?hash=ite m230300229520&_trkparms=72%3A1420%7C39%3A1%7C66%3A2%7C65%3A12%7C 240%3A1318&_trksid=p3911.c0.m14
The price was right.

Archangel
- 4th February 2009, 20:27
Hi everyone,
Forum member SAM brought to my attention this code wasn't doing as expected
with the sepecified display. When I first set this up, the display I used did not
agree with the printed data in the data sheet, the new display they are selling does.
Replace the eeprom data in the listed code with the following:


data @ 0,252,96,218,242,102,182,62,224,254,230

Update, the Chinese vendor which supplies this display is : http://www.sureelectronics.net/
My Thanks to SAM for bringing this to my attention.
JS

mister_e
- 4th February 2009, 21:46
Seems they have pretty nice stuff there, probably not suitable for mass production, but interesting and cheap.

Sam
- 5th February 2009, 01:20
Well the code provided by Joe works great now. I really appreciate Joe posting this and then taking the time to help me get it working. I have three machines that I really need tach's on, a spincaster, a cnc mill, and a lathe and this display and Joe's code fits the application perfectly.

The display I got from Sure Electronics was this (http://cgi.ebay.com/1-5-Character-Height-7-segment-LED-Information-Board_W0QQitemZ350160395798QQcmdZViewItemQQptZUK_B OI_Electrical_Components_Supplies_ET?hash=item3501 60395798&_trksid=p3911.c0.m14&_trkparms=72%3A1205|66%3A4|65%3A12|39%3A1|240%3A13 18) one. It was only $14.00 delivered and is quite bright.

I'm in the process of setting up a hall effect sensor as the pickup and it should work fine for this.

Thanks again Joe,

Sam

Sam
- 6th February 2009, 02:23
I guess I was a bit too quick to think that my hall sensor implementation would be simple. Here's (http://www.diodes.com/datasheets/AH180.pdf) the hall effect sensor I have, it works great as a switch, such as for a cell phone lid or laptop lid switch or some application like that, as it's recommended for.

But it just doesn't appear to be able to switch quickly enough. Can anyone recommend or have experience with one that is better suited for a tachometer yet inexpensive ?

Thanks

jderson
- 6th February 2009, 05:02
Hi Sam-

I have been using the AFL series parts from NVE (DigiKey). They work good, but kind of expensive ($9 U.S.) The datasheet says bandwidth is 100khz., but I have only run them at several hundred R.P.M.

Sam
- 7th February 2009, 02:19
Hi Sam-

I have been using the AFL series parts from NVE (DigiKey). They work good, but kind of expensive ($9 U.S.) The datasheet says bandwidth is 100khz., but I have only run them at several hundred R.P.M.

Thanks jderson, I'll take a look at those. I'm also considering trying IR emitter/detector with a reflective stripe. But would prefer the hall sensor method.

Thanks again,

Sam

Archangel
- 7th February 2009, 03:42
Thanks jderson, I'll take a look at those. I'm also considering trying IR emitter/detector with a reflective stripe. But would prefer the hall sensor method.

Thanks again,

Sam
So many ways Sam, Hall effect, plain old coil and magnet glued on the shaft **, spinning disk with holes and opto, old relucter and pickup from car distributor, heck even points for low rpm application, all can be directly driven or run off an idler belt / pulley setup, who cares how many sensor triggers per revolution, you can tweak it in the software to do any math required. On my lathe I plan to put a small belt to the "encoder" from the headstock so I do not have to hassle modifying the spindle. Oh I thought of another one, if your spinning shaft has a nut spinning too aim a small magnet at the nut and a coil of wire at it at about a 60degree angle, might work as a reluctor. Or a spinning gear . . .
** Note: Remember those aftermarket Cruise Control units from the 1980s?

mister_e
- 7th February 2009, 09:42
Yup, we used to install some magnet on the drive shaft when there was no existing VSS source. been a long long time ;)

Sam
- 8th February 2009, 16:30
Joe, thanks for all the ideas. I chose to go with the coil and magnet. I did this for several reasons, mainly I didn't want to wait for a new hall effect module to come in.

I used the coil from a 24v relay I had, I left the bar in the center of course. I got a small but quite strong round magnet from the earpiece of an old cell phone. I connected the coil to a NPN transistor which I forward biased to increase the sensitivity and then ran the output of that NPN into a PNP to give a good positive pulse to the 16F628A.

As a test while everything was still breadboarded, I put a cardboard disc about 6" in dia. on a variable speed drill, taped the magnet to the edge of the disc a gave it a spin. The readout appears to work perfectly, varying with the speed of the drill very reliably ! And the magnet will still work when it's about 1" away. I will have it setup so that the coil and magnet are in close proximity though.

Now I'm going to do the board design in Eagle, then use PCBGcode and mill several boards out on my CNC mill and I should be set.

I'm real happy about this and again, I really appreciate the code and all the help !

Best regards,

Sam

EDIT: I forgot to mention that it displays only in multiples of 60. ie: 60,120,180,240, etc. RPM. Not "linear", I left the formula as displays=(displays*60) as that's all I need for the way I'll have it attached to the first machine I use it on.

Archangel
- 8th February 2009, 19:32
EDIT: I forgot to mention that it displays only in multiples of 60. ie: 60,120,180,240, etc. RPM. Not "linear", I left the formula as displays=(displays*60) as that's all I need for the way I'll have it attached to the first machine I use it on. I never noticed that, I will look into it.
EDIT: Ok I think it is Displays = Displays * 60 If you use 6 magnets and make this statement Displays = (displays * 10) you will get 10 RPM resolution. I plan to use a multiple pulse per revolution encoder scheme which will significantly increase resolution. I think I will build it using parts from an automotive distributor (the guts) and fabricate all of the rest.

Sam
- 8th February 2009, 22:16
Hi Joe,

I must be doing something wrong. I mounted the magnet to the spindle of my mill which on high should be spinning about 2400 rpm. The display is reading anywhere from 250 to 1010 and constantly fluctuating. This is with displays=displays*10. When programmed with displays=displays*60 it's varying from 3000 to over 5000 and again, constantly fluctuating.

I'm using a 10mhz xtal and have the code set at 10mhz OSC too. Could this be causing a problem ? I'm trying to figure it all out on my own but I'm not getting it, "obviously".

Archangel
- 9th February 2009, 03:38
Try putting a resistor from the input to ground, it sounds like it is picking up stray signals (rf?) and twist the input wires or shield them. I would try say 10K first. The displays=displays*10 would only be valid with 6 magnets.

Sam
- 5th March 2009, 03:11
Hey Joe,

I've been real busy with other things and meant to update this sooner.

The tach is working just fine, I have milled the PCB and installed one in my SC machine and it's great. I did switch to shielded wire and had to use a 1K resistor (I already had a 10K in place and that didn't work) and a .01 uf to ground.

When I get some more time I'm going to order two more of the 4 digit displays from Sure Electronics and add them to my lathe and CNC mill.

So again, I really appreciate you providing the code (I've learned from it too) and your help.

I'll post a pic of the tach in operation later. Also, if anyone would like the schematic and PCB layout from Eagle I'll provide that.

Best regards

Archangel
- 5th March 2009, 06:53
Hey Joe,

I've been real busy with other things and meant to update this sooner.

The tach is working just fine, I have milled the PCB and installed one in my SC machine and it's great. I did switch to shielded wire and had to use a 1K resistor (I already had a 10K in place and that didn't work) and a .01 uf to ground.

When I get some more time I'm going to order two more of the 4 digit displays from Sure Electronics and add them to my lathe and CNC mill.

So again, I really appreciate you providing the code (I've learned from it too) and your help.

I'll post a pic of the tach in operation later. Also, if anyone would like the schematic and PCB layout from Eagle I'll provide that.

Best regards
Hi Sam,
I appreciate the feedback! Thanks!

Sam
- 6th March 2009, 19:22
Here it is in operation ! It's doing a fine job, very happy with it.

Also a pic of the pickup coil embedded in epoxy inside a plastic tube, the magnet is epoxied to the shaft.

DanPBP
- 12th March 2009, 23:10
First, I would like to say thanks to Sam for sending me the code and the schematic.

Second, I have a question: what is the maximum RPM this circuit/code can read?

Thanks!

Daniel.

Archangel
- 13th March 2009, 01:38
First, I would like to say thanks to Sam for sending me the code and the schematic.

Second, I have a question: what is the maximum RPM this circuit/code can read?

Thanks!

Daniel.
Hi Daniel,
I added this line:


if displays > 9999 then displays = 9999

to keep the display from rolling over 9999. What use do you have for this tach? I do not think I would try it on a turbine, as it updates too slowly, but it was written for a lathe. It will go over 9999 without that line, the max is unexplored. Perhaps someone who is skilled at math could tell you. The displays can be cascaded, if you feel adventurous.

DanPBP
- 13th March 2009, 04:53
What use do you have for this tach?

I have a few brushless R/C trucks, they have an optic sensor on the transmission and I would like to read the RPM. They go up to 50.000 RPM! I'll give it a try.

Archangel
- 13th March 2009, 06:13
I have a few brushless R/C trucks, they have an optic sensor on the transmission and I would like to read the RPM. They go up to 50.000 RPM! I'll give it a try.
Cool, keep us posted, I am curious as to the limits of count. I am thinking the variable might overflow if RPM goes too high, and you might have to alter the sampling rate or use some form of prescaler.

fratello
- 26th January 2010, 20:03
I try to use code from post #1 to my thermometer with 16F628A, DS18B20 and LED display ( like in : http://melabs.com/resources/articles/ledart.htm fig.6). To another topic, I receive one working code, from one user (thanks !).
But, I am still disappointed, because MY code don't work. Please, what's wrong with him ? Thank you !

@ DEVICE pic16F628A, intOSC_osc_noclkout, WDT_OFF, PWRT_ON, MCLR_OFF, LVP_OFF, CPD_OFF, PROTECT_OFF
TRISA= %11110000 ' RA0..3=Outputs RA4=Input
TRISB= %00000000 ' RB0..RB7=Outputs
CMCON=7 ' Disable comparators



DQ VAR PORTA.4
DS18B20_12bit CON %01111111 ' 750ms, 0.0625°C
I VAR BYTE
SIGN VAR BIT
TEMPERATURE VAR WORD ; TEMPERATURE REGISTER
n var byte
segments var portb
digits var porta
value var word




MAINloop :
OWOUT DQ ,1,[$CC,$44]

WaitLoop:
While not DQ
Wend

OWOUT DQ ,1,[$CC,$BE]
OWIN DQ ,2,[TEMPERATURE.LOWBYTE , TEMPERATURE.HIGHBYTE]

IF TEMPERATURE.15 = 1 THEN
TEMPERATURE = (65535 - TEMPERATURE) + 1
SIGN = 1
ELSE
SIGN = 0
ENDIF

value = (TEMPERATURE * 10)/16


gosub display

goto mainloop


' Subroutine to send the number (0 - 9999) in Value to LEDs
display:
For i = 0 To 3 ' Loop through 4 digits
n = value 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 1 'Increase to make digits brighter and flicker worse
Return

end

Acetronics2
- 27th January 2010, 10:17
Hi, Fratello

One thing is obvious ...

The " Waitloop " , for sure, can't be used whith multiplexed LED's ...


One thing is surprising ...

Do you think your temp calculation is compatible with the provided Led Display ???


One thing is really hazardous ...

While dealing with the display ... you write over your PortA inputs as well as outputs !

Alain

fratello
- 27th January 2010, 14:55
One, two, three things are for sure : I am a sucker !
It's not the first time when "the language barrier" make me problem...I'm really sorry if I borried somebody :( .
In the link that I posted it's the schematic (with reference to PBP code) I tried to make...It's sure that I must careful read (and understand !). Thank You verry much for attention and reply ! All the best !