Hello Guest it is March 29, 2024, 03:19:00 AM

Author Topic: MACH4 - Modbus  (Read 80283 times)

0 Members and 1 Guest are viewing this topic.

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: MACH4 - Modbus
« Reply #80 on: February 24, 2015, 06:39:57 PM »
now THAT is useful!!

Is there any other calls to the register about modbus for:

  1).  Get the Serial and/or Ethernet Com error., i.e. Com disconnected etc.
  2).  Get if the user has or has not "enabled" the modbus Plugin (active, and should be communicating).
  3).  Is there a way, to get or set, Com "Time outs" and Get/set how many "Retries" before throwing
        a lost communication error (watch dog type thing).

As the Evil Terry always says.........  "Just a Thought"... ..  HEHEHE

Scott
   

« Last Edit: February 24, 2015, 06:50:15 PM by poppabear »
fun times

Offline simpson36

*
  •  1,369 1,369
    • View Profile
Re: MACH4 - Modbus
« Reply #81 on: February 25, 2015, 09:10:14 AM »
First, thanks to Smurf for the response, I will checkout the .ini

Scott, I will send you the .ini file intact as it is possible that either your MAD software, or my incorrect use of it, cause the gremlin because it started with the MAD install
 

Now a general FWIW. While I do not yet know how useful the built-in MACH4 Modbus 'monitor' will be, I am happy to have it and will investigate. Meanwhile, this is what I am doing to 'monitor' the TCP Modbus. This is a general description of the function. Please do not ask for the code. It is not generic.

1) in the device, track the number of modbus reads
2) send that number continuously over Modbus to MACH3 (I have not done this with MACH4 yet - and may not have to)
3) read the counts in MACH and compare each number to the previous.
    A) read
    B) store the value
    C) start a timer of some kind
    D) read again (after a longer period than the Modbus speed)
    E) compare reads
    F) if the reads do NOT match, Modbus is not only running, but the data is being passed correctly. If they do match, the com is broken, the device has locked up, of Mach has stopper sending queries for some reason. 

There are doubtless lots of way to skin this cat. I am using the MacroPump to do this. In my setup, it actually is already in use for monitoring/sending E-stop to my Motor controller, and the Modbus 'monitoring' code was just added to it.

Since I do not want to pause the E-stop monitoring waiting for the next Modbus read, I am using the actual MacroPump execution loop as the timer.

So far it is working fine.





Offline simpson36

*
  •  1,369 1,369
    • View Profile
