Machsupport Forum

Third party software and hardware support forums. => Modbus => Topic started by: Cncman2nv on December 07, 2008, 03:54:00 PM

Title: Allen Bradley micro logix and Modbus
Post by: Cncman2nv on December 07, 2008, 03:54:00 PM
I have Mach3 and a AB micro logix 1100 plc and trying to communicate with modbus
currently there are talking and the coils can be written to and read only in binary not word format contacts are the same way

AB modbus registors are like this

coils  ( 0001 to 4096)
contacts ( 10001 to 14096 )
Holding ( 40001 to 40256 )
inputs ( 30001 to 30256 )
Title: Re: Allen Bradley micro logix and Modbus
Post by: Peter Homann on December 08, 2008, 07:34:45 PM
Hi,

Not sure what your question is. Yes Coils and contacts are single bit ON/OFF discretes.
Holding registers and Input are 16 bit registers.

The Mach3 Modbus setup allows to to read/write to both 16 bit registers and single bit discretes.

Cheers,

Peter.
Title: Re: Allen Bradley micro logix and Modbus
Post by: Cncman2nv on December 08, 2008, 10:03:42 PM
Don't know why but Mach can't read the input or holding registers or the AB PLC won't let Mach read them  Mach's mod test page gives a( Illegal Data )MSG
Does the 5 place AB modbus address mapping have any thing to do with it


here are the AB address mapping
Title: Re: Allen Bradley micro logix and Modbus
Post by: Peter Homann on December 08, 2008, 11:15:09 PM
Hi,

It is not Mach that is giving the error, it is your PLC. Mach is just reporting what is being returned.

I don't know what you mean by "Does the 5 place AB modbus address mapping have any thing to do with it "

Cheers,


Peter.

Don't know why but Mach can't read the input or holding registers or the AB PLC won't let Mach read them  Mach's mod test page gives a( Illegal Data )MSG
Does the 5 place AB modbus address mapping have any thing to do with it


here are the AB address mapping
Title: Re: Allen Bradley micro logix and Modbus
Post by: Peter Homann on December 08, 2008, 11:26:52 PM
Looking at your Memorty map definition you can only read the coil space as discretes and not packed into 16 bit registers.

Presumably your PLC allows you to write ladder logic in it. If so, write a ladder to pack the coils into a holding register, then rad the holding register via Modbus.

Cheers,


Peter.
Title: Re: Allen Bradley micro logix and Modbus
Post by: Cncman2nv on December 09, 2008, 08:29:02 AM
Here are some screen shots from Ab software and Mach
Title: Re: Allen Bradley micro logix and Modbus
Post by: poppabear on December 09, 2008, 11:16:19 AM
The Bit-Of-Word does not work in Brains, so, in your PLC your going to have to read/write to a range of User Vars in your PLC, to do discrete set your PLC vars to 14000.0, 14001.0 etc. you will burn up an entire word in your PLC just to move a single bit, but until the Bit of word is fixed in brains that is the way it is.
ON the other hand, if you are brining this in via Serial cable to your PLC then, you can use the VB Mach Specific Modbus control launguage that allows in/out over discreate I/O and you CAN do Bit of word that way.....  More work for you though. You would have to run your code in the Macro pump for it to act as your Poller/interface between Mach and your PLC.

scott
Title: Re: Allen Bradley micro logix and Modbus
Post by: Cncman2nv on December 09, 2008, 11:23:04 AM
So how does the VB and modbus work together can analog values be read or MPG thru script



Adam
Title: Re: Allen Bradley micro logix and Modbus
Post by: Peter Homann on December 09, 2008, 02:30:49 PM
Here are some screen shots from Ab software and Mach

The reason why it is failing with Mach is that you are setting up the MAch Modbus test page to read holding registers. From your table of addresses you posted, all the registeres in the 3***** range are input registers NOT holding registers 

In the Modbus  test  page, select input register, rather than holging register. See if it works now.

Cheers,


Peter.
Title: Re: Allen Bradley micro logix and Modbus
Post by: Cncman2nv on December 09, 2008, 03:39:08 PM
Peter,

 Yes I see what you mean and i tried It the other way and still no luck


Is there any modbus VB script examples I saw the video in the feed pot  but i may need something more to fall back on
Title: Re: Allen Bradley micro logix and Modbus
Post by: Peter Homann on December 09, 2008, 04:00:58 PM
Peter,

 Yes I see what you mean and i tried It the other way and still no luck


Is there any modbus VB script examples I saw the video in the feed pot  but i may need something more to fall back on


