Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Convert digital output of arduino to analog with an R2R ladder

NotificationsYou must be signed in to change notification settings

mjkloeckner/DAC_6bit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

This is an Arduino program to make a 6 bit DAC using anR2Rladder connected to thecorresponding pins on the Arduino.

The code is a slight modified version of a previously existing one provided byFIUBA'sprofessors from lecture "Introducción a la Ingeniería Electrónica", andcorresponds to the Final Group Project. The modification adds the ability to usepins from different ports instead of all the pins from the same port.

The ports are 8 bits registers that Arduino uses to internally represents theoutput pins. You can find which pin correspond to which port by looking on anyArduino pinout diagram, being the most common ports PORTB, PORTC and PORTD.

The code uses PORT manipulation since its faster than using builtin functionlike pinMode(), and thus improving the softness of the recreated wave by theR2R.

The following statements produce the same effect on the arduino output pins andshows the difference in speed of using builtin functions and port manipulation(Taken fromthis arduino forumquestion)

pinMode(5,OUTPUT);// takes 71 clock cycles (~4.430us@16Mhz)DDRD |=0b00010000;// takes  2 clock cycles (~0.125us@16Mhz)bitSet(PORTD,5,1);// takes  2 clock cycles (~0.125us@16Mhz)

Also assigning the new value to the port allow for multiple ports to be updatedon a single statement, for example turning on both pin 4 and 5 at the same timecan be done with the following statement

DDRD |=0b00011000;

For more information I suggest readingArduino Reference on PortManipulation

About

Convert digital output of arduino to analog with an R2R ladder

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp