<!-- hrefloc=this.location function NewWindow1() { //#1 window1=window.open("LoPIC-Pgm&Sounds-F84.html", "NewWindow1", "toolbar=no,directories=no,menubar=no,scrollbars=yes,top=25,left=400,width=390,height=500"); } hrefloc=this.location function NewWindow2() { //#2 window1=window.open("LoPIC-Pgm&Sounds-F84Verdana.html", "NewWindow2", "toolbar=no,directories=no,menubar=no,scrollbars=yes,top=25,left=350,width=440,height=500"); } hrefloc=this.location function NewWindow3() { //#3 window1=window.open("LoPIC-Pgm&Sounds-508A.html", "NewWindow3", "toolbar=no,directories=no,menubar=no,scrollbars=yes,top=25,left=350,width=440,height=500"); } -->
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:
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 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.
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.
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).
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.
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
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
Quick Links
Legal Stuff
Social Media