[SOLVED] What is the use of UART terminal in proteus?

Status
Not open for further replies.

rado

Member level 2
Joined
Feb 15, 2014
Messages
42
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Visit site
Activity points
293
I am using Proteus for simulation and micro c for hex file generation, is there any option to verify my code with out going to hardware?
What is the use of UART terminal in proteus? and also in micro c?
Can i use them for my purpose?
how to use them?
I am using pic 16F877A and 434MHz transmitter and Receiver. I need to send a code like ' START ' to run a 7 segment display counter and a motor.
I have done the simulation and succeeded, but transmission and reception part remains.
Can anyone help me with the required micro c code for transmission and reception? It will be a great help.
could i use HT12E or HT12D pair?
:roll:
 

Re: RF Transmitter and receiver interfacing with PIC16F877a

if you use ht 12 e and 12 d then it will become simple to do because the ic converts simple parallel 4 bit data into serial data.
 

Re: RF Transmitter and receiver interfacing with PIC16F877a

yes atul it will become simple. But i want to know that, if their voltage requirements could be met with the output voltage of pic16f877a?
 

Re: RF Transmitter and receiver interfacing with PIC16F877a

Use this attached Proteus RF template file for RF projects. Change the micro-controllers to yours.
 

Attachments

  • Proteus RF Template.rar
    12.8 KB · Views: 176

Re: RF Transmitter and receiver interfacing with PIC16F877a

first of all thanks for your attention sir.
i replaced that pic with Pic 16F877a which iam using.then loaded with the following micro c codes, just to try
a transmitter side

Code C - [expand]
1
2
3
4
5
6
7
void main() {
int dat;
UART1_Init(9600);
dat=25;
delay_ms(100);
UART1_Write(dat);
}



at the receiver side i used these codes.

Code C - [expand]
1
2
3
4
5
6
7
8
void main() {
int dat;
UART1_Init(9600);
delay_ms(100);
if(UART1_Data_Ready() ==1)
dat= UART1_Read();
 
}



i actually meant to send the data 25 and receive it
but nothing is displayed on the uart terminal.
actually how could we use this uart terminal in proteus?
could we see the transmitted and received data?

I need to transmitt a code like start and at receiver side it is recognized and then run a motor.
should i use array?
 
Last edited by a moderator:

Re: RF Transmitter and receiver interfacing with PIC16F877a

Try these codes.


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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//Tx code
 
char uart_dat = 25;
 
void main() {
 
    TRISA = 0xFF;
    TRISC = 0x80;
    PORTA = 0x00;
    PORTC = 0x00;
 
    UART1_Init(9600);
    Delay_ms(100);
 
    while(1) {
          UART1_Write(uart_dat);
          Delay_ms(2000);
    }
}
 
//Rx code
 
sbit LED at RD0_bit;
 
char uart_rd = 0;
 
void main() {
 
    TRISA = 0xFF;
    TRISC = 0x80;
    TRISD = 0x00;
    PORTA = 0x00;
    PORTC = 0x00;
    PORTD = 0x00;
    
    UART1_Init(9600);
    Delay_ms(100);
 
    while(1) {
    
          if(UART1_Data_Ready() == 1) {
                uart_rd = UART1_Read();
                
                if(uart_rd == 25)LED = 1;
                else LED = 0;
                
                uart_rd = '\0';
          }
    }
}

 

Re: RF Transmitter and receiver interfacing with PIC16F877a

nothing was displayed on the virtual terminal sir.
sorry for the delay to reply
 

Re: RF Transmitter and receiver interfacing with PIC16F877a

Maybe you selected wrong crystal type and or frequency in mikroC or in Proteus or wrong baudrate settings for VT in Proteus.
 

Re: RF Transmitter and receiver interfacing with PIC16F877a

That was the reason sir, my virtual terminals baud rate was different.
now i could see the transmitted and received data.
now what to do to send a data like " START "? should i use a string?
then in practical case there could be a problem by the noise.
By using this function UARTx_Read_Text(char *Output, char *Delimiter, char Attempts);
in UART library, and sending repeatedly the data, will my problem get solved?
 

Re: RF Transmitter and receiver interfacing with PIC16F877a

At Tx you have to use

Code C - [expand]
1
UARTx_Write_Text("START$$");

The read text function at Rx side should check for "$$" delimiter. Keep baudrate low like 600 bps.
 
Reactions: rado

    rado

    Points: 2
    Helpful Answer Positive Rating
Re: RF Transmitter and receiver interfacing with PIC16F877a

Hi, i tried the code for the same baud rate 9600 and found the response correctly.
As i already said i need to use this as a start command to run a counter and dc motor , whose simulation had completed successfully. now i added the two simulations together. so Sir i will come back with my doubts, so please keep your kind mind to help me.
 

