{"action":"created","issue":{"url":"https://api.github.com/repos/grbl/grbl/issues/565","labels_url":"https://api.github.com/repos/grbl/grbl/issues/565/labels{/name}","comments_url":"https://api.github.com/repos/grbl/grbl/issues/565/comments","events_url":"https://api.github.com/repos/grbl/grbl/issues/565/events","html_url":"https://github.com/grbl/grbl/issues/565","id":53994656,"number":565,"title":"grbl for EDM","user":{"login":"JaakkoFagerlund","id":10484803,"avatar_url":"https://avatars.githubusercontent.com/u/10484803?v=3","gravatar_id":"","url":"https://api.github.com/users/JaakkoFagerlund","html_url":"https://github.com/JaakkoFagerlund","followers_url":"https://api.github.com/users/JaakkoFagerlund/followers","following_url":"https://api.github.com/users/JaakkoFagerlund/following{/other_user}","gists_url":"https://api.github.com/users/JaakkoFagerlund/gists{/gist_id}","starred_url":"https://api.github.com/users/JaakkoFagerlund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JaakkoFagerlund/subscriptions","organizations_url":"https://api.github.com/users/JaakkoFagerlund/orgs","repos_url":"https://api.github.com/users/JaakkoFagerlund/repos","events_url":"https://api.github.com/users/JaakkoFagerlund/events{/privacy}","received_events_url":"https://api.github.com/users/JaakkoFagerlund/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-01-11T15:26:21Z","updated_at":"2015-01-13T04:44:58Z","closed_at":null,"body":"# Intro\r\n\r\nI'm a Finnish tool & die maker by profession and use electrical discharge machines (EDM's) almost daily at work. On my free time I do machining as a hobby and use the machines at work to build stuff for myself. I have built a working wire EDM system completely from scratch during the last couple of years and it is currently running as a stand-alone system with Arduino MEGA 2560 R3 board. Only portion of grbl I used was the G code interpreter from some early grbl version and did my own motion controls.\r\n\r\nTo see videos and explanations of the wire EDM system and its use, mechanics and electronics, please visit my YouTube channel at http://www.youtube.com/TheWireEDM as those videos will answer most of the questions I usually get.\r\n\r\n\r\n# Typical EDM features\r\n\r\nThe moving parts see little to no resistance as the cutting process is contactless. Thus the only friction comes from the drive components themselves. Typical spark gap size, meaning the distance between the workpiece and electrode, is about 0.02 to 0.1 mm depending on many variables.\r\n\r\n\r\n## Sinker EDM\r\nThe simplest sinker EDM is a 1-axis machine where only the Z axis moves under CNC control. A more sophisticated machine has the basic XYZ configuration and the next step from that is a 4 axis machine with usually a C axis so that the electrode can be rotated.\r\n\r\nUsual feature in a sinker is hydraulic or hydrostatic flushing, where the electrode is 'pumped' periodically up and down to flush the gap better. This retraction amount and interval time is usually selectable and the movement is usually done with rapid moves. Though with big enough electrode surface area the forces might become so great under the fluid that a rapid move is impossible.\r\n\r\n## Drill EDM\r\nOne special case is a drill EDM, which acts like a 1-axis sinker EDM. The Z axis sports a constantly rotating (0-300 rpm) tube eletrode, which is used to drill small holes (0.1-6 mm) to workpieces. Usual use case is starter holes for wire EDM.\r\n\r\n## wire EDM\r\nThe simplest wire EDM is a 2-axis machine with XY controlled by CNC and Z axis (upper wire guide) being manually positioned for workpiece thickness. The next step up is a 4 axis version that has XYUV, allowing thus tapered features to be done.\r\n\r\nMachine feed rates are in the range of 0-20 mm/min (sinker EDM) and 0-50 mm/min (wire EDM) when cutting, so there is no sudden changes in speed/acceleration. Only G0 commands need proper accelerations as they are used to go from one place to another quickly with the assumption that no cutting is done during such a move.\r\n\r\n## Spark generator\r\n\r\nThe open gap voltage for a typical sinker is in the 100-200 VDC range and 100 VDC for wire EDM. A typical spark gap voltage is something between 30-70 VDC, depending on electrode size, preferred gap size, finishing/roughing, etc. Typical average currents are anything from 0 to several tens of Amperes for a sinker EDM, while on the wire EDM an average current is 0-6 A (pulse current can exceed 1000 A).\r\n\r\nThe spark generator is either RC type self-oscillating system or a PWM pulse controlled supply. RC type is the easiest to build and use, but changing R and C values to get different machining parameters requires extensive amount of switches (digital or mechanical) and of course parts. With a pulse type generator system it is easy to change parameters by changing the frequency and the duty cycle of the output and controlling the maximum output current with either a set of fixed value resistors (easy) or with an adjustable active current limitation (complex).\r\n\r\n## Dielectric fluid\r\nThe machines have some sort dielectric fluid that is circulated with a pump through a filter. It is used to flush the eroded particles and to keep everything cool. In a sinker EDM this is usually a very light weight special oil.\r\n\r\nBut on wire EDM's the most used dielectric is water. This poses an issue as the eroded particles make water electrically conductive over time. This is why in a wire EDM there is a water treatment system in which another pump is used to pump the filtered water through a deionisation resin to remove conductivity. This conductivity is monitored with an EC meter and the controller tries to keep this reading between 10-50 uS/cm.\r\n\r\n\r\n# EDM behaviour\r\n\r\nIn short, an EDM system constantly watches the spark gap voltage and if it is higher than set point value, it advances the electrode towards the workpiece. When the voltage goes below the wanted set point voltage, it enters a feed hold situation until the voltage rises high enough again. If the voltage goes too low (i.e. shorted), the machine will back out from the cut until the voltage rises back to the wanted limits or errors out if the maximum retraction distance is reached (something gone completely wrong).\r\n\r\nThus an EDM is a process-controlled machining situation, in which you can't just feed it with constant velocity and be happy. It will either result in a short-circuit condition or it will go much much slower than it could. And as EDM is slow to begin with, this is not good, especially as such on-off sparking results in poor cutting conditions due to unstable burn. Thus the movement needs a P(ID) loop from the gap voltage at the very least.\r\n\r\nIn my own original machine this was done such that before stepping the motors one step the machine checked the gap voltage. If it wasn't high enough, it waited until it was and only then took the step. This made my wire EDM approach the workpiece in cutting conditions at 30 mm/min and when the sparking started it basically slowed down to a perfect speed, i.e. the speed that the eroding process dictates.\r\n\r\n\r\n# Existing solutions\r\nHardly none. I've seen 5 or 6 wire EDM's done by hobby crowd, countless sinker EDM's and not a single drill EDM. All of these have used varying degrees of software solutions and different hardware. The wire EDM systems have been basically without any good motion controllers except the one I made, unless you count proprietary systems which are not open source and also not designed for EDM use.\r\n\r\n\r\n# Intention at the moment\r\n\r\nAfter reading that the current (v0.9) version of grbl supports feed hold and cycle start inputs, I'm inclined to setup and test my wire EDM with a grbl controller. Only thing I need between the machine and grbl controller is a small circuitry to watch the spark gap voltage and control the grbl input pins based on that value.\r\n\r\n\r\n# Problems & possible solutions\r\n\r\n1. The biggest problem is that grbl is not designed to be process controlled. This can be circumvented by the feed hold and cycle start inputs that have been added, but it isn't still perfect as the initial maximum program feed rate has to be adjusted so slow that the machine actually stops 'immediately' after feed hold input so that it won't short circuit. This is because the spark gap is a very small distance and when grbl is instructed to feed hold, it will decelarate to a controlled stop.\r\n\r\n2. Adjusting the initial maximum feed rate to 'something' becomes completely experimental based on workpiece material and thickness and the generator settings. For example, my wire EDM would go under 1 mm/min with 10 mm thick steel piece, while in 1 mm thick aluminum it tried to go as fast as my Arduino program code (not optimal) could execute. Thus the feed rate should be adjusted via process parameter, in other words the gap voltage, as the work piece and generator power settings affect the possible feed rates dramatically.\r\n\r\n3. Short circuit handling. In short (no pun intended), there is none in grbl, as it is designed for a 3 axis milling machine. Thus the controller has no idea how to back out the same way it came in to the position at which the short circuit condition occurred. The only workaround that I could think of currently is to use an external buffer device like another Arduino between the G code sender and the grbl controller to detect the gap voltage and control the grbl with feed hold and cycle start inputs. If the gap is shorted, it would send the grbl a command to flush the motion planner buffer, send in a movement command that would reverse the movement until the short is cleared and resend commands to get where it was when the short occurred and continue to send the original code.\r\n\r\n4. Control inputs/outputs for different machine functions. Flushing pump is pretty obvious, just use the coolant output, as is the wire speed (variable spindle speed). But the EC meter input, resin pump output, spark generator settings (like relays for different R values) etc. can't be controlled. With an external Arduino these could be done in the background by spying on the G code traffic sent to the grbl controller.\r\n\r\n5. Industry standard M-codes for cut/rethread wire. M60 and M61 are these codes, which on a machine without Automatic Wire Threading (AWT) would halt the program, wait for user to cut and remove the wire, then cycle start would reposition the machine to the M61 line and wait the user to rethread the wire and hit cycle start to continue. So basically M60/M61 works about the same as M0 does, except that wire feed handling manually is allowed to feed the wire as needed for rethreading.\r\n\r\n6. Amount of pins for input/output. Now, this could be a little problematic with just the Arduino UNO, but doable with the Arduino MEGA 2560 without any additional hardware. BUT, most of the inputs/outputs needed are not real-time sensitive (like activating a pump or changing the power settings), so they could be done via I2C port with something like the MCP23017 I/O-expanded IC. This I haven't fully investigated yet but it is an idea that wouldn't require changing from the Arduino UNO to some other board to keep code changes to minimum. Though I'm sure the following suggestion is such a large addition/change that changing the board to the Arduino MEGA 2560 wouldn't be such an issue.\r\n\r\n7. All of the above *could* be circumvented with an external hardware wrapper that would control the G code sent to grbl and would also keep track of the EDM process and contrl the extra machine inputs/outputs and make the grbl behave about as it is supposed to in an EDM application, but I would really call this is a hack at the best.\r\n\r\n\r\n# Suggestion\r\n\r\nAs EDM's are a completely different animal compared to conventional machining in the way they behave and are controlled, I would suggest that there would be a 'grblEDM' branch developed that is separate from the actual grbl. The difference would be in that the grblEDM would be a process dictated controller with the possibility to reverse direction. Most of the motion control planner wouldn't be needed as the eroding movements are so slow that they can be calculated on the fly. Only fast moves would be G0 rapids to position the machine as that condition assumes that no cutting takes place.\r\n\r\nI would be prepared to help develop this system as I have skills in mechanics, electronics, CNC work and can also code more than enough but not at the level which grbl is done, which kind of excludes modifying the grbl as I don't quite have a full understanding of its inner workings. I also have no idea how the github repositories work or how they are supposed to be used, as most of the names for things are not familiar for me (the language isn't the problem, but limited knowledge on multi-coder projects and repositiories).\r\n\r\nI also have the incentive to do this as I already have a wire EDM at home to play with and I can also do testing with a sinker and drill EDM if it is needed (very simple to build as additions to the wire EDM frame fo testing). I also have access to a MasterCAM 3D license to generate test tool paths for various parts if necessary.\r\n\r\nI would be very interested in hearing back from the grbl dev team about this whole thing and would like to engage in discussions about the possibility of this. I can be contacted via here or fastest through my email address which should be visible in my profile.\r\n\r\nAnd what I would like to see of the possible grblEDM is that it would be under GPL to keep the open source community and activities thriving without limitations :)\r\n\r\n\r\n# TL;DR\r\nThis isn't the project you are looking for ;)\r\n\r\n\r\n# Outro\r\nThank you for your time and hope to hear from the dev team and others for feedback on this topic. Ideas are also welcome, though they are the next step after getting feedback.\r\n\r\nJaakko Fagerlund\r\ntool & die maker\r\n"},"comment":{"url":"https://api.github.com/repos/grbl/grbl/issues/comments/69694857","html_url":"https://github.com/grbl/grbl/issues/565#issuecomment-69694857","issue_url":"https://api.github.com/repos/grbl/grbl/issues/565","id":69694857,"user":{"login":"JaakkoFagerlund","id":10484803,"avatar_url":"https://avatars.githubusercontent.com/u/10484803?v=3","gravatar_id":"","url":"https://api.github.com/users/JaakkoFagerlund","html_url":"https://github.com/JaakkoFagerlund","followers_url":"https://api.github.com/users/JaakkoFagerlund/followers","following_url":"https://api.github.com/users/JaakkoFagerlund/following{/other_user}","gists_url":"https://api.github.com/users/JaakkoFagerlund/gists{/gist_id}","starred_url":"https://api.github.com/users/JaakkoFagerlund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JaakkoFagerlund/subscriptions","organizations_url":"https://api.github.com/users/JaakkoFagerlund/orgs","repos_url":"https://api.github.com/users/JaakkoFagerlund/repos","events_url":"https://api.github.com/users/JaakkoFagerlund/events{/privacy}","received_events_url":"https://api.github.com/users/JaakkoFagerlund/received_events","type":"User","site_admin":false},"created_at":"2015-01-13T04:44:58Z","updated_at":"2015-01-13T04:44:58Z","body":"@chamnit @EliteEng : Ah, just discovered the cpu_map file that relates to MEGA and its pins :) Somehow had missed that completely while browsing through the files, as I've been trying to get a mental image of the whole system and been plotting a little functionality graph for myself so that I can easily see what function does what is called from where.\r\n\r\nI'll see what I can do, if I don't run in to memory issues or lack of pins, then two Arduino UNO's should suffice, as one would hold a modified grbl (without Z-axis, with addiotional M codes) and one would feed it with the program information based on the spark gap."}}