arduino CNC
Sunday, 24 March 2013
Web interface fun
So far have the basics covered; connecting and disconnecting and initializing the machine, uploading and selecting files and choosing which one to load as well as a simple self updating page that sits in an iframe tag that shows the position of the machine.
So we are getting there...
Wednesday, 13 March 2013
Well that sounded easier in my head
Wednesday, 6 March 2013
A slight change of mind.
While I have been fiddeling with pyGTK I have found that debugging can be a bit of a problem as the GTK backend seams to handle errors silently and doesn't like pyscripter breakpoints. Further more, one of the things i want to add later is networkability so you can control your machines using a lan or over Wifi. I have been wondering for a while about how best to do this and then I came across this. And loe and behold that's what they have done. Their system works on the bottle web server and lots of javascript. I think we can go 1 better here and use Django and html5 and then for the icing on the cake, WebGL to provide a 3D representation of the program we are running and the machine it is running on.
There are actually lots of advantages to using a web interface. Its portable across systems, since all you need to use it is a machine with a browser. The user can be any distance from the machine they are using. It can be made to look like any other system with a bit of coding and a css script.
Books have been ordered. Tutorials are being read. Threading code is being rewritten. Soon something good should be produced.
Saturday, 23 February 2013
More hardware
I have posted some pics here of my initial investigations. It's not going to be long before someone gets hurt by one of these as they are VERY badly designed, but they do give you all the complex bits of a decent laser engraver so so long as you know what you are doing and modify it correctly it can be made to be safe.
THESE THINGS ARE LETHAL. DO NOT BUY ONE OR FIDDLE WITH THEM IF YOU DON'T KNOW WHAT YOU ARE DOING. IF FACT EVEN IF YOU DO KNOW WHAT YOU ARE DOING IT WOULD STILL BE VERY EASY TO GET SERIOUSLY BURT OR BLINDED OR SET ON FIRE.
Why are they so bad? Well let's see;
- It's a Class 4 in there and there are no interlocks, no beam tubes, no key switch and no emergency stop button. also missing the big yellow "Class 4 Laser Product" sticker. (admittedly if it had all that stuff it could probably be Class 1 laser product as everything would be enclosed.)
- The cutting compartment has vents in the sides and holes in the bottom so there is always the chance that a shiny thing could send the beam out one of said holes and set something near by (or not so near by) on fire or blind or burn you.
- There is no laser supervisor system. A 40W laser needs looking after. You need to make sure the pump hasn't died or a pipe clogged and than the cooling water is actually cold. You need to make sure the power that its drawing is not above the damage threashold. You need to make sure that the flying optics are in flight, if not it will just start a fire (like if the firmware crashes and stops the motors moving but doesn't turn off the laser.) Its also nice to know how long the laser has been on and at what power so you can schedule tube and optics replacements when they come to the end of their life
- The work area is pathetic. The optics fly over a much larger area than they give you to work in, I can only assume its space to accelerate.
- The case is massively too big for what's in it. (Although that does mean that there is room for all the things it is missing)
- The cooling system is a bucket of water and a fountain pump that they have modified with hot glue to fit the pipe they are using.
- The extractor fan is just a ceiling fan but not a good fan, probably the worst one i have ever seen
- Electrically they are abysmal:
- Mains and low voltage wiring not well separated (although better than some I have seen)
- Wires going through burred holes in steel with no grommets,
- No real isolation barrier for the controller
- Front panel controls connected to rectified mains!!
- Laser current meter connected in series with laser, which operates at 22kV!!! (OK, on the low side but if anything goes wrong with that big ceramic ballast resistor...)
- The fan and pump both have American plugs and are designed to run from 240VAC, not a good combo.
- The laser is turned on and off by a 24V signal going to an opto-isolator but that signal goes through a connector with pins right next to the signal pins at rectified mains potential so not that well isolated.
- The laser PSU is built around a TL494 on which they change the current by fiddling with the potential on the timing resistor, very odd.
So what am I going to do?
- Interlocks. I like to have anything that can blind me or set me on fire with an invisible and non dispersing ray of light locked away when in use. It's just a good idea. While I am at it, a key switch and stop button.
- I need to baffle up all the vents so nothing can get out and weld up all the left over holes.
- The optics need cleaned and aligned.
- An air assist needs to be installed.
- A pair of alignment lasers need to be added.
- A new power supply
- Rewire everything.
- Replace the current meter with a hall effect current sensor around an appropriately insulated wire.
- Replace the twiddly pot for current setting with a dig-ipot and ensure it is opto-isolated from what ever controls it.
- Opto-isolate the inputs to the laser PSU
- New control board.
- Supervisor board.
- Fit all the cooling in the case. I am thinking of something similar to a liquid cooling system on a computer (laser tube should be dissipating around 300W in heat so should be doable)
Progress thus far
After reading in the file you need check it for errors and just to be annoying two different dialects of Gcode will consider each others commands as errors, for this reason most machine implement their dialect. Then you have to translate any commands you think you might come across but know that your machine won't accept. then feed those comands to the machine and allow the user to say at any moment "STOP!!" and then maybe "Whoops, my mistake, carry on...." and the problems continue.
Now most programmers will recognize this as the art of programming, but none the less it can be quite down heartening when you find another hole to patch up.
So what have I actually done then?
Well...
For the CNC machine, I have simply plonked and Arduino UNO in the control box and wired it to the stepper drivers and limit switches. Then I spent a good month of spare time writing C to control it and debugging with a n AVR Dragon (if you cut the little track in the solder jumper just behind the USB socket it works well, but I haven't worked out how to get the chip out of Debug-Wire mode yet)
The basic structure of this code is 3 files; a main code file, a library for working with ring buffers used by the serial port and a file containing all the global variables and #defines. Not the best structure but it works and is quite navigable with code folding. First we initialize everything, then home the axes, then drop into the main loop where we tell the hast we are ready for a line, get that line, then process the M codes and then the G codes. all the serial coms are done with interrupts as is the step timing which uses a timer interrupt to get the steppers to move at the right time.
For the host machine I have been playing with pyGTK. I tied using Glade to design the GUI but when I imported it and run it in pyscripter I couldn't get it to close gracefully so I did it the old fashioned way by defining sizes and position of controls.
My initial plan was to use a separate thread to be the host controller and handle coms with the machine and let the main thread just keep the GUI alive, however I need to work on my use of Queues and thread control as many of my attempts ended up with the control thread blocking and then still waiting to quit when the app closed. So for now all the coms are handled by a routine called every 100ms in the GUI. The GUI is also very basic for the moment but there are a few useful methods in the Programme class that can be used to get your machine to do almost anything. Still need to get acceleration done and put some backlash compensation in there but that's for the future.
code produced thus far
Sunday, 17 February 2013
Slight change in direction
So since new year i have been working on two aspects of this project
PortRewrite the code for the Arduino in AVR studio.- Write a new PC control app in python
The second action was brought about by the Raspberry Pi. if I write the control app in python then I can put it on a Pi and with a small monitor I have a cheap high powered CAM and GUI on my machine. The latency and timing jitter for a multitasking operating systems makes running the stepper driver straight from the Pi a no starter (a problem I came across years ago when I tried something similar and converted a Boxford Duet controller to a PIC18F4550 and use VB to calculate the steps and timings). So the best solution is to have the fast computer (Pi) do all the fancy stuff and then just tell the uC (Arduino) what to in terms of lines and arcs and at what speed. this means that the machine need only implement G0,1,2 and 3 as well as a few others and a handful of M codes making the coding much easier and then things like G53 and G54 or G90 or G20 all get dealt with by the python host controller.
So its all getting somewhere and I shall post some pics/code in a few days, all being well.