Anyone tried EMC2Arduino

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

Re: Anyone tried EMC2Arduino

Post by dewy721 » Mon May 28, 2012 12:30 pm

BTW: I wanted to take a moment and say that I really admire your project as it brings more to the CNC hobbyist's table than my own. Helping makers get to making better things even easier is very cool indeed.

I myself don't have a CNC rig yet, though I've been building one slowly from the inside out. Learning about it mostly.

I'm happy to help in any way I can, now that the 'can' is growing, but for now I'm limited to what I have to play with:

An Arduino or two (Mega2560 & Uno).
Sparkfun's Quadstepper driver board.
4x NEMA 23 steppers.
Various salvaged switches (optical & mechanical)
Misc. salvaged computer parts.

The rest is developed against a mental model, but even this has limits. Lol.

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

Re: Anyone tried EMC2Arduino

Post by neilhand » Mon May 28, 2012 5:04 pm

Thanks for the reply - any idea on the timing issue that is leaving the step pins active sometimes?

In the original code there was the "digitalWriteFast2" which i replaced with the standard "digitalWriteFast" - was there something different with the version you were using?

With regards to the ShapeOko, the working are is 8"x8"x3.5" and in its current configuration there are no limit or home switches (although i would like to add some at some point).

Not sure if you also need the specifics of steps, timing, etc in the emc2 files, since i assume that is all in the ino file on the arduino which i have already configured. But there is a goof calculator put together by DrRob at http://noblesque.org.uk/ShapeOko/grblcalc/

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

Re: Anyone tried EMC2Arduino

Post by dewy721 » Mon May 28, 2012 6:07 pm

Oops, I forgot to mention it in my previous post. (Sleepy)

Active step pins:
The Arduino code may hold the step pins active once it reaches a given position. But I could add a rest timer to it if you like. For the Allegro A4983 based driver that I use its more accurate to stop without resting even if it results in a logic level HIGH (active) state.

digitalWriteFast2 vs digitalWriteFast:
This is odd to me I'll look into it further.
I wonder if it relates to the library flavor (interrupt safe vs not).

Steps, Timing, Etc. config in EMC:
Your right, the Arduino handles all of it, EMC just needs some fictitious 'convincing' in order to bring it to a stage of handing out the coordinates the Arduino is looking for. EMC2Arduino sidesteps that entirely, but alas EMC/Axis requires it during setup. For that, just pick a popular vendor choice, move on.

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

Re: Anyone tried EMC2Arduino

Post by neilhand » Tue May 29, 2012 2:41 am

Looking into the digitalWriteFast vs digitalWriteFast2 it seems that the latter is removed from the "interrupt safe" download, yet the comment in the EMC2Arduino indicates that that is the version that should be used.

Recommendation? Should i use the safe version and edit the file, or use the non-safe version and ignore the comment?

Thanks for your help dewy721 i am looking forward to getting this working...

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

Re: Anyone tried EMC2Arduino

Post by dewy721 » Tue May 29, 2012 3:08 am

Impressive, You must have a night vision scope mounted to that troubleshooter of yours. :)

Hmm, spindle tachometer uses an interrupt so we'll need the 'safe', version if we ever intend to use it. Otherwise the non-safe is supposedly SLIGHTLY faster. But you'll loose tach support I think.

Either way, thanks for the heads-up. I'll get that fixed.

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

Re: Anyone tried EMC2Arduino

Post by dewy721 » Tue May 29, 2012 1:16 pm

Here's a modified set of files to help get your ShapeOko up and running like a champ.
Please review them before use...

Included:
Tweaked Emc2Arduino 0.07b firmware. So you can review min/max/home settings that match up to the my-mill.ini file.

my-mill.ini 3-axis config with looser latency settings, 8"x8"x3.5" limits (-1" max Z depth) mill settings. Should home to 0.25" shy of Zmax at table center.

custom.hal file with 3-axis config.



Please note the Arduino will loose its motor positions every reset. Defaults to x0.0 y0.0 z0.0

For your rig the Arduino will power up thinking the gantry is all the way to the front with the spindle carriage all the way to the left and that the Z axis is at 1" above bottom limit. You'll need to manually set the machine in that position prior to every power-up for as long as virtual limit switches are used. If you don't, it will 'crash' one or more axises when you home the machine.

Real switches however allows the machine to figure it all out for itself, You'll never need to pre-position your CNC as well as having some cheap but good anti-crash insurance.

But I digress,
attached are the files I mentioned. Enjoy.
Attachments
ShapeOko.zip
(13.92 KiB) Downloaded 110 times

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

Re: Anyone tried EMC2Arduino

Post by neilhand » Wed May 30, 2012 5:21 am

Quick update for those following the thread...

Dewy721 - thanks for the files. I merged them with my own which had the appropriate steps per inch for each axis, and had to make a few tweaks to remove your paths and custom panels.

Short version - i have movement. The X and Y seem to work both under manual control and "home-ing". I have not been able to run a job yet, but more on that shortly.

First the good news - the X and Y.

I am using the files provided by Dewy721 with the following changes.

