Hello Guest it is May 06, 2024, 05:18:59 AM

Author Topic: Modbus Programming guidance needed  (Read 4269 times)

0 Members and 1 Guest are viewing this topic.

Re: Modbus Programming guidance needed
« Reply #20 on: January 03, 2021, 12:02:31 PM »
Using a PLC for IO is the best option IMHO. Very stable communication in a robust setup. It’s rather easy to do in Mach4.  All my inputs are in the input configuration. I guess I set it up right long ago lol. I would like a manual of o go over how stuff works together.
Brian, if you need some real word examples of PLC and Mach working together, let me know.
Chad Byrd
Re: Modbus Programming guidance needed
« Reply #21 on: January 03, 2021, 12:47:42 PM »
I was going to use a click PLC to get my screen shots. I have one on the bench all setup. If you guys have some drives you would like examples of I could make an appendix in the manual to show people what the settings are for a few devices. I am thinking click PLC , automation direct drives and then a few of the Chinese ones that people seem to use. I know this sounds dumb but I did a VFD on a coolant pump before. It was really cool! I set it so you could do m8 p50 and get 50% flow :)
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com
Re: Modbus Programming guidance needed
« Reply #22 on: January 03, 2021, 01:19:22 PM »
Now that’s pretty cool.  I’d love to see how you did that.
I also used a BRX from automation direct. It’s a pretty sweet little PLC. Got the communication setup for it as well.
Chad Byrd
Re: Modbus Programming guidance needed
« Reply #23 on: January 03, 2021, 07:51:51 PM »
Brian,
Using an Arduino to add extra I/O and analog inputs to add FRO, SRO and RRO would be nice.


I have trouble starting from scratch but I can copy and paste with the best of them.

Mike
We never have the time or money to do it right the first time, but we somehow manage to do it twice and then spend the money to get it right.
Re: Modbus Programming guidance needed
« Reply #24 on: January 03, 2021, 08:02:09 PM »
Are you guys tapping the lines here? I have been taking with someone about a project for a simple serial communication. We are looking at a simple command set so you can easily send control panel commands. I won’t mention any names in the event we don’t follow through. This seems like it could be a bunch of fun for people.

Mike wound that work for you? You can do it now but you would need to use the serial plugin.
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com
Re: Modbus Programming guidance needed
« Reply #25 on: January 04, 2021, 09:30:07 AM »
Here you are Chad... it is not code that will change the world or anything but it should give you what you need as a base to start from. The cool part is that it shows you how you can read data from the line of the Mcode! The only thing I could not do for you is set the max Hz or set the register that would set the value.

Please tell me if this works for you ..

Code: [Select]
function m8(hParam) --The param is a P value called from Gcode. M8P50 for example would be 50%, No value will be 100%.
local inst = mc.mcGetInstance()
local varP = 100.00 -- default is 100%
if (hParam ~= nil) then
local flagP, rc = mc.mcCntlGetLocalVarFlag(inst, hParam, mc.SV_P)
if (flagP == 1) then --Check that the flag has been set so we do not get an unexpected value for mc.SV_P
varP = mc.mcCntlGetLocalVar(inst, hParam, mc.SV_P)
end
end
mc.mcCntlSetLastError(inst, string.format("P val == %.0f",varP))
local handle = 0;
handle = mc.mcRegGetHandle(inst,"0Regs0/test")-- TODO  !!!!!!!!!!!!!!! Set Modbus register value here
if (handle ~= 0)then
local MaxVFDSpeed = 7000
local val =  MaxVFDSpeed*varP/100
val = string.format("%.0f",tonumber(val))-- Get Val as an int
mc.mcRegSetValue(regH ,tonumber(val))-- Set the speed of the pump
end
handle = 0;
handle = mc.mcSignalGetHandle(inst, mc.OSIG_COOLANTON)
if (handle ~= 0)then
mc.mcSignalSetState(handle, 1)
end
end

if (mc.mcInEditor() == 1) then
    m8()
end
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com
Re: Modbus Programming guidance needed
« Reply #26 on: January 04, 2021, 09:46:18 AM »
Thanks Brian,  that’ll be nice to use for other things as well!
Chad Byrd
Re: Modbus Programming guidance needed
« Reply #27 on: January 04, 2021, 10:16:24 AM »
I can't tell you that I will not miss some but I am going to try to hit this one message board on a regular basis. So if you have something you would like to see I will be around.  I forgot how much fun I had solving problems ;) .
Fixing problems one post at a time ;)

www.newfangledsolutions.com
www.machsupport.com
Re: Modbus Programming guidance needed
« Reply #28 on: January 04, 2021, 10:45:58 PM »
I will definitely welcome the help if you have time to remote in.  I run Mach 4 hobby on a old laptop and have found I have less problems if I keep it off the internet, seems like Windows waits until I hit cycle start to try and update. You let me know when and I’ll get it connected to the internet .  I’ll give you some background on my setup. I bought and finished a partially assembled machine from Alex Burt at CNC Depot. It is a 3 axis bridge mill/gantry router. It’s a beast. Table is 30”x 96” and it weights about 4000 pounds.It came with a Click PLC, WJ200 VFD, and Clear-path SDSK Nema 34 servos turning ball screws. Later I put a S30C ATC spindle from CNC Depot (which I love). I use an Ethernet Smoothstepper for motion control and now that you helped me get Modbus working, I use the Click PLC as remote relays for stop/start of my drive, power drawbar, and I have several extra air solenoids for a future air blast/mist coolant and retractable dust boot. I use a PWM to 0-10 volt conversion module to set my speed on the drive from the smoothstepper. It works ok. The VFD only has 1 set of  programmable contacts, so you have to pick what info is most important. I’d like to be able to read fault status during normal operation AND be able to read Zero Speed status before the drawbar releases during an auto tool change.  Seems like Modbus might be a solution. Would it be better to get a second USB to rs232 for my laptop and have a dedicated Modbus circuit for the drive or would it be better to daisy chain the drive on the same Modbus circuit as the Click PLC? Is there a preference on baud rate for Mach?
Re: Modbus Programming guidance needed
« Reply #29 on: January 05, 2021, 07:05:13 AM »
Are you guys tapping the lines here? I have been taking with someone about a project for a simple serial communication. We are looking at a simple command set so you can easily send control panel commands. I won’t mention any names in the event we don’t follow through. This seems like it could be a bunch of fun for people.

Mike wound that work for you? You can do it now but you would need to use the serial plugin.
Hi Brian, since there is already a Modbus library for Arduino and I also have a Click PLC, and possibly some VFD's to connect, I personally would like to stick with Modbus.


It is nice to see that Mach 4 has matured enough that you are not stuck in development mode all day everyday.

Mike
We never have the time or money to do it right the first time, but we somehow manage to do it twice and then spend the money to get it right.