HELP for programming µc

Status
Not open for further replies.
Can you please explain how to device works? My google translate is not working and I am also not able to save the file. What is the purpose of keypad? It looks like a simple circuit which operates a relay. Is it code lock device where you enetr some number and if it matches lock is opened?
 

It's a power line remote control it's composed of a transmetter and a receiver. you locked the keypad and you press a number the number will bil tansmitted with le line 220v to the receiver it compares the number to the position of the dip switch and it activate the relay
 

you locked the keypad and you press a number the number will bil tansmitted with le line 220v to the receiver it compares the number to the position of the dip switch and it activate the relay

What do you mean by locking the keypad? Are you telling that 8 different codes can be set for 8 receivers and the keypad is in transmitter circuit. Right? The relay board is the receiver. Right? if the correct code is entered at transmitter it will operate the particular relay in the receiver. Right? It is a simple project. The key code is transmitted through power line. Why use individual receiver boards? You can have one receiver board with 8 or 16 relays. Calculate how many codes you can get with 9 buttons. Is there any limitation for the length of the key code? Can it be 5 digits or 15 digits, like that?

Instead of using the dip switch, the receiver mcu can be programmed to detect different codes. DATA IN pin of TDA can be connected to Tx pin of MCU and DATA OUT pin of TDA can be connected to Rx pin of MCU.

Try to modify the transmitter and receiver circuits by implementing bi-directional communication. Then if you send a code and receiver operates a relay, it will send a message like relay1 ON back to the transmitter. Transmitter on receiving the message will log the time and status of each relay. You can use PIC18F4550 at transmitter as it has USB. You can connect it to computer to log messages from receiver and also to send key codes from PC. On the receiver side use PIC16F887.
 
Last edited:

it's remote to contol lamp or store or motor at home.
after composing the right code to lock the keypad after that you press for exemple the number 1 this number wil be transmited to the receiver. the receiver read this number transmetted and after that activate the right relay for exemple when we press 1 in the keypad we can turn off the lamp ect...
you have interstand me??
and in the link of the project their is 2 diagrams describe how microcontrollers works
 

But you can use your own encryption and decryption algorithm. lets say you input 257936 as the code. Then it can be encrypted to something like ALPTQG and transmitted. At the receiver it will decrypt the code and it gets 257936. It then compares that code for which relay to activate. Lets say the code matches for 6th relay, so, 6th relay is activated. If 6th relay is activated the receiver can send back a message to the transmitter and transmitter on receiving the message logs it in the PC. No need for dip switch.
 

yes i can cancel the use of dip switch
but not the code will be transmited only the number pressed after you have locked the keypad
for exemple
the code of locking the keypad is 1234. we compose it after a message in lcd will appear code correct after an other message appear that is press a key
we press for exemple 5. this 5 will be transmitted with power line and the receiver decrypt it and activate the relay after that send a messageto transmetter to say garanted operation
 

but not the code will be transmited only the number pressed after you have locked the keypad
for exemple
the code of locking the keypad is 1234.

I don't understand what you are saying? Are you saying that before sending any code like 184628 to receiver the number 1234 has to be entered and message to enter key is displayed on LCD? What do you mean by Locking keypad? Is it locking keypad before entering the code or unlocking the keypad before entering the code?
 

the code to unlock the keypad is for security like in mobile phone you can make a security code to protect your phone from the use foreign people ( give the permition only for person who know the code )
 

Ok. I understand now. Keypad will be locked with some code and it has to be unlocked by entering some code before entering any other code. If you do the project successfully then you can integrate GSM transmitter to the transmitter so that it will send SMS to mobile which shows the status of relays. You have to use UART to interface GSM.
 

power line communication is the base of this project
i have a problem in code of µc how i can send the code to the receiver and the receiver how it can activate the relay
if u can help me
 

Are you using the same PICs mentioned in the circuit? Digital data is sent to DATA_IN pin and digital data is taken from DATA_OUT pin of TDA IC. You have to send data serially. If you can use any other PIC you can use the Rx and Tx pins to connect to TDA IC. I don't know about PIC12F IC used in the project. I will look at its datasheet and reply.
 

i can use the 16f using the RX and TX
i have remplace the 12f with 16f.
 

Then you have to send data serially. If you keycode is 123456 then send the ascii equivalent code for each character. The receiver will receive the ascii characters and compare it with the code stored in eeprom. If it matches then that particular relay is switched. What Compiler are you using?
 

Then use UART library and use UARTx_Write_Text(keycode) function to send key code. You have to store keycode in keycode variable. It should be string. In your keypad routine should assign character to keycode array like if you press 9 it should assign '9' to keycode[] array. After all the keys are enetered and before transmitting the code it should add '\0' to end of keycode[] array to make it string. Then use the function I mentioned before to send the string.
 

Have you written the code for keypad? If yes is the keycode value returning as a string? If yes, I can give you the UART code.


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
28
29
30
31
32
33
34
35
36
For Transmitter
 
 
void main() {
  
 
  UART1_Init(9600);               // Initialize UART module at 9600 bps
  Delay_ms(100);                  // Wait for UART module to stabilize
  
  while (1) {                     // Endless loop
    
      UART1_Write_Text(keycode);       // and send data via UART
    
  }
}
 
 
For Receiver
 
char uart_rd;
 
void main() {
                       
  UART1_Init(9600);               // Initialize UART module at 9600 bps
  Delay_ms(100);                  // Wait for UART module to stabilize
 
  while (1) {                     // Endless loop
    if (UART1_Data_Ready()) {     // If data is received,
            UART_Read_Text(uart_rd, "99", 8);    // reads text until 'OK' is found
      
    }
    
  }
}
 
You should sent code like 12345699. Code is 6 characters and delimiter is 2 characters.

 
Last edited:

i have written the code how to unlock the kepad and the messages appear in lcd
 

See my last post. If your keypad unlock code is 1234 then when you enter 1234 it is stored in a array either integer variable or string array. Lets take it as an integer variable ikeycode. ikeycode contains 1234 now. the unlock code stored in eeprom is read and stored in a variable like imemkeycode. Then you compare both the variables. If they match then you display message "Keypad Unlocked" and "Enter Code to Send". After you enter and send code you can have another number like 4321 to lock the keypad.

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
unsigned int ikeycode = 0;
unsigned int imemkeycode = 0;
 
void main() {
 
    while(1) {
 
        if(ikeycode <> 0) {
            
            imemkeycode = eeprom_read(addr);
            temp = eeprom_read(addr++) * 100;
            imemkeycode =  imemkeycode + temp;
 
            if(ikeycode == imemkeycode) {
 
                //LCD Code
            }
 
 
        }
    }
}

 
Last edited:

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…