A couple of things to try:

1.  Change the address 40001 to 40005. THis is because plc addressing subrtracts 1 sometimes.
2.  Change the address 40001 to 5. This is because holding registers are in the range 40000 ->


Cheers,


Peter
Title: Re: Allen Bradley micro logix and Modbus
Post by: poppabear on December 09, 2008, 08:16:39 PM
Here is the VB for accessing serial

Function: GetInBit(buffIndex, Bit Number) as Integer
  Function: SetOutBit(buffIndex, Bit Number) as Integer
  Function: ResetOutBit(buffIndex, Bit Number) as Integer
GetInBit(BuffIndex, BitNumber) to use this one, Index number is 0-63 on channel one, and 64-127 on Channel 2, and BitNumber is 0-15 relating to the individual bit status in that word that you want, i.e. 0 or 1. See the Input section of config autopoller modbus. NOTE If you are using Bit packing special control then you can only Use the GetInBit on the 2cd channel 64-127. You have to use something like "IsActive(INPUT1)" on channel 1. If you don't use bit packing then you can use it with the 1st channel.
SetOutBit(BuffIndex, BitNumber) to use this one, Index number is 0-63 on channel one, and 64-127 on Channel 2. and BitNumber is 0-15 relating to the individual bit status in that word that you want, It Turns the bit ON!!. See the Output section of config autopoller modbus. NOTE If you are using Bit packing special control then you can only Use the SetOutBit on the 2cd channel 64-127. You have to use something like "ActivateSignal(OUTPUT1)" on channel 1. If you don't use bit packing then you can use it with the 1st channel.
ReSetOutBit(BuffIndex, BitNumber) is just like SetOutBit(BuffIndex, BitNumber) above, but it turns the requested bit OFF.


GetMasterInput(0-1023)
GetMasterOutput(0-1023)

SetMasterOutput(0-1023, 0-16bit)

SetMasterInput(0-1023, 0-16bit)

scott
Title: Re: Allen Bradley micro logix and Modbus
Post by: Cncman2nv on December 10, 2008, 08:33:00 AM


So to use VB script calls the does modbus still has to be configured?


Title: Re: Allen Bradley micro logix and Modbus
Post by: poppabear on December 10, 2008, 09:35:10 AM
Use these if your using the "Serial Plugin Enabled" Modbus:

GetMasterInput(0-1023)
GetMasterOutput(0-1023)

SetMasterOutput(0-1023, 0-16bit)

SetMasterInput(0-1023, 0-16bit)

YES, you have to set up the Modbus config to communicate with your PLC.

scott
Title: Re: Allen Bradley micro logix and Modbus
Post by: KTM on December 10, 2008, 09:39:50 AM
Make sure that your plc comms protocol is set up as RTU 57600,8,1,N

In Mach modbus under special control select input word - 16 bits.
In ports and pins select modbus I/O support.

Regards

KTM
Title: Re: Allen Bradley micro logix and Modbus
Post by: poppabear on December 10, 2008, 03:52:32 PM
KTM:

Actually the Modbus protocol was fixed by Art to: 8,2,N, even if you type in 8,1,N the Sepia modbus module changes it to 8,2,N (that as the last I was told by Art himself
at the Galesburg 2 annual workshop.

scott
Title: Re: Allen Bradley micro logix and Modbus
Post by: Cncman2nv on December 10, 2008, 09:00:35 PM
I an trying to do some scripting and getting off to a slow start Is there a good way to see if the registers are beaning read
with out setting up screen
 
here is some code i have been trying with no luck
ModTest = GetInput(64)
Call SetUserDRO(39 , ModTest )

I could also use more clarification on these please
"IsActive(INPUT1)"
ActivateSignal(OUTPUT1)"
Title: Re: Allen Bradley micro logix and Modbus
Post by: poppabear on December 10, 2008, 11:41:43 PM
to write to 39 from the modbus you need to put in this VB to run at least Once in your init at start up, or once in your macropump: SetParam( "RPMOverRide" , 1 )

To check your registers on inputs and outputs, Use the "Mach Brains" and make you a Modbus input and output testing Brian to see your IO
GetINPUT(64) is for the "Old style" serial modbus, you need to enable Modbus support and serial plugin modbus under ports;pins

"IsActive(INPUT1)"  = this will return a 1 if that signal is on, 0 if off

ActivateSignal(OUTPUT1)"  will activate OUTPUT1
DeActivateSignal(OUTPUT1)"  will deactivate OUTPUT1