Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Interfacing PIC16F877A and TWS 434/ RWS 434

Status
Not open for further replies.

Mr.Khiros

Junior Member level 3
Junior Member level 3
Joined
Aug 25, 2013
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
176
Hi ,
i'm tring to send data recieved from a temperature sensor using TWS 434/ RWS 434 & 2 PIC16F877A
Sans titre.png
I'm using Mikroc , but not able to write a programme for the tow PIC's
For Pic transmitter
PHP:
void main() {
     PORTA = 0;
     TRISA = 0X01;
     PORTB = 0;
     TRISB = 0;
     ADCON1 = 0x0E;
     ADC_Init();
     uart1_init(9600);
     while (1){
           ADRead = (ADC_Get_Sample(0) * 500) >> 10;
           WordToStr(ADRead, Display);
           UART1_Write_Text(Display);
           }
}
For reciever
PHP:
void main() {
     LCD_Init();
     LCD_Cmd(_LCD_CURSOR_OFF);
     LCD_Cmd(_LCD_CLEAR);
     uart1_init(9600);
     while (1){
           Lcd_Out(2, 1,  Uart1_Read());
           }
}
Need your hlp plz
 

PHP:
Lcd_Out(2, 1,  Uart1_Read());
Lcd shows what the pic recived from Uart
+
if you have any idea for 2 pics help me
 

Try this.


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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
unsigned char Display[23];
unsigned int strLen = 0;
float ADRead, oldVal = 0;
 
void main(){
 
        TRISA = 0X01;
    PORTA = 0x00;
    TRISB = 0; 
    PORTB = 0; 
        ADCON1 = 0x0E;
      
        UART1_init(9600); 
    Delay_ms(100);
 
        while (1){ 
 
            ADRead = ADC_Read(0) * 3.333333333333333 / 1023;  // 1.5V = 306.9 to 1.5V = 1023
                                  // 150 degrees = 5V = 1023 raw 
 
                                  // ADC value
        ADRead = ADRead * 0.1466275659824047;         // 1023 to 150 degree C
 
        if(oldVal != ADRead){
 
                FloatToStr(ADRead, Display);
            strLen = strlen(Display);
            Display[strLen - 1] = 'T';
            Display[strLen] = 'x';
            Display[strLen + 1] = '\0';
 
                UART1_Write_Text(Display);
            oldVal = ADRead;
        }
         
        } 
}  
 
 
unsigned char output[21];
 
void main(){
    
    TRISB = 0x00;
    PORTB = 0x00;
    TRISC = 0x80;
    PORTC = 0x00;
     
        LCD_Init(); 
        LCD_Cmd(_LCD_CURSOR_OFF); 
        LCD_Cmd(_LCD_CLEAR);
 
        UART1_init(9600); 
    Delay_ms(100);
    
        while (1){
 
        if (UART1_Data_Ready() == 1) {          
                UART1_Read_Text(output, "Tx", 12);    // reads text until 'Tx' is found
                
        }
     
            Lcd_Out(2, 1, output); 
        } 
}

 
Thx a lot for your replay
but for the first time lcd don't show anything , but when i change the value and i choose 32 for example i didn't got the right value
Sans titre.png
 

The is the simulation & transmitter code
 

Attachments

  • Simulation.rar
    34.6 KB · Views: 72
  • Transmitter.rar
    19.2 KB · Views: 74
  • Reciever.rar
    34.1 KB · Views: 78
Last edited:

What should I do with the Proteus file? Zip and send mikroC files.

Make +Vref = + 1.6V.


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
unsigned char Display[23];
unsigned int strLen = 0;
float ADRead, oldVal = 0;
 
void main(){
 
        TRISA = 0X01;
    PORTA = 0x00;
    TRISB = 0; 
    PORTB = 0; 
        ADCON1 = 0x83;
    CMCON = 0x07;
    CVRCON = 0x00;
      
        UART1_init(9600); 
    Delay_ms(100);
 
        while (1){ 
 
            ADRead = ADC_Read(0) * 0.156403 / 1023;  
                                        
        if(oldVal != ADRead){
 
                FloatToStr(ADRead, Display);
            strLen = strlen(Display);
            Display[strlen - 1] = 'T';
            Display[strlen] = 'x';
            Display[strlen + 1] = '\0';
 
                UART1_Write_Text(Display);
            oldVal = ADRead;
        }
         
        } 
}

 
Last edited:

It is a bug of Proteus PIC16F877A model. Try with some other PIC like PIC16F887. The pins should not show grey boxes. It should be blue or red. The receiver PIC is not reading UART data. Data is being transmitted and received by receiver module but receiver PIC is hanging.
 

Attachments

  • ADC_RF.rar
    82.8 KB · Views: 74
I'm trying now to inject signals instead of temperature sensor in AN0 , How can i recieve & show those signals in the oscilloscope ?
 

The hole of my project is to simulate an calculator , so i should inject 4 signals that vary in amplitude, then i'll sample them into digital using ADC , executing some calculs and sending them to reciever pic in order ti show them in the oscilloscope
 

Showing new ampitudes in function of time. Is it possible ?
 
Last edited:

How could i show the variation of any signal recieved from PIC in function of time ?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top