API for Mk2 and Mk2/4

API for Mk2 and Mk2/4

Postby Andrej » 02 May 2013, 07:17

New API for Mk2 and Mk2/4 will be available soon.

With this API it will be possible to control all axes and outputs and monitor position and all inputs with your own software.

API will be in the form of .NET class library.

Do you have idea how or where to use it? Please share it with us!
Andrej
 
Posts: 2489
Joined: 10 Jan 2012, 16:09
Controller: Many controllers

Re: API for Mk2 and Mk2/4

Postby Jorn Deruyck » 28 May 2013, 17:50

Will the api be available when USBCNC software is running?

Because i would use it to add more vision based capabilities to my CNC machine in conjunction with your software.
Jorn Deruyck
 
Posts: 23
Joined: 19 Feb 2012, 21:31
Controller: Mk2

Re: API for Mk2 and Mk2/4

Postby Andrej » 29 May 2013, 07:26

Yes, you can use both at same time.
Andrej
 
Posts: 2489
Joined: 10 Jan 2012, 16:09
Controller: Many controllers

Re: API for Mk2 and Mk2/4

Postby grmccray » 30 May 2013, 01:32

I am very interested in using your new Mk 2 board for robotic applications and would like to have more primitive access to dir, steps, feedback and control (non-G Code and non-axis limited).

With the USB interface (and buffer) it is ideal for this application.

Will this be possible in API / SDK?

I already have a Probotix board running on 3 Axis CNC but this is completely different application.
grmccray
 
Posts: 6
Joined: 30 May 2013, 01:23
Controller: Probotix Mk1

Re: API for Mk2 and Mk2/4

Postby Andrej » 30 May 2013, 07:06

With this API you can move all 9 axes, control all outputs and monitor position and inputs.
There is no need for g-code.
Andrej
 
Posts: 2489
Joined: 10 Jan 2012, 16:09
Controller: Many controllers

Re: API for Mk2 and Mk2/4

Postby Next2you » 08 Jun 2013, 18:31

Hello

Is there an example for vb.net 2010?

regards Lars
Next2you
 
Posts: 9
Joined: 26 May 2013, 07:32
Location: Spjald, Danmark
Controller: Mk2/4

Re: API for Mk2 and Mk2/4

Postby Andrej » 08 Jun 2013, 20:03

I don't have VB.NET example jet.
SDK should be easy to use. C# example should help you enough.
Andrej
 
Posts: 2489
Joined: 10 Jan 2012, 16:09
Controller: Many controllers

Re: API for Mk2 and Mk2/4

Postby Next2you » 09 Jun 2013, 05:03

What am I doing wrong, I've downloaded your example.

Lars
Attachments
usbcnc.png
usbcnc.png (61.12 KiB) Viewed 10466 times
Next2you
 
Posts: 9
Joined: 26 May 2013, 07:32
Location: Spjald, Danmark
Controller: Mk2/4

Re: API for Mk2 and Mk2/4

Postby Andrej » 09 Jun 2013, 09:31

You should add reference to CncUsbControllerAPI.
I suggest your .exe is in same folder as CncUsbControllerAPI.dll, CncUsbControllerLib.dll and CncUsbController.exe
Andrej
 
Posts: 2489
Joined: 10 Jan 2012, 16:09
Controller: Many controllers

Re: API for Mk2 and Mk2/4

Postby Next2you » 09 Jun 2013, 10:01

CncUsbControllerAPI.dll and CncUsbControllerLib.dll where can I download them, they are not in your example.
Next2you
 
Posts: 9
Joined: 26 May 2013, 07:32
Location: Spjald, Danmark
Controller: Mk2/4

Re: API for Mk2 and Mk2/4

Postby Jorn Deruyck » 09 Jun 2013, 11:31

i've tried the API in labVIEW, and i'm able to succesfully query the software version, but when i query the valid licence command, it always returns false.
Hence i'm unable to command any axis to move.

Am i missing something?
Jorn Deruyck
 
Posts: 23
Joined: 19 Feb 2012, 21:31
Controller: Mk2

Re: API for Mk2 and Mk2/4

Postby Andrej » 09 Jun 2013, 12:05

@Next2You
CncUsbControllerAPI.dll and CncUsbControllerLib.dll are part of software.
Download and install latest beta version.

@Jorn Deruyck
Even without license you should be able to move axes. Your problem is elsewhere.
Does "Initialize" return true?
Andrej
 
Posts: 2489
Joined: 10 Jan 2012, 16:09
Controller: Many controllers

Re: API for Mk2 and Mk2/4

Postby Next2you » 09 Jun 2013, 17:04

you are the man :D
Next2you
 
Posts: 9
Joined: 26 May 2013, 07:32
Location: Spjald, Danmark
Controller: Mk2/4

Re: API for Mk2 and Mk2/4

Postby Jorn Deruyck » 09 Jun 2013, 17:26

