Reputation: 147
I wrote a code to communicate via ModBUS RTU for Master device with 9600 baudrate. I downloaded a Simulation Program which is ModBUS Slave. I could communicate with PC by this way. I could read Input Register with my microcontroller. I downloaded another program which is ModBUS Poll to read Krohne IFC050 input registers. I got registers value of Krohne IFC050. But, i need to take Input Register Values from Krohne IFC050 Flowmeter by using CC430F6137. I have tried with same code to read input registers of Krohne IFC050 but i couldn't. I used RS485 interface for communication. Many times i have changed terminals of RS485. However, there is no response. I couldn't read any information from Krohne by using microcontroller.
Krohne Slave ID =1. That code just try to communicate it's not professional. Here I tried to take device informations. There is my code:
modbusMsg[0] = 0x01; modbusMsg[1] = 0x2B; modbusMsg[2] = 0x0E; modbusMsg[3] = 0x02; modbusMsg[4] = 0x00;
crc =0xFFFF;
CRC16(modbusMsg[0], &crc);
CRC16(modbusMsg[1], &crc);
CRC16(modbusMsg[2], &crc);
CRC16(modbusMsg[3], &crc);
CRC16(modbusMsg[4], &crc);
modbusMsg[5] =crc;
modbusMsg[6] =crc >>8;
RS485_EN_WRITE;
RS485_EN_READ;
writeCircBuf(&bufOUT, modbusMsg[0]);
if(!(UCA0IE & UCTXIE))
UCA0IE |= UCTXIE;
writeCircBuf(&bufOUT, modbusMsg[1]);
if(!(UCA0IE & UCTXIE))
UCA0IE |= UCTXIE;
writeCircBuf(&bufOUT, modbusMsg[2]);
if(!(UCA0IE & UCTXIE))
UCA0IE |= UCTXIE;
writeCircBuf(&bufOUT, modbusMsg[3]);
if(!(UCA0IE & UCTXIE))
UCA0IE |= UCTXIE;
writeCircBuf(&bufOUT, modbusMsg[4]);
if(!(UCA0IE & UCTXIE))
UCA0IE |= UCTXIE;
writeCircBuf(&bufOUT, modbusMsg[5]);
if(!(UCA0IE & UCTXIE))
UCA0IE |= UCTXIE;
writeCircBuf(&bufOUT, modbusMsg[6]);
if(!(UCA0IE & UCTXIE))
UCA0IE |= UCTXIE;
Upvotes: 2
Views: 442
Reputation: 147
I have solved the problem. It's so simple thing. If anyone got a problem like mine, solution is check your RS485 converter Enable Pins. When I changed Data Enable and Read Enable status, problem was solved.
Thanks for your comment, thanks all of viewers.
Upvotes: 1
Reputation: 1141
Since the address is hardcoded (not going to change). you can pre calculate the CRC high and CRC low . I suggest you to do the following
connect the RS485 mostly it should work
All the best
Upvotes: 0