Re: RF Transmitter and receiver interfacing with PIC16F877a

Sir i used this code for verification
but it shows an error, when i writes uart_rd == " STOP"
i had initialized uart_rd as char type
what is going wrong?
if i give uart_rd == 25 it is compiled successfully but i want to check that a STOP is received or not
how will i do this?

Code:
if(UART1_Data_Ready() == 1) {
               // uart_rd = UART1_Read(); this is a comment
                  UART1_Read_Text(uart_rd, "$$", 15);
                  if(uart_rd == " STOP") portb.f0=1;
                  else portb.f1=1;
 

Re: RF Transmitter and receiver interfacing with PIC16F877a

Your code is wrong.

char is one byte wide. You need string.

Try these... Use 'S' for Stop and 'R' for Start (Run)


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
//If Tx is sending 25
 
unsigned char uart_rd = '\0';
 
if(UART1_Data_Ready() == 1) {
        uart_rd = UART1_Read();
 
        if(uart_rd == 25)PORTB.F0 = 1;
        else PORTB.F0 = 0;
}
 
 
//If Tx is sending "STOP"
 
char uart_rd[];
char cmd1[] = "STOP";
 
 
if(UART1_Data_Ready() == 1) {
        UART1_Read_Text(uart_rd, "$$", 6);
 
        if(!strcmp(uart_rd, cmd1))PORTB.F0 = 1;
        else PORTB.F0 = 0;
}

 

Re: RF Transmitter and receiver interfacing with PIC16F877a

i had started doing the project on breadboard, that counter+ dc motor part, It's simulation in Proteus was correct and i programmed the pic with corresponding program [ hex file obtained in micro c ]
i connected my pic 16f877A's clear pin to +4.8v,put an 8MHz crystal between pins 13and 14 which is for osc in and out respectively. i connected the VSS pin to ground and VDD pin to +4.8v
but the output pins give a voltage of .03v what happened?
 

Re: RF Transmitter and receiver interfacing with PIC16F877a

my code is

Code:
void main() {
int i,j,k;
TRISB =0;
TRISD =0;
TRISC =0;
PORTC =0;
if(PORTC.F5==1) goto check
else portc.f5 =1;
for(i=5;i>=0;i--)
{
PORTB =i;
 for(j=9;j>0;j--)
{
PORTD =j;
delay_ms(80);
}
PORTD =0;
delay_ms(80);
}
PORTD.F6  =1;
  check: PWM1_Init(1000);
PWM1_start();
PWM1_Set_Duty(125);
if (PORTB.F0==0)
{ repeat:PORTB.F4 = 1; //Run motor in clockwise
 }

 delay_ms(170);
 PORTB.F4 = 0;
 TRISB.F6 = 1;
 if(PORTB.F6==1)
  {
 PORTB.F5 = 1; //Run motor in anti-clockwise
 delay_ms(170);
 PORTB.F5 = 0;
 delay_ms(500);
 goto repeat;
  }
  else PORTD.F7=1;
  if(PORTD.F7 =1)
  {PORTD.F6 = 0;
  }
  portc.f5 =0;
   }


hi, I also started a new thread on this topic and you had responded to it.
thread name is using pic microcontrollers.
 

Re: RF Transmitter and receiver interfacing with PIC16F877a

Post your exact circuit.
 

Re: RF Transmitter and receiver interfacing with PIC16F877a

sir my circuit and codes are these
PROTEUS simulation is in 7 seg
and code is in 7segment

- - - Updated - - -

sir my another doubt is,
for my project i first sends a code to run the counter and then a motor [ used code is S means start , this transmission and reception works finely ]
if everything goes fine, then i will send a code back [ i used P means pass ] , i could see the transmitted signal, that is P.
but at receiver, it shows the first code ie S. Transmission and reception are between two points.
the problem is the receiver, which should receive a P is now receiving S .
 

Attachments

  • 7seg.rar
    15.4 KB · Views: 110
  • 7 segment.rar
    30 KB · Views: 110
Last edited:

Re: RF Transmitter and receiver interfacing with PIC16F877a

Your code is difficult to read as it doesn't have indents. Also you were advised not to use goto statements.

If your are using 434 MHz RF modules are similar which doesn't have address detection then you need to send data like this...

Tx1 sends data to Rx1 like Tx1S

Tx2 sends data to Rx2 like Tx2P

If you just send S and P then S sent from one Tx is received by all the other Rx.
 

Re: RF Transmitter and receiver interfacing with PIC16F877a

yes sir , I am using a 434MHz RF transmitter and receiver. How this type addressing possible, sir? should i use that delimiter case? i mean the function, UARTx_Read_Text(char *Output, char *Delimiter, char Attempts);
send S1 ,then put delimiter as 1. I will try this option , if there is another right way, kindly redirect me to that.
 

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…