Today is...
Tuesday, April 23, 2019
Welcome to, the global online
community of automation professionals.
Featured Video...
Featured Video
A demonstration of EtherCAT control of linear motors using the CTC EtherCAT master.
Our Advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive
Difficulties Getting KL2404 To Work
Beckhoff KL2404 is not responding to Write Multiple Coils

Greetings everyone,

I have a BK9100 with a KL1404 and a KL2404 modules. I am using modbus to communicate with them.

I use Read Discrete Inputs to get input from the KL1404, and that works every time.

When I try Write Single Coil and Write Multiple Coils, I have only ever gotten the KL2404 to do anything exactly twice. The two times I have gotten it to work, I use Write Multiple Coils passing 8 bits to address zero. I have repeated this hundreds of times, trying every possible combination I can think of, but I cannot (usually) get anything to happen.

Why it worked twice is beyond me. Is this common? Does anyone know the exact modbus output that should work on a KL2404?

Is it possible that the device is damaged? It is brand new.

thank you

I assume you mean Beckhoff modules? have you tried using modscan or another emulator to read or write directly to the module?

Thanks for the tip. I downloaded ModScan64, connected, and then could set a coil once. The output LED would glow for about 1 second and then go out.

After the first time I get ** MODBUS Exception Response from Slave Device **

I could repeat the process by unplugging the power supply and plugging it in every time, but I still can only set 1 coil once.

It is interesting that I can close ModScan and reopen it, and it will remember the coil status values...presumably the device remembers the coil status values, but the device won't stay on and after the first will generate the error.

Is there some other command I need to send to the Beckhoff, in between setting coils?

thank you

In case anyone comes across this thread, I fixed it.

It was the watchdog that was shutting down the device after the first write. Rather than disable the watchdog, I just send in the magic "unlock" key that resets it. I do this before every write.

My code looks like this:

modbusClient.WriteSingleRegister(0x1121, 0xBECF);
modbusClient.WriteSingleRegister(0x1121, 0xAFFE);
modbusClient.WriteSingleCoil(channel, value);

I do not know if sending this before every write is a good idea or not, but if the code cannot guarantee the state of the device, it seems prudent to me to just do it. This way the watchdog can run all it wants, and I can always fix it regardless.

I was very surprised that the watchdog bricks the device instead of just turning off the outputs, but that's what it does. Anyone else ever have this issue?