master1auto / ADC

1 stars 1 forks source link

adc #1

Open zakariarz opened 8 years ago

zakariarz commented 8 years ago

salam ostad ana zakaria rizoug zeghlache 7abit nssakssik 3la mini projet ta3na adc 1/ ki ndir d'un capteur de temperature relier a l'entrée RA2 du pic16f887 ih ou mba3ad wach ndir fi lprogramme 2/ yafichie ficheur LCD walla kifah 3/ le rolle ta3 plrogram hada wchih ?

ucm1auto commented 8 years ago

salam -pour toi , utiliser un potentiomètre pour simuler une sortie d'un capteur de temperature. -afficher le résultat en utilisant des LEDs connectées au portb et portc. -le role, j'attends la réponse nta3ak.

zakariarz commented 8 years ago

safai nkhdam le program ou nab3atlk simulation ta3 proteus ou C ?

ucm1auto commented 8 years ago

le programme hatou hna fi github. w zid ab3atli proteus fi email.

ucm1auto commented 8 years ago

yakhi fhamte mlih kifah dir fi programme.

ucm1auto commented 8 years ago

rani b3atlak invitation ta3 github.

zakariarz commented 8 years ago

ok . lbut hada nagdar nossallo mi manich 3arf kifah ndiro sont instruction ADC

zakariarz commented 8 years ago

perdon mi win ndir accept ? walla win nalgaha ?

ucm1auto commented 8 years ago

this link will help you https://electrosome.com/adc-pic-microcontroller-hi-tech-c/

ucm1auto commented 8 years ago

rahou jak email aftah le premier lien w dir join.

zakariarz commented 8 years ago

ani dirtak ami fi lemail li b3atli bih psk mawssalni wallo

ucm1auto commented 8 years ago

??? normalement jak email?

zakariarz commented 8 years ago

mi limail wssalni ou fiha la cum hadi ba3d

ucm1auto commented 8 years ago

??????

zakariarz commented 8 years ago

image hada wach djani fi imail ta3i

ucm1auto commented 8 years ago

chouf fi email li dart bih compte ta3 github

zakariarz commented 8 years ago

makayn wallo fih !!!?

ucm1auto commented 8 years ago

15

zakariarz commented 8 years ago

ih lgito ani dkhalt fih ^_^

ucm1auto commented 8 years ago

now you can edit the mini_project.c file on github

zakariarz commented 8 years ago

ana dorka rani m3ah mi 7ssalt fii 2 erreur nab3tlk tchofo ?

zakariarz commented 8 years ago

ila rani fi tarik alsa7i7 ?

ucm1auto commented 8 years ago

ok

zakariarz commented 8 years ago

void main() { float reading, act_reading; char disp [10]; trisa =1 ; porta = 0 ; trisb = 0 ; portb = 0 ; trisc = 0 ; portc = 0; trisd = 0 ; portd = 0 ; // initialize a0 as analog input adcon1 = 0b1110;

 // lcd intructions
 lcd_init(&portb);
 lcd_Cmd (lcd_cursor_Off);

 // gatting the reading
 reading = Adc_Read(2);
 act_reading =(reading*5)/1024;

 // converting
 floattostr(act_readnig, disp);

 //displaying
 lcd_out(1, 1, disp);

}

ucm1auto commented 8 years ago

you still use adc read

zakariarz commented 8 years ago

ana krit manual li b3ato ou 3labali bali takhdam prencip de 100%=5v ou 0%=0v mi kifah ndirha ? i have no idea

ucm1auto commented 8 years ago

ok, tomorrow incha alah, i will try to help you.

zakariarz commented 8 years ago

thank's , the port analogic i do't know how to work's with

zakariarz commented 8 years ago

salam oustad i realy need your help

ucm1auto commented 8 years ago

ok, could you wait me around 30min?

zakariarz commented 8 years ago

Yes of course

ucm1auto commented 8 years ago

well, did you solve your problem

zakariarz commented 8 years ago

no.

zakariarz commented 8 years ago

man lbar7 malgit wallo jadide

ucm1auto commented 8 years ago

lien li mditholak ma dart bih walou

zakariarz commented 8 years ago

lien hadak fih la frequence de echantiellen ta adc ou les rgister et ladrass taw3o

zakariarz commented 8 years ago

mi bwach nagdar nromplacer adc b base instruction ma3labalich kifah

ucm1auto commented 8 years ago

