585,996 active members*
4,570 visitors online*
Register for free
Login
Page 1 of 2 12
Results 1 to 20 of 24
  1. #1
    Join Date
    May 2007
    Posts
    1026

    EMC with Arduino for USB I/O?

    I'm looking to build a custom keypad which would have a large number of keys, some of which I'd like to include status lights which would reflect the state of the machine (such as the G20/G21 for inch vs mm mode).

    Basically, I will have too many I/O lines for simplistic use of the parallel port, and I'd prefer to avoid something like a Mesa card, mainly for cost reasons.

    I've built a bunch of things using the Arduino boards before, and I'm curious whether anyone has gotten one to talk with EMC. If there is a way to send discrete messages ("G20 is enabled") between the two systems, then I can easily figure out how to wire up the keypad with the Arduino.

    Has anyone done or seen anything along these lines?

  2. #2
    Join Date
    Nov 2005
    Posts
    496

  3. #3
    Join Date
    May 2007
    Posts
    1026
    Thanks Chester. That worked--well, I was able to turn an LED on and off using the test control panel. I don't really understand the parts well yet, or how they fit together, but at least they seem to fit! From experience I know it's easy to spend hours trying to get Plug A to fit into Socket B so it is always nice to see "hello world." Now the real work begins....

  4. #4
    Join Date
    May 2007
    Posts
    1026
    Since my last post I've managed to get things working pretty well. I ended up starting over pretty much from scratch compared to the example chester88 posted, cribbing together bits from various tutorials and asking stupid questions on the EMC lists and IRC channel.

    This video shows an Arduino being used as both an MPG with an encoder and a remote DRO with a 20x4 LCD. Cost of the whole setup is a little under $100 so far.

    [nomedia="http://www.youtube.com/watch?v=flajZMff28U"]YouTube - Integrating an Arduino with EMC[/nomedia]

    Next step is to design and etch up a board to support a full keypad. I have 10 I/O lines to work with, which would give me room for a 25-key matrix. If I can squeeze all that in, it will make a pretty nice unit. As it continues to mature a bit more I will post sources for anyone who wants to see how it all goes together.

  5. #5
    Join Date
    Jun 2005
    Posts
    55
    Nice! I'd love to see a finished product. Maybe as a kit

  6. #6
    Join Date
    May 2006
    Posts
    122
    seconded. A kit for a usb pendant/remote DRO would be really cool.

  7. #7
    Join Date
    May 2007
    Posts
    1026
    OK, so here's the latest:

    [nomedia="http://www.youtube.com/watch?v=n9YMpQjsab4"]YouTube - Arduino EMC Pendant II[/nomedia]

    This adds a 25-key keypad to the mix, which I wasn't sure if the Arduino could cope with on top of the encoder and LCD. So far, so good. 25 keys is a pretty healthy number, and unless your machine has an ATC or some other sophisticated systems, should be enough to cover around 95% of what you'd want on a hardware interface. As it is now, I have these:

    - XYZA axis selection
    - Jog rate selection (4 positions)
    - Spindle speed and feed rate override select (uses the encoder)
    - X and Y continuous jog
    - Coolant on/off
    - Axis home (homes the selected X/Y/Z/A axis)
    - Cycle start, stop, pause, and single block mode


    If anybody has some suggestions for what they'd like to have, I'm all ears. I'm considering getting some quotes for proper membrane keypads to see how much it would cost to do say 50-100 of them, versus a PCB with switches and a printed overlay. Obviously there are going to be some differences between a router table, milling machine, and lathe, so whatever I do, you're probably going to end up with a few labels stuck on top of it. Either way, the hardware config will be hackable to allow you to get it to do what you want.

  8. #8
    Join Date
    Aug 2003
    Posts
    9

    Smile

    Hi sansbury!

    Nice work.
    This is something that i have been looking fore. One thing to implement is the connection of touch probe so you can use it for scanning, center finding and so on with the G38.2 code.
    Why are you not using Z in continuous?

  9. #9
    Join Date
    May 2007
    Posts
    1026
    Thanks Gunnar!

    The keypad design is still evolving. The main reason I didn't add continuous jog keys for the Z was that in my experience, the Z moves a lot less than X/Y. If you want to retract the Z all the way, there is always the homing function, assuming your Z homes away from the table (as is usual).

    But, if you prefer, you could modify the keypad and firmware pretty easily to support a Z jog instead of tool release, coolant, or some other function you don't care about that I do

    Probing is a good question. My sense was that the right place to implement this might be in the EMC GUI layer, rather than the pendant. Probing the center of a pocket is easy since there's only one way to do it, but edges have four possible ways to go, so you need at least 5 keys, unless you want to have multi-key functions (e.g. select probe function, select axis, select direction) which are harder to use and make the software more complicated.

    One thing I might look into is the use of soft keys, though these also add a good deal of complexity to the software, and I'm not sure how much headroom I have at this point.

  10. #10
    Join Date
    Nov 2010
    Posts
    0
    Sansbury, good job so far. I am planning on using an arduino or a teensy++ for my sensors (limits, over-current, axis encoders etc). I was wondering if you could share any of the details. For instance, are you running firmata on the arduino and grabbing the info from within EMC? Any info you can share as far as setup on the EMC side? Are you using USB serial or direct serial? In case you are curious about the teensy, it has a higher gpio count (45 in the case of the ++ model) plus speaks at usb bus speeds vs serial speeds. Did I mention that it is cheaper and easier to breadboard?

  11. #11
    Join Date
    May 2007
    Posts
    1026
    half_life, I did a longer write-up on my blog that goes into a bit more detail:

    Arduino-EMC Integration: How it Works | Just Milling Around

    I am not using Firmata, I implemented my own serial protocol. Outputs to the Arduino are seven-character fixed-length messages like "X123456" which would be interpreted as "the X axis position is now 12.3456." The Arduino outputs are shorter, only 3 chars, as they don't need to carry nearly as much information. I could probably cut the length of both in half, at the cost of making them harder for humans to work with. Given that current performance appears adequate, I'm leaving it be.

    The reasons I chose the Arduino are simple: it's drop-dead easy to work with, and has a huge installed base. If somebody wants their pendant to have probing functions instead of coolant and spindle control, I want it to be easy for them to do that. Right now, I think Arduino is the best place to start with that goal in mind. The teensy or some other less-common solution, let alone something that requires an external programmer, would be great if I really wanted to extract maximum commercial value at the cost of end-user openness. For an example, the Shumatech DRO's software and schematics are open, but as best as I know, the only DROs out there using that code are Shumatech's. Given that this thing can do a lot more than a DRO, I'd rather give up some number of sales to people who DIY the whole stack and benefit from the whole community contributing code and using this platform as the basis for more intricate HMIs.

  12. #12
    Join Date
    Oct 2010
    Posts
    0
    Does your sourcecode/ the HAL system in general allow the arduino to also generate step and dir signals to control steppers directly from EMC?

  13. #13
    Join Date
    May 2007
    Posts
    1026
    Quote Originally Posted by holyjewsus View Post
    Does your sourcecode/ the HAL system in general allow the arduino to also generate step and dir signals to control steppers directly from EMC?
    No. It is effectively impossible to get the necessary real-time performance using anything other than the parallel port or the PCI bus.

    There has been limited discussion of using ethernet to connect to drives, and there is a project to create a real-time USB driver for Linux, but neither of these are anywhere close to even being prototypes. When you get down to it, the parallel port actually works really well for machine control. You might not find parports on cheapo Dells, but they are still on many if not most mobos, even some of the cheap Atom-based ones that are starting to become really popular with EMC builders.

    A pendant or control panel doesn't have to be anywhere near real-time so USB/serial works fine for this purpose.

  14. #14
    Join Date
    Nov 2010
    Posts
    0
    Thanks for responding. I see that HAL and i need to become better friends. I think that we are looking to scratch different itches. I might suggest that you look at low cost transceivers (about $8 a pair) and the virtual wire library. This would allow you to un-tether without giving up anything. I am heading in the direction of controlling non time critical machine functions keeping my parallel port pins open. One desire I do have is to show commanded position vs actual position maybe in the the form of a delta. I have found what could be an interesting encoder to use at digikey Digi-Key - EVB90316-DC-ND (Manufacturer - EVB90316-DC) talked about here Lab3 - Laboratory for Experimental Computer Science $26 an axis plus a little coding. I will let you know when I have something put together if you are interested. BTW the teensy while less known is pretty much code compatible with the arduino.

  15. #15
    Join Date
    Oct 2010
    Posts
    0
    Thanks for responding, and not to derail your intended use, perhaps I should make a separate thread, but I just wanted to ask as you've accomplished a lot, and I'm not a programmer: would a non realtime control be possible with some sort of buffering on the arduino, recording pulses and then relaying them or it's just not possible?

    Guess I need to start looking for a parallel ported computer




    Quote Originally Posted by sansbury View Post
    No. It is effectively impossible to get the necessary real-time performance using anything other than the parallel port or the PCI bus.

    There has been limited discussion of using ethernet to connect to drives, and there is a project to create a real-time USB driver for Linux, but neither of these are anywhere close to even being prototypes. When you get down to it, the parallel port actually works really well for machine control. You might not find parports on cheapo Dells, but they are still on many if not most mobos, even some of the cheap Atom-based ones that are starting to become really popular with EMC builders.

    A pendant or control panel doesn't have to be anywhere near real-time so USB/serial works fine for this purpose.

  16. #16
    Join Date
    May 2007
    Posts
    1026
    Quote Originally Posted by half_life View Post
    I am heading in the direction of controlling non time critical machine functions keeping my parallel port pins open.
    Yeah, the Arduino rig works nice for that also since it saves you having to mess with 30+ wires. I don't really care about making it wireless--to me that would just be another thing to go wrong.

    One desire I do have is to show commanded position vs actual position maybe in the the form of a delta. I have found what could be an interesting encoder to use at digikey Digi-Key - EVB90316-DC-ND (Manufacturer - EVB90316-DC) talked about here Lab3 - Laboratory for Experimental Computer Science $26 an axis plus a little coding. I will let you know when I have something put together if you are interested.
    Does that encoder output quadrature? You can get a regular encoder of suitable resolution for under $50, and wire it straight into EMC. If the board doesn't do quadrature you might need to do extra work to get a signal into EMC. People have done setups with steppers and encoders where EMC will fault and stop if the following error exceeds some value. Personally, I see these as interesting but largely beside the point. A properly-sized stepper system doesn't lose steps. I've built 5 machines and step loss has never been in my top 10 problems. You just need to spec things right in the beginning.

    The other thing is, an encoder on the shaft only gets you motor position, not the actual position of the machine. It misses out on both leadscrew pitch deviation and backlash, which, unlike lost steps, *are* significant sources of error.

    I once tried getting an Arduino to read the output signal from a digital scale (i.e. one of those $20 electronic calipers), and didn't have much luck, but I also was a lot greener then. Either way, those would be much more interesting, as you could mount them to the machine, and use them to measure leadscrew deviation and backlash. Putting them into the control loop directly would be really hard, but you might be able to feed the data in as a DRO and do some logging for metrology.

  17. #17
    Join Date
    May 2007
    Posts
    1026
    I've written up a much-simplified example of my Arduino-EMC interface with source code over on my blog.

    Simple EMC-Arduino HOWTO | Just Milling Around

    The example is very basic but should serve as a good baseline for something more involved.

  18. #18
    Join Date
    May 2007
    Posts
    1026
    Chugging along slowly. The prototype enclosure is together, and it fits, but I still need to figure out how to make the second one a lot nicer-looking. I think I have a way. Also, it's time to get back into the software to see if it can be made more stable. Right now it works fine so long as you don't give the encoder a good spin (why would you want to?). Bigger pics and more build details on my blog....

    Thinking Inside the Box | Just Milling Around


  19. #19
    Join Date
    May 2007
    Posts
    1026
    I think I finally figured out the problem that was causing some transient instability. At least, my solution makes the problem go away (chair)

    This update video shows the pendant in action with the latest firmware.

    [nomedia="http://www.youtube.com/watch?v=ONxVoAXadTk"]YouTube - Arduino EMC Pendant Prototype[/nomedia]

    For those curious about the problem, there's a detailed writeup over on my blog at We Have a Winner! | Just Milling Around

    There's some more work still to do, particularly in making the enclosure something anyone could build, but I am starting to see light at the end of the tunnel. In another month or two I may be ready to start selling kits, or at least PCBs with a BOM and source code.

  20. #20
    Join Date
    Apr 2012
    Posts
    0

    Post LinuxCNC control of and Arduino based mill.

    A lot of people have an Arduino and they sometimes consider making a CNC machine but get put off by the software daisy chain and modest G-Code support. I was one of them. So I sat down and made Emc2Arduino an open source Arduino based CNC controller firmware and got it talking to LinuxCNC.

    If any body is interested it supports:
    • USB CNC controller upgrades.

    • Adding features to existing CNC machines.

    • Touch probes.

    • Simultaneous 0 to 9 axis motion control.

    • Full Min/Max/Home limit switches. (Both virtual and physical.)

    • E-Stop, Power, Start, Stop, Pause, Resume and Program Step inputs.

    • Coolants outputs, flood and mist.

    • Power supply control, powers up/down automatically.

    • Spindle controls on/off, direction, tach/speed control.

    • E-Stop and Power indicator outputs.

    • More features by popular request.


    Interested? Let me know.

Page 1 of 2 12

Similar Threads

  1. Arduino Resolver Converter
    By andypugh in forum Open Source Controller Boards
    Replies: 3
    Last Post: 12-23-2018, 06:31 PM
  2. My new CNC machine. Arduino controlled:
    By aventgps in forum Open Source CNC Machine Designs
    Replies: 45
    Last Post: 05-03-2012, 05:39 PM
  3. Arduino Mega driving my cnc.
    By aventgps in forum Videos
    Replies: 2
    Last Post: 12-30-2009, 08:57 AM
  4. Arduino AlienCNC C control
    By gremilRoute in forum CNC Machine Related Electronics
    Replies: 6
    Last Post: 04-23-2008, 10:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •