سلام بچه ها..... من یه مشکلی با این adc 16 بیتی(ad7715) دارم.... تقریبا راش انداختم ولی اعداد روی lcd بین 0 تا 65535 پرش داره.... کسی میتونه کمکم کنه.....؟ یه سوال دیگه هم دارم در مورد ad7710..کسی تا حالا راش انداخته....؟آقای نجفی میشه در این مورد کمک کنید....؟
اطلاعیه
Collapse
No announcement yet.
Ad7715و ad7710
Collapse
X
-
پاسخ : Ad7715و ad7710
پرش رو از چند راه میتونی بگیری:
***1.سرعت نمونه برداری رو پاین بیاری حتی تو خود برنامه میکرو.
2.زمین آنالوگ و دیجیتال رو جدا کن و در آخرین مرحله به هم با یم سیم متصل کن.
3.از فیلتر استفاده کن.
4.رو قسمت نویز گیری تو دیتا شیت AD7715 بیشتر وقت بزارخدا گفت : به جهنم ببریدش، او برگشت و با تعجب به خدا نگاه کرد. خدا گفت : به بهشت ببریدش. فرشتگان پرسیدند: چرا؟! خدا گفت : او هنوز به من امیدوار است...
-
پاسخ : Ad7715و ad7710
من راه انداختم
شما هم اطلاعات کامل و نحوه راه اندازی 7715 رو بزار با توضیحات
PORTD=0x00;
DDRD=0xF0;
///////////////////////////////////////////7710 /////////////////////
unsigned int con[24];//={0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1} ,i;
void export(void)
{
unsigned int i;
PORTD.7=0; //A0
PORTD.4=0;//RFS
for(i=0;i<24;++i)
{
delay_us(10);
PORTD.6=0;//CLK
delay_us(10);
PORTD.6=1 ;//CLK
con[i]=PIND.2;//data
};
PORTD.4=1;//RFS
PORTD.7=1; //A0
}
////////////////////////////////////////7710 Zero/////////////////////////////
void zero(void)
{
unsigned int i;
con[0]=1;con[1]=0;con[2]=1;con[3]=1;con[4]=1;con[5]=0; //gain & Zero
con[6]=0;con[7]=0;con[8]=0;con[9]=0;con[10]=0;con[11]=0;
PORTD.6=0;//CLK
PORTD.7=0; //A0
PORTD.5=0;//TFS
DDRD=0xF4;
for(i=0;i<24;++i)
{
PORTD.2=con[i];//data
delay_us(10);
PORTD.6=1;//CLK
delay_us(10);
PORTD.6=0 ;//CLK
};
DDRD=0xF0;
//while(PIND.3==1);//DRDY
}
PORTD.4=1;//RFS
PORTD.5=1;//TFS
PORTD.7=1; //A0
export();
zero();
PORTD.4=1;//RFS
PORTD.5=1;//TFS
PORTD.7=1; //A0
while (1)
{
/////////////////////////////////////////////////////////////
if(PIND.3==0){ //DRDY
delay_us(10);
PORTD.7=1; //A0
delay_us(10);
PORTD.4=0;//RFS
delay_us(10);
for(i=0;i<16;++i)
{
delay_us(10);
PORTD.6=0;//CLK
delay_us(10);
PORTD.6=1 ;//CLK
thermo[i]=PIND.2;//Data
};
PORTD.4=1;//RFS
PORTD.7=0; //A0
bhh=thermo[1]*64+thermo[2]*32+thermo[3]*16+thermo[4]*8+thermo[5]*4+thermo[6]*2+thermo[7];
bh=thermo[8]*128+thermo[9]*64+thermo[10]*32+thermo[11]*16+thermo[12]*8+thermo[13]*4+thermo[14]*2+thermo[15];
if(thermo[0]==1){bhh=127-bhh;bh=255-bh;}
zero();
PORTD.4=1;//RFS
PORTD.5=1;//TFS
PORTD.7=1; //A0
export();
th=(bhh*256+bh);
if(thermo[0]==1) th=th*-1;
};
// lcd_gotoxy(0,2);
// sprintf(buff,"%2.3f",th);
// lcd_puts(buff);
//////////////////////////////////////////////////////////////////////////
دیدگاه
-
پاسخ : Ad7715و ad7710
ممنون از لطفتون.......من برنامه رو می زارم ولی هنوز مشکله پرش اعداد رو بر طرف نکردم.....هر موقع کامل شد دوباره میزارم.....راستی میشه در مورد سخت افزار ad7710 اگه نکته ای هست بگین...؟ بازم ممنون......
/************************************************** ***
This program was produced by the
CodeWizardAVR V1.24.6 Professional
Automatic Program Generator
© Copyright 1998-2005 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
e-mailffice@hpinfotech.com
Project :
Version :
Date : 2007/08/09
Author : F4CG
Company : F4CG
Comments:
Chip type : ATmega32
Program type : Application
Clock frequency : 16.000000 MHz
Memory model : Small
External SRAM size : 0
Data Stack size : 512
************************************************** ***/
#include <mega32.h>
#include <delay.h>
#include <stdio.h>
#include <stdlib.h>
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x12 ;PORTD
#endasm
#include <lcd.h>
// SPI functions
#include <spi.h>
#define ADC_RESET PORTB.1
#define ADC_CS PORTB.3
#define ADC_DRDY PINB.0
#define high 1
#define low 0
void adc_init(void);
unsigned int read_spi();
char lcd[16];
// Declare your global variables here
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port A initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTA=0x00;
DDRA=0x00;
// Port B initialization
// Func7=Out Func6=In Func5=Out Func4=Out Func3=In Func2=In Func1=In Func0=In
// State7=0 State6=T State5=0 State4=0 State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0xB0;
// Port C initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTC=0x00;
DDRC=0x00;
// Port D initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;
// SPI initialization
// SPI Type: Master
// SPI Clock Rate: 1000.000 kHz
// SPI Clock Phase: Cycle Start
// SPI Clock Polarity: High
// SPI Data Order: MSB First
SPCR=0x5D;
SPSR=0x00;
// LCD module initialization
lcd_init(16);
while (1)
{
adc_init();
while(1)
{
float resultf;
char data[16];
lcd_clear();
lcd_gotoxy(5,0);
lcd_putsf("DATA:"
lcd_gotoxy(3,1);
resultf=read_spi();
ftoa(resultf,2,data);
// sprintf(lcd," %s",data);
lcd_puts(data);
delay_ms(500) ;
}
};
}
void adc_init(void)
{
lcd_clear();
lcd_gotoxy(3,0);
lcd_putsf("Please wait"
ADC_RESET=low;
ADC_CS=low; //Set low to AD7715 chip select low pin
ADC_RESET=high; //Set high to AD7715 reset low pin
ADC_CS=high;
delay_ms(3000);
ADC_CS=low;
spi( 0x10 );
ADC_CS=high;
ADC_CS=low; //Communications Register
spi( 0x74); //250Hz update rate
ADC_CS=high; //Setup Register info here
lcd_gotoxy(3,1);
lcd_putsf("Calibrated"
delay_ms(1000);
lcd_clear();
}
unsigned int read_spi()
{
unsigned result;
while ( ADC_DRDY);
while (! ADC_DRDY );
while ( ADC_DRDY );
ADC_CS=low;
spi(0x38);
ADC_CS=high;
ADC_CS=low;
result=(unsigned) spi(0)<<8;
ADC_CS=low;
result|=spi(0);
result=(unsigned) ((unsigned long) result);
return result;
}
دیدگاه
-
پاسخ : Ad7715و ad7710
سلام آقا ایمان....واقعا از توجهتون ممنون.....
من شرمندم که شماتیکی از مدار ندارم ولی ترتیب پایه هایی که وصل کردم رو براتون مینویسم.....
پایه ad7715 atmega32
1 sclk به PORTB.7
2و3 کریستال 2.4576
4 CS به PORTB.3
5 RESET به PORTB.1
6 +5
7و8 ورودی آنالوگ
9 +2.5
10 GND
11 GND
12 DRDY به PORTB.0
13 DOUT به PORTB.6
14 DIN به PORTB.5
15 +5
16 GND
برای تغذیه ها هم خازن های صافی (100nf و 10uf) گذاشتم
اگه دیتا شیت AD7715 رو ندارید بگید تا براتون بفرستم..... بازم از لطفتون ممنون
دیدگاه
دیدگاه