6 years ago.

RS485

I am not getting any data. Rs485 is not readable. My slave Id is 112. I am not getting these parameters, byte data[9] = {0x70,0x04,0x00,0x48,0x00,0x02,0xf1,0xdd}; Speciely these 0x48,0x00,0.

<code>

  1. include "mbed.h"
  2. include <RS485.h>

Serial pc(PC_6, PC_7);

RS485 RS485(PA_2,PA_3, PC_3); Tx, Rx , !RE and DE MAX485 pin

DigitalOut ho(PC_3); this pin should be connected to !RE and DE typedef uint8_t byte;

byte regvalue[9]; byte data[9] = {0x70,0x04,0x00,0x48,0x00,0x02,0xf1,0xdd};your data 0xf1,0xdd int main() { RS485.baud(9600); pc.baud(9600); pc.printf("main\t"); while(1) { pc.printf("Starting\t"); ho = 1; Enable sending on MAX485 RS485.sendMsg(data,sizeof(data)); wait_ms(600); Must wait for all the data to be sent ho = 0; Enable receiving on MAX485 pc.printf("Getting data\t"); pc.printf(RS485.readable() >0 ? "Yes" : "Not readable \t");

if(RS485.readable() >0){ memset(regvalue,0,sizeof(regvalue)); wait_ms(200); RS485.recvMsg(regvalue,sizeof(data),500); wait_ms(200); for (int count = 0; count < 9; count++) { pc.printf("%X - ", regvalue[count]); } }else printf("No Data\t"); printf("Done\n"); wait_ms(1000); } }

</code>

Thank you.

Be the first to answer this question.