Discussion in "8051 Discussion Forum" started by    hotzinfo    Sep 18, 2010.
Tue Oct 12 2010, 10:47 am
#41
they r control signal of encoder and decode u have to check that in coding for reliable communication i see ur reeor what ur ding in rx side that is just p1 u move p1 to char but it has extra 4 1's like 11110001 bits so if instruction not works
Tue Oct 12 2010, 10:58 am
#42

u move p1 to char but it has extra 4 1's like 11110001 bits so if instruction not works



I didn't get what u want to say. Please explain. and if possible hint me for Tx and Rx coding.
Tue Oct 12 2010, 11:03 am
#43
i see your Proteus diagram later so comment before
Proteus diagram is ok and ru make it as it is in proteus
why u need noe rx and tx coding now ur communication is of 4 bit perallel not a serial one so now u do not to tx and rx
in parallet there r 2 important signals
in encoder it is E
in decoder it is VT
i am seeing ur coding now and update u here
Tue Oct 12 2010, 11:08 am
#44
check ur rx code this was the error

unsigned char mybyte,


replace it with

unsigned char mybyte;
Tue Oct 12 2010, 12:24 pm
#45
Thankyou mazoka,
i made the silly mistake.Thanks for correcting me.
well when i simulate it on proteus it behaved as expected.
But this code is useful until we press only one switch at a time.
when i pressed two or more switches simultanously , it not behaving as expected.
I want that if i press switch 1 and switch 4 simultaneously, i want both devices (device 1 and device 4) corresponding to switch1 and switch 2 to be turned on.

I know that its coding problem. so please help me to get the following target.
Tue Oct 12 2010, 12:35 pm
#46
hi pash119
here is a description and code what u want now i believe it will run

in encoder HT12E
there is a pin TE when its goes low transmission is enabled u have to control this signal with micro controller also
in decoder HT12D
there is a pin VT means valid transmission it pin is active high mean when a valid data is revived by the reviver then this pins go to high otherwise it is low u have to control this signal with micro controller also

tx code

#include<reg51.h>


void DelayMs(unsigned int);

sbit sw1=P1^0;
sbit sw2=P1^1;
sbit sw3=P1^2;
sbit sw4=P1^3;
sbit sw5=P1^4;
sbit sw6=P1^5;
sbit sw7=P1^6;
sbit sw8=P1^7;
sbit TE = P3^7;		// TE connected to p3.7 

void main()
{
P1=0xFF;
while(1)
{

if(sw1==0)
{
TE=0;
 P2=0x01;
DelayMs(500);
TE=1;

}

else if(sw2==0)
{
TE=0;
 P2=0x02;
DelayMs(500);
TE=1;
}
 else if(sw3==0)
{
TE=0;
P2=0x03;
DelayMs(500);
TE=1;
}
else if(sw4==0)
{
TE=0;
P2=0x04;
DelayMs(500);
TE=1;
}
else if(sw5==0)
{
TE=0;
P2=0x05;
DelayMs(500);
TE=1;
}

else if(sw6==0)
{
TE=0;
P2=0x06;
DelayMs(500);
TE=1;
}
 else if(sw7==0)
{
TE=0;
P2=0x07;
DelayMs(500);
TE=1;
}
 else if(sw8==0)
{
TE=0;
 P2=0x08;
DelayMs(500);
TE=1;
}

}
}


//---------------------------------------
// Delay mS function
//---------------------------------------
void DelayMs(unsigned int count) 
{  // mSec Delay 11.0592 Mhz 
    unsigned int i;		       		// Keil v7.5a 
    while(count) {
        i = 115; 
		while(i>
0) i--;
        count--;
    }
}



if still u get a problem then change delay to 1000 instead of 500 in each if statement it verify that we provide low signal to TE for sufficient time encoder encode the address and data and transmit serially at some baud rate.

rx code


#include<reg51.h>


sbit led1=P1^0;
sbit led2=P1^1;
sbit led3=P1^2;
sbit led4=P1^3;
sbit led5=P1^4;
sbit led6=P1^5;
sbit led7=P1^6;
sbit led8=P1^7;
sbit VT =P3^7;          // VT is connected to p3.7

void main()
{
       unsigned char mybyte;
        P2=0xFF;
        while(1)
        {
		       	while(VT==1);    // wait here for coming data
                         mybyte=P2;

                        if(mybyte==0x01)
                                led1=~led1;
                        else if(mybyte==0x02)
                                led2=~led2;
                        else if(mybyte==0x03)
                                led3=~led3;
                        else if(mybyte==0x04)
                                led4=~led4;
                        else if(mybyte==0x05)
                                led5=~led5;
                        else if(mybyte==0x06)
                                led6=~led6;
                        else if(mybyte==0x07)
                                led7=~led7;
                        else if(mybyte==0x08)
                                led8=~led8;  
			while(VT==0);    // wait here until user release the button at tx side
                     
        }
 	 
}



i invert the pins in coding so 1st time when button is pressed it on the device and next time it off the device.

here is schmetics






[ Edited Tue Oct 12 2010, 12:39 pm ]
Tue Oct 12 2010, 04:08 pm
#47
hi..
i want to simulate in proteus first, but didn't get any HT12E encoder and HT 12D decoder IC model in its library.

how should i simulate the program on that??
Tue Oct 12 2010, 08:41 pm
#48
proteus has not such libraries u have to do it on hardware becoz it is a wireless system and proteus can't do it
try the above program ones then tell what is the response even u can make its hardware if it is working after that any thing can be changed on coding bases.
ur above problem can also be implemented but u first try it it is simple on off individually if it run then we go to complex if directly goon that then it will be difficult to trouble shoot
hop so u understand and will try it
Wed Oct 13 2010, 09:59 am
#49
ok...i'll try it and get bck 2 u very soon....
Wed Oct 13 2010, 10:03 am
#50
ok pash119
hope so now u will be succeeded

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Martinorics
Sun May 12 2024, 02:03 am
Nigarcarm
Sat May 11 2024, 11:22 pm
JefferyBrazy
Sat May 11 2024, 02:33 pm
autogCar
Sat May 11 2024, 03:38 am
Dulcehet
Fri May 10 2024, 04:22 pm
ElvasKl
Fri May 10 2024, 04:54 am
RonaldNak
Thu May 09 2024, 07:45 pm
Jamescon
Thu May 09 2024, 12:52 pm