Is EMC the software I need, or should I look for s
I happen to have a (pretty basic, but hard to modify further) CNC machine. It contains 6 stepper motors (2 per axis) and a controller board which presents an FTDI 2XX chip to the outside world, a USB device. The software it comes with is, pardon the term, a piece of feces, written in Visual Basic, which I simply don't find usable -- while it can do everything the machine can do, it's very crude. Looking around the net, I have found that EMC2 is the place to go for CNC in the open source world.
But EMC, as far as I can see, is the easiest to set up when it comes to driving motors from parallel port pins, which, in this particular case, is out of the question.
After a few hours of reverse engineering and some minor swearing, I have been able to write a Python script which uses libftdi to run the machine -- it moves nicely along each axis in 0.002mm increments by sending a byte into the port to move the motors one step per byte sent, and requires a few initialisation commands to get the FTDI chip to properly start up. It's now a problem of somehow patching that into EMC, so if anyone would be so kind as to answer a few questions for me, it would be very nice:
- Is EMC the software for me, or should I look for something else entirely? After all, driving the machine in this manner is far from realtime. If EMC is not it, what would it be? A searchstring to google for would be quite helpful.
- I have looked at the HAL documentation and it seems to deal mostly with directly driving motors anyway, while the access I have to the hardware limits me to telling it which axis should be stepped in which direction, and it will do the actual stepping of the motor by itself. Am I missing something? Is there an example of a HAL component for working with similar hardware anywhere that I could study?
- For that matter, can I get away with writing the component in Python starting with the script I have, or will I have to use something else?
Please Log in or Create an account to join the conversation.
John
Please Log in or Create an account to join the conversation.
The USB interface is not capable of controlling a CNC machine in real time.
In this case I wouldn't necessarily give up so soon.
The interface between the FTDI chip and the hardware is likely to be near-realtime.
It might be possible to create a realtime component that can bit-bang P-Port pins to create a version of USB that the FTDI chip can understand.
Alternatively, you might be able to hook into the hardware somewhere after the USB interface. Do you have the exact part number of the chip? The first one I looked at converts USB to four 8-bit parallel data buses, and it would be fairly easy[1] to hook EMC2 in at that point. (especially if what appears on the output is step-direction bits)
[1] For moderately intrepid values of "fairly easy"
Please Log in or Create an account to join the conversation.
Just how realtime does realtime need to be? The machine has no sensors, just steppers, which step at a fixed speed and can't really go faster, so as long as my driver reports where it thinks the motors are and ensures it doesn't send commands faster than they can be executed, why exactly should it be problematic?
Failing that, ok, if not EMC, what else?
Please Log in or Create an account to join the conversation.
John
Please Log in or Create an account to join the conversation.
Failing that, ok, if not EMC, what else?
I hate to say it, but possibly Mach3. I think that supports some USB step generators, but they probably don't use the same protocol as yours, and it is not open-source so changing it is tricky.
I think that EMC2 perhaps adheres too closely to the Realtime mantra. In your position I would certainly consider hooking your Python script into HAL and seeing what happens.
git.linuxcnc.org/gitweb?p=emc2.git;a=blo...r_comps/hal_input.py
Is an example of a python userspace component that creates HAL pins. You could do something equivalent in your script then hook the EMC movement commands to that.
I don't think such a setup would ever find its way into the main distribution for machine control, but if it gets you going that might not matter.
(Actually, you could try seeing if hal_input can do anything with your drive, if it creates usable pins then you are almost there. Try following the instructions here wiki.linuxcnc.org/cgi-bin/emcinfo.pl?Simple_Remote_Pendant and see if it all just magically works...)
Please Log in or Create an account to join the conversation.
- Finds the FTDI chip by directly addressing it's Windows driver with it's DLL, resets it and puts it into bitbanging mode. (For some reason, it doesn't start out in one even though it's supposed to have an EPROM in it) FTDI can actually report a latency timer of some kind, but the native software doesn't care.
- Hooks a control function into the timer tick that fires every 50 milliseconds, i.e. at 20Hz.
- When motion is commanded by the G-code interpreter or manually, the control function calls an interface function that sends data to the FTDI chip: 0b10000 for X, 0b100 for Y, 0b10100 for Z (huh?), ORs it with the 0b1 to invert direction. OR with 0b10 for every other step. Each step moves the axis 0.002mm. ...Once that command is sent, the interface function adds a delay by counting up to 200000. The drives appear to work completely identically without that delay, it's there for speed control -- as far as I can see if the timer tick doesn't interrupt it, the function will keep moving the drive in an infinite loop until it does. I might, of course, be horribly wrong, but...
The native software doesn't know (or want to know) what state the drives are in and gets no input from them. (But I happen to have a Velleman K8000 which I might try to use for homing switches later...) It actually has a G-code interpreter and stuff, but it's extremely painful to use.
Please Log in or Create an account to join the conversation.
Actually, that's what I've been reading up on for the past few hours, this seems like the way to go, at least initially, to see if I can get any practical result. What I don't quite understand is how should I interpret the EMC movement commands, which pins they go out on and whether I need to keep track of the coordinates internally.andypugh wrote:
Is an example of a python userspace component that creates HAL pins. You could do something equivalent in your script then hook the EMC movement commands to that.
I don't expect that it can make it into the tree, but nothing stops me from putting up a LiveCD pre-setup for the machine.
Please Log in or Create an account to join the conversation.
so it's mostly a question of figuring out what sort of pins exactly does EMC expect from a HAL component that handles it's own stepping, and why,
To an extent the existing stepgen code does that, there is a base-thread part that creates the pulses, and a controller in the servo-thread that tells it how fast.
An even better example would be one of the existing drivers which hands off control to external hardware.
The Pluto driver is a good example, and is written in "comp" which is the friendly way to write hal components. Just don't buy the actual Pluto hardware.
git.linuxcnc.org/gitweb?p=emc2.git;a=blo...ec4eed6bfeae;hb=HEAD
comp docs are here:
linuxcnc.org/docs/html/hal_comp.html
I imagine that your driver could emulate variable speed by running the drives for varying times.
cgi.ebay.co.uk/3-Axis-CNC-Stepper-Motor-...4489a#ht_5881wt_1147
You mentioned that there is not much to be found where you are. Might one ask where you are?
Please Log in or Create an account to join the conversation.
Thank you. I expect there's no other documented work of similar nature anywhere? Well, there's the Arduino USB driver in Python, but it doesn't expect to control any axes, so while it plainly shows how to expose pins to HAL in Python, it doesn't answer my question of what to do with the motion commands and what format to expect them in.andypugh wrote:
The Pluto driver is a good example, and is written in "comp" which is the friendly way to write hal components. Just don't buy the actual Pluto hardware.
The drives really aren't that bad by themselves, I expect, it's the software and the stock controller. But I'm not up to making a controller from scratch right now, and, there's people out there using the device as is with good results, might as well try helping them while helping myself. If I were up to building a machine from scratch, I'd be reading the RepRap instructions right now, but since this one ended up in my hands for a time, (actually, my father wanted it, and I'm the non-mainframe-IT guy in the family... so now I'm the one stuck getting it easy enough for him to use) I'm thinking of using it to make the component parts for one. Before I can do that, though, I need to make it work in a non-painful fashion.Your drives sound basically horrible. It is unfortunate that you have two motors per axis, as that will double the cost of changing the drives, but I would be looking hard at things like
Russia. Which makes ebay really not a very good option because my local post office passionately hates me.You mentioned that there is not much to be found where you are. Might one ask where you are?
Please Log in or Create an account to join the conversation.