LoPIC
LOGIC PROBE with  PULSER 
Going Further

 

GOING FURTHER
Now that you have built the LoPIC (Logic Probe with Pulser), you may want to go further and add more features. 
This is the advantage of a microprocessor-based design. It is very easy to add features by simply adding lines of code to the program and you can go to this new section of program by carrying out a sequence of events with items already on the project. In this case you can use the earth clip and probe tip as a switch, as explained below.
The LoPIC project already has three main features:
1. As a Logic Probe to detect HIGH, LOW and PULSE waveforms. 
2. As a Logic Pulser to check the operation of LEDs, speakers and Piezo's.
3. As a 25mA current source for injecting into a project. It is very handy to have a low current source that will not damage anything. You can see if a LED or piezo is connected to a particular line or operate a speaker without damaging the output of a chip.
A handy additional feature is a set of Sounds and tones to test different audio circuits. 
We have provided a number of sounds and tones in our Library of Routines section and it is handy to be able to hear each of them, if you are designing an alarm system, for instance.
One of the Sounds, Siren-Up can also be used to test the output of a piezo/choke combination. If you want to get the maximum output from a piezo diaphragm, it must be connected in parallel with a choke. These two devices make up a circuit know as a parallel tuned circuit very similar to that covered in the Basic Electronics section. 
Basically the energy delivered to the circuit is fed into the coil to produce magnetic flux. This flux collapses and produces a voltage in the opposite direction that is generally higher than the applied voltage. This voltage is then passed to the piezo diaphragm. The piezo is effectively a capacitor and it responds to the voltage by deforming the shape of the diaphragm and also storing some of the energy. It then delivers this energy to coil and if the incoming energy arrives at exactly the same time as required by the coil, they add together without conflict. The result is the output from the diaphragm is greater than expected. This is called the
resonant frequency of the circuit. The piezo diaphragm, by itself, does not have a resonant frequency however some types do have a range where their output is greater. This varies for each device and if you have a gliding tone, you can very easily see how each device performs. 
The Probe and Pulser routines occupy less than half the memory of a '508A and we can use the remaining locations for additional routines. To get to these routines without adding any additional hardware (switches) to the project, we can introduce a "series of events."
By connecting the probe tip to earth and turning ON the power switch. The Start-Up program can be designed to detect the LOW input and count a number of cycles to make sure the input is LOW, then go to the new section of sub-routines. To get back to the Probe/Pulser section, simply turn the power OFF and switch ON again without the probe tip connected to earth. 
When we are in the new section, we can create any number of sounds suitable for testing piezo's and amplifiers etc.  
The sounds we have placed in this area are:
1. Siren - A siren-Up sound suitable for a car or house alarm
2. AckAck - An alarm sound similar to an anti-aircraft gun. 
3. Hee Haw - Standard Hee Haw sound for an alarm. 
4. 500Hz tone -  to check the output of a piezo/speaker etc.
5. 750Hz tone
6. 1,000Hz tone
7. 1,250Hz tone
8. 1,500Hz tone
9. 2,000Hz tone
10. 2,500Hz tone
11. 3,000Hz tone
12. 3,500Hz tone
13. 4,000Hz tone
14. 4,500Hz tone
15. 5,000Hz tone
16. 6,000Hz tone
17. 7,000Hz tone
18. 8,000Hz tone
19. 9,000Hz tone
20. 10,000Hz tone
You can cycle around these sounds and tones (from 1 to 20) by placing the probe on the earth clip and waiting for the end of the sound to be recognised by the program. Remove the clip for at least one repetition of the sound and replace it again on the probe tip to hear the next sound. 

THE PROGRAM 
The Sounds program is separate to the Logic Probe/Pulser program. The micro enters the Sounds section when it detects a low on the Logic Probe at Start-Up. 

AT START-UP
The Start-Up routine must detect a long period of time (in computer terms) for a LOW to be present on the input of the Logic Probe. This is a form of very heavy debounce to make sure the project only goes into the Sounds section when a DEFINITE LOW is detected. 
 
