Follow along with the video below to see how to install our site as a web app on your home screen.
Nota: This feature currently requires accessing the site using the built-in Safari browser.
Ningun pic tiene salida analogica, solo entradas. Lo que podes hacer y es barato es poner un led y una resistencia enfrentados y controlar el led con pwm, filtrado con una resistencia,un capacitor y un operacional en modo seguidor para tener continua.con un pic sin salidas analogicas...
PWM
Syntax
PWM Pin , Duty , Cycles
Overview
Output pulse-width-modulation on a pin, then return the pin to input state.
Operators
Pin is a Port.Pin constant that specifies the I/O pin to use.
Duty is a variable, constant (0-255), or expression, which specifies the analogue level desired (0-5 volts).
Cycles is a variable or constant (0-255) which specifies the number of cycles to output. Larger capacitors require multiple cycles to fully charge. Cycle time is dependant on Xtal frequency. If a 4MHz crystal is used, then cycle takes approx 5 ms. If a 20MHz crystal is used, then cycle takes approx 1 ms.
Notes
PWM can be used to generate analogue voltages (0-5V) through a pin connected to a resistor and capacitor to ground; the resistor-capacitor junction is the analogue output (see circuit). Since the capacitor gradually discharges, PWM should be executed periodically to refresh the analogue voltage.
PWM emits a burst of 1s and 0s whose ratio is proportional to the duty value you specify. If duty is 0, then the pin is continuously low (0); if duty is 255, then the pin is continuously high. For values in between, the proportion is duty/255. For example, if duty is 100, the ratio of 1s to 0s is 100/255 = 0.392, approximately 39 percent.
When such a burst is used to charge a capacitor arranged, the voltage across the capacitor is equal to:-
(duty/ 255) * 5.
So if duty is 100, the capacitor voltage is
(100/255) * 5 = 1.96 volts.
This voltage will drop as the capacitor discharges through whatever load it is driving. The rate of discharge is proportional to the current drawn by the load; more current = faster discharge. You can reduce this effect in software by refreshing the capacitor's charge with frequent use of the PWM command. You can also buffer the output using an op-amp to greatly reduce the need for frequent PWM cycles.