Nano DAC-ADC

Download required update
Download required samples

The Arduino Nano is used in this tutorial to build a basic Analog2Digital and Digital2Analog conversion. The Arduino Nano is placed on a breadboard and connected to Caspoc via an USB cable.

Configuration

First the configuration is designed. This can be done in Caspoc, to get an overview about the placement of components on the breadbaord. A typical configuration, using a potentiometer and LED is build using the Half+ breadboard model in Caspoc

<br>Click to close the image

Build the breadboard

The breadboard is assembled around the Arduino Nano. Components are connected to the Nano.

<br>Click to close the image

Test the set-up in simulation

The set-up can be tested in Caspoc, before connecting to the Arduino Nano. Add the Nano-DAC-ADC library block to the workscreen and connect the Tx and Rx wires to the Nano library block. In the example simulation a blockdiagram block KEY(enter text1="R" as parameter) is connected to the first Digital output pin D2. Pressing the "R" on the keyboard during simulation/animation, will light up the LED on the breadboard.

The analog pins A0 and A1 of the Arduino Nano are connected to two potentiometers. The voltages of the two potentiometers are measured and displayed on the Digital Multimeters. The sampled voltage is output at the Nano-DAC-ADC library block and is numerically displayed in the simulation.

<br>Click to close the image

Run the set-up and the Arduino Nano

Connect an USB cable between the Arduino and the PC. To find out the correct port, you can either look in the Arduino development environment, or in the Windows "Device Manager"

<br>Click to close the image

A SerialPort block from Components/BlocksCoSimulation is selected and placed between the Rx and Tx connections of the Nano-DAC-ADC library block. The port number as found in the "Device Manager" and the baudrate have to be set inside the SerialPort block. A typical baudrate is 38400 and should be equal to the baudrate in the Arduino Code.

<br>Click to close the image

If the Arduino Nano is loaded with the correct Arduino script (same filename as the library block "Arduino-Nano-DAC-ADC.ino"), the Arduino Nano ccan be controlled via Caspoc.Start the simulation and observe the measured voltage on the analog pins A0 and A1 and control the LED by pressing the "R" key during the simulation, to turn on the LED connected to the Digital output pin D2.

<br>Click to close the image

The Digital output pins D3,D5,D6,D9,D10,D11 are PWM pins. The input in Caspoc controls the dutycycle at these pins. A value of 255 at the input pin corresponds to a 100% dutycycle. Pins D2,D4,D7,D8,D12 and D13 are digital pins. A numerical value larger than 0 will make these pins HIGH, otherwise LOW.

The voltages at the analog pins A0,A1,A2,A3,A4,A5,A6 and A7 are measured and are available as numerical values at the output A0 to A7 in the block Nano-DAC-ADC. A measured voltage between zero and the voltage at pin Vref(5Volt) of the Arduino Nano, is given as a numerical value between 0 and 1023.

<br>Click to close the image The Arduino Nano is capable to follow time-varying signals with a bandwidth up to 10Hz, depending on the size of the model in Caspoc.

video 1


video 2

© 2024 CASPOC, All rights reserved. Home   |   Terms and Conditions   |   Legal   |   Export Compliance   |   Privacy Policy   |   Site Map