can somebody help me with the following programs.if possible write comments on all lines.i cannot understand it.The project is a transmitter with adc having 3 inputs.The following is transmitter code.
#include <REGX51.H> // standard 8051 defines #include <stdio.h> // printf #include "adc.h" #include "utils.h" sfr RFPORT = P0; sbit RF1 = P3; sbit BUZZER = P1^6; void main() { BUZZER = 0; // -=-=- Intialise -=-=-= initADC(); // -=-=- Program Loop -=-=-= while(1) { RFPORT = getADC(1); delayms(50); RF1 = 0; delayms(250); RF1 = ADC(1); delayms(1000); RFPORT = getADC(2); delayms(50); RF1= 0; delayms(250); RF1 = ADC(2); delayms(1000); RFPORT = getADC(3); delayms(50); RF1 = 0; delayms(250); RF1 = ADC(3); delayms(1000); } }
and this is the reciever code
#include <REGX51.H> // standard 8051 defines #include <stdio.h> // printf // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-=-=-=- Include files -=-=-=-=-=-=-= // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #include "serialio.h" #include "utils.h" // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-=-=-=- Hardware Defines -=-=-=-=-=-=-= // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sfr RFPORT = 0x80; //P0 sbit BUZZER=P1^5; sbit RF1 = P0; sbit LED = P1^4; // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-=-=-=- Variables -=-=-=-=-=-=-= // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= unsigned char adc1, adc2, adc3, adc4; } // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-=-=-=- Main Program -=-=-=-=-=-=-= // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= void main() { // -=-=- Intialize variables -=-=-= BUZZER = 0; LED = 1; // -=-=- Intialise -=-=-= serialInit(); // -=-=- Program Loop -=-=-= adc1=0; adc2=0;adc3=0; while(1) { if(RF1 == adc1) print ( putchr adc1); { LED = 0; adc1 = ~RFPORT; } if(RF1 == adc2) print ( putchr adc2); { LED = 0; adc1 = ~RFPORT; } if(RF1 == adc3) print ( putchr adc3); { LED = 0; adc1 = ~RFPORT; } }
well actually the one who designed these programs is not willing to help.and i actually wanted an explaination for the same because i;m not familiar with utils.h and adc.h. thz y i posted this here.thx
But you did not even post the code you wasn't familiar with...
the actual questions are what is the use of utils.h. why is delayms used 3 times for 1 adc.
unfamiliar code
RFPORT = getADC(1); delayms(50); RF1 = 0; delayms(250); RF1 = ADC(1); delayms(1000);
also in 2nd program
while(1) { if(RF1 == adc1) print ( putchr adc1); { LED = 0; adc1 = ~RFPORT; }
delayms(50); // Gap Delay? RF1 = 0; // out low (Sync) delayms(250); // low delay RF1 = ADC(1); // output 1 or 0 depending on ADC Channel 1 delayms(1000);// hold output