Discussion in "Project Help" started by    kira113    Aug 19, 2017.
Sat Aug 19 2017, 08:52 AM
#1
hello everyone
i write a simple program using c language for read analog value from adc0804 then convert that value to three decimal number and then display them on 3 seven_seg but when i compile the program using keil ide i got some error ( like 'multiple public definition ')
can anyone help me with it .
#include <REGX51.H>
sbit cs   = P3^7 ;
sbit WRIT	= P3^5 ;
sbit READ	= P3^6 ;
sbit inter= P3^4 ;
#define adc_port  P1 
#define seg_port  P0 

char ones,tens,hunds,digital_value,rfd;
int table[16]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,0x08,0x03,0x46,0x21,0x06,0x0e};
void conv();
void read_adc();
void delay_us(int);
void delay_ms(int);
void delay_sec( char);
void div23dig(char);
void disp ( char , char, char );
void main(){
							
							adc_port = 0xff	;		//init adc_Port as input
									P0 = 0X0			;//init p0 as output
									P3= 0x10		;	//init p3.4 as input
								while(1){
									
									
										conv();
										read_adc();
										div23dig(digital_value);
									  disp(ones,tens,hunds);
										delay_sec(1);
									 
										
												}
            }

void conv()
	{
		cs=0;
		WRIT=0;
		WRIT=1;
		cs=1;
		while(inter);
	}

void read_adc()
	{
			cs=0;
			READ=0;
			digital_value=adc_port;
			READ=1;
			cs=1;
  }

void delay_us( int us_count)
 {
    while(us_count!=0)
      {
         us_count--;
       }
   }
void delay_ms( int ms_count)
 {
        while(ms_count!=0)
         {
            delay_us(112);   /*delay_us is called to generate 1ms delay*/
             ms_count--;
            }
   }
void delay_sec( char sec_count)
 {

     while(sec_count!=0)
      {
         delay_ms(1000);    /*delay_ms is called to generate 1sec delay*/
         sec_count--;
        }
 }
void div23dig(char x )
 { 
		hunds= digital_value/100 ;
		rfd = digital_value%100 ;
	  tens = rfd/10;
		ones = rfd%10;
	
 }
void disp ( char x , char y ,char z )
 {  char i; 
		i = table[ones] ;
	  seg_port = i ;
	  P2=P2|1;
	  delay_ms(16);
		P2=P2&254;
	  i=table[tens];
	 seg_port=i;
	  P2=P2|2;
		delay_ms(16);
	   P2=P2&253;
		i= table[hunds];
	  seg_port=i;
	  P2=P2|4;
		delay_ms(16);
	  P2=P2&251;
 
 }



[ Edited Wed Aug 23 2017, 01:26 PM ]
Sun Aug 20 2017, 08:31 PM
#2

"when i compile the program using keil ide i got some error
( like 'multiple public definition ')"

When asking for help, giving the exact error message is important.
It is better to zip and post your full code,
as copying off the web page is not 100% successful.

I tried your code and got unused variables warnings for call
"void disp ( char x , char y ,char z )"
x,y and z are not used in the procedure.

I notice you declared it as
"void disp ( char , char, char );" without naming the variables.
That may be legal, but makes it harder to spot errors, as in the case above.


[ Edited Sun Aug 20 2017, 08:35 PM ]
Wed Aug 23 2017, 01:30 PM
#3
It will be easier to help if you can post the complete error message with line number. So we know which line is generating the error.
By the way, it's better to define "table" as const since you're not going to change it but just use it as a reference for digits.
 kira113 like this.
Sun Oct 08 2017, 08:33 PM
#4
actually i solve this problem , and it was just test for my project which is"power meter"
so i could measure the ac voltage and display it on 3 7-seg , and then moved to measure current using CT 1000:1 and it worked very good with some error , but when i tried to merge current and voltage together i used tow adc0804( i could to use adc0808 but the time was very short to do that ) and connect it with same PORT on micro , i will attach the schematic and the code to understand what i'm trying to say so maybe you can help me .
Sun Oct 08 2017, 08:40 PM
#5
these are my schematic and c source file , and i hope to help me because i tried to solve it for two weeks and there is no progress at all
Sun Oct 08 2017, 08:42 PM
#6
https://drive.google.com/open?id=0B_IGcFftMx3fYV9VTmw5dkp2Q2s


