Note that the Ccal capacitor is critical! (see later comment).
I did try a NPN transistor in an early version of the prototype, but wasn't happy with the stability. This was probably due mainly to my "rat's nest" construction. My excuse for using a relay is pure laziness - having got it working, I wasn't going to mess with it.
You will have to modify the source code in the subroutines Get_Lcal and Get_Ccal to use appropriate constants. I don't want to do this on an individual basis. It's not quite straightforward and I have conveniently forgotten how to do it!
If you want to change Get_Lcal and Get_Ccal, then the following "Floating Point Converter" *may* help you convert a real number into Microchip's 24 bit FP format. Of course, you have to know what value calibration constant you want to use.
Go to the Microchip Web Site - http://www.microchip.com find the file FP24.A16 (and/or search for Application Note AN575). Take out the subroutines FLO1624 and INT2416, which aren't used.
I have updated the hardware to use a 16F628. This has an internal comparator (2 actually), so the LM311 is no longer required.
The code is done and I am now laying out a printed circuit board.
Stay tuned for more!
First, check the power and ground wiring. You should have +5.0 (+/-0.3) volt present on pin 14 of the PIC and 0 volt present on pin 5 of the PIC.
Next, check the reset wiring ("zero" push button). When the button is released You should have +5 volt present on pin 4 of the PIC and 0 volt when it is pressed.
The circuit diagram does not show the power supply connections to the LM311 (sorry). Connect pins 1 and 4 to ground. Connect pin 8 to the 5 volt power supply.
Some LM311's may not oscillate too readily at "high" frequencies. You can speed them up a little by joining pins 5 and 6 together. It is probably a good idea to do this anyway.
To aid troubleshooting, you should find the following voltages on the pins of the LM311 (measured on the prototype).
The DC voltages on pins 2, 3 and 7 should appear steady when measured on a "multimeter". If these voltages "bounce around" several times a second, then your inductor may have become disconnected. ie. The parallel LC tuned (1000pF, 82uH) circuit is no longer parallel resonant. Check all the wiring around the LC function switch.Pin 1: 0.00 (ground) Pin 2: 2.46 +/- 0.5 volt Pin 3: 2.46 +/- 0.5 volt Pin 4: 0.00 (ground) Pin 5: ???? (don't care) Pin 6: ???? (don't care) Pin 7: 2.43 +/- 0.5 volt Pin 8: 5.00 (power)
If you have access to an oscilloscope, have a look at this page to see what the LM311 is doing.
Please try the following tests:
If the frequency is too high (anything over 655.350KHz), the display will show "Over Range". If the oscillator isn't running, the display will show "0".
For best accuracy, the free running frequency should be 10% to 15% below 655KHz. If it is too close, it may accidentally overflow the PIC's internal 16 bit count. You may need to adjust the inductance to get get the frequency right.
A second link, LK2, connects the calibration capacitor. The oscillator should then run at about 394KHz.
One version is logically an 8 character by two line display, but with all the characters displayed on the one line. To cater for this, the PIC program is able to insert a "move to the second line" command (set Display Ram address to 40 hexadecimal) after the eigth character
The PIC tests pin 10 to see wether to insert this command or not. If your display only ever shows 8 characters (ie. no pF, nF or uH as appropriate) then try grounding pin 10 of the PIC ("short" pins of LK3)- or if you are already grounding pin 10, then disconnect it from ground (remove the link).
#define ENA PORTA,0x02 ; Display "E" #define RS PORTA,0x03 ; Display "RS" #define relay PORTA,0x01 ; 0 = energise relay
#define FIXIT PORTB,0x04 ; Pin 10, 0 = "fix bad display" #define setup PORTB,0x06 ; Pin 12, 0 = "Setup" #define functn PORTB,0x07 ; Pin 13, 0 = "Inductor"PORTA,5 is presently not used, but is defined as an input anyway.
Go to the "ironbark home page", select "Bendigo Staff", then my name. Don't be frightened by my picture - I don't bite. Select my personal page and click the email link on that.