Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: stirling on October 21, 2010, 05:02:58 AM

Title: modbus
Post by: stirling on October 21, 2010, 05:02:58 AM
Anyone know how to send a byte or a word or indeed anything from Mach VB to a modbus slave (direct access - not autopolling preferably)? I can happily read/write data from/to my slave's holding registers using the Mach modbus test interface - but how to do with VB?

The wiki teases us with this:

Quote
Direct access to Modbus registers

There are occasions when a VB Script writer needs direct access to Modbus device registers. This is provided by an interface which allows reading and writing of a block of one or more registers into Mach3 buffers (distinct from the autopoller buffers) and routines for accessing data in the buffers.

But sadly no mention that I can find of WHERE these elusive VB calls are documented.
Any seasoned modbus gurus out there?

Cheers

Ian
Title: Re: modbus
Post by: BR549 on October 21, 2010, 10:27:37 AM
Ian , you need to contact Peter Holmann designer of the MODIO system  he is a Modbus Guru.

Last I heard the new Plugin Modbus is broken and no imediate plans to fix. The OLD serial system still works LAST I USED IT.

Seems most abandoned modbus for USB.  Shame really as MODBUS is one of the MOST used protocalls and USB well it is just USB(;-)

I can round up some info on the VB side for you if needed.

(;-) Tp
Title: Re: modbus
Post by: BR549 on October 21, 2010, 10:47:23 AM
IAN look in the Mach wiki under Mach subfunctions it gives the basic VB  commands and syntax to talk to a modbus device. It shold be what you need.

(;-) TP
Title: Re: modbus
Post by: stirling on October 21, 2010, 11:04:55 AM
IAN look in the Mach wiki under Mach subfunctions it gives the basic VB  commands and syntax to talk to a modbus device. It shold be what you need.

(;-) TP
I'm currently ploughing through this BUT there doesn't seem to be anything other than using autopolling. There are hints that direct access is possible but no explanation of how. I'll keep reading.

All I want to be able to do is send an 8 bit DRO value to my THC when I hit a screen button (required torch voltage). I've looked at sendserial but there are issues that make it less than ideal. I thought modbus would be the way but now I'm not so sure - it seems to be about the most complex method imaginable to send a few bits of data.
Title: Re: modbus
Post by: BR549 on October 21, 2010, 03:30:37 PM
I see your point. (;-) 

I used to have a good pendant that was Modio it worked great UNTILL someone changed something in MACH and it never worked right again.

What did not work about the send serial, that is an 8bit transfer.??

Title: Re: modbus
Post by: BR549 on October 21, 2010, 03:45:21 PM
IAN I don't see any way to do a VB based direct write TO the modbus registers. You can only do a direct read FROM the modbus register to mach

The only way I see is to write  thru the autopolling method. I do know that works fine as that is the basis of the pendant I have.

Peter could tell you for sure. OR possibly SCOTT. I forgot about Scott.

(;-) TP
Title: Re: modbus
Post by: stirling on October 22, 2010, 04:12:36 AM
What did not work about the send serial, that is an 8bit transfer.??

The problem with sendserial is that it isn't session based. It opens the port, sends the data and closes the port again. The way I've designed the THC is that it treats a port open as the start of a session and resets the MCU. If sendserial is what I have to use then I'll re-jig this - just thought modbus might be the way but I'm going off it by the minute!

I agree it seems a read is trivial but not a write - strange. I may be wrong but I'm getting the feeling that Mach's modbus protocol is non-standard and has been fudged to work with particular hardware rather than with any general modbus slaves. I'll keep at it for a short while and see where I get.
Title: Re: modbus
Post by: BR549 on October 22, 2010, 10:17:33 AM
Well the problem with a standard IS there are so many of them(;-).

It sounds as though the modbus is what you are needing as it is available ALL the time.

Many have used the Modbus to drive PLCs so it does work

Just a thought, (;-) TP


Title: Re: modbus
Post by: BR549 on October 22, 2010, 11:30:37 AM
Just a thought, looking at other THC they used the serial port BUT it seems to be a hybrid protocal that is done through a PLUGIN.

(;-) TP
Title: Re: modbus
Post by: BR549 on October 22, 2010, 01:40:31 PM
I guess the first question IS what com protocol does your THC unit use to communicate.