[ Edited Sun Oct 08 2017, 08:45 PM ]
Thu Oct 12 2017, 01:04 AM
#7
I don't think the 0804 works as it should in Proteus.
I ended up greatly simplifying your design to get it working.
The good news is that you have a working start point.
Use the virtual serial port in Proteus to print messages to help
with debugging.

Attachment

Get Social

Information

Powered by e107 Forum System

Conversation

Wed Nov 08 2017, 07:05 PM
Anirudh jain
I want to burn code in atmel 89s51 24pc 0329 but cannot get the connection with the burner. Can somebody provide me with the circuit diagram for connecting controller to burner. I'm using usb burner
Thu Nov 02 2017, 05:14 PM
karpal
write a program to exchange the content of b register with external RAM address 02CFH help me
Wed Nov 01 2017, 11:17 PM
sanae
i am using the DHT11 but i'm getting some errors in the simulate the programe in proteus 8 professional,: 1)cannot find model file 'DHTXX.MDF'.2)simulation failed due to netlist linker error(s).
Fri Sep 29 2017, 08:15 AM
Maaz
i am doing the same project on verilog please contact me [email protected]
Wed Sep 20 2017, 06:06 AM
Ted
In a missing pulse detector using a 555 timer connected as a monostable vibrator with a PNP transistor,how does the positve input pulse turn on the PNP transistor?
Sun Sep 03 2017, 07:59 PM
martymarty
How do I connect an <NOKIA 1100 LCD > to an atmega328P ?
poojab51296
Sun Aug 20 2017, 03:53 PM
i am intending to interface sd card with STM32F4 and want to write a file in sd card using SPI protocol but using HAL only. Can anyone help me PLEASE!!!!
poojab51296
Sun Aug 20 2017, 03:52 PM
hello
rawat742
Fri Aug 18 2017, 05:07 PM
hi @ angel patel i will attach a file i hope it will be helpfull for you
ExperimenterUK
Tue Aug 15 2017, 03:27 AM
@ angel patel... just log in and post your problem

Downloads

Comments

Wed Nov 15 2017, 10:46 AM
Ansh12
Sat Nov 11 2017, 03:43 AM
AngelGT93
Fri Nov 10 2017, 06:53 AM
JardCrocker
Wed Nov 08 2017, 05:27 PM
vivitern
Tue Nov 07 2017, 09:08 AM
catrons
Sat Nov 04 2017, 10:46 PM
JFTech
Fri Nov 03 2017, 05:58 AM
Sindhuspoo
Wed Nov 01 2017, 04:32 AM

Online

Guests: 60, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37916
Newest member: [email protected]
Forum Activity
Ansh12 Avatar
Posted By Ansh12
Fri Nov 17 2017, 04:07 AM
I am looking keypad interfacing program. I was rea...
JardCrocker Avatar
Posted By JardCrocker
Wed Nov 08 2017, 05:29 PM
Hi...i am a new user here. I was also facing the s...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Nov 07 2017, 07:13 PM
> It employs a fairly advanced technique to detect...
vivitern Avatar
Posted By vivitern
Tue Nov 07 2017, 09:33 AM
I own a used Clavia ddrum4 SE drum module. It empl...
bvdb Avatar
Posted By bvdb
Wed Oct 18 2017, 01:50 AM
I purchased the RKitL51 8051 C compiler from Raiso...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Oct 16 2017, 11:44 PM
That looks complicated.Is 8051_BLK a standard 80...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sun Oct 15 2017, 07:29 PM
According to this, gmail should support POP3.https...
Help Avatar
Posted By Help
Sun Oct 15 2017, 03:21 AM
AT+POP3READ=? +POP3READ: (1-1460) OK AT+POP3READ=...
ExperimenterUK Avatar
Posted By ExperimenterUK
Sat Oct 14 2017, 08:06 PM
What happens if you ask for the full email ieAT+PO...
Help Avatar
Posted By Help
Sat Oct 14 2017, 02:28 AM
Dear all, AT // OK // 3.1 Bearer profile // Conf...