Page 189 -
P. 189

176   Chapter Eleven

                        word is detected, the output (pin 2) drops to ground momentarily. The micro­
                        controller monitors this line to determine when a word has been detected.
                          Once a word has been detected, it is necessary for the interface to read the
                        BCD output from the speech recognition circuit. By using the high­ and low­
                        digit BCD nibbles, it’s possible to distinguish trained target words. To do so,
                        the interface must distinguish the error codes 55,  66,  and 77 from trained
                        words numbered 5, 6, and 7. To accomplish this, the interface circuit uses four
                        NAND gates off the 4011 integrated circuit. The NAND gates are connected to
                        the high­digit nibble. If the high­digit BCD nibble has the equivalent word
                        numbers of 5, 6, or 7, the output from the four NAND gates is low. The output
                        from the four NAND gates is connected to pin 11 (RB5) of the 16F84. The
                        16F84 reads this pin to determine if the high­digit nibble is a 5, 6, or 7 (0 V or
                        ground). If these numbers are not displayed, the output of the NAND gates is
                        high (�5 V).
                          So far our circuit can tell when a word has been detected and if the result­
                        ing word is an error code. If the output of the speech recognition circuit is an
                        error code, nothing else happens; the microcontroller loops back to the begin­
                        ning of the program, waiting for another word detection. On the other hand, if
                        a word is detected and it is not an error code, the microcontroller passes the
                        low­digit number through to the 74HC154 (4­ to 16­line decoder) IC.  The
                        74HCT154 decoder reads the binary number passed to it and brings the cor­
                        responding pin equivalent to that number low.


            PIC 16F84 microcontroller program
                        The PIC 16F84 used in both interface circuits contains the following PicBasic
                        program:

                           ‘Speech recognition interface program
                           symbol porta = 5
                           symbol trisa = 133
                           symbol portb = 6
                           symbol trisb = 134
                           poke trisa, 255
                           poke trisb, 240
                           start:
                           peek portb, b0
                           if bit4 = 0 then trigger  ‘Trigger enabled, read speech recognition
                                                     circuit
                           goto start               ‘Repeat
                           trigger:
                           pause 500                ‘Wait .5 second
                           peek portb, b0           ‘Read bcd number
                           if bit5 = 1 then send    ‘Output number
                           goto start               ‘Repeat
                           send:
                           peek porta, b0           ‘Read port a
                           if bit4 = 1 then eleven   ‘Is the number 11
                           poke portb, b0           ‘Output number
   184   185   186   187   188   189   190   191   192   193   194