Open zakariarz opened 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.
safai nkhdam le program ou nab3atlk simulation ta3 proteus ou C ?
le programme hatou hna fi github. w zid ab3atli proteus fi email.
yakhi fhamte mlih kifah dir fi programme.
rani b3atlak invitation ta3 github.
ok . lbut hada nagdar nossallo mi manich 3arf kifah ndiro sont instruction ADC
perdon mi win ndir accept ? walla win nalgaha ?
this link will help you https://electrosome.com/adc-pic-microcontroller-hi-tech-c/
rahou jak email aftah le premier lien w dir join.
ani dirtak ami fi lemail li b3atli bih psk mawssalni wallo
??? normalement jak email?
mi limail wssalni ou fiha la cum hadi ba3d
??????
hada wach djani fi imail ta3i
chouf fi email li dart bih compte ta3 github
makayn wallo fih !!!?
ih lgito ani dkhalt fih ^_^
now you can edit the mini_project.c file on github
ana dorka rani m3ah mi 7ssalt fii 2 erreur nab3tlk tchofo ?
ila rani fi tarik alsa7i7 ?
ok
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);
}
you still use adc read
ana krit manual li b3ato ou 3labali bali takhdam prencip de 100%=5v ou 0%=0v mi kifah ndirha ? i have no idea
ok, tomorrow incha alah, i will try to help you.
thank's , the port analogic i do't know how to work's with
salam oustad i realy need your help
ok, could you wait me around 30min?
Yes of course
well, did you solve your problem
no.
man lbar7 malgit wallo jadide
lien li mditholak ma dart bih walou
lien hadak fih la frequence de echantiellen ta adc ou les rgister et ladrass taw3o
mi bwach nagdar nromplacer adc b base instruction ma3labalich kifah
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
ADCON0 ,ADCON1 to initialize the ADC module
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.
ou step 7 had linsruction ma3lich ndiroha ? Read ADC
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
I will check it , but it looks wright in general.
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
Check the go done bit
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 ?
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 ?