Writing multiple constant values using FC16?

Hello folks,

I need to write multiple values/registers in one write session to be able to set DO of a Schneider meter. I am still pretty new to all the libraries, but I have found FC16WriteRegistersTask which should be able to do the trick. Issue is that I am not sure how to write constants inside the Task. For instance, I need to write 4 registers with the first 3 being constants “21000”, “0”, “1”. Register 4 then follows with an element that can be controlled.

Can someone please point to such an example?

Kind Regards,


Hi Bart,

there is no predefined function to write a static value to a write register on every Cycle, but you can easily do it yourself. Use GridconPcsImpl.java as an example, it does something similar.

  1. Register your Component for the TOPIC_CYCLE_BEFORE_WRITE event:

The BEFORE_WRITE event is a good place, because it is executed just before the Registers are written on Modbus.

[...] implements EventHandler {
@EventTopics({ //
		EdgeEventConstants.TOPIC_CYCLE_BEFORE_WRITE //
  1. Set the Next Write Value in the event:
public void handleEvent(Event event) {
	if (!this.isEnabled()) {
	switch (event.getTopic()) {
	case EdgeEventConstants.TOPIC_CYCLE_BEFORE_WRITE:
		try {
			var channel = (IntegerWriteChannel)this.channel(ChannelId.CHANNEL_1);
		} catch (OpenemsNamedException e) {
			this.logError(this.log, "Setting WriteChannel failed: " + e.getMessage());

NOTE that only those Channels in an FC16 task are written, that have their Next Write Value set. If not all Channels in a Task are set, the FC16 task is split in multiple tasks. Respective code is here: openems/FC16WriteRegistersTask.java at develop · OpenEMS/openems · GitHub


Hi Stefan,

Thanks for the prompt and detailed reply. I will give it a go!

Also, thanks again for the awesome work that you guys are doing!