Function Generator

Have you ever wondered how to generate a sine wave using PIC microcontroller. In this post I’ll show you a simple circuit design that can generate arbitrary wave forms including sine by using MCU and PCF8591 D/A converter. PCF8591 was briefly mentioned in PIC Development Board post as a possible upgrade. It’s a 8-bit CMOS data acquisition device with four analog inputs, one analog output and a serial I2C-bus interface. We are going to configure it as D/A converter controlled by PIC16F876A.

Function Generator Prototype Board
The interface is not too complicated. Send valid address followed by configuration word, wait for acknowledge. Continue sending data to be converted. See attached code at the bottom of the page for more details. The simplest wave to generate is DC. Just output 8 bit number representing desired voltage value to a digital to analog IC using I2C communication protocol and you’re done. Triangle wave is more complex to produce but still not too complicated. By sending an increasing binary number from 0 to 255 you can produce linearly rising wave. When you reach 255 change the direction by decreasing the number from 255 back to 0 to complete falling wave part and repeat in a loop. More explanations on the next page.

Posted in PIC16F87X Projects
 

Leave a Reply

Your email address will not be published. Required fields are marked *

*