You can create an analogue output by using a PWM output connected to a capacitor. It will take some tweaking to get the PWM frequency to match the capacitor charge rate. Then you should be able to set a mark space on the PWM and get a linear analogue voltage out.
Benj wrote:You can create an analogue output by using a PWM output connected to a capacitor. It will take some tweaking to get the PWM frequency to match the capacitor charge rate. Then you should be able to set a mark space on the PWM and get a linear analogue voltage out.
The code generated by Flowcode V3's PWM component is very bloated for your needs. Also, it is designed for a different compiler than C2C and so it will not work without modification.
I suggest you look at the datasheet for the PICmicro you want to use instead. The section on PWM generation is pretty good and should explain everything you require. For example:
15.4.4 SETUP FOR PWM OPERATION
The following steps should be taken when configuring
the CCP module for PWM operation:
1. Set the PWM period by writing to the PR2 register.
2. Set the PWM duty cycle by writing to the CCPRxL register and CCPxCON<5:4> bits.
3. Make the CCPx pin an output by clearing the appropriate TRIS bit.
4. Set the TMR2 prescale value, then enable Timer2 by writing to T2CON.
5. Configure the CCPx module for PWM operation.
I've a new problem. I whant to change the light of a seven digit display by using the pwm. Is someone knows the frequence to have a output 1V< CCP1< 5V ?
You need a PWM frequency that is fast enough to acheive a good refresh rate. Then you can simply change to mark space ratio to control the brightness of the display.