_____________________________________________________________________________________ Rev 1.01 rev.1.01 145 Rt. 46 West E‐mail: sales@electro‐set.net Wayne, NJ 07470 Web: www.Electro‐Set.net 1 CB-028 12-Bit D/A Converter Module September 04, 2014 Introduction This application note will show two minimal code set ups to operate the 12-bit D/A converter module CB-028 one with an Arduino board and the other with Cardinal’s CB-026 Microchip microcontroller module. The CB-028 has two output terminals, ground and the D/A output to which can be connected to a voltmeter or oscilloscope to observe the module’s output. Arduino The Arduino example will take consecutive values from an array and output them to the D/A converter. The array is initialized as a sine table. These values are also be presented to the Arduino serial monitor port. Before proceeding any further, please have the Arduino software install to your computer. Visit Arduino’s user setup guide at http://arduino.cc/en/Guide/windows for step-by-step instructions. Hardware Parts List: Arduino Uno USB type B connector CB-I-022 Cardinal Interface Board CB-028 D/A converter module
10
Embed
CB-028 12-Bit D/A Converter Module - Jameco Electronics · Arduino Uno. A voltmeter can then be connected to the two terminals of the CB-028 module. ... CB-028 12-bit D/A converter
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
r e v . 1 . 0 1 145 Rt. 46 West E‐mail: sales@electro‐set.net Wayne, NJ 07470 Web: www.Electro‐Set.net
1
CB-028 12-Bit D/A Converter Module
September 04, 2014
Introduction
This application note will show two minimal code set ups to operate the 12-bit D/A converter module CB-028 one with an Arduino board and the other with Cardinal’s CB-026 Microchip microcontroller module.
The CB-028 has two output terminals, ground and the D/A output to which can be connected to a voltmeter or oscilloscope to observe the module’s output.
Arduino
The Arduino example will take consecutive values from an array and output them to the D/A converter. The array is initialized as a sine table. These values are also be presented to the Arduino serial monitor port.
Before proceeding any further, please have the Arduino software install to your computer. Visit Arduino’s user setup guide at http://arduino.cc/en/Guide/windows for step-by-step instructions.
Hardware
Parts List:
Arduino Uno USB type B connector CB-I-022 Cardinal Interface Board CB-028 D/A converter module
r e v . 1 . 0 1 145 Rt. 46 West E‐mail: sales@electro‐set.net Wayne, NJ 07470 Web: www.Electro‐Set.net
2
Connect the components as shown in the picture below
Plug the CB-I-022 interface into the Arduino Uno board and the CB-028 D/A module into the interface’s Electro-Set 6 pin connector. Connect the USB cable between the computer and the Arduino Uno. A voltmeter can then be connected to the two terminals of the CB-028 module.
The computer will supply 5 volts through the USB cable which will be regulated on the Arduino interface board to 3.3 volts to run the CB-028 D/A module. The D/A module has an onboard 2.5 volt reference regulator which we will configure the D/A to use.
Two jumpers on the CB-028 can be used to change the slave address of the D/A. For this code we are using 0x10 as the 7-bit slave address so the two jumper should be populated towards the boards male connector as shown in the picture above.
r e v . 1 . 0 1 145 Rt. 46 West E‐mail: sales@electro‐set.net Wayne, NJ 07470 Web: www.Electro‐Set.net
5
The setup() function is called when a sketch starts. The setup code, initializes the serial monitor baud rate at 9600, outputs a welcome message and then initializes the I2C port as a master. The D/A is also initialized to use the external on board reference by writing 0x70 as the command byte, which is the first of 3 bytes in an I2C write to the D/A. See the chip datasheet for more information.
.
After setup has completed sketch causes the function loop() to be repeatedly called.
The variable ‘index’ is used to access through the sine array sequentially. The integer sine value retrieved is split into two byte which are written into the D/A with the command byte 0x30. This command byte causes the two data byte to be written to the D/A input register and the D/A output to be updated with the new value.
A delay of 200mS helps aloow the output from the D/A to be observed which will change between 0 volts for a data code of 0x000 to the reference voltage of 2.5 volts for a data code of 0xfff0.
The index is incremented each time around the loop and tested for a value of greater than or equal to 200, which indicated the index has passed the end of the array and is wrapped back to zero to repeat the sequence again.
As compiled on Arduino 1.0.5 r2 and with the delay(200) and Serial.print lines commented out, the loop function take 432uS to complete. With 120 data points in one sine cycle the output sinusoidal period will be 0.432*120mS or
r e v . 1 . 0 1 145 Rt. 46 West E‐mail: sales@electro‐set.net Wayne, NJ 07470 Web: www.Electro‐Set.net
6
51.8mS.
Microchip Module CB-026
The CB-026 example in PICBASIC PRO will write digital values to the D/A converter to form a saw tooth waveform and also output the values via the serial port to a terminal emulator such as hyperterminal.
Before proceeding any further, please have the MicroCode Studio PICBASIC PRO suite installed on your computer.
includes configuration for the programmer in the output hex file so it does not necessary to manually change the entries in the programmer configuration window every time you come to write a new version of your program to the microcontroller.
The port pins for the I2C interface are set on PORTC pins 3 and 4. The CB-026 board wires these to the Electro-Set 6 pin connector.
The microcontroller serial port pins are set on PORTC pins 6 and 7, these connect to the FTDI chip on the CB-026 which couples through to the USB and so when plugged into a PC producing a virtual COMM port where the microcontroller’s serial data can be seen on a terminal emulator such as hyperterminal. The terminal emulator should be set to connect to the virtual COMM port assigned to the FTDI driver and connect at 38400,8,N,1.
We declare the variable baud1 for use in the serout2 to set the baud rate. For a baud rate of 38400, baud1 is set to 6, see the MicroChip documentation for other rates and options.
The first parameters for the PicBasicPro functions i2cread and i2cwrite uses and 8-bit slave address which is a one bit left shift of the 7-bit slave address, so the D/A module’s 8-bit slave address is 0x20.
The line
i2cwrite sda,scl,$20,[$70],nodata
initializes the D/A to use its external reference pin, which is supplied by the 2.5 volt regulator on the CB-028 module.
Next the welcome messages are sent out the serial port.
The for loop causes the variable ‘testword’ to increase from low to high. On each iteration of the for loop the value of ‘testword’ is written to the D/A’s internal register address 0x30 causing the D/A’s output to change accordingly, rising from low to high.