Hello Guest it is May 25, 2019, 07:33:29 AM

Author Topic: Mapping modbus to PLC  (Read 3875 times)

0 Members and 1 Guest are viewing this topic.

Mapping modbus to PLC
« on: December 19, 2010, 01:09:10 PM »
I'm having a time getting my head wrapped around this.  I'm working with a DL05 and have a program running on the PLC.  It responds as it should to switch X inputs and triggers Y outputs.  Just to get something up and running quickly, to communicate with mach, I energize a Y output which puts 5V on a mach PP pin.  Mach sees this and does it's thing.  The PLC also has 4 analog inputs for doing various things.  One comes from my plasma voltage divider so that one has to be a analog input, but the other three are just for setting parameters.  These parameters could be set on a mach screen and written to the PLC V memory via modbus.  My analog input is binary, so when I write a value (a number between 0 and 50) in needs to be in binary.

I guess my issue is that I'm lost when it comes to modbus addressing.  All I know for sure through trial and error with the modbus monitor is that 1024 - 1028 are my 4 analog inputs.  I can see X inputs at 2048 but only if I select "Discrete Inputs" and specify 8 inputs in the monitor.  I can see all 8 switch no problem.  If I select "Input Registers" I see nothing, just zeros.

What I would like to do is pick a V memory range on the PLC and use that for bit input/output.  For instance, use V2200 for X inputs and V2201 for Y outputs.  X0 = V2200.0, X1 = V2200.1......X7 = V2200.7.  Same thing for V2201.  So my PLC program wanted to notify mach of an event, it, for instance, would set V2201 bit 0.  Mach would then need to see this....and this is where I'm running in circles.

I've gone through the PLC manual but it's pretty vague when it comes to modbus addressing, and the examples they give don't seem to make sense.  Could someone please give me a rundown on how the modbus maps to V memory locations on the PLC?

Thanks
Re: Mapping modbus to PLC
« Reply #1 on: December 19, 2010, 05:35:22 PM »
I'm making headway.  I think I've figured out how to map a specific V memory address to the modbus.  I tested setting bits both ways and it seems to be working.  The question I have now is how to send actual data, like the number 50 and have it formatted in binary in the PLC so the program can use it.   Do you convert the number in VB then send it using SetModOutput()?  I know that's how you set a bit, but will it also work for sending a word?

Offline poppabear

*
  • *
  •  2,231 2,231
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Mapping modbus to PLC
« Reply #2 on: December 19, 2010, 09:12:37 PM »
look, in the "Members docs" and look for the Brains users guide, it goes into detail on doing Modbus with ADC plcs.....
you can send the value in decimal in mach3, and then convert or not, in the pLC, the pLC has many ways to do data conversion types.....

scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: Mapping modbus to PLC
« Reply #3 on: December 19, 2010, 11:24:40 PM »
I've pretty much been through all the vids and docs.  I'm real close.  I've got everything working in NP modbus.  I can assign inputs and outputs in ports and pins and everything works.  I can set modbus data in VB, but the only thin I can't get working is brains.  I may be using the wrong address.  I used the same address specified in the modbus setup, which didn't work.  Then I tried the PLC address (1500) and that didn't work.  Seems the one only thing it will accept in a small integer.  It accepts 0 and 1 as address but neither work.  What am I doing wrong?
Re: Mapping modbus to PLC
« Reply #4 on: December 19, 2010, 11:42:41 PM »
I got it.  The address is the pin number.  0 - 63.  Working great now.

Offline poppabear

*
  • *
  •  2,231 2,231
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Mapping modbus to PLC
« Reply #5 on: December 20, 2010, 08:07:41 AM »
in the member docs area, the "Brains users guide" goes into that stuff.....
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: Mapping modbus to PLC
« Reply #6 on: December 20, 2010, 02:48:47 PM »
I see a conversion instruction for going from BCD to binary.   The PLC only seems to be able to go between BDC and binary, unless there are some more conversion instructions that I'm not seeing.  Could you explain how you would do a decimal to binary conversion in a DL05?

Thanks

Offline poppabear

*
  • *
  •  2,231 2,231
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: Mapping modbus to PLC
« Reply #7 on: December 20, 2010, 05:54:53 PM »
your making it FAR more complex than it needs to be, open and use Windows Calculator in scientific mode. it has numbering system converters, i.e tick the binary button and put in the binary equivelant of 50, or start at 50 in decimal, and thne convert to binary......

All numbers are really binary, in a PLC or PC anyway, so your just changing how it is presented to the user or manipulation filters.......

ADC has a "Decimal" data type, use that for your numbers, and just keep what the binary is doing in your head, OR, you can use the DATA VIEW window and look at, and change the data view type......

for example if you have a 12 bit number, then its max in decimal would be 4096, or 0-4095 in computer talk.

50 decimal, in binary would be: 110010  (using win calculator).

So, in Mach3 if I send a DECIMAL 50 across the modbus, into a User VARIABLE address in the PLC, the PLC sees the 50 as a Binary number, you DONT have to do anything to it.......

scott
« Last Edit: December 20, 2010, 05:58:53 PM by poppabear »
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: Mapping modbus to PLC
« Reply #8 on: December 20, 2010, 06:10:20 PM »
I did notice that in data view the scale of the analog input is 0 - 4095.  So lets say I have the pot about half way and I have 2000 sitting in VMemory.  If I write 2000 from Mach to another VMemory address, the PLC will see the two as equal, correct?
Re: Mapping modbus to PLC
« Reply #9 on: December 20, 2010, 11:13:59 PM »
I ended up scaling the data in mach the same as it is scaled in the PLC.  I made a slider with a scale of 0 - 4095.  The upper range of the slider = 10V.  I wrote a brain formula to convert the scaled digital data to analog and show that in a separate DRO. Another brain writes the slider DRO to the modbus.

Thanks for the help.  Your explanation helped me get it straight in my head.