Machsupport Forum
Mach Discussion => Mach SDK plugin questions and answers. => Topic started by: jarekk on February 25, 2011, 10:12:23 AM
-
Hi,
I have my own USB CNC controller ( something close to ncPod - 120Mhz Arm Cortex CPU capable of about 100kHz operation). It works with different software then Mach.
I wanted to to write Mach plugin for it, but there is no good documentation for it. There are few people who know it quite well, but this knowledge is commercially valuable , so nobody was interested to join me.
I have it quite alive. There are few things missing ( like input/output processing, homeing, jog operation), but basic motion works. There is also console windows to dump all interesting internals
I decided to share it before finishing as there are some other people working on similar design (http://www.machsupport.com/forum/index.php/topic,17602.0.html)
So - please have a look at sources, play with it.
It is free to use as long as you share your knowledge to make it really good template for starting own motion plugins.
You need Visual C++ Express 2010 to compile it.
You will need to change in project post processing step - to accomodate path to your Mach directories.
In case your console window is too small - change it . Once changed it will keep setting for consequiteve runs.
-
Hello, thank you for your help and the example that I've provided, I have compiled and now I understand better how Mach3 inside.
As you rightly said you can not find a working example to see how Mach3 sends commands.
Almost all USB Mach3 to do nothing but take the data in Modbus format and then regenerate the toolpath, my idea is instead to capture the pulse of step and direction, sending them to the usb it will not do more than repeat the impulses Mach3, which sends the parallel.
I do not know if I was very clear but my English is at school, thanks again Daniele
-
Well... I'm taking a look in your plugin but I don't get one thing - Where do you send the data trought the USB? I can't find any function that send's the data to the USB port, could someone please point that for me?
-
This is virtual plugin designed to show Mach internals. So no real USB - just software emulation of it.
But - if you are asking about it - it depends on your particular USB device. For most of my USB devices sending data is like writing to FIFO or file. If you are interested in real examples see libusb project (http://sourceforge.net/apps/trac/libusb-win32/wiki) or FTDI library (http://www.ftdichip.com/Support/SoftwareExamples/CodeExamples.htm)
-
actually I'll be using a PIC18F4550 to convert the USB into a LPT1 to run 3 stepper motors axis :\
-
Use external USB/ serial port or fifo controller. It adds about 19$ to the cost ( for ready made DIP style module from DigiKey ), but it is easier in the beginning.
-
Actuallly, I develop cnc's using pic's, thats the first time I'll try to use the usb port to communicate with the pic instead of using the Parallel, the problem is actually making the mach3 send the data to the pic via USB :\
-
Mach will *NEVER* send anything on USB - it has to be your plugin which takes Mach data and sends it itself.
Have a look at some my routines - PC side for FT245R chip ( USB-> Parallel FIFO) converter and LPC1769 code to get data from it.
If this is too complicated - then wait until you try to extract motion data from Mach....
-
Something you may find interesting.
http://www.machsupport.com/forum/index.php/topic,17992.0.html
Tweakie.
-
Mach will *NEVER* send anything on USB - it has to be your plugin which takes Mach data and sends it itself.
Have a look at some my routines - PC side for FT245R chip ( USB-> Parallel FIFO) converter and LPC1769 code to get data from it.
If this is too complicated - then wait until you try to extract motion data from Mach....
Yeah, i know, thats way I asked how to make THIS plugin send data via USB :\
I'll keep searching how to do it, but the hardware is pretty much standar - usb input, control of steppers, etc...
Something you may find interesting.
http://www.machsupport.com/forum/index.php/topic,17992.0.html
Tweakie.
really interesting, actually thats EXACTLY what I'm trying to do, but instead of atmel MCU I'll be using a Microchip PICmcu and instead of an Altera FPGA I'll be using 3 pics mcu specialized on driving step-motors (to decrease the learning/development time).
-
really interesting, actually thats EXACTLY what I'm trying to do, but instead of atmel MCU I'll be using a Microchip PICmcu and instead of an Altera FPGA I'll be using 3 pics mcu specialized on driving step-motors (to decrease the learning/development time).
I did something like that. Using LPC2378 and 4x LPC2104 as step motors accelerators.
I would say that this is not the right way to go. The communications channels between processors are the bottlenecks. It is not efficient to split work like that. Most efficient way is floating point CPU and FPGA as FIFO step/dir generator.
I am not sure which PIC you have choosen, but unless it is PIC32 you will have problems with computing power - I do know what I am saying as I have my own motion planner ( for different commercial software - not Mach).
I can show you prototype of my small toy - see attachement. Largest available through hole dsPIC. If I get it running nicely - I will sell just DIY schematics + plugin license , so everybody could make it himself ( no SMD technology, single layer board which can be etched).
Preliminary tests show that it can go up to 100..150kHz with 2 seconds buffer and 4ms time slices using LPT style data generated by Mach ( kind of "LPT player" mode).
-
Something you may find interesting.
http://www.machsupport.com/forum/index.php/topic,17992.0.html
Tweakie.
This looks strange. Even if it uses HID USB classes it still needs Mach plugin. Will be interesting to see review. I have seen it being sold as option with some Chinese CNC machines.
-
Actually all I need is something to make my USB become a parallel port, I was thinking of making it using a PIC18F4550, so he would basically take the USB data and converto to all the 17 I/O's of the DB-25, the other pic's would just receive the signal and then turn pass it on, OR the signal will just be driven to the board outputs (there is no need for extra processing since I already have a working external steper motor driver, a working stepper motor driver that works with MACH3 paralell, the driver is controlled by a pic 18F4520).
basically wha I gonna do is a board with DB25 input AND one USB input, the USB input will work like an USB/Paralel converter and the DB25 will be the normal paralel input (in the case it have one).
The extra 3 PIC's MCU are to drive a servo motor driver and read the Quadrature encoders IF it ever gets implemented.
-
Actually all I need is something to make my USB become a parallel port,
So basically you want to do something like my proto - USB to LPT converter for Mach.
But life is not that simple - USB has it bottlenecks, so you need to buffer data ahead. Mach can give you the trajectory ahead, so no problem.
But it does not give you directly anything like DB25 output pins state - you are getting either point coordinates ( the hard way, you need motion processing) or amount of LPT pin "ticks" within your time slice ( you can configure it - I use 4ms). So basically you have to send to your device packages containing "tick" counters for each slices. 4ms x 4 axes gives you at least 4000 variables of raw data per second. And this is the challenge - as you need to continuously buffer data and generate step/dir signals. Not mentioning poor Mach documentation about how to get the data and interact with Mach internals...
-
I think that I get it now.
I'll discuss about it with my partners and try to figure out how to do it with the info we have in hands, thanks Jarekk
-
Hi all, I'm new to the forum, I met and spoke with Brian Barker at the recent CNC Workshop in Michigan and he mentioned that he had an example plug in for sending data to an external (USB) pulsing engine. Since this seems to be the way to make contact I'll try here first. The CNC Workshop was a lot of fun. I would highly recommend it for any CNC hobbyist!
Similar to a lot of other people in this thread, I'm interested in rolling my own pulsing engine. (or at least looking at what it would take to do so) The particular hardware that I am looking at using is an ATMEL XMEGA processor with an FTDI USB interface. I've got several breadboards with this processor and an FTDI Serial and Parallel interfaces left over from a recent project where I work, and they just look like a solution waiting for an answer. The XMEGA had a lot of really nice timers in it that look like they are begging to become a pulse engine...
What I'm probably looking for is an example of how the data would be send to a USB port which contained pulses per time period. I think I saw mentioned a 4 ms frame time in a previous post.
What will most likely happen is that I'll look at it for a while and then go buy a smooth stepper. But I'd kind of like to know how it all works and maybe take a stab at it myself.
So thanks in advance!
-
I can show you something:
(http://www.kartech.org/step2mach/step2mach.png)
I am actually building hardware for my virtual plugin.
I intend to make it as DIY project - as I have choosen mostly through hole components and easy to assembly SMD components. It also uses FTDI, either as SMD or DigiKey module - so everybody will be able to prepare it himself ( PCB is single layer board, you will be able even to make it on universla board).
Right now it works as standalone device ( not yet from Mach, only from my test app - Mach will be next). I plan publish Eagle design and to sell plugin licenses for the software.
With XMega you should be able to make something similiar ( although it is slightly less powerfull then the dsPIC - I have choosen one of most powerfull CPUs found in DIP package). The critical parameters are the CPU speed and RAM size. 16kB is minimum I would say.
In mach SDK you have examples of sending USB data. Just that you need target device which processes it properly.
Timers are not that easy to be used as pulse engine - you would need at least four independent 32 bit timers with configurable pin control, otherwise you may have resolution problems to operate with e.g. 100kHz pulse frequency. Most designs (like SmoothStepper) use specialized cascaded high frequency timers in FPGA
-
Very interesting, but the USB as a connection between a PC and a CNC machine may not be ideal.
The voltage levels on the USB interface are very restricted and they are NOT immune to noise.
The USB is fine for hooking up a keyboard, a mouse, a camera, to a PC: they are all floating. But a CNC machine may be handling kilowatts of power, and that has HUGE potential for noise problems. It can be done of course - the SmoothStepper does it, but you need to keep the USB card well away from the CNC and have TOTAL optical isolation.
Just my experience and 2c.
Cheers
-
USB is not ideal - I agree. I sometimes use galvanically isolted USB ( Analog devices provides chip with trafo coupling e.g. ADUM3160 ), but it still does not help if you use plasma cutter because USB does not handle gracefully mess on physical layer.
-
do your project still Continue to jarekk?
-
Kind of:
http://www.machsupport.com/forum/index.php/topic,19697.0.html
I have created real motion controller and shared the code. But due to small interest I have not developed it further ( it does work, but it would require much more testing)
-
Jarekk, in your example, Mach_vmotion, the jog hotkeys not working on that is?
regards
-
Well - I do not remember. I think they should work as both hot keys and Mach buttons end up calling same motion function
-
Hi Jarekk !
I tried to compile your project, and I did not succeed, VC + + gives an error:
fatal error C1083: Не удается открыть файл включение: _TrajectoryControl.h: No such file or directory
-
Well, did you install the Mach plugin wizzard ? (this file comes from there). It is described in the documentation
-
Hi!
I have a problem interfacing Mach3. I tried to use Engine->Trajectories, and I found that
1) it has data only when running g-code (from Program Run or MDI tab), but not when driving with keyboard;
2) shown position in mach3 doesn't change when running g-code, only using keyboard - however, Engine->Trajectories[ x ].Points change.
In the implementation found here, I also found MainPlanner->Movements, but in my case, it is always filled with zero values. I use Windows 7 64bit system, without the parallel port driver. Is it possible that in this case, mach3 doesn't plan trajectory, and I should fill MainPlanner->Movements data?
-
Well it is not a bug - just feature.
1) This is Mach feature. Motion plugin get only g-code data. For homeing, keyboard etc. you have to calculate the trajectory yourself. See example in my plugin
2) Motion plugin has to update the coordinates shown in Mach itself. Again - see my plugin for example.
There is a lot of junk in Mach - not all data is actually filled or used. But you will never find any documentation about it. So do not touch MotionPlanner
-
I see... I ran into an other problem: I cannot control time step for planning. I set
MainPlanner->ExTime = 1e-6;
MainPlanner->ExternalType = EX_VMS;
but after initialization, ExTime becomes 0.04 (at 100kHz kernel setting in printer port). If I change it back to 1e-6, motion is carried out normally, but very slow. I want to change time resolution for planner because I have a step/dir converter that requires single steps. Is there an easy way?
-
Hi Jarekk,
Don't get discouraged at the appearance of low interest in you work. I believe you opened the door for
many to make products from your example and they just lurk.
I decoded the spi protocol for cheap calipers and scales around 1999 and many people took the
information(ie Shumatec ) and made products. I did it for Wilfried Fedtke
See http://rchobby-net.de/start.htm. It took days of staring at a scope and checking the
bits relations with respect to counting in unkown format.
I felt like they didn't share any mention of me, but later some did add credit to some faqs.
So I thank you and praise your hard work and spirit of sharing. Please let me know if you ever need help in
electronics or software.
Best Regards -Lee