Does the initialize command load its settings from the same settings file that CNCUSBController.exe uses?
Because i managed to move the Z axis on my machine, but the steps/unit and direction is wrong.
And it no longer seems to look at limit switches.

Also, i'm getting an unhandled exception during the init command:

************** Exception Text **************
System.InvalidOperationException: DragDrop registration did not succeed. ---> System.Threading.ThreadStateException: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.
at System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)
--- End of inner exception stack trace ---
at System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)
at System.Windows.Forms.Control.OnHandleCreated(EventArgs e)
at System.Windows.Forms.Form.OnHandleCreated(EventArgs e)
at System.Windows.Forms.Control.WmCreate(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmCreate(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at (Object , Message& )
at A..(Object , Message& )
at A. .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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


Perhaps this is the reason why the settings won't load?
Jorn Deruyck
 
Posts: 23
Joined: 19 Feb 2012, 21:31
Controller: Mk2

Re: API for Mk2 and Mk2/4

Postby Andrej » 09 Jun 2013, 20:08

Same setting file is used.

You need to add [STAThread] attribute to your Main().
Andrej
 
Posts: 2489
Joined: 10 Jan 2012, 16:09
Controller: Many controllers

Re: API for Mk2 and Mk2/4

Postby Jorn Deruyck » 10 Jun 2013, 19:06

Tnx for the tip

Wasn't so straight forward in LabVIEW though :(
Appearantly LabVIEW VI's are coinitialized as Multi-threaded apartment threads. and not STA's :/

I was able to force the VI into STA mode by changing the execution system to User Interface.
Jorn Deruyck
 
Posts: 23
Joined: 19 Feb 2012, 21:31
Controller: Mk2

Re: API for Mk2 and Mk2/4

Postby Andrej » 10 Jun 2013, 23:37

It would be great if you can make and post example application in LabView.
Andrej
 
Posts: 2489
Joined: 10 Jan 2012, 16:09
Controller: Many controllers

Re: API for Mk2 and Mk2/4

Postby Jorn Deruyck » 11 Jun 2013, 18:28

I'll try to post an example project this weekend, if i can get it working :p

Problem with the error is fixed, but the settings are still not loaded correctly.
When i use the initialize function, it seems to revert to default settings (steps/unit = 200, etc)
Even when CNCUSBController.exe is running, when i use the init function, all settings are lost.

Is there a requirement for the settings file to be in a specific location relative to the caller?
or could you add a variant of the init function in which we could specify a path to a settings file?
Jorn Deruyck
 
Posts: 23
Joined: 19 Feb 2012, 21:31
Controller: Mk2

Re: API for Mk2 and Mk2/4

Postby Andrej » 11 Jun 2013, 21:41

No special requirement. I keep everything in same folder.
Andrej
 
Posts: 2489
Joined: 10 Jan 2012, 16:09
Controller: Many controllers

Re: API for Mk2 and Mk2/4

Postby internetscooter » 18 Jun 2013, 12:32

Andrej wrote:New API for Mk2 and Mk2/4 will be available soon.

Do you have idea how or where to use it? Please share it with us!


Great! I want to link visualisation stuff with controlling my cnc machine. I gave your test a little go and it seems to work. Looking forward to more updates!
internetscooter
 
Posts: 12
Joined: 05 Mar 2012, 09:22
Location: Melbourne, Australia
Controller: Mk2

Re: API for Mk2 and Mk2/4

Postby haavardsunnset » 24 Jun 2013, 11:25

Would it be possible to get the same API for microcontroller use? (I2C or something similar)
haavardsunnset
 
Posts: 5
Joined: 13 Jan 2012, 21:04

Re: API for Mk2 and Mk2/4

Postby Andrej » 24 Jun 2013, 12:32

I don't understand what you want.
Andrej
 
Posts: 2489
Joined: 10 Jan 2012, 16:09
Controller: Many controllers

Re: API for Mk2 and Mk2/4

Postby Moonglow » 24 Jun 2013, 13:45

i think haavardsunnset ask about add other control port instead USB to control your device... as example via I2C... to use it with microcontrollers and other lowend embedded devices without OS and without USB HOST controller ;)
Moonglow
 
Posts: 104
Joined: 11 Jan 2012, 04:45
Controller: Many controllers

Re: API for Mk2 and Mk2/4

Postby Andrej » 24 Jun 2013, 14:39

Unfortunately this is not possible.
Andrej
 
Posts: 2489
Joined: 10 Jan 2012, 16:09
Controller: Many controllers

Re: API for Mk2 and Mk2/4

Postby haavardsunnset » 24 Jun 2013, 23:39

thanks for clarifying moonglow :) And thanks for the prompt response Andrej. I had hoped to save some work on a machine I'm building. CNC USB does a great job at cnc, so I figured it might be possible to use it as a "co-processor" handling the motion control on a cutting machine I'm building.
haavardsunnset
 
Posts: 5
Joined: 13 Jan 2012, 21:04

Next

Return to API



Who is online

Users browsing this forum: No registered users and 1 guest