EmcArduino_07b:
[*]Used the "non-interrupt-safe" version of the digitalWriteFast library since we are not using the spindle tacho, and it saves editing the file.
[*]Used the following steps for each axis
stepsPerInchX 2222
stepsPerInchY 2222
stepsPerInchZ 8128

[*] changed the pin configurations to match DrRob's board and my bad wiring (swapped X and Y).
[*] inverted the Y and Z axis - could be my bad wiring. The odd thing is that in GRBL i needed to invert all three so i think that emc2Arduino has an inverted X compared to GBRL.

Custom.hal:
* commented out the external pannel switches I am not using
* edited the path ti the 9axis_arduino file

my-mill.ini
* edited the program prefix to point to my own home directory
* removed the reference to the "custompanel.xml" file

Now to the issues...

1) The drivers are always enabled, this is different to GBRL (which only enables when motion is happening) and means that (a) the motors will draw more power and heatsinks working harder since they are constantly holding once everything is powered up and (b) that power up sequence seems very important. For the latter i needed to first power up the 24V rail, then the arduino and shield, and lastly cnclinux. any other order lead to some sort of race with the motors drawing more current and exceeding the limits of my bench supply. While a bigger supply may have overcome this, i am not sure i would be comfortable with sinking that much current. This should be a simple fix by initializing the enable to an inactive condition in the sketch (in this case active high).

2) th Z axis is non functional. It makes noise, tries to move - and does a little - but for the most part nothing meaningful happens. I suspect that it could be due to the sampling rate in the original code being tied to the number of steps per inch rather than the actual step rate per minute. the only difference with Z is that even with no microstepping, by my calculation it is 4x the steps needed per inch for x any y. I have hooked up the load LED to pin 13, and the first time i manually move Z it is constantly off, after that it behaves the same as the other axis however so i am not sure i truly believe it.

3) Unable to actually cut anything... the virtual limits and homes are getting in the way at the moment, although I agree that in the longer term both virtual and real limits are a very good idea. First, it would be good to get a version of "hello world" (what i was hoping to draw as a test) that used non negative references. As for anything else, it seems i constantly hit some virtual limit switch - usually Z.

Summary
1) Things are moving
2) need to fix z
3) need to generate a 0,0,0 reference gcode file (trashed by windows/bootcamp machine trying to expand the HD - will be back up tomorrow)
3) need to find the proper limits for axis, especially z

I'll play more tomorrow - maybe drop the steps/in of Z to test my theory on the code (easier than digging in)

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

Re: Anyone tried EMC2Arduino

Post by dewy721 » Wed May 30, 2012 12:44 pm

I think I know whats going on with your Z axis. The step rate frequency is too high for it to move (in full steps).

The Arduino code needs to be modified to allow individual step rates on a per axis basis.

Power problems:
There's a easy software solution to your powerup sequence. If you can slave the PSU to the eStopLedPin and your shield to the powerSupplyPin in EMC2Arduino that will allow you to control both your power supply and shield seperately from within the Axis GUI as well as enforce the proper sequence you speak of.

In Axis the Toggle Machine Power button (linked to your shield) cannot be activated while an E-Stop condition exists. The E-Stop will enable/disable the PSU appropriately, ie. smack the E-Stop button and PSU cuts out while turning the machine power state to off. Thus, resetting the power up sequence.

E-Stop off + Machine power on = motors go "hot" > tool held rigidly in position ready for work. Just like traditional CNC machine does.

I'll look into modifying EMC2Arduino and provide those adjustments I mentioned.

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

Re: Anyone tried EMC2Arduino

Post by neilhand » Wed May 30, 2012 6:09 pm

I was digging into the code to make the mods and think there is a logical error in the way "stepState" is implemented.

I understand that you are treating it as a flip-flop state so double the number of steps for something to happen, but given that you invert the state every loop though "stepLight" there is the chance to loose an edge. While only a minor thing it may add up over time.

In order to accommodate per axis delays however, it would be simpler using a per access stepState and only change it when there is activity. This would solve the missing edges while at the same time making implementation simpler.

[deleted part about optimizations since i realized that it is compiled not scripted - hence the complier is likely to do the things i mentioned automatically]


I will probably take a crack at the mods myself tonight just for fun and post the results.

For the power up, i may try a shortcut. I think the main problem is that the drivers do not like being enabled before the power is supplied. I plan on editing the state that the enable pins are disabled in the setup, and are set to enabled when the power control is toggled. the race condition may exist for a short time, but since the startup loop will disable the drivers it should reset the race.

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

Re: Anyone tried EMC2Arduino

Post by dewy721 » Wed May 30, 2012 10:10 pm

Hehe, I think I might have beaten you to it....

Attached is an alpha release featuring some of your suggestions:

Power conservation, drivers sleep when the machine idles for more than 2 seconds.
Configurable enable/disable drives at boot.
Individual step state variable per axis.
Individual step rate timing per axis, for mixed mode setups.

Happy hacking.
Enjoy.
Attachments
EmcArduino_08a.zip
(10.96 KiB) Downloaded 115 times

Post Reply