Machsupport Forum
Mach Discussion => Mach SDK plugin questions and answers. => Topic started by: madfly on February 24, 2011, 03:25:43 AM
-
Hello I want to write a plugin for Mach3 for use in PCs that do not have a parallel port, I had in mind to capture the signals that Mach3 send to the parallel port, how can I do?
regards
-
I have the same problem. A didn`t have any LPT on my motherboard so i decided to control mi driver trough USB. I have my progrma writen in C# which gets and sends data to my PIC trough the USB using HID. A managed to control a stepe motor trough the PC and now Im working on making Servo controler mith my PIC18F2455.
First i thought that i wil capture the LPT data which Mach3 sends and redirect it to the USB and the PIC but when i dont have a LPT it sounds imposible unles i make some Emulated LPT.
But now i am workingo on making plugin for Mach3 . I want to do it in C# .NET
I`ve read this topic http://www.machsupport.com/forum/index.php/topic,11589.0.html (http://www.machsupport.com/forum/index.php/topic,11589.0.html) and i`m trying to acces the Mach3 , But i get an error
System.Runtime.InteropServices.COMException was unhandled
Message="Невалиден низ за клас (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))"
Source="mscorlib"
ErrorCode=-2147221005
StackTrace:
at System.Runtime.InteropServices.Marshal.CLSIDFromProgID(String progId, Guid& clsid)
at System.Runtime.InteropServices.Marshal.GetActiveObject(String progID)
at Test_Mach3_plugin.Form1.button1_Click(Object sender, EventArgs e) in C:\Users\Asen\Documents\Visual Studio 2008\Projects\Test Mach3 plugin\Test Mach3 plugin\Form1.cs:line 33
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Test_Mach3_plugin.Program.Main() in C:\Users\Asen\Documents\Visual Studio 2008\Projects\Test Mach3 plugin\Test Mach3 plugin\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
-
Hello I would like to develop the plugin with Visual Studio 2008 and C + +, have already managed to make the first plugin, now the problem is figuring out how Mach3 sends commands to the parallel port to interpret them and send them to USB.
regards
-
I think that perhaps you two guys should work together, sharing your accumulated knowledge. Would be a welcomed project for many, once you have cracked it.
Tweakie.
-
Hello this is my code:
void piUpdate()
{
int axis;
int iMax;
char c;
if (MG::lamiaForm){
LaMiaForm^ lamiaform = MG::lamiaForm;
lamiaform->textBox1->Text ="";
for(int i=0;i<30;i++)
{
lamiaform->textBox1->Text +="\r\n" + i.ToString();
c = Engine->OutSigs[i].OutPin;
lamiaform->textBox1->Text += ";" + c.ToString();
c = Engine->OutSigs[i].OutPort;
lamiaform->textBox1->Text += ";" + c.ToString();
lamiaform->textBox1->Text += ";" + Engine->OutSigs[i].Negated.ToString();
lamiaform->textBox1->Text += ";" + Engine->OutSigs[i].Activated.ToString();
lamiaform->textBox1->Text += ";" + Engine->OutSigs[i].active.ToString();
}
}
}
I knew that you could see how Mach3Engine->OutSigs announced the step and direction to the parallel port, but so far I could not understand how it works.
regards
-
How do you get this Mach3Engine ? If you can get te step and dir you can make it.
Now i am triyng to make Plugin in diferent way and have done a couple of steps to the succes.I am using http://www.machsupport.com/forum/index.php/topic,10733.0.html (http://www.machsupport.com/forum/index.php/topic,10733.0.html) - Te MachPluginWizard . For now i`ve made simple plugin , accesing the mach3 and reading the X Y and Z axes position values . Now im triyng to include in the plugin my existing program which does the usb job and controls the PIC through te USB.
By the way can you post some info about your controler , the USB interface and how will you control your device(step/dir , position , coils (if step motor) , velociti or smoe other way).
-
You all should read the Mach 3 internals Plug-In writers bible (http://f1.grp.yahoofs.com/v1/cHJmTWTC8ovDO_Ee0mDx6oG5D8rvkY-5CHFsfXYj4QeLERCr4NiVAuHbvbsqE5A7SOgWEyUsbf5dbcdfMpNrsHkn4ShOPFmbofRVvQ/Mach3Mysteries.pdf)
All about movement plugins is written there.
Steffen
-
hello, i have try this code
while(Engine->TrajHead!=Engine->TrajIndex)
{
i= Engine->TrajIndex;
//lamiaform->textBox1->Text +=
if (MainPlanner->Movements[Engine->TrajIndex].sx!=0)
{
lamiaform->textBox1->Text += MainPlanner->Movements[Engine->TrajIndex].sx.ToString("F4") ;
}
/*
lamiaform->textBox1->Text += ";" + MainPlanner->Movements[Engine->TrajIndex].sy.ToString("F4");
lamiaform->textBox1->Text += ";" + MainPlanner->Movements[Engine->TrajIndex].sz.ToString("F4");
lamiaform->textBox1->Text += "\r\n";
lamiaform->textBox1->Text += ";" + MainPlanner->Movements[Engine->TrajIndex].ex.ToString("F4");
lamiaform->textBox1->Text += ";" + MainPlanner->Movements[Engine->TrajIndex].ey.ToString("F4");
lamiaform->textBox1->Text += ";" + MainPlanner->Movements[Engine->TrajIndex].ez.ToString("F4");
lamiaform->textBox1->Text += "\r\n";
lamiaform->textBox1->Text += ";" + MainPlanner->Movements[Engine->TrajIndex].Time.ToString("F4");
lamiaform->textBox1->Text += ";" + MainPlanner->Movements[Engine->TrajIndex].type.ToString("F4");
*/
lamiaform->textBox1->Text += "\r\n";
Engine->TrajIndex = (Engine->TrajIndex+1) & 0xfff;
}
but mach3 is blocked and not respond, why?
regards
-
I have cracked it a bit :-) - I also have USB controller. It works with different software then Mach, I wanted to enable it with Mach as well.
I will create separate thread for it - so we can join our efforts
http://www.machsupport.com/forum/index.php/topic,17612.0.html
-
Hi
I am also looking for plugin for usb.
Has any one made it?
Please guide me with this.
-
Hi
I am also looking for plugin for usb.
Has any one made it?
Please guide me with this.
About a year ago I was also interested in finding a USB plugin for Mach3 and had no success in my search so I decided to make one myself using VS2013 and PIC microcontroller. After some months working on it on my free time I moved from PIC to arduino as it is less time consuming and some days ago I finally got my CNC working with the system I created. You can see the first test here: https://www.youtube.com/watch?v=O385I6P_o8o
As you can see the motors do not move perfectly because I used DC motors with low resolution encoders (16 steps per revolution) and the control is based on a PID algorithm so it will always have some error between desired position and current position (about 5 steps) but it has an advantage: it will never lose steps permanently as the PID algorithm is constantly correcting the error.
As I said here http://www.machsupport.com/forum/index.php/topic,27232.0.html I have the intention to share the plugin and the firmware as it would be helpful for some hobbyst who is not ready to buy a commercial motion controller.
I am working on some improvements now. Shortly I will post another video milling something and if there is sufficient interest I will release the pluging.
-
Excellent work Peta.
I am looking forward to seeing your next video and hearing more about your achievements with the plugin.
Tweakie.
-
Thank you Tweakie.CNC
I forgot to mention an important thing:
The controller is just for servo motors (DC motor with encoder) but I do think it's not too hard to adapt it for stepper motors.