Professional Documents
Culture Documents
by Vulcaman
For example:
For a simple simulation of this R2R DAC I haved used Tinkercad circuits.
This time I have extended the R2R DAC to an resolution of 8bit. You can simply press the "Simulation" button in
the Tinkercad project to start the simulation and see an sawtooth function on the oscilloscope. The Tinkercad-
Circuit project can be accessed by this link: https://www.tinkercad.com/things/bXuK4iUc6im . I have also
implemented rectangle, triangle and sawtooth functions. The functions needs to be comment out, then you can
start your simulation again. This code uses portmanipulation which makes the thing a lot easier than using arduino
functions like digitalwrite().
void setup()
{
DDRD = B11111111; // set all Digital Pins on PORTD to OUTPUT
}
void loop()
{
//Rectangle
//PORTD = 255; // 255 is 11111111 in binary
//delay(1);
//PORTD = 0; // 0 is 00000000 in binary
//delay(1);
//Sawtooth
level %= 255;
PORTD = level++;
//Triangle
//for(int i = -255 ; i < 255 ; i++){
//PORTD = abs(i);
//}
}
Rectangle:
Conclusion: