Modbus Communication

edward.ortiz

Member
Join Date
Jun 2015
Location
Houston
Posts
28
I am working with a DL205 PLC with a 250-1 CPU. I am using modbus protocol to read values from a slave. How do i convert this 16bit register into a real number?
 
Are you wanting to take a valid whole number as a decimal number and convert it to a real number? Is the value in decimal form (not BCD)?

If yes to both questions:
In the PLC, the real will occupy 32 bits as Archie said.

So, you will want to LD the value into the accumulator first. This will put the value from the memory location of your choosing into the lower 16 bits of the accumulator, and the upper 16 bits will be set to zero.

Then use the BTOR instruction to convert the two 16 bit registers in the accumulator into a real number.

Finally, use OUTD to copy the 32 bits of the accumulator to two consecutive "V" registers where it will be available as a real number.

If the number you are bringing in over Modbus is in some other form, please explain.
 
Last edited:
I think I initially misread your post as to why I questioned what you were reading with. Is your PLC your Modbus master reading the values from a slave it is connected to?
 
Do the numbers look correct if you view them in DirectSoft? You can use a Data View window to view them and alter the radix (BCD, Decimal, etc.) to find out for sure. If the number is truly BCD, then you can add a step to the logic I described above to convert to binary. After you load a BCD value into the accumulator, use the BIN instruction to convert it to decimal before you use the BTOR instruction to convert it to real.

If your PLC firmware is new enough, it may support IBox instructions which can make short work of this whole operation. There is an IBox called BCDTOR to take a 16 bit BCD number from a V memory location, convert it to a 32 bit real number and put it in two consecutive V-memory locations. This instruction also provides for an implied decimal point so you could change 2345 BCD to 234.5 (real) in one fell swoop.

If you have a whole bunch of these conversions to perform, it may be worthwhile to update firmware to gain these instructions. I did that with a DL-06. It took about fifteen minutes of down time to accomplish and greatly cleaned up my logic. I have never used the 250-1, so I am not sure if that is possible for you.
 
Last edited:

Similar Topics

Apologies for not being the best IDEC programmer. I recently was doing some inspections on a site that had 3 FC6A IDEC processors. The issue is...
Replies
0
Views
75
Hi all I need help on this As in my project used Schneider TM241 controller. Now I want to communicate Elite energy meter with controller by...
Replies
3
Views
157
Hello, I need to access the bits from the fire system control panel through RS-485. So, I used Read Var block to read from the panel...
Replies
0
Views
187
Hi, i cant establish communication between fatek plc with an energy meter, both capable for modbus tcp, i did with modscan but fatek plc does not...
Replies
1
Views
150
Hi Guys, I am a new member and this is my first post! I have a little PLC experience but it is mostly with siemens logo and using ladder...
Replies
4
Views
902
Back
Top Bottom