The digital to analog converter (DAC) in the RFzero can be used to make a real analog voltage with up to 10 bits resolution. This means that the voltage is not emulated like in the case of Pulse Width Modulation (PWM).
In the below example the voltage made by the DAC, is set to 1 V using 10 bits/1024 steps 0-1023 resolution. Default is eight bits resolution, i.e. 256 steps 0-255.
1 2 3 4 5 6 7 8 9 10 11 12 |
// RFzero include and object creation #include <RFzero.h> // MUST ALWAYS be included for RFzero void setup() { analogWriteResolution(10); // Change the DAC resolution to 10 bits, i.e. 1024 steps analogWrite(A0, 310); // Set the DAC to 1 V, i.e. value = 1023 * Uout / 3,3 V } void loop() { } |
If you want to use the above example on your Arduino Zero or Arduino M0, the DAC is on the same pin/port A0/DAC.
If the analog voltage needs to be amplified, an operational amplifier (Op Amp) implemented as a DC-coupled and non-inverting amplifier is a good solution, e.g. LM324 see section 8.2.1.
Example of a DC amplifier using an LM324 Op Amp in non-inverting configuration. Picture courtesy Texas Instruments and own work.
Output voltage range [V] | Amplification ratio | R1 (E96, 1%) [kΩ] | R2 [kΩ] | R2 (E96, 1%) [kΩ] |
---|---|---|---|---|
0,0 - 4,0 | 1,21 | 10 | 2,1 | 2,10 |
0,0 - 5,0 | 1,52 | 10 | 5,1 | 5,11 |
0,0 - 8,0 | 2,42 | 10 | 14,2 | 14,3 |
0,0 - 12,0 | 3,64 | 10 | 26,4 | 26,1 |
0,0 - 13,8 | 4,18 | 10 | 31,8 | 31,6 |