Gemalto Concept Board to Modbus RTU

164 views
Skip to first unread message

dug patel

unread,
Jul 10, 2014, 9:36:54 AM7/10/14
to java...@googlegroups.com, ns...@ciright.com, dpa...@ciright.com
Hello to all,

We are try to connect Gemalto concept board having ESH6 module to Power Meter(Modbus RTU) over serial communication(RS232).

We have written below code to send Modbus Request to meter. For read 48 holding register from meter.
Sending hex code : 01 03 00 00 00 30 45 DE.

The java code has been given below:
//......................

        CommConnection  commConn;
        InputStream     inStream;
        OutputStream    outStream;

        //......
        String strCOM = "comm:COM1;baudrate=9600;bitsperchar=8;stopbits=1;parity=even";
        commConn = (CommConnection)Connector.open(strCOM);
        System.out.println("CommConnection(" + strCOM + ") opened");
        System.out.println("Real baud rate: " + commConn.getBaudRate());
        inStream  = commConn.openInputStream();
        outStream = commConn.openOutputStream();

        // code to send Modbus command to Power Meter
        System.out.println("start");
        byte modbusOutFrame[] = new byte[17];
        modbusOutFrame[0] = (byte)0x01; //slave address
        modbusOutFrame[1] = (byte)0x03; //Function code to read holding register
        modbusOutFrame[2] = (byte)0x00; //Start address HI/Li
        modbusOutFrame[3] = (byte)0x00;
        modbusOutFrame[4] = (byte)0x00; //Number of registers HI/Li
        modbusOutFrame[5] = (byte)0x30;
        modbusOutFrame[6] = (byte)0x45; //CRC
        modbusOutFrame[7] = (byte)0xDE; //CRC

        outStream.write(modbusOutFrame,0,8);
        
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                        
        int reads = inStream.read();
        while(reads != -1){
                baos.write(reads);
                reads = inStream.read();
        }

        byte[] readBuffer = baos.toByteArray();
        System.out.println("hex : "+byteArrayToHexString(readBuffer));


        //...........
        //method for return byte array to hex
        private static String byteArrayToHexString(byte[] b) {
                StringBuffer sb = new StringBuffer(b.length * 2);
                for (int i = 0; i < b.length; i++) {
                        int v = b[i] & 0xff;
                        if (v < 16) {
                                sb.append('0');
                        }
                        sb.append(Integer.toHexString(v));
                }
                return sb.toString().toUpperCase();
        }
        //..........
        

//......................

This code when executed using the Oracle emulator on PC(state the link here) runs fine. We connect Power Meter to pc using USB to TTL converter http://www.adafruit.com/products/954?gclid=CjwKEAjw8_idBRCExfC15My3owwSJACSDX_W_8UMrux6J7a5icEi0St0P1LgCrZ1Duzz6BUeSte-oxoCbTHw_wcB

Response: (Power Meter to PC)
"Hex : 010360039400000000000000C600000000000000000000000000000000000000000000045A00000000000000000000045A000004BF0000000000020258FF0F0000000000000000000000000000000000000000000000000000000000000000000000003C29"

This is exactly what we expect. Hence we are sure that the power meter is responding to the correct calls.

Next we connected gemalto concept board EHS6 to laptop using the ASC1 port. Since the ASC1 port runs on 5V TTL and the power meter runs on 3.3V TTL we have used a Logic level converter : https://www.sparkfun.com/products/12009. Here as using the RS232Demo code and made sure what we transmit on the Tx line, we receive on the Rx line back on the terminal program on the PC.

Now we connect the Gemalto board to Power meter and using the same code as stated earlier on the emulator we are trying to get a response from the meter but we couldn't get a response. We checked TX and RX signal on oscilloscope and verified that the baud rate at which the meter and the concept board communicate is 9600.

In essence, PC to Power meter working fine; PC to Gemalto Concept board EHS6 working fine but when Gemalto and Power meter are connected the meter doesn't respond.

So please help me where we are wrong.

Thanks in Advance.

eppie

unread,
Jul 14, 2014, 10:34:50 AM7/14/14
to java...@googlegroups.com, ns...@ciright.com, dpa...@ciright.com
Could hardware flowcontrol be the problem? (CTS/RTS)
Reply all
Reply to author
Forward
0 new messages