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.

Pls, HELP ME about RS485

Status
Not open for further replies.

potato89

Newbie level 4
Joined
Mar 12, 2011
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,333
I am working on a project of interfacing PIC uP (MASTER) to Multiple PIC uP (SLAVES) through the use of half-duplex RS-485 chips.
I'm new member in PIC. So, I have many troubles! Can you guys help me?
I wanna transmit a frame infomation from master chip (use 18f4xxx) to slave chip (16f87xx).Chip slave used to measure temperature, it will send infomation about temperature to chip master after requested!
How do I do! pls help me!
thanks so much!
 

hi!
you find in this link a Modbus Comunication project based on Pic 16f87x (slave and master).
 
I found many projects but I didn't find the project that I need! I have to transmit by USART protocol! If you have any ideal, plz help me!
I have to complete my project in April :((
 

with this requirement what help do you expect. unless you tell what you need in particular and what you did till now, it is difficult to help you.....
 

I have to transmit by USART protocol!
Suggested MODBUS is an application protocol on top of half-duplex UART. I think it's a good suggestion, it would also allow to use standard software tools for test. Otherwise you have to define your own protocol, involving addressing, representation of data, handling of transmission errors etc.
 

Thank you guys replied!
In CCS software have an example about RS485! and I wanna use it for my project!
I post the example is here:
#include <16F628A.h>
#device *=16
#fuses HS, NOWDT, NOLVP, NOBROWNOUT, NOPROTECT, PUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_B2, rcv=PIN_B1, stream=MASTER)

#define RS485_RX_BUFFER_SIZE 64
#define RS485_USE_EXT_INT TRUE

int8 OUR_RS485_ID = 0;
#define RS485_ID OUR_RS485_ID

#include <rs485.c>
#include <stdlib.h>

int8 in_char = 0;
//int8 next_in = 0;
//int8 next_out = 0;
int8 msg[64];

#INT_RDA
void serial_isr()
{
in_char = fgetc(MASTER);
}

#INT_TIMER1
void timer1_isr()
{
int8 i;

if(rs485_get_message(msg, FALSE))
{
printf("\n\r%d: ", msg[0]);

for(i=0; i < msg[1]; ++i)
putc(msg[i+2]);

printf("\n\r");
}
}

void RS485send(char* s, int8 id)
{
int8 size;

for(size=0; s[size]!='\0'; ++size);

rs485_wait_for_bus(FALSE);

while(!rs485_send_message(id, size, s))
delay_ms(OUR_RS485_ID);
}

char MASTERgetc()
{
in_char = 0;

while(!in_char);

return in_char;
}

int8 MASTERgetInt()
{
int8 i, s[3];

for(i=0; (s=MASTERgetc()) != '\r' && i<3; ++i);

return atoi(s);
}

char* MASTERgetMsg()
{
int8 i;

for(i=0; (msg = MASTERgetc()) != '\r' && i<64; ++i);

msg = '\0';

return &(msg[0]);
}

void main()
{
int8 i, send_addr = 0;
char command;

setup_timer_1(T1_INTERNAL | T1_DIV_BY_1);

enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);

rs485_init();

while(OUR_RS485_ID == 0 || OUR_RS485_ID >= 255)
{
printf("Please choose a network ID (1-255): ");
OUR_RS485_ID = MASTERgetInt();
}

printf("\n\rYour ID is: %d\n\r\n\rIf you require assistance, press h.\n\r", OUR_RS485_ID);

while(command != 'Q')
{
enable_interrupts(INT_TIMER1);

command = toupper(MASTERgetc());

disable_interrupts(INT_TIMER1);

switch(command)
{
case 'S':
if(send_addr == 0 || send_addr > 255)
{
printf("\n\r\n\rEnter send address (1-255): ");
send_addr = MASTERgetInt();
}

printf("\n\r%d:>", send_addr);
RS485send(MASTERgetMsg(), send_addr);
printf("\n\r");
break;

case 'C':
send_addr = 0;

while(send_addr == 0 || send_addr > 255)
{
printf("\n\r\n\rEnter send address (1-255): ");
send_addr = MASTERgetInt();
printf("\n\r");
}
break;

case 'I':
OUR_RS485_ID = 0;

while(OUR_RS485_ID == 0 || OUR_RS485_ID >= 255)
{
printf("\n\rPlease choose a network ID (1-255): ");
OUR_RS485_ID = MASTERgetInt();
}
printf("\n\rYour ID is: %d\n\r\n\r", OUR_RS485_ID);
break;

case 'H':
printf("\n\rCommands: (S)end message, (C)hange Send Address, ");
printf("Change (I)D, (H)elp, (Q)uit.\n\r");
break;

default:
if(command != 'Q')
printf("\n\rInvalid command!\n\r");
}
}
}
Now, Master have to transmit information to slave and ask slave answer information about temperature! I have to transmit information about temperature from salve 1 to master! How do I have to do? I had information about temperature by use LM35!
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top