void ADC_Init() { ADCON0 = 0x41; //ADC Module Turned ON and Clock is selected ADCON1 = 0xC0; //All pins as Analog Input //With reference voltages VDD and VSS }

unsigned int ADC_Read(unsigned char channel) { if(channel > 7) //If Invalid channel selected return 0; //Return 0

ADCON0 &= 0xC5; //Clearing the Channel Selection Bits ADCON0 |= channel<<3; //Setting the required Bits __delay_ms(2); //Acquisition time to charge hold capacitor GO_nDONE = 1; //Initializes A/D Conversion while(GO_nDONE); //Wait for A/D Conversion to complete return ((ADRESH<<8)+ADRESL); //Returns Result }

void main() { unsigned int a; TRISB = 0x00; //PORTB as output TRISC = 0x00; //PORTC as output TRISA = 0xFF; //PORTA as input ADC_Init(); //Initializes ADC Module

do { a = ADC_Read(0); //Reading Analog Channel 0 PORTB = a; //Lower 8 bits to PORTB PORTC = a>>8; //Higher 2 bits to PORTC __delay_ms(100); //Delay }while(1); //Infinite Loop } hada modifih chwiya bark

ucm1auto commented 8 years ago

ADCON0 ,ADCON1 to initialize the ADC module

ucm1auto commented 8 years ago

In order to measure voltage on an input pin by the A/D converter, the following should be done:

Step 1 - Port configuration:

Write a logic one (1) to a bit of the TRIS register, thus configuring the appropriate pin as an input.
Write a logic one (1) to a bit of the ANSEL register, thus configuring the appropriate pin as an analog input.

Step 2 - ADC module configuration:

Configure voltage reference in the ADCON1 register.
Select ADC conversion clock in the ADCON0 register.
Select one of input channels CH0-CH13 of the ADCON0 register.
Select data format using the ADFM bit of the ADCON1 register.
Enable A/D converter by setting the ADON bit of the ADCON0 register.

Step 3 - ADC interrupt configuration (optionally):

Clear the ADIF bit.
Set the ADIE, PEIE and GIE bits.

Step 4 - Wait for the required acquisition time to pass (approximately 20uS).

Step 5 - Start conversion by setting the GO/DONE bit of the ADCON0 register.

Step 6 - Wait for ADC conversion to complete.

It is necessary to check in the program loop whether the GO/DONE pin is cleared or wait for an A/D interrupt (must be previously enabled).

Step 7 - Read ADC results:

Read the ADRESH and ADRESL registers.
zakariarz commented 8 years ago

ou step 7 had linsruction ma3lich ndiroha ? Read ADC

zakariarz commented 8 years ago

slm void ADC_Init() { ADCON0 = 0x41; //ADC Module Turned ON and Clock is sele cted ADCON1 = 0xC0; //All pins as Analog Input //With reference voltages VDD and VSS } unsigned int ADC_Read(unsigned char channel) { if(channel > 7) //If Invalid channel selected return 0; //Return 0

ADCON0 &= 0xC5; //Clearing the Channel Selection Bits ADCON0 |= channel<<3; //Setting the required Bits delay_ms(2); //Acquisition time to charge hold capacitor GO_nDONE = 1; //Initializes A/D Conversion while(GO_nDONE); //Wait for A/D Conversion to complete return ((ADRESH<<8)+ADRESL); //Returns Result }

void main() { unsigned int a; TRISB = 0x00; //PORTB as output TRISC = 0x00; //PORTC as output TRISA = 0xFF; //PORTA as input ADC_Init(); //Initializes ADC Module

do { a = ADC_Read(0); //Reading Analog Channel 0 PORTB = a; //Lower 8 bits to PORTB PORTC = a>>8; //Higher 2 bits to PORTC delay_ms(100); //Delay }while(1); //Infinite Loop }

chfli win galt nbadl

ucm1auto commented 8 years ago

I will check it , but it looks wright in general.

zakariarz commented 8 years ago

ou chikh ani 7ab nagra 3la lfikra li dirtha bal kamira li tcommender fi quadro , wach ismha ou ila chkon li khir ndirha b matlab walla c++. , wach tanssa7ni , psk gotlk bali ra7 ndir mimoir ma3 djma3a 3la détction obstacl dynamique

ucm1auto commented 8 years ago

Check the go done bit

zakariarz commented 8 years ago

void ADC_Init() { ADCON0 = 0x41; //ADC Module Turned ON and Clock is sele cted ADCON1 = 0xC0; //All pins as Analog Input //With reference voltages VDD and VSS } unsigned int ADC_Read(unsigned char channel) { if(channel > 7) //If Invalid channel selected return 0; //Return 0

ADCON0 &= 0xC5; //Clearing the Channel Selection Bits ADCON0 |= channel<<3; //Setting the required Bits delay_ms(2); //Acquisition time to charge hold capacitor ADCON0, GO = 1; //Initializes A/D Conversion while(ADCON0, GO); //Wait for A/D Conversion to complete return ((ADRESH<<8)+ADRESL); //Returns Result }

void main() { unsigned int a; TRISB = 0x00; //PORTB as output TRISC = 0x00; //PORTC as output TRISA = 0xFF; //PORTA as input ADC_Init(); //Initializes ADC Module

do { a = ADC_Read(0); //Reading Analog Channel 0 PORTB = a; //Lower 8 bits to PORTB PORTC = a>>8; //Higher 2 bits to PORTC delay_ms(100); //Delay }while(1); //Infinite Loop }

haka s7i7a ?