(;-) TP

Title: Re: modbus
Post by: poppabear on October 22, 2010, 06:43:52 PM
Stirling, you can write to/from the mod bus, using the OLD style modbus, not the new plugin modbus, for the new on you haev to do indirect via, Brians....

the Wiki, under modbus has the calls for OLD style serial MB to send/receive data....

scott
Title: Re: modbus
Post by: stirling on October 23, 2010, 11:58:17 AM
Hi Scott

I've not been able to find anywhere in the wiki where you can WRITE to a modbus slave from Mach OTHER than via autopolling. The wiki promises you can use direct access but gives you no clue as to how. I don't really want to use autopolling because all I want to do is send the reference voltage the THC should use for any particular cut setup. I just need to do that once per run when the cycle start is hit. The THC has enough to do without continually being polled unneccessarily so hence my desire to use direct access.

Terry

The THC is my own design - hardware and software and so I can make it use any protocol I like. I thought I'd try modbus because it seemed the obvious way to communicate with a bespoke device via serial from Mach - BUT I guess not. Like I said earlier, I'll just re-jig the serial hardware interface and use Mach's sendSerial. All other comms between the THC and Mach are done conventionally via Torch On/Up/Down etc. it's just that one serial tx I need to send the required voltage.

Thanks both

Ian
Title: Re: modbus
Post by: BR549 on October 23, 2010, 12:55:51 PM
Ian keep us up to date (;-) There IS a need for a good simple thc .Now I am sure it is NOT simple but you get the idea.

(;-) TP
Title: Re: modbus
Post by: stirling on October 24, 2010, 06:22:12 AM
Would that life was so simple. At the moment my THC is designed to work only with the hypertherm range as they're the only systems I've come accross that have a ready built in interface. I may look at a more generalized system at some point but here in Europe a system that requires the user to insert a custom interface into a plasma unit presents quite a challange from a H&S/legal/warranty perspective so I'm not sure there's any milage in it sadly - unless someone can tell me otherwise.

Ian
Title: Re: modbus
Post by: poppabear on October 24, 2010, 09:09:38 AM
oh, ok......

Here is two other possilbe simple solutions, one you do the other buy off the shelf stuff.......

1).  since you only need a voltage to send, at start up of m3, (or on changes?)
      convert your voltage to a BYTE format, and send each BIT if it is a 1, to one
      of m3's 8 OUTPUTs, this could be an standard piece of CAT5 cable wiht RJ's on each end.
      in your hardware, you look at the pattern of on/off on the 8 wires, and rebuild the byte,
      and convert it back to a number, that represents you voltage.
           You could put an "Init" macro in mach that would pull the starting voltage from a DRO,
      on your screen, converts it to a BYTE, sends it as 8 output lines each line representing one BIT.
     Your hardware reads the value, converts it to a number, and sets the voltage with it.

          1A). If you did need to make a run time change of the voltage, just put a screen button,
                 that has the "sending code" discussed above, your hardware could note that the value
                 in its register has changed, and set to volt to a new level.

2). Off the shelf solutions, use PLC with analog card (I have used ADC DL05 with analog card for THC, you can ajdust the PID
loop as well, so that you can elimitate "Dive" and get intellegent control), cost of that is about 300.00 US funds.
2A). Since you might want other intellegent IO, try a MESA board.  The stuff like the PK, MODIO, Modbus board, are tied to some kind of continual update loop, for there analog outputs. The PK, I could put a "run once" in it on an analog or IO pattern for you. BUT, I think fx issolation would be an ongoing issue with the Plazma.

3). As a side note: Brian released a "General Serial" plugin template, you could download and modify that for your needs.
or pay some poor sap like me, or Steve, or Ed to do it for you, or yourself.....hehehhee.

scott
           
Title: Re: modbus
Post by: stirling on October 24, 2010, 11:41:51 AM
hmmmmm - I think I'll do as I said earlier to Terry and re-jig my hardware. I'll disconnect the DTR which I use to signal a THC CPU reset when uploading the firmware to my board and then I can use sendSerial to send my required ref voltage. I'll just need to re-connect it to do the firmware updates as and when. Might even stick a gate in there and then I can control whether DTR is acted on or not via another input to the board.

Ian