Hello Guest it is April 24, 2024, 02:04:29 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - wz2b

Pages: 1 2 »
1
Mach SDK plugin questions and answers. / Re: Mach4IPC.dll interop for C#
« on: December 22, 2021, 12:15:07 PM »
I'm still trying to get real time XYZ and machine state out of my older Mach 4 and am taking another path.  I watched a youtube video where somebody was doing some control by attaching to MachIPC.DLL from C#.  I couldn't find any documentation on MachIPC.DLL but I did a dumpbin on it and it has many of the same symbols as MachCore.DLL including things like:

Code: [Select]
    _mcAxisGetMachinePos@12
    _mcAxisIsHoming@12
    _mcAxisIsStill@12
    _mcSpindleGetMotorRPM@8
    _mcAxisGetPos@12

Based on nothing more than the names matching, I copied a few mappings out of one of the samples, hoping it would work the same:

Code: [Select]
[DllImport("Mach4IPC.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.I4)]
public static extern int mcAxisGetPos(
[param: MarshalAs(UnmanagedType.I4)] int mInst,
[param: MarshalAs(UnmanagedType.I4)] int axis,
[param: MarshalAs(UnmanagedType.R8), In(), Out()] ref double val);

[DllImport("Mach4IPC.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.I4)]
public static extern int mcAxisGetMachinePos(
[param: MarshalAs(UnmanagedType.I4)] int mInst,
[param: MarshalAs(UnmanagedType.I4)] int axis,
[param: MarshalAs(UnmanagedType.R8), In(), Out()] ref double val);


I don't know that is right, and I don't know that MachIPC.DLL is intended to be used this way, but based on the name it seems so.  My goal here would be to create a standalone program that gets the info that I want out of running Mach4 and then sends it out over the network, probably via MQTT.

I do not know how to begin a 'session' either - mInst looks like it's some kind of handle that I need to obtain first.

Am I on the right path here?





2
Mach SDK plugin questions and answers. / Mach4IPC.dll interop for C#
« on: December 21, 2021, 08:32:55 AM »
Does anybody have a Mach4IPC interop bindings library for C#?

3
Mach SDK plugin questions and answers. / Re: Machine / Production State
« on: November 19, 2021, 03:36:07 PM »
Hi there,

I definitely have Mach4.
https://photos.app.goo.gl/bG6DY1nJj54rLteX9
but it's an older version.  instead of Mach4API it has Mach4IPC.DLL.

I would LIKE to do it with the built-in API but how then do I get the data OUT?  That's my problem.  The lua install doesn't have the sockets library.  The modbus plugin does work but it doesn't seem really able to read values out of the core.  I don't really want modbus, anyway.

Does anybody know if me having just Mach4IPC.dll is the clue here?  If IPC means what IPC usually means, it sounds like that might be the way, and I just need an older set of headers to link again.




4
Mach4 General Discussion / Re: Modbus sending same register twice
« on: November 12, 2021, 10:19:35 AM »
I would love to do that because then I'd skip modbus entirely and send the data the way I really want it to be sent: via MQTT.  I tried to create a C# project though and I think my older version of mach4 might not have the ability?  I went to create a visual studio C# project and I couldn't figure out which of the DLLs I have are something I could attach to.  The docs suggest I should have MachAPI.lib but I don't have that library anywhere on my system.


5
Mach4 General Discussion / Re: Socket support
« on: November 09, 2021, 05:11:55 PM »
Unfortunately, support told me my best best was to ask here haha.

6
Mach4 General Discussion / Re: Modbus sending same register twice
« on: November 09, 2021, 02:02:35 PM »
I think I misunderstood what it means to declare a register under modbus2.  I can name that register ContAxisPos2 but that doesn't connect it to that variable in mach. I discovered that if I force that value to "2"on the Mach register diagnostics screen that it does indeed push a 2 to my device.  So I think the problem is I don't know how to connect that Modbus register (on the Mach end) to the actual info I want it to send somewhere in mach. Is this something I have to write as a lua task?

7
Mach4 General Discussion / Modbus sending same register twice
« on: November 09, 2021, 01:56:39 PM »
Version 4.0.1.2259

I'm using the NewFangled modbus plugin to try to send X,Y,Z to an external data logger.  As configured there were two modbus devices, so I added a third.  I then set it up to send some registers using write multiple. Basically it's identical to one of the modbus configurations that writes to an on board PLC, but I'm also having it write to my own device.

The registers I'm trying to send are ContAxisPos1, ContAxisPos2, etc.  My modbus device is modbus2; modbus0 and modbus1 are PLCs on the machine.

Near as I can read, my modbus write function is identical to the one that writes to modbus0.  Same function code, same references. Very fast round trip time reported in Modbus Diagnostics (<5 msec).  The other end (my device) is receiving the messages no problem.  However, it's all zeros.

I can't figure out why when I look at modbus0 diagnostics ContAxisPos1 would have a value (say -118) but just below it trying to write the exact same register to device modbus2 that value (and all other values) is sending 0.  I confirmed with wireshark that's really what it's doing.

Is there any problem with trying to send the same register to two different places?


8
Mach4 General Discussion / Re: Socket support
« on: November 09, 2021, 01:51:44 PM »
Thanks for that reference.  The sockets library is, however, not in my installation.  Could that be because of the older version I'm running?  Or can I download / install it?  The only lua sockets library I was able to find was in source form, I'm not exactly set up to build it.  I think a lua module is just a dll though so ifI could find one for win7/32 I could just use it.

9
Mach4 General Discussion / Socket support
« on: October 30, 2021, 04:48:19 PM »
I have a machine that is running Mach4 version 4.0.1.2259 with some custom add-ons that were put in to control a laser.  It's an older version of Mach4, but it is a licensed version and unfortunately upgrading it is out of the question because of all the custom development that went into it.

I want to modify it to do something relatively simple (I think).  I want to write a lua script that runs either on a timer or creates its own thread with a timer.  I want it to get the mc object and periodically spit out some data via a UDP socket:

* What program (g-code file) is currently running
* Current spindle speeds
* Current X,Y,Z

I'm stuck trying to figure out how to do this.  I think an .mcs file is really just lua, so I thought I could download a copy of a luasockets dll and 'require' it, but that doesn't seem to work and I'm not sure why.

Is this approach even possible?  Or do I really need to develop a legitimate external plugin?  An .mcs file is just lua, right?  Is there any way to figure out what version of lua it is?

It does seem to have modbus included.  If what I'm trying to do won't work, then maybe there's a way to do the same thing by having it just push this data to a modbus device that happens to be my PC (running a tcp modbus server) rather than a PLC?

10
Mach4 General Discussion / Re: Lua script for feeding OEE
« on: September 22, 2021, 05:07:06 PM »
Thanks, Steve!  Part of the reason I was confused was the Docs folder was for some reason EMPTY.  I don't want to screw up the real installation so I installed Hobbyist just to get the Docs folder and it looks pretty understandable.

At one point in time, was there also a .DLL interface you could just attach to?  Or was that only a Mach 3 SDK thing?

(I'm a very experienced developer, but not so much in lua- though I have written quite a bit of network analysis code in Lua because it's built into Wireshark.  So I don't think that part should really be too bad).

Pages: 1 2 »