PRODUCING A TONE 
To produce a tone such as 500Hz, the length of the HIGH and LOW must be 1,000uS (each). If the clock frequency is 4MHz, (the RC components: 4k7 and 22p for the PICF84 create a clock frequency of 4MHz while the internal oscillator in the '508A is 4MHz), the chip divides the clock frequency by 4 making the length of each instruction 1uS. The length of the HIGH and LOW is called a Delay period and it requires exactly 1,000 instructions for each period - making 2,000 instructions for each cycle of the waveform.
To produce a frequency of 10,000Hz, each cycle requires 100 instructions, with each HIGH and LOW requiring 50 instructions. 
These values can be placed in a table with a Tone routine calling the necessary delay value for each tone.
When the frequency is low (500Hz), the number of microseconds for each delay period is large and it does not matter if the delay is one or two microseconds longer or shorter than needed. But when the frequency gets higher, the length of each delay period is very critical and a single microsecond can alter the final frequency by a noticeable amount. To produce frequencies as close as possible to the required frequency we have had to introduce two loops, a main loop and a trimming loop. One loop takes 4 instructions to execute and the other takes 3 instructions. By adjusting the loading of each loop we can create a delay that is accurate to 1 microsecond for all frequencies. 
The only varying factor is the frequency of the chip. Since we are using a resistor and capacitor for the PICF84, we can trim the resistor to produce very near to 4MHz and thus get a very accurate scale. The following values are those taken from our prototype:

Nominal Frequency Measured Frequency:
500 Hz 506 Hz
750 Hz 757 Hz
1,000 Hz 1,005 Hz
1,250 Hz 1259 Hz
1,500 Hz 1.512 Hz
2,000 Hz 2,015 Hz
2,500 Hz 2,503 Hz
3,000 Hz 3,028 Hz
3,500 Hz 3,539 Hz
4,000 Hz 4,018 Hz
4,500 Hz 4,563 Hz
5,000 Hz 5,017 Hz
6,000 Hz 6,106 Hz
7,000 Hz 7,041 Hz
8,000 Hz 8,050 Hz
9,000 Hz 9,058 Hz
10,000 Hz 10,184 Hz

The 6,000 Hz frequency is slightly off target because the delay periods require a fraction of a microsecond more and this is not possible with 1 microsecond instructions. 
To work out a delay period you have to know exactly how many microseconds it takes to decrement a file in a loop. If we take Loop1, for example, and load the decrementing file with 08. This will produce 7 loops of 4 microseconds and a final loop of 3 microseconds. For Loop2, it takes 3 instructions per loop and a final loop of 2 instructions. If a file is loaded with 1, the delay time is 2 microseconds for Loop2. There is only one delay in the Tone Routine, made up of two loops and "setting up" instructions.  Within the delay time is an instruction to toggle the output and this is how the HIGH and LOW is produced. 
It is important to take into account the number of instructions at the end of each HIGH or LOW, for setting up the files and checking to see if the earth clip is touching the probe tip (this is called the "look" feature). These instructions take 14 microseconds are are a constant for each tone. The instructions consist of the following lines:
line 23 (1uS), Line 24 (1), Line 25 (1), Line 26 (1), Line 27 (1), Line 28 (2),  Line 38 (1), Line 39 (2), 
Line 14 (1), Line 15 (1), Line 16 (1),  and Line 17 (1).    

The Tone Routine:

1   Tones      CLRF 0C        ;Clear the Table-jump1 file
2                   MOVLW 01
3                   MOVWF 0F    ;Put 01 into Table-jump2 file
4   Tones1    BSF 1F,0        ;Set the debounce flag
5                   MOVF 0C,0     ;Move jump1 value into W for table CALL
6                   CALL Table1
7                   MOVWF 0D      ;File 0D is holding file1
8                   XORLW 0FFh    ;Ex-OR W with FF for end of table
9                   BTFSC 03,2       ;Look at zero flag in Status file
10                 GOTO Siren      ;End of table found
11                 MOVF 0F,0       ;Move jump2 value into W for Table CALL
12                 CALL Table1 
13                 MOVWF 10h     ;File 10h is holding file2
14  Tones2   MOVF 0D,0       ;Move file 0D into W
15                 MOVWF 0E       ;File 0E is decrementing file1
16                 MOVF 10h,0      ;Move file 10h into W
17                 MOVWF 11h      ;11h is decrementing file 2
18   Loop1    NOP
19                 DECFSZ 0E,1      ;Create HIGH and LOW values 
20                 GOTO Loop1
21   Loop2    DECFSZ 11h,1
22                 GOTO Loop2
23                 MOVLW 20h 
24                 XORWF 06,1        ;Toggle piezo line
25                 MOVLW 04
26                 XORWF 06,1        ;Toggle Pulser line
27                 BTFSC 06,3          ;Is Probe touching earth?
28                 GOTO Tones3      ;No
29                 BTFSC 1F,0          ;Yes. See if Probe has been lifted
30                 GOTO Tones2      ;No
31                 DECFSZ 1A,1       ;Yes. 256 loop debounce
32                 GOTO Tones2
33                 INCF 0C,1              ;Increment the table-jump value1 
34                 INCF 0C,1              ;Increment the table-jump value1 
35                 INCF 0F,1              ;Increment the table-jump value2 
36                 INCF 0F,1              ;Increment the table-jump value2 
37                 GOTO Tones1      ;Go to next tone
38   Tones3  BCF 1F,0               ;Clear the debounce flag
39                 GOTO Tones2 

The "look" feature can also be called debounce. A very long debounce is needed with any mechanical switch to make sure that only one registration is recorded each time the switch is opened or closed. Each loop of the routine above produces only half a cycle of the frequency and thus it is executed very quickly. The routine above detects when the probe is touching earth and looks at the "debounce-flag" to see if it has been lifted. If so, it decrements file 1A, 256 times before incrementing the table-pointer files so that the next tone will be generated.
Inserting the instructions for the debounce feature, into the program, at the correct places, is very important.  
 A "flag" (file 1F) is set before the micro enters the Tone Routine (at line 4) and the routine is executed. At line 27, the probe tip is checked to see if it is still touching earth. Obviously it will be, as the user has touched earth to get the micro to advance to this routine and it will only take a few milliseconds to execute one complete cycle. When the probe tip is lifted, the debounce flag is cleared (at line 38). The next time the probe tip is checked, and it is touching earth, a 256 loop debounce feature is executed before the program increments the table-pointers for the next tone. 
The purpose of this debounce is to prevent to micro skipping past a routine. If the 256 cycles of debounce were not present, the action of removing the probe would be detected by the micro as a removal and re-connection due to the scraping nature of the clip on the probe. It would be impossible to increment the Tones feature without a long debounce feature. 

LOGIC PROBE with Pulser 
 
Complete Program & .hex file with tones for 16F84:

  

  

        
The block of numbers below is the HEX file for Logic Probe with Pulser for 16F84 with Tones. Copy and paste it into a text program such as TEXTPAD or NOTEPAD and call it: LoPIC84T.hex  
:100000008316083086008312860191019E01A0307C
:100010009B0006169A0B0928831608308600831267
:10002000861913289E0A9B0B09289E1F73281F14EC
:10003000B1282030920040309300930B1D282030CF
:100040008606940B1B28920B1B2891018612080030
:1000500005308E00B0308D00332056208D0B2C28BB
:100060008E0B2A2808009E019F0108308C0006167E
:100070000000000000000000861D40289E0A412864
:100080009F0A0612000000000000000000000000AF
:100090000530930086195028930B4A289F0A51284F
:1000A0009E0A8C0B372806108610080000301E06AA
:1000B00003195E2804301E02031C672800301F0647
:1000C0000319672800301E0603196B28080040300A
:1000D0009A0086146D2806146D289A0B6D2820301E
:1000E00086069101080006152820061128200530F3
:1000F0008E00B0308D0004308606332056208D0BE4
:100100007B288E0B792806112820910A4030110691
:1001100003191920861273288207F5340134A2349A
:100120000234793402345F3403344F3402343B34C4
:1001300001342E34023426340134203401341B348B
:10014000023418340134143403340E3405340C34BE
:1001500004340C3401340834043408340234FF34D9
:100160001F1480308E00900050308F0050308C0073
:100170000C088D00861606158D0BBA288D00861288
:1001800006118D0BBF28900BB8288C038E0A0E0821
:1001900090008F0BB828861DCF281F10B1281F1C78
:1001A000D228B1281F1440309400C03095001508A3
:1001B000960086160615960BD92886120611960B00
:1001C000DD2895039503940BD728861DE9281F1079
:1001D000D3281F1CEC28D3281F14FF309400C030F4
:1001E000861606150000950BF228C0309500861281
:1001F00006110000950BF928940BEF28C0309400ED
:10020000FF309500861606150000950B0429FF3077
:100210009500861206110000950B0B29940B0029FE
:10022000861D14291F10ED281F1C1729ED288C018D
:1002300001308F001F140C088C208D00FF3A031929
:10024000B0280F088C2090000D088E001008910037
:1002500000008E0B2829910B2B29203086060430B4
:10026000860686193C291F1824299A0B24298C0AF2
:0C0270008C0A8F0A8F0A1A291F102429FB
:00000001FF

 

LOGIC PROBE with Pulser 
 
Complete Program & .hex file with tones for 12c508A:

    

           

The block of numbers below is the HEX file for Logic Probe with Pulser for 12c508A with Tones. Copy and paste it into a text program such as TEXTPAD or NOTEPAD and call it: LoPIC08T.hex   
:10000000080C060002006600860571006606630A99
:10001000A00A200C3200400C3300F3020D0A200C21
:10002000A601F4020B0AF2020B0A7100A6040008F2
:10003000050C2E00B00C2D0023094609ED021C0A08
:10004000EE021A0A00087E007F00080C2C008605CC
:1000500000000000000000006607300ABE02310AFE
:10006000BF02860400000000000000000000000045
:10007000050C33006606400AF3023A0ABF02410A41
:10008000BE02EC02270A060426040008000C9E01AA
:1000900043064E0A040C9E000307570A000C9F01FA
:1000A0004306570A000C9E0143065B0A0008400CF9
:1000B0003A0026055D0A06055D0AFA025D0A200C73
:1000C000A601710000084605180946041809050C28
:1000D0002E00B00C2D00040CA60123094609ED02E8
:1000E0006B0AEE02690A46041809B102400C91013C
:1000F00043060909A604630AE201F5080108A208FB
:100100000208790802085F0803084F0802083B0844
:1001100001082E08020826080108200801081B080B
:10012000020818080108140803080E0805080C083E
:1001300004080C0801080808040808080208FF0859
:100140001F05800C2E003000500C2F00500C2C008E
:100150000C022D00A6054605ED02AA0A2D00A604F4
:100160004604ED02AF0AF002A80AEC00AE020E024D
:100170003000EF02A80A6607BF0A1F04A10A1F0782
:10018000C20AA10A1F05400C3400C00C350015023C
:100190003600A6054605F602C90AA6044604F6027C
:1001A000CD0AF500F500F402C70A6607D90A1F0454
:1001B000C30A1F07DC0AC30A1F05FF0C3400C00C6A
:1001C000A60546050000F502E20AC00C3500A604AB
:1001D00046040000F502E90AF402DF0AC00C34000C
:1001E000FF0C3500A60546050000F502F40AFF0CD9
:1001F0003500A60446040000F502FB0AF402F00AEA
:100200006607040B1F04DD0A1F07070BDD0A6C00DD
:10021000010C2F001F050C027C092D00FF0F430667
:10022000A00A0F027C0930000D022E0010023100DE
:100230000000EE02180BF1021B0B200CA601040CAF
:10024000A60166062C0B1F06140BFA02140BAC0257
:0C025000AC02AF02AF020A0B1F04140B3B
:00000001FF

 

     Go to: Introduction to the Logic Probe with Pulser - discusses how the project works etc
     Go to: Using the Logic Pulser - Testing circuits with the Logic Pulser
     Go to: Multi Chip Programmer - for burning  '508 and F84 chips
     You will also need to download the programming program IC-Prog.exe     
 You should also go to the section "Burning a Chip." This section explains how to load the PIC chip with a .hex file. It is part of our 5x7 Display project.