Microchip Technology

user Occupation hasn't been added

 Microchip


  • PIC16F876A Function Generator

  • Created: Oct 20, 2016

    • view403
    • comment0
    • bookmark0
    • fork1

Description

No description available.

Summary

Function generators are electronic instruments that can be used to output various waveforms. Waveforms that a function generator basically outputs are sinusoidal, square, or triangular waves. A function generator can be used in audio or RF applications. But the signal that it outputs is not really ideal for those types of application. Audio or RF applications require very low distortion and very stable frequency signals. Function generators are used in development, test, and repair of other electronic circuits. They can be used to produce a signal to test an amplifier or input an error signal to an electronic system and see how the system responds.


This reference design features a simple function generator that is created out of a PIC16F876A microcontroller and a PCF8591 A/D and D/A converter. The PIC16F876A is an 8-bit microcontroller that has a 14KB program memory, 256B of EEPROM, and 368B of RAM. It has 22 I/O pins and supports I2C, SPI, and UART/USART protocols. The PCF8591 is a device that can act as an analog-to-digital converter or a digital-to-analog converter. When the device is used as an ADC, it provides four analog inputs where analog signals can be inserted and the output can be taken at the I2C bus interface. If the device is used as DAC, data input is through the I2C interface and the analog output is taken at its AOUT pin. In this design, the PCF8591 device is used as a DAC. The PIC16F876A microcontroller, which sends data to be converted, is connected to the I2C interface of the PCF8591 and the output is taken from the AOUT pin of the PCF8591 device.


The interface between the microcontroller and the DAC is just simple. The microcontroller sends an address followed by a configuration word to communicate with the DAC. The address of the PCF8591 device is determined by its A0-A2 pins, which in this case are all grounded (A0 = 0, A1 = 0, A2 = 0). When the DAC acknowledge the address and configuration sent by the microcontroller, the microcontroller continues to send data, which commands the DAC to generate a specific waveform. The headers J1, J2, and J3 change the output waveform of the whole function generator, in which the RC0, RC1, and RC2 pins of the microcontroller are connected, respectively. When RC0 is HIGH while RC1 and RC2 are LOW, the output is triangular. If RC0 and RC2 are LOW while RC1 is HIGH, the output will be DC. If all of them are pulled to ground, the output is a sine wave. In this design, the only way to vary the amplitude and frequency of the signal is to modify the code. The frequency is also limited to few KHz due to the speed of the PCF8591 device.