View previous topic :: View next topic |
Author |
Message |
oanguloc
Joined: 02 Jul 2012 Posts: 3
|
MAX517 DAC |
Posted: Mon Jul 02, 2012 12:39 pm |
|
|
I'm trying to make a DAC using a MAX517 with PIC18F6622. Could somebody provide me with a working code? |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Jul 02, 2012 3:19 pm |
|
|
Hi,
Setup your I2C communications like this:
Code: |
#define MAX517_SCL PIN_A0 // Serial Clock signal to the MAX517
#define MAX517_SDA PIN_A1 // Serial Data signal to the MAX51
//-----< I2C Port Definition >-----
#use i2c(master, sda=MAX517_SDA, scl=MAX517_SCL, FAST)
|
Use whatever I/O pins you want, and be sure to use appropriate pull-up resistors on the SCL ans SDA lines. 4.7K works well.
and send data to the MAX517 like this:
Code: |
write_dac(128); //set D/A to 2.5V
|
Here is the subroutine that controls the MAX517:
Code: |
// This routine receives a byte from Main, and sends it out to the MAX517
// D-to-A converter. The range of the input is 0 to 255, which corresponds
// to an output voltage of 0 to 5V.
void write_dac(int data_out)
{
i2c_start();
i2c_write(0x58); // Device address when AD0 and AD1 are tied to ground
i2c_write(0);
i2c_write(data_out); // Send the data to the device
i2c_stop();
}
|
Good Luck!
John
Last edited by ezflyr on Mon Jul 02, 2012 8:12 pm; edited 1 time in total |
|
|
oanguloc
Joined: 02 Jul 2012 Posts: 3
|
|
Posted: Mon Jul 02, 2012 3:54 pm |
|
|
Thank you very, John. It is nice found people like you. |
|
|
|