Re: MACH4 - Modbus
« Reply #82 on: February 25, 2015, 09:26:18 AM »
There is an orphan node in the modubs settings (inside the profile's Machine.ini).  Choose "no" or "cancel" and try to use the modbug config dialogs to get rid of it or edit the Machine.ini file.

Steve

I did not find anything in the .ini relative to Modbus except Modbus=1. I searched on 'Mod' on 'Bus' and 'reg' and found nothing relating to Modbus. What should one look for in the .ini?   This was a fresh install so perhaps there is no Modbus config data in the .ini yet?

On to success: I clicked cancel at the error message and was taken to the config screen, but it was blank as before.  I clicked on the 'add connection' icon and got an input screen and was able to set up a Modbus connection.

Closing and reopening MACH4 and the Modbus config is working and it kept the first connection, so I think I'm off and running.

Thanks!



Offline simpson36

*
  •  1,369 1,369
    • View Profile
Re: MACH4 - Modbus
« Reply #83 on: February 25, 2015, 09:55:05 AM »
Update:

After configuring some Modbus connection/function the stuff showed up in the .ini

Scott, original .ini has no Modbus data, so it would not be useful.

Mach4 is once again talking to my processor, so I'm good to go for porting over the Mach3 stuff

Offline simpson36

*
  •  1,369 1,369
    • View Profile
Re: MACH4 - Modbus
« Reply #84 on: February 26, 2015, 03:59:19 PM »
So far I have only spent a couple of hours on the controller port and it is about 90% functional on MACH4. It turned out to be just ridiculously easy. Having the entire controller already moved to TCP Modbus and all serial connections (like the Configurator program) already removed, it was just a matter of setting up Modbus and making a bunch of screen buttons.

Except for . . . .  I'm struggling with making the Y and Z axis data continuously stream to respective Modbus registers.

Should there just be a function created and stuck in the 'screen script' and is there a special function name that means 'run this function continuously' in the manner of the MACH3 macro pump?. Should there be a timing loop to throttle how much processing time such a script consumes?

Secondly, I have found no way to connect a slider to a Modbus register. Not an emergency, but is his doable?

Lastly another wish list item; is there, or will there be an 'image toggle' button. The toggles are uber convenient and a dream compared to MACH3, but they are also pretty ugly.

The first issue is the most pressing; streaming axis coord to a Modbus register. Actually two registers, one for the integer portion and another for the fractional portion, but I can take care of that if I can figure out how/where to put code to stream the data.

Thanks!

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: MACH4 - Modbus
« Reply #85 on: February 26, 2015, 04:54:32 PM »
Use the screen PLC script to push the axis values to modbus.  There is an interval to control the PLC script timing.  If you want a function of that, just make the modbus update every other PLC script run or something along those lines.  

You can connect a slider to a modbus register by also using the PLC script.  The plc script should get the value of the slider via the scr.GetValue('control name', 'property name') function (I may not have that syntactically correct).  Then push that value to the modbus register.

With wxWidgets 3.0+, toggle buttons can have images.  We started with 2.8, so toggles never got images.  So I will add that when I get a chance to get back into the GUI code.

Steve

Offline simpson36

*
  •  1,369 1,369
    • View Profile
Re: MACH4 - Modbus
« Reply #86 on: February 27, 2015, 05:31:25 PM »
Use the screen PLC script to push the axis values to modbus.  There is an interval to control the PLC script timing.  If you want a function of that, just make the modbus update every other PLC script run or something along those lines.  

THANKS! That was the nudge I needed. I had to do some homework around the forum to figure out what PLC Script is, but all working well now.

Tremendously faster than MACH3! :o

The Axis data is used to calculate RPM based on SFM and OD during turning operations. This method is activated only in 'AutoSpeed' mode. To keep the CPU load minimal, I only turn on the streaming when in AutoSpeed Mode and then only for the axis that is being tracked.  The CPU in the new MACH4 TCP version of my Motor Controller is about 5x (real world) faster than the previous version, so together with the uber fast MACH4 Modbus, I should get very close follow, instant response time (effectively)  and very smooth ramping.

You can connect a slider to a modbus register by also using the PLC script.  The plc script should get the value of the slider via the scr.GetValue('control name', 'property name') function (I may not have that syntactically correct).  Then push that value to the modbus register.

Have not tackled this yet, but not a high priority. Should be no problem, now that I have the basic process figured out. Something I like about MACH4 (and Lua) is that once you get a certain process figured out, it works pretty much across the board. Each little thing you want to do is not 'slightly different' or need a particular work around.

At least that's my impression at the moment.  8)

With wxWidgets 3.0+, toggle buttons can have images.  We started with 2.8, so toggles never got images.  So I will add that when I get a chance to get back into the GUI code.

Steve

Perfect!  It won't work any better, but it will look GOOD. and as Fernando says 'Is better to look good than to work good, and image toggle buttons will look MARVELOUS!"
« Last Edit: February 27, 2015, 05:35:24 PM by simpson36 »

Offline simpson36

*
  •  1,369 1,369
    • View Profile
Re: MACH4 - Modbus
« Reply #87 on: March 01, 2015, 06:02:13 AM »
Quick update;

Sliders are working fine. Better than fine, actually. I have two sliders, one for RPM input and one for SFM input. Each has a corresponding DRO that is both a readout and numeric input. The sliders are only active when the mode that they effect is selected.

E-stop is tied to the motor controller and it notifies the controller and turns off the spindle and disables the ON/OFF button while in E-stop. and leaves the spindle switched OFF at reset (so the spindle does not suddenly start up again on  reset). All relatively simple tasks to accomplish in MACH4. These same tasks required a lot of 'smoke and mirrors' as well as a MacroChargePump in MACH3. Switching off the  spindle and leaving it off on reset was a fairly good sized PIA in MACH3. In MACH4 it took literally a few minutes and no workarounds and it functions reliably and instantly.

The last task in porting over the controller is a program to collect and feed user parameters to the controller for storage (previously in EEPROM, now on an SD card). This program will use Modbus to send the collected data to the controller, but since I hope to make a nice looking single input screen for al of the parameters (like the original Windows 'InTurn™ Configurator' program), I will take that task over to the 'Scree Ideas' thread where this stuff seems to be happening, and then come back here for the Modbus functionality.

Impression: MACH4 is worlds apart from MACH3 as a development base. Literally in a few hours I have been able to accomplish in MACH4 (starting with zero experience and not knowing Lua) what took days and much frustration to accomplish in MACH3.  ;D

Specific to Modbus, I have noted even after everything is configured and working, MACH3 sometimes starts up with TCP Modbus unconnected and a restart is needed to get it going. MACH4 is somewhat unstable while writing scripts, but so far it has never started up with Modbus dead and needed a restart.

Apart from the ugly screen, MACH4 is 'looking' very good to me at this point!
« Last Edit: March 01, 2015, 06:04:41 AM by simpson36 »

Offline smurph

*
  • *
  •  1,544 1,544
  • "That there... that's an RV."
    • View Profile
Re: MACH4 - Modbus
« Reply #88 on: March 01, 2015, 03:43:21 PM »
The screen can be changed to anything you like.  It is a bit spartan.  Believe it or not, that screen design is over 15 years old!  It came from my milling machine GUI front end for Galil controllers way back in the 90's (before I stumbled upon Mach3).  When we were developing the Mach 4 core, and hadn't really done a GUI or any sort at that time, we needed something quick and dirty to test with.  So that old code/screen design is what I had from way way back and it became wxMach.  Then when we did the user configurable GUI, the test was to see if we could duplicate wxMach with Mach4GUI.  And we did, as unfortunate as it may seem.  :)

I'll be the first to admit that I have no "flare" for GUI interfaces.  Not my cup of tea, so to speak.  In fact, I can't do anything artistic as it pertains to drawing or anything visual.  I have to leave that up to people that have the talent for it.  I like DOS screens.  And I think the Fanuc screens are "works of art".   :)

Steve

Offline simpson36

*
  •  1,369 1,369
    • View Profile
Re: MACH4 - Modbus
« Reply #89 on: March 01, 2015, 05:33:28 PM »

I'm just waiting for a paintbrush and I'll take it from there. The 'paintbrush' in this case is images on the toggle buttons.

I have seen from other posts that there is a way to add large images, so the ugly background is probably pretty easy to replace. Nothing we can do about the ugly buttons until you (or whoever) implements the image Tbuttons. Yes, the non-'T' buttons can have images, but the 'T's are just too convenient to use

Personally, what I would like to see is a screen with only a single big button in the middle of the screen labeled 'Make Part' . . . . .  ;)

Not sure who to credit this to . . Mark Twain maybe . . .  who was admonished by a female patron in a bar for being overly inebriated. He replied 'Yes Madam, I am quite drunk, however, tomorrow I shall be sober and you will still be ugly' . . . .