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.

How to implement RS485?

Status
Not open for further replies.

bskumar7080

Member level 2
Member level 2
Joined
Feb 8, 2010
Messages
48
Helped
4
Reputation
8
Reaction score
3
Trophy points
1,288
Location
India
Activity points
1,579
Hi all,

How to implement RS485 communication between PC and PIC micro controller. I have used MAX485 to convert RX and TX signal to D+ and D-.
In PC side RS485 to RS232 converter is used. I think the hardware part is ok..

How to write a C Code for communication between microcontroller and PIC .

Code:
#include<p18f452.h>
#include<usart.h>


/****************************** Set up the configuration bits *******************************/
 #pragma config OSC = HS, OSCS = OFF
 #pragma config PWRT = OFF
 #pragma config BOR = OFF
 #pragma config WDT = OFF
 #pragma config CCP2MUX = OFF
 #pragma config LVP = OFF




void main()
{
    OpenUSART( USART_TX_INT_OFF &USART_RX_INT_OFF &USART_ASYNCH_MODE&USART_EIGHT_BIT &USART_CONT_RX &USART_BRGH_HIGH,64 );        // 64 = 19200bps // 10 = 15200
putrsUSART((const far rom char*)"IT WORKS !!! ");

}

I am not getting output for the above code

what modifications i have to make


Regards
sivakumar
 

Is your PC sending the information out? Some converter doesn't work =)
 

Finally after long time i was able to send data from pic to PC through RS485. for sending data from PIC to PC pins RE & DE must be made high. For Receiving data pins RE & De must be made low

my code is
Code:
#include<p18f452.h>
#include<usart.h>


//**************Configuration Bits******************

#pragma config OSC = HS
#pragma config OSCS = ON
#pragma config PWRT = OFF
#pragma config BOR = OFF
#pragma config WDT = OFF
#pragma config CCP2MUX = OFF
#pragma config STVR = OFF
#pragma config LVP =OFF
#pragma config DEBUG = OFF
#pragma config CP0 = OFF
#pragma config CP1 = OFF
#pragma config CP2 = OFF
#pragma config CP3 = OFF
#pragma config CPB = OFF
#pragma config WRT0 = OFF
#pragma config WRT1 =OFF
#pragma config WRT2 = OFF
#pragma config WRT3 = OFF
#pragma config WRTB = OFF
#pragma config WRTC = OFF
#pragma config WRTD = OFF
#pragma config EBTR0 = OFF
#pragma config EBTR1 = OFF
#pragma config EBTR2 = OFF
#pragma config EBTR3 = OFF
#pragma config EBTRB = OFF


//*******************Main **************************

void main(void)
{
	 while(1)
	 {
        TRISC=0;
        PORTCbits.RC2 = 1; //RE and DE pins of MAX485 connected 

	OpenUSART(USART_TX_INT_OFF &
	          USART_RX_INT_OFF &
	          USART_ASYNCH_MODE &
	          USART_EIGHT_BIT &
	          USART_CONT_RX &
	          USART_BRGH_LOW, 32);
	          
	          putrsUSART((const far rom char *) "Test");
	          
	          
	  }        
}

Sivakumar
 

Re: can anyone send me circuit diagram of pic to pc communication using max485

Plz mr shivkumar can you send me diagram of pic to pc communication using max485 on my email id my email is

mvekariya07@gmail.com

thank you
 

anyone help me for disigning of circuit for max485 communicate with pc and pic controller please help me as soon as possible.

Thank you in advance
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top