PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : کمک برای ساخت driver ad799.c



novintablo
22-12-2009, 22:25
سلام

ad7799 یک ای سی خیلی جالبی که هم ولتاژ ورددی تقویت میکنه و هم تبدیل به دیجیتال میکنه(24bit)
لطفا"کمک کنید این آی سی راه اندازی کنیم تا دیگرانم بتونن استفاده کنن.
قیمتشم حدود 10000تومان
اینم دیتاشیتش


You can see links before reply

mehrdadgh
28-12-2009, 21:14
سلام

پیشنهاد می کنم شما دست به کار شید و ما هم کمکتون میکنیم ( البته اگه سوادمون قد بده )

اگه با adc خارجی کار نگکردی تو وب مطالب خوبی میتونی پیدا کنی ، بهتره اول اونا رو انجام بدین بعد بریم سراغ 24 بیت !

novintablo
29-12-2009, 23:20
#include <18F452.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

// SPI chip select pin
#define AD7799_CS PIN_C0

// SPI mode definitions (for 16F and 18F PICs).
#define SPI_MODE_0 (SPI_L_TO_H | SPI_XMIT_L_TO_H)
#define SPI_MODE_1 (SPI_L_TO_H)
#define SPI_MODE_2 (SPI_H_TO_L)
#define SPI_MODE_3 (SPI_H_TO_L | SPI_XMIT_L_TO_H)

// AD7799 commands
#define AD7799_READ_DATA_CMD 0x58
#define AD7799_WRITE_CONFIG_CMD 0x10

//---------------------------------------
// Call this function to read the 24-bit A/D result
// from the AD7799.
int32 ad7799_read_data(void)
{
int32 retval;
int8 msb, mid, lsb;

output_low(AD7799_CS);
spi_write(AD7799_READ_DATA_CMD);
msb = spi_read(0); // Data comes out MSB first
mid = spi_read(0);
lsb = spi_read(0);
output_high(AD7799_CS);

// Convert the data bytes into a 32-bit value.
retval = make32(0, msb, mid, lsb);

return(retval);
}

//---------------------------------------
// Call this function to write a 16-bit value
// to the AD7799 Configuration register.
void ad7799_write_config(int16 config)
{
output_low(AD7799_CS);
spi_write(AD7799_WRITE_CONFIG_CMD);
spi_write(config >> 8); // Write MSB first
spi_write(config); // then write the LSB
output_high(AD7799_CS);
}

//---------------------------------------
// Setup the hardware SPI module in the PIC.
// The AD7799 uses SPI mode 3. The maximum SPI clock
// rate is 2.5 MHz. For a 20 MHz PIC, the closest
// clock divisor that will work is 16, giving 1.25 MHz.
// Initialize the chip select pin to the inactive state.
// Do the required 500 ms initial delay mentioned on
// page 19 of the AD7799 data sheet.
void ad7799_init(void)
{
setup_spi(SPI_MASTER | SPI_MODE_3 | SPI_CLK_DIV_16);

output_high(AD7799_CS);

delay_ms(500); // Startup delay

// Channel = 0, Gain Select = 0, Unipolar, 2.5v input range
ad7799_write_config(0x0010);
}

//====================================
void main()
{
int32 result;

ad7799_init();

// Read the AD7799 every 500ms and display the result.
while(1)
{
result = ad7799_read_data(); // Get 24-bit A/D value
printf("%lx \n\r", result);
delay_ms(500);
}

}[hr]
هنوز این برنامه تست نکردم.اگر ایرادی تو برنامه هست بگید

mehrdadgh
30-12-2009, 12:48
سلام

بنده سی کار نمی کنم

باید سعید یه نفر رو ببینین !