I want to use a PIC as a two output DAC. I was looking at the PIC16F685 to do this. It has 4 PWM channels, and is the cheapest that I could find with 2 or more PWM channels. Does anybody have any cheers or jeers for this PIC?
After I choose my PIC, anything special I should look out for making it PWM? I think I can figure most of it out from the datasheet. I prefer to program in C.
What circuit do I need to use to make the PWM be a DC voltage? Will a simple capacitor work? What kind of response times will I get using said circuit? It is important that this be able to change the DC voltage very quickly.
PIC microcontrollers with Enhanced Flash have self-programming capabilities. You can use a bootloader to program the microcontroller in the target board.
PIC microcontrollers with Enhanced Flash have self-programming capabilities. You can use a bootloader to program the microcontroller in the target board.
I did a little more searching and decided the 886 would be best for my purposes. What circuit do I need to make the PWM DC? Also, how fast will I be able to change that voltage?
You need a low pass filter, I suggest you check the MicroChip application notes, there's at least one that tells you all about using PWM as a DAC and how to calculate the filter values.
The following diagram is with a duty cycle of 25% (63) and a frequency of 32767Hz on channel 1 (CCP1) eg: HPWM 1, 63, 32767 With a duty cycle of 25%, the output will be 25% of 5V, or 1.25V. Note the PSU/OSC are not shown.
**broken link removed**
The command in Proton+ is
Code:
HPWM Channel , Dutycycle , Frequency
As it so turns out, the channels on the 16F877 are CCP1 and CCP2, but CCP1 is on PORTC.2 and CCP2 is on PORTC.1.. I have no idea why, but you can declare the pins into what would seem the correct format like so,
I'm using 1 channel for this example, and a simple RC circuit that will average the PWM signal and turn it into a rather constant analogue output. The op-amp is not required for all applications, but it definitely is good practice to use it as a buffer. The frequency should always be on max, i.e. 32767Hz for DAC, a lower frequency will make the output appear laggy / have a long response time.