go ahead
Junior Member level 1
- Joined
- Aug 30, 2012
- Messages
- 15
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,421
HT12E is encoder, can't work as decoder.
You have to map 8-bit data to an unique sequence of 4-bit codes
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 unsigned char myData = 0xEF; void main(){ while(1){ //RB0-RB3 connected to D0-D4 of HT12E PORTB = PORTB | (myData & 0x0F); //sending low nibble PORTB = PORTB | ((myData >> 4) & 0x0F); //sending high nibble } }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 algo... if read counter == 0 lownib = PORTB; inc read counter if read counter == 1 highnib = PORTB read counter = 0 byte = highnib << 4 | lownib
in TX side i had an extra switch,which is connected to TX controller .when this switch is pressed then it will send the data .- There must be a delay between nibbles
- How do you detect the start of transmision (low nibble)?
Yes, low nibble is sent first and at decoder it is received and appears at D0-D3 Data out pins which will be connected to receiver micro PORTB. PORTB is read like below.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 algo... if read counter == 0 lownib = PORTB; inc read counter if read counter == 1 highnib = PORTB read counter = 0 byte = highnib << 4 | lownib
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #include<reg51.h> #include<delay1.h> #include<lcd.h> sbit sensor=P3^3; // this switch is used to increment the counter sbit switch1=P3^4;// this switch is used to display the value of counter char a; void main() { //a=0; lcd_cmd(0x34); lcd_cmd(0x0e); lcd_data_string("welcome"); while(1) { if(sensor==0) { a++; } if(switch1==0) { lcd_cmd(0x01); lcd_cmd(0x80); lcd_data(a+48); }
That is for RX side. Tx side code was given in post #12. As FvM said add delay between sending nibbles. At receiver side data appears at D0-D3 lines only if address is valid. You can monitor VT pin using external interrupt pin and read data @ PORTx whenever there is an interrupt. ISR code has to be written which is more efficient. Mention Compiler used. If it is allowed to use software encoding/decoding then you can use manchester coding/decoding. This will eliminate HT12x. You only need 2 micros and RF modules.
Edit: Again use external interrupt at Tx side for button. On interrupt data is sent. Use 8 pin DIP switches with both pullup and pulldown resistor pairs for the HT12x address lines. You can have 255 different addresses.
Code C - [expand] 1 2 3 4 5 6 7 On interrupt //VT pin to ext int if(nibcnt==0) byte = (PORTB & 0x0F) << 4 //RB0-RB3 is connected to D0-D3 of HT12D else if nibcnt == 1 byte = byte | (PORTB & 0x0F); nibcnt++ if (nibcnt == 2)nibcnt = 0
if i can get Manchester code examples for this task then i will surly remove HT12D/E ....
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?