Mustafa
Mustafa

Reputation: 147

ModBUS RTU with CC430F6137

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

Answers (2)

Mustafa
Mustafa

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

WorkaroundNewbie
WorkaroundNewbie

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

  1. take some modbus master program (with same slave id and baud rate)check if you are able to get the flow rate this will confirm that modbus slave is working
  2. check the uart output of the micro controller . If you are able to see a valid request in same baud rate . this will confirm that microcontoller is sending a valid request
  3. connect some modbus slave program to microcontoller check if slave program is responding by sending the data .

connect the RS485 mostly it should work

All the best

Upvotes: 0

Related Questions