Anyone tried EMC2Arduino

neilhand
Posts: 24
Joined: Thu Apr 26, 2012 7:03 pm

Anyone tried EMC2Arduino

Post by neilhand » Mon May 14, 2012 8:50 pm

Hi all,

Wondered in anyone has experimented with this approach (http://emc2arduino.wordpress.com/).

If it works, Its nice that you can use the same electronics setup and just change the Arduino code between in and GRBL to try out different workflows. I have not had a change to test it yet since I have not been able to get EMC running. Wondering if anyone else has any experience before i go down a path that has already been looked at.

[the site mentioned ShapeOko in the get parts section...]

edwardrford
Posts: 1250
Joined: Mon Apr 09, 2012 5:40 pm
Location: Dixon, IL
Contact:

Re: Anyone tried EMC2Arduino

Post by edwardrford » Mon May 14, 2012 9:03 pm

Actually,

The creator emailed me a while back. I meant to look into it, because it sounds interesting and I really <3 EMC2!

I had some questions for him about *how* it worked.
...Here's my question to you: How does this work? There isn't a proper interrupt with USB. How are the steps and frequency controlled?

Next question: How do I get this going. I only have arduino 328p arduinos laying around (about a dozen of them). Can I use this on one of those or will I need to buy an Uno or a Mega?
He replied with this:
Well, I tool a more or less abstract approach to the problem...

Rather than trying to get EMC to directly drive step and direction IO over usb and through the Arduino. That would be WAY to slow!

Instead I set EMC up to delegate movement control over to the Arduino. To move two axises million steps each you don't need to send 2million step and 2million dir commands over the serial link. Just send the coordinates and let the Arduino do the rest.

Like dogs at a dog track chasing the fake bunny around, Emc issues the location of the bunny and the Arduino updates the movements of the dogs to give chase.

Are far as speed goes:
At one 1inch per motor revolution (at 1/16th microstepping) x4 axis in motion I can pull 130ipm rapids. Plenty fast for working speeds.

Will you need a Mega 2560?:
No, its not required but the extra pin makes like easier. You'll need two pins per axis to drive the stepper controllers. A pin for each additional feature like switches, PSU control, blinky lights, etc.

In the future I plan on making on make micro-builds that would allow an 'Arduino swarm' to control one or more tasks individually. (Big speed boost.)

The program is about 15~16k so the 328p should run it just fine.
If anyone is up for giving it a try, let me know how it goes. It's on my to-do list, but at this point it's so long I can't see the bottom, so I'm not sure when I'll get to it. The one thing I would *LOVE* to know is if this would work while I was running EMC2 from a VM! That would be hot.

-edward
Shapeoko 1 #0 - a couple of upgrades.
Shapeoko 2 #0 - a couple of upgrades.
Shapeoko 3 #2 - Stock

Enraged
Posts: 230
Joined: Mon Apr 09, 2012 8:29 pm

Re: Anyone tried EMC2Arduino

Post by Enraged » Mon May 14, 2012 10:49 pm

wow, that would be great if this works out. EMC2 is a fantastic software with lots of expandability, using it on a Shapeoko would be great.

AtomSoft
Posts: 589
Joined: Mon Apr 09, 2012 9:15 pm
Location: Brooklyn NY
Contact:

Re: Anyone tried EMC2Arduino

Post by AtomSoft » Tue May 15, 2012 1:57 pm

I guess since my todo list isnt as large. Ill try it out in a VM. Im sure it will work :)

Ill setup software today and plug in some hardware. I wont be able to do a RUN really until i get my cnc. But i can test to see if things are getting controlled :)
Blog / Store
Live to Love, Not to Hate.
You're not a failure because you don't make it, you're a success because you tried.
Do you like the help i give? Think i deserve a tip? DONATE

AtomSoft
Posts: 589
Joined: Mon Apr 09, 2012 9:15 pm
Location: Brooklyn NY
Contact:

Re: Anyone tried EMC2Arduino

Post by AtomSoft » Tue May 15, 2012 11:42 pm

Ok i have this installed in a VM using there live cd (but installed). I can run it but when i close the main program (linuxCNC) it crashes and freezes the VM.
Blog / Store
Live to Love, Not to Hate.
You're not a failure because you don't make it, you're a success because you tried.
Do you like the help i give? Think i deserve a tip? DONATE

neilhand
Posts: 24
Joined: Thu Apr 26, 2012 7:03 pm

Re: Anyone tried EMC2Arduino

Post by neilhand » Wed May 16, 2012 2:52 am

