|
|
View previous topic :: View next topic |
Author |
Message |
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
DAC using MAX 517 |
Posted: Thu Feb 23, 2006 8:12 am |
|
|
Guys..I am using a Max517,,, with the connections as shown....
with the code below....
Code: | #ifndef MAX517_SDA
#define MAX517_SDA PIN_C4
#define MAX517_CLK PIN_C3
#endif
//System Initialisation
#include <18F2525.h> // Call for PIC18F2525 Driver
#device ICD=TRUE
#device ADC=10 // Use 10bits ADC
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=16000000) // 16Mhz Crystal is Used
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8) // RS232 Configuration for COM Port Communication
#use i2c(master, sda=MAX517_SDA, scl=MAX517_CLK, FAST)
//#define use_portb_lcd TRUE // Using Port B for LCD Display
//#include <lcdmod.c> // Initialise Modified LCD to suit
//#byte PORTB = 0xf81
//#byte PORTC = 0xf82
#include <stdlib.h>
#include <math.h>
void write_dac(int data_byte);
//Start main program
void main()
{
int data_byte;
while(1)
{
write_dac(0xFF);
output_high(PIN_B3);
delay_ms(1000);
output_low(PIN_B3);
delay_ms(1000);
printf("\n\r Hello");
write_dac(0x00);
}
//return();
}
void write_dac(int data_byte) {
i2c_start();
i2c_write(0x58);
//i2c_write(0x5e); // Send the address of the device
i2c_write(0);
i2c_write(data_byte); // Send the data to the device
i2c_stop();
}
|
From my OUT0 of DAC,,I am always getting -4.95 V instead of 5V to 0V switching...
Last edited by sonicdeejay on Thu Feb 23, 2006 11:08 pm; edited 1 time in total |
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Thu Feb 23, 2006 11:21 am |
|
|
I might be wrong, but if you have wired the slave address pins as in your drawing, the first byte you are sending should be 0x5A. See fig.6 in the datasheet. |
|
|
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Thu Feb 23, 2006 8:29 pm |
|
|
kender wrote: | I might be wrong, but if you have wired the slave address pins as in your drawing, the first byte you are sending should be 0x5A. See fig.6 in the datasheet. |
thx for the help..but I still can't get it works...
I think something wrong with Resistor Values....
What is the best value for resistors???my connection shown below...
thx guys.,..
Code: |
#include <18F2525.h>
#fuses RC,LVP,NOWDT,NOPROTECT, PUT, NOBROWNOUT
#use delay(clock=1000000)
#use I2C(master, sda=PIN_A1, scl=PIN_A2, FAST)
void main()
{
i2c_start();
i2c_write(0x5A); //It is changed according to my connection....
i2c_write(0);
i2c_write(255); // Send the data to the device
i2c_stop();
while(1);
} //eom
|
looks like PCM programmer doesn't want to help me anymore.. :sad
Last edited by sonicdeejay on Thu Feb 23, 2006 11:10 pm; edited 3 times in total |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1939 Location: Norman, OK
|
|
Posted: Thu Feb 23, 2006 10:13 pm |
|
|
Why are you not using the MAXIM recommended pullup resistor values given in the datasheet schematic? |
|
|
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Thu Feb 23, 2006 11:10 pm |
|
|
dyeatman wrote: | Why are you not using the MAXIM recommended pullup resistor values given in the datasheet schematic? |
may I know which page of datasheet u r refering to??
page 14(Figure 17/18)??? |
|
|
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Fri Feb 24, 2006 3:39 am |
|
|
I have tried the following connection with the code below...(REF0 is 'not connected')
and my code is
Code: |
#include <18F2525.h> // Call for PIC18F2525 Driver
#device ICD=TRUE
#device ADC=10 // Use 10bits ADC
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=16000000) // 16Mhz Crystal is Used
#use rs232(baud=9600, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8) // RS232 Configuration for COM Port Communication
#include <MAX517mod.c>
//Start main program
void main()
{
while(1)
{
output_high(PIN_A0);
delay_ms(5000);
write_dac(0xFF);
output_low(PIN_A0);
delay_ms(5000);
write_dac(0x00);
printf("\n\r Hello");
}
}
|
MAX517mod.c is
Code: |
#ifndef MAX517_SDA
#define MAX517_SDA PIN_C4
#define MAX517_CLK PIN_C3
#endif
#use i2c(master, sda=MAX517_SDA, scl=MAX517_CLK, FAST)
void write_dac(int data_byte) {
i2c_start();
i2c_write(0x58); // AD0 and AD1 are tied to ground
i2c_write(0);
i2c_write(data_byte); // Send the data to the device
i2c_stop();
}
|
and I measure the output0...
When
Code: |
output_high(PIN_A0);
delay_ms(5000);
write_dac(0xFF);
|
My LED ON
My multimeter show 0.009 V as below..
and
When
Code: |
output_low(PIN_A0);
delay_ms(5000);
write_dac(0x00);
|
My LED goes off
My multimeter show 0.010 V
Looks like the DAC output is swtich from state to state but they are not switching from 5V to 0V...Something wrong with the pull-up resistor or any additional components needed lik CAP??
|
|
|
Ttelmah Guest
|
|
Posted: Fri Feb 24, 2006 5:07 am |
|
|
On the 517, the output _reference_, must be connected. This is probably why you are seeing nothing out...
In none of your diagrams, do you actually show the power connections to the chip. Hopefully they are there!.
Change the I2C initialisation, to:
#use i2c(master, sda=MAX517_SDA, scl=MAX517_CLK, FAST=400000)
The latter compilers allow you to specify the rate used for I2C. Some devices now allow rates up to 1MHz, and it may be that the compiler is defaulting to this faster rate, when you don't specify the speed.
The main problem is the lack of an output reference.
Best Wishes |
|
|
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
Posted: Fri Feb 24, 2006 5:45 am |
|
|
Ttelmah wrote: | On the 517, the output _reference_, must be connected. This is probably why you are seeing nothing out...
In none of your diagrams, do you actually show the power connections to the chip. Hopefully they are there!.
Change the I2C initialisation, to:
#use i2c(master, sda=MAX517_SDA, scl=MAX517_CLK, FAST=400000)
The latter compilers allow you to specify the rate used for I2C. Some devices now allow rates up to 1MHz, and it may be that the compiler is defaulting to this faster rate, when you don't specify the speed.
The main problem is the lack of an output reference.
Best Wishes |
I got it working.,,,,
thx guys....
really greatful... |
|
|
sonicdeejay
Joined: 20 Dec 2005 Posts: 112
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|