Hello Guest it is April 24, 2024, 09:38:21 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 - langosta39

Pages: 1 2 »
1
General Mach Discussion / Re: coordinate accuracy in position and time
« on: January 18, 2012, 12:31:58 PM »
In my experience, when using the Mach Parallel Port driver, you can not capture position information any faster than about 12Hz (don't recall the exact number).  Mach is operating much faster than that, but AFAIK for motion it queues up move/trajectory commands in the PP driver and then checks it that ~12Hz rate, at which time the DROs are updated.  The only way to get Mach's position is to read the DROs, so that's the limiting factor.  When writing plugins you can give trajectory commands to the engine faster, but you can't read the trajectory data out of the engine.  

In my project where I needed to sync graphics to the position I worked on this for a very long time and finally gave up on getting faster data.  What I did is oversample Mach's DROs (say 50Hz) then I could reasonably calculate the exact update interval that Mach was using, then I used interpolation to calculate where the machine PROBABLY was in between DRO updates.  This gave me a decently smooth graphical system @ 24Hz. It has the occasional jump when the interpolation is wrong, but generally is good.  Interpolation is making up data, so it won't be perfect.  It is fairly CPU intensive to poll Mach at a high rate through the Mach4 Scripter interface, so that is a consideration, too.

If anyone has a solution I'd love to hear it, too!

2
In case anyone is interested, or knowledgeable, in these things I thought I'd report back my findings.  I still can't find a way to receive event notifications from Mach, but here's what I know:

I can import the typelib from Mach3.exe, or I can use tlbexp.exe to generate a Mach DLL that works with .NET/C#/CLR.  This library is called "Mach4" and contains a Mach4 interface and a MyScriptObject interface. Mach4 has some methods for controlling Mach's startup and shutdown, and MyScriptObject contains many methods for controlling Mach, examples of which are on this forum.  Along with those, a few other interfaces appear, too, which are fairly well explained by this .NET/COM book: http://www.informit.com/articles/article.aspx?p=25922&seqNum=5 .  Looking at the DLL in the Object Browser of Visual Studio 2008 shows all of these things, and reveals many (100+?) events that Mach supposedly can fire.  After using the previous link and 50 other sites to figure out why I couldn't just add my event handler to the events I have pretty much given up.  I've used every workaround suggested on the internet but it all comes down to the fact that I can't get an IConnectionPointContainer from Mach.  It is frustrating because in the ILDASM.EXE utility I can see a private class in the library (IMyScriptObject_EventProvider which exists just as explained in the link above) that has the IConnectionPointContainer and IConnectionPoint variables, but I can't get to them.  Ultimately I guess that Visual Studio already knew this based on the error message I pasted into my previous post.  I should also mention that I've tried using the Mach.Remote example which is written in MFC C++ and also grabs a hold of Mach3.exe.  The MFC Class Wizard finds the basic classes, but it doesn't see any events.  Internet searching suggests that MFC can't handle events like that and ATL should be used.  I've also seen suggested that mixed-mode C++ can handle it while providing nice CLR/.NET access once you get it all wrapped up.

My old school C++ experience isn't sufficient enough to tell me that I really am out of luck or if I'm just doing it wrong.  Any input or suggestion is more than welcome.

3
Mach SDK plugin questions and answers. / Re: Faster DRO updates
« on: December 07, 2011, 03:45:35 PM »
Thanks for the link.

After digesting that document I'd say that I can't directly get what I want because Mach really only gets an update from the motion driver (parallel port in the case) every 100ish milliseconds.  But, I might be able to use the velocity data and do some interpolation to smooth out the GUI.

I appreciate your help!

4
Ok, I've found everything I need to get a hold on Mach from an external program or a plugin via the COM automation interface (http://www.machsupport.com/forum/index.php/topic,11589.0.html).

The one thing that I haven't been able to figure out is how to use all of the great exposed events in C#.  I get a weird exception thrown when I try to do this:
Mach.DoOEMButton += new Mach4.IMyScriptObject_DoOEMButtonEventHandler(Mach_DoOEMButton);
               
The exception says:
Unable to cast COM object of type 'System.__ComObject' to interface type 'System.Runtime.InteropServices.ComTypes.IConnectionPointContainer'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B196B284-BAB4-101A-B69C-00AA00341D07}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

I haven't seen anything on the forums regarding the use of events, but to me the use of events makes total sense or you have to poll dozens of states to keep the external program in sync.

Thanks all

5
Turns out there is a lot of information out there if you do forum search for "Mach4"

6
I'm having this exact problem with the FNF exception... http://www.machsupport.com/forum/index.php/topic,16664.0.html

Scoppio, did you ever get it to work?

7
Hi Steffen,

I've considered doing it that way too, but it takes a lot more work and then the user can edit the button script and mess it up.

Since posting my cry for help I found Jemmyell's tutorial post (http://www.machsupport.com/forum/index.php/topic,4884.0.html) and on Page 67 he talks about an Object Model Support.  Now I'm programming in C++ .NET and don't want to use MFC because lots of my code is managed, but that did tip me off to something.  In my VC++ project I added a reference to the Mach3.exe file and lo-and-behold a managed class called Mach4 showed up.  Unfortunately I haven't quite yet figured out how to use it, but it does reveal 100+ events that I should be able to listen to, including a DoOEMButtonEventHandler.  Right now I'm in the thick of it, and a couple of the questions running through my mind right are how I get a pointer to the running Mach instance instead of just instantiating the Mach4 class (you'd think there'd be a static reference in the class interface), and how I reference Mach3.exe so it doesn't crash with a File Not Found exception at run time (which I am seeing).

Thanks guys.

8
Is it possible to have Mach notify a plugin, or have a plugin detect, when an OEM Button is pushed?

I've been pouring over the Wiki and documents for a couple weeks now and either its not mentioned, or my brain is sufficiently fried so I can't remember anything : )

9
Mach SDK plugin questions and answers. / Re: Faster DRO updates
« on: December 06, 2011, 07:26:44 PM »
Thanks for your input.  I decided to do a test, too, and I found out that wherever the GetDRO function pulls its data from is only updated at about 12Hz. I configured the HighSpeedUpdate to be 100Hz and then called GetDRO after which I logged the data.  At 100Hz I would just get 9 of the same readings in a row, but the machine was smoothly jogging at the same time.  If Mach is pulsing the parallel outputs it must know how many pulses its doing (since it is so darn precise), so it seems like I should be able to get at it. 12Hz is just a little too slow for a nice GUI update rate.

If anybody has any great ideas, please let me know, I'm willing to experiment.

10
Mach SDK plugin questions and answers. / Re: Faster DRO updates
« on: December 02, 2011, 02:47:12 PM »
Thanks for your input anyway.  Bring on the experts! : )

I'm hoping that internally the position is updated faster.  It's doing something really fast since it is doing stepping at many kHz and the lowest core speed you can choose is 25kHz.  After looking around the Engine API I don't see anything immediately apparent that will give me what I want.  I could try to use the axis velocity and do dead reckoning for position then resync every 10Hz when the DROs are updated.  That sounds possible, but I'm hoping to use something a bit more exact!

Thanks again

Pages: 1 2 »