is there a quickstart guide somewhere for configuring EMC2 for shapeoko? The wiki is rather sparse. I have a spare laptop as well as a VM that i am happy to set it up with - but i need to get EMC2 setup first.

Plan at the moment is just to rerun the hello world via EMC2 and EMC2Arduino and see how it looks.

dewy721
Posts: 16
Joined: Sun May 20, 2012 10:12 pm

Re: Anyone tried EMC2Arduino

Post by dewy721 » Sun May 20, 2012 10:27 pm

Well it may prove challenging to get LinucCNC (EMC) to run inside a VM at least according to the http://wiki.linuxcnc.org website.
Here's an excerpt from it:

"Why won't LinuxCNC run on Windows?

LinuxCNC runs in real-time, to give smooth motion. This is critical to accuracy and machine life. Hard real-time is not available on Windows in a price range many can afford... especially those interested in using a PC-based control.
LinuxCNC is intended to control machine tools. Machine tools are DANGEROUS and reliability/consistent behavior is extremely important. Compared to Windows, few viruses affect Linux. Even without consideration of viruses, Linux is far more stable.
The above also apply to virtual machines (e.g., VMware or Virtual Box) and emulators. It may be possible to trick LinuxCNC to run on a virtual machine but do so at your own risk!
The above notwithstanding, one can access a running LinuxCNC machine from a Windows machine, e.g., by running a Windows-based VNC client or X11 server. "


HOWEVER: I may have found a caveat for anyone interested...
Simulation mode has no Real-Time requirements but (if memory serves) one would need modify mymill.ini to load HAL and HALUI. This will provide the necessary hooks Emc2Arduino needs to make use of.

More info can be found here:
http://wiki.linuxcnc.org/cgi-bin/wiki.p ... _Simulator

Hope it helps.

dewy721
Posts: 16
Joined: Sun May 20, 2012 10:12 pm

Re: Anyone tried EMC2Arduino

Post by dewy721 » Sun May 20, 2012 10:39 pm

I found the easiest way to setup Emc2Arduino with LinuxCNC is to just install it natively. The linux installer will let you keep windows as well (if you like), this way you may choose to use Windows or LinuxCNC at boot time.

Ignore the latency test for LinuxCNC if your using Emc2Arduino. That timing test is only relevant to old school parallel port driven CNC controllers. It serves no purpose regarding Emc2Arduino. So one may use an old USB based laptop (even if it scores horribly in the timing test) so long as it has the performance to run LinuxCNC acceptably well. The Arduino IDE is even available for linux. One 'could' elect to go 100% Open-source entirely.

neilhand
Posts: 24
Joined: Thu Apr 26, 2012 7:03 pm

Re: Anyone tried EMC2Arduino

Post by neilhand » Mon May 28, 2012 5:00 am

not sure if Dewy721 is monitoring this thread (i hope so), but here is an update of progress so far (slow going due to multiple computer failures).

I now have a dedicated machine for linuxcnc and emc2arduino (virtual machine was so far no luck)
I have followed the install instructions and set up both enc2 and arduino
i did have to make to following changes (will post full details to wiki once working)
- edited digitalWriteFast to work with Arduino 1.0
- edited the emc2arduino files to replace digitalWriteFast2 and digitalReadFast2 with
digitalWriteFast and digitalReadFast respectively
- edited the 9axis_arduino with the correct port for the arduino

The good news is that something is happening!!!

I initially tried with the motor shield connected, and quickly feared for my life/steppers... Next step LED to the step pins.

In EMC2 when i use manual control to STEP on any of the setting (continuous or fixed stepping) the LED will show activity but will sometimes stay on after the activity. The direction pin works as expected.

I should point out i am using a Duemilanova 328 board and not an Uno and the driver board that I (no longer) am connecting to is DrRob's version of the StepperSheild.

I have multiple other errors within EMC2, but i believe that is due to a bad setup in EMC2, if anyone reading has a working setup for ShapeOko that they can share that will remove one additional variable.

dewy721
Posts: 16
Joined: Sun May 20, 2012 10:12 pm

Re: Anyone tried EMC2Arduino

Post by dewy721 » Mon May 28, 2012 11:30 am

If you can give me the physical parameters for your ShapeOko I might be able to make a mymill.ini to complement it.

Here's what I'll need to know:
Travels on the X,Y and Z axises.
What limit switches you have and where they are located per axis of travel on the machine.
Are your limit switches and homing switches combined or separate.
Where would you like the head to end up once its "Homed".
What bells and whistles you'll be needing or want readied for later use.

That should give me enough info to rough out a template that shouldn't gripe when you load Axis2.4 and be close enough to tweak easily into perfection.

Post Reply