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.

RS485 Source Code for PIC

Status
Not open for further replies.

weberclas

Newbie level 1
Joined
Oct 27, 2003
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
15
pic rs485

Hi all.

I need RS 485 rx and tx comminication commands for Pic Basic Pro.

(use pic 16f84)

Thanks.


R.Can RAKAN
Teknik Danýþman
+90.555.311.55.71
 

rs485 code

Hi,

Much simplier to use a 16F628 or similar with
built in USART and use an RS485 transceiver like
MAX487. Than all u have to do is send and receive
with the USART and control the direction with MAX's
T/R pin (Transmit/Receive).

Zed
 

rs485 source code

It is a very strange circuit from the link provided by C_Man: 485 drivers in 232 DB-9 configuration????!!!!
Use one of the RS-485 drivers (MAX485, 487, ...) Connect PB0 to DE/RE*, PB1 to RX and PB2 to TX- you are the design engineer, it is up to you which pin goes where.
If your micro doesn't have UART it is still fine: you can create one in software, but as Zedman said it is just easier to select a micro with UART in.
 

picbasic rs485

IanP,

weberclas was asking for a code in Picbasic Pro and this was the only example I found on the net ...

best regards
 

rs485 pic

On this page
**broken link removed**

you will find all about communication between PIC and other devices or with other

PIC with useful picbasic source code.

The example show diferent way to communicate with other device using PIC

16F877 but it is adaptable for other PIC.
 

pic rs485 circuit

Hi
Checkout this site
h**p://web.ukonline.co.uk/j.winpenny/

( Interconnect many PIC devices over an RS485 network. PIC network protocol source code and application schematic based on a PIC16F873 )

although source code is in C , you can easily port it to basic. It is a clean code implementing rs485 network.
Rs485 is similiar with rs232 . basic code which is written for for rs232 will meet your requirement

Bilge Kaan
 

rs485 picbasic

It is a very strange circuit from the link provided by C_Man: 485 drivers in 232 DB-9 configuration????!!!!

YES. My comments concern to the electrical drawing example. It use the SN75176
tranceivers to drive the RS485 line but in a strange configuration. I´m sure they
will NOT work properly in such way, I mean from the noise rejection point of view,
because it break the most important feature of the RS485 wich is the
differential current mode
in wich any electrical noise is cancealed.
In the pin assignements, they use the PIN2 & PIN3 of a DB9 without take
care that such pins are used universally for a RS232 communicaton. As the RS485
Standard Protocols doesn´t mention any hardware specification, it´s usual to see
an RS485 node sharing a DB9 connector with RS232 BUT using another pins.

What I guess they try to do is a "quasi-full duplex" configuration with 2 wires (??).
It will work sending and receiving chars for hobbies purpose, but THIS IS NOT RS485.
I would preffer to use only one tranceiver, in half duplex but full differential wired.
IMO, it´s not a model to follow nor suggest.
Just my $0.02.


Humber555
 

sample code for rs-485 communication

Hi,

As long as you don't connect those pins to RS232, nothing wrong... And you have RS485 link.
If want some compatibility...

Cheers !
 

Re: help me,help me,help me....

Sorry I'm not good at Endlish because I'm Vietnamese. I have a problem.I want to connect pic to pic use rs485.The master is pic 18f4550 and slave is 16f887.I use pins TX,RX(rs232) to transceiver
And my code master:

#include <18f4550.h>
#include "LCD_SD.C"


#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, PUT

#use delay(clock=16000000)

//#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=9,stream=bus)

#define RS485_DEST_ID 0x11
#define RS485_ID 0x7f
#define RS485_USE_EXT_INT false
#include <rs485.c>

#use rs232(baud=9600, xmit=RS485_TX_PIN, rcv=RS485_RX_PIN, enable=RS485_ENABLE_PIN, bits=9, long_data, errors, stream=bus)

int8 buffer[2];
int8 next_in = 0;
int8 next_out = 0;





#define bkbhit (next_in != next_out)

int8 bgetc()
{
int8 c;

while(!bkbhit);
c = buffer[next_out];
next_out = (next_out+1) % sizeof(buffer);
return c;
}



void main() {
int8 i, msg[2];
i=2;
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
rs485_init();

while(1) {
msg[0]="d";
msg[1]="u";
output_low(pin_d2);
delay_ms(500);
output_high(pin_d2);
delay_ms(500);

rs485_wait_for_bus(FALSE);
while(!rs485_send_message(RS485_DEST_ID, 2, msg))
delay_ms(RS485_ID);




}
}

code slave:

#include <16F887.H>
#include "LCD_SD.C"


#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, PUT

#use delay(clock=20000000)



#define RS485_DEST_ID 0x00

#define RS485_ID 0x10
#define RS485_USE_EXT_INT false
#include "rs485_dung.c"
#use rs232(baud=9600, xmit=RS485_TX_PIN, rcv=RS485_RX_PIN, enable=RS485_ENABLE_PIN, bits=9, long_data, errors, stream=bus)

int8 buffer[4];
int8 next_in = 0;
int8 next_out = 0;//tuong ung so byte khung truyen




#define bkbhit (next_in != next_out)//làm chi???

#INT_RDA
void serial_isr()
{
int8 t=0;

buffer[t] = getc(bus);
t+=1;
if(t>=sizeof(buffer)){
t=0;}
output_high(pin_d5);
delay_ms(500);
output_low(pin_d5);
delay_ms(500);
// Buffer full !!
lcd_gotoxy(1,1);
printf(lcd_putc,buffer[1]);
delay_ms(5);
}


void main() {
int8 i, msg[2];

i=0;
LCD_INIT();
LCD_GOTOXY(1,1);
LCD_SEND_BYTE(0,0x01);
DELAY_MS(5);

enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
rs485_init();
while(1);
}
thanks for your attention!
 
Re: help me,help me,help me....

Hi Everyone,

Good thread this one.
Just wondered if anyone has used the Modtronix RS485 boards.
I am getting to grips with the SBC83IL-D485M dual RS485 ports.
**broken link removed**

Regards
Nic
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top