[SOLVED] RF remote control using pic16f628a and mikroc programming

Status
Not open for further replies.

choura

Member level 1
Joined
Apr 28, 2010
Messages
41
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Location
algeria
Activity points
1,558
hi this my first program with uart ; so, I want to know is this program true or not
I'm going to use it with RF module
if there is faults tell me
how to declare the errors of signals when i send it to another pic

this is my program

unsigned char i;
void main() {
TRISA = 0xff; //set all pin of port A as an input
TRISB = 0x00; //set all pin of port B as an output
PORTB=0;
UART1_Init(9600); // initialize UART module
while (1) {
if (portA.f0==1) //if push button is pressed
UART1_Write('f'); //send forword signal
delay_ms(500);
}
}
my circuit in file attachments
I'm sorry for my english

thank U before

- - - Updated - - -

I have tested it with my circuit but the signal I got is not true

- - - Updated - - -

I have tested it with my circuit but the signal I got is not true
 

Attachments

  • RF remote control using pic16f628a.rar
    12.7 KB · Views: 143

Are you sure that UART1_Init will configure the Hardware-UART correctly ?
Check help for that UART1 library function. (that must configure TX and RX pin in PORTB of PIC as inputs)
 

First of all I could not able to open your attached file so please put the schematic in jpg or some thing also in my view you are missing couple of things here in the code .....

1) Header files of the PIC IC
2) Configuration setting of the PIC ( I mean Config Register )
3) If you are using external clock then you need to choose proper config setting based on the frequency and need to mention clock speed some where in the code if you are planning to use internal oscillators then you need to use internal registers configuration for internal oscillators
4) Did you have Max232 IC on your board with proper combination
5) Apart from Init_UART function did you have UART_Write code or header file added to your code or not

Check all this and then one can help you on this....

Good Luck
 

The code is working properly.

Code:
void main() {
     TRISA = 0xFF;              //set all pin of port A as an input
     TRISB = 0x00;              //set all pin of port B as an output
     PORTB=0;
     UART1_Init(9600);          // initialize UART module
     Delay_ms(100);
     
     while (1) {
           if (PORTA.F0 == 0) {       //if push button is pressed
              Delay_ms(20);
              if(PORTA.F0 == 0) {                        //send forword signal
                   UART1_Write('H');
                   UART1_Write('e');
                   UART1_Write('l');
                   UART1_Write('l');
                   UART1_Write('o');
                   UART1_Write('!');
              }
           }
     Delay_ms(500);
     }
}

You had interchanged the Rx and Tx wiring to Virtual Terminal. Rx goes to Tx and Tx goes to Rx.
 

Attachments

  • ss3.jpg
    231.8 KB · Views: 217
  • rf.rar
    13.1 KB · Views: 125
Last edited:
Reactions: choura

    choura

    Points: 2
    Helpful Answer Positive Rating
Input lines of your circuit are pulled up by resisters; when you press the switch they go down (ie. ground of power)
To detect pressed switch you should use "(PORTA.F0 == 0)".

Like in the working code insert a delay after initializing the UART.
UART1_Init(9600); // initialize UART module
Delay_ms(100);
 

thank you for help

in my circuit I need just to use Tx as output to send my signal to other pic 16f877a, this program is the first of main, I know it has sevral errors,

my think is: to send letters (F,B,R,L,S) to control the robot using "non return to zero" code of digital transmission; by my program that I posted I'm trying to learn how to config the UART as i need in project; also i'm very small mikroC , so PLZ go step by step with me to learn; I'm student and you are my teachers ^_^. when i create new program i will post it in this forum to note me.
thank you.

- - - Updated - - -

to my freind milind.a.kulkarni thank you for your reply , the picture of my circuit has posted by internetuser2k12, what do you think about my program and the circuit .

- - - Updated - - -

i'm not going to use max232 , I just want to send the signal from pic to pic
 
Check this. It sends FBRLS signal to another PIC which transmitts the received data.
 

Attachments

  • pic2pic_receiver.rar
    404 bytes · Views: 121
  • pic2pic_transmitter.rar
    12.6 KB · Views: 147
Reactions: choura

    choura

    Points: 2
    Helpful Answer Positive Rating
my friend internetuser2k12 ; I want to send every char (F, B, R, L, S) alone , it means ; when I press a push button the pic will send only one char
puchbutton1 to send F, pushbutton2 to send B... i used port A for five push button and portB to send the char through Tx pin .

_ if I want to send char ; do I must use ADC or not, i'm gonna to use non return to zero; PLZ any help for that ?.
 
You dont have to use ADC for that. What problems are you facing?

- - - Updated - - -

You dont have to use ADC for that. What problems are you facing?

----------update---------------

Check these files
 

Attachments

  • pic2pic_tx_1.rar
    13.5 KB · Views: 126
  • pic2pic_rx_1.rar
    404 bytes · Views: 110
Reactions: choura

    choura

    Points: 2
    Helpful Answer Positive Rating
thank you very much internetuser2k12 ; i don't have any problems; i looked some examples that used ADC , thanks friend
 
hi internetuser2k12 , can you write me the programs of the circuit you posted ,
thank you before.
 
Last edited:

code for transmitter

Code:
void main() {
     TRISA = 0xFF;              //set all pin of port A as an input
     PORTA = 0x00;
     TRISB = 0x00;              //set all pin of port B as an output
     PORTB = 0x00;
     CMCON = 0x07;
     UART1_Init(9600);          // initialize UART module
     Delay_ms(100);


     while (1) {
           if (PORTA.F0 == 0) {       //if push button is pressed
              Delay_ms(20);
              if(PORTA.F0 == 0) {                        //send forword signal
                   UART1_Write('F');
                   Delay_ms(500);
              }
           }
           if (PORTA.F1 == 0) {       //if push button is pressed
              Delay_ms(20);
              if(PORTA.F1 == 0) {
                   UART1_Write('B');
                   Delay_ms(500);
              }
           }
           if (PORTA.F2 == 0) {       //if push button is pressed
              Delay_ms(20);
              if(PORTA.F2 == 0) {
                   UART1_Write('R');
                   Delay_ms(500);
              }
           }
           if (PORTA.F3 == 0) {       //if push button is pressed
              Delay_ms(20);
              if(PORTA.F3 == 0) {
                   UART1_Write('L');
                   Delay_ms(500);
              }
           }
           if (PORTA.F4 == 0) {       //if push button is pressed
              Delay_ms(20);
              if(PORTA.F4 == 0) {
                   UART1_Write('S');
                   Delay_ms(500);
              }
           }


     }
}

code for receiver

Code:
void main() {
    unsigned int receive;
    TRISA = 0xFF;              //set all pin of port A as an input
    TRISB = 0b00000010;              //set all pin of port B as an output
    PORTB=0x00;
    UART1_Init(9600);          // initialize UART module
    Delay_ms(100);
    
    while(1) {
    if (UART1_Data_Ready() == 1) {
            receive = UART1_Read();
            UART1_Write(receive);
    }
    }
}
 
Reactions: choura

    choura

    Points: 2
    Helpful Answer Positive Rating
thanks friend for every thing you helped me in this circuit
 

hi friend

can any one tell me; how to use non return to zero in UART and how to configure it in mikroC

thanks before.
 

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…