Control Solutions Knowledgebase

Translating Modbus coils to LonWorks SNVT_switch NV’s

This article describes the process for having the BB2-LON gateway read Modbus coils from a Modbus slave and providing that data as a SNVT_switch Network Variable Output. The same process applies for monitoring Modbus discrete inputs from LonWorks via SNVT_switch network variables. If an input register or holding register contains packed bits with up to 16 states represented in the same register, you can apply this same principle if you add a bit mask to the map to select a specific bit from the 16-bit register. To control coils from LonWorks, reverse the process, mapping a Network Variable Input to writing a Modbus coil.

Note: The process described here requires BB2-LON device firmware v3.10.9 or higher, and configuration tool v2.15 or higher.

The example we will work with starts out with a CSV file containing a set of 4 coils that will be read by the BB2-LON gateway.

From the Reg Import page, the file illustrated above was opened. All registers were selected and added to the Reg List.

The register list on the Reg List tab initially has no assignments.

Next, on the Reg List page, the "Auto-create NV's and assign FB #'s" was executed. Then "Auto-assign data objects" was executed. The register list now looks like this:

Next, we go to the NV List, which initially looks like this:

For each coil to be converted to SNVT_switch, double click the NV line to open the NV Editor dialog. Select SNVT_switch from the SNVT Type list. Secondly - and this is important - select Special Conversion from the Method list. Then click Apply.

The Modbus coil is very basic 1-bit value with a 0 representing off and 1 representing on. The only "switch" available in LonWorks is SNVT_switch which is a 2-part structure designed for dimmable switches. The first part of SNVT_switch is the dimming level that may be 0% to 100%. The second part is state, either on or off. In most cases, LonWorks devices will not treat a "switch" as "on" unless state is set to ON, and level is something greater than 0%.

If you did not select the Special Conversion (which defaults to formula 1 for SNVT_switch), you would need to provide two Modbus registers per SNVT_switch, one mapped to level (and must be capable of 0-100%), and the other mapped to state. The Special Conversion supported by the BB2-LON gateway automatically converts the Modbus data to both parts of the SNVT_switch structure.

When the NV type changes have been completed, the NV List now looks like this:

Now move to the Master List, which will look like this:

Double click on a Modbus related area of the line to open the Modbus Register Editor dialog. Enter 100 for Scale/Slope. Click Apply. Do this for all of the coils.

As noted above, SNVT_switch expects a level in the range of 0-100%. The data value of a coil will be either 0 or 1. To convert that 1 to 100%, a scale factor of 100 is used. If you wanted the coil to only set the LonWorks side to 50%, you would enter a scale factor of 50 instead of 100.

The internal object data format will default to bit/boolean when the Modbus register is a coil. In order to make the scaling work, you must change the internal data format to Unsigned Integer. Double click on the object number to open the Object Editor dialog. Select "16-bit Unsigned Int" for Data Format and click Apply.

You are now ready to send the configuration to the device. From the Master List, select "Send NV definitions to device" and click Execute. Next, select "Send Object maps to device" and click Execute. (This assumes you have connected the USB cable, selected the port on the Connect page, and clicked Connect with successful results prior to clicking Execute.)

Once configured, the data illustrated in this Modbus simulator screen shot...

...will appear as illustrated here on the View Data tab after selecting "Get Object data values" and clicking Execute.

When the local object contains the value 100, the SNVT_switch will produce a level of 100% with state 'on'.. If you use Nodeutil.exe or some other tool to look at raw data, the 2-byte hexadecimal value for SNVT_switch on at 100% will be C8 01. The C8 is a decimal 200 - percentages are 0.5% per bit (or scaled x2).

Attached Files
There are no attachments for this article.
Related Articles
Restoring Neuron State in LonWorks Gateway
Added on Fri, Jan 22, 2016