Emc2Arduino 0.07b has been released.

I’m slowly working on adding new features as often as I can.

So far it features: (as of 0.06b)

  • 0~9 Axises of synchronous motion using non-blocking stepper motor control.
  • Full support for both virtual and physical limit switches. (Use ’em if you got ’em.)
  • Inputs for E-Stop, Power, Start, Stop, Pause, Resume and Program Step switches.
  • Software controllable microStepping down to 1/16th step.
  • Simple ASCII serial based control makes it usable for general robotics enthusiasts.

Features added just recently in 0.07b:

Outputs for:

  • Spindle controls; on/off, direction, RPM control.
  • Coolant control. Both flood and mist are supported.
  • Power Supply control.
  • Status indicators for E-Stop and Power. (More coming soon.)

In the pipeline:

  • LCD Support.
  • Encoder Support.
  • Jog Wheel & Joystick Support.
  • Arduino CNC swarm tactics. (Think LEGO-style CNC/Robotics!) Implemented in HAL2Arduino
  • Micro-builds. (Swarm) Implemented in HAL2Arduino

That’s all for the moment.

112 Responses to Emc2Arduino 0.07b has been released.

  1. Patrick Lim says:

    I have an 1996 model of engraving machine using Windows98 to operate n wish u can help me to convert it to Arduino operated using the Linux software. As the engraver is very old it uses the serial port ton control which is very slow using it with usb could be more faster. Any suggestions from u will be much appreciated

    • dewy721 says:

      The bad news: Actually, at best it could do no better than the exact same speed as your old fasioned serial port. The reason for this is due to the fact that while the Arduino has a USB port it only uses it to emulate a serial port. So by method of execution, it would (in theory) be exactly the same speed as your current setup. No faster.

      The good news: If you already have a hardware controller for your engraver (which you do) then you can just use LinuxCNC (formerly EMC) directly! LinuxCNC should talk to it just fine. The best part is that you can test it out without losing windows!

      Here’s how:
      Download the LinuxCNC live cd image to your computer.
      Burn the image to a CD and just boot from it. No install required!
      Try it out. If you find that you like it, just doubleclick the install icon on the desktop.

      In your case, as far as the Arduino is concerned, it would be a great add on to what you already have. Just because Emc2Arduino can run an entire CNC machine it doesn’t have to. One of its neat features is that you can take your existing setup and expand it with an Arduino to give it those extra options your machine may be missing. Say for example your happy with your engraver but you just wish to add coolant and/or probe features. Emc2Arduino can do that. You find one day that you want to add a rotary chuck and engrave some spindles. Emc2Arduino can do that! Just what you want even if what you want is just one thing or the whole thing.

      • Patrick Lim says:

        Can I run the LinuxCNC on the windows98 (my present engraver controller can only work on this plateform) Can your Emc2Arduino run an engraver without controller? Like home built type of CNC etc

      • dewy721 says:

        Unfortunately LinuxCNC won’t run from within Windows. But it can used several other ways:
        1. Run completely from CD (without installing), You can boot from the CD without changing anything on your hard drive.

        2. Be installed side by side with your existing windows, allowing you to choose between them at startup. (Keeps your working setup as a fallback.)

        3. Be used as a complete replacement to windows.

        LinuxCNC is a whole operating system (similar to windows).

        Emc2Arduino *can* be used to replace the controller but it will need a stepper driver board to do so. It would be my second choice if I was stuck with a dead/missing or incompatible controller.

        To put it metaphorically, your CNC controller would be like using the factory v8 engine to push a truck down the road, where as Emc2Arduino is more like using v6 engine.

        Both will work, but the v8 is slightly faster.

        *EDIT*
        Re-reading your last post: ‘(my present engraver controller can only work on this plateform)’…

        Yes you can replace your controller with Emc2Arduino.

        As far as speed goes:
        I get about 130ipm at (1rev/inch) rapids out of my setup and it just uses an Arduino Mega2560 and a small’ish QuadStepper driver board from SparkFun’s website.

        Here’s the links for the parts I’m using:
        Arduino Mega2560 >>> http://www.radioshack.com/product/index.jsp?productId=12272877
        QuadStepper >>> http://www.sparkfun.com/products/10507

        If the quad stepper is too anemic to run your engraver there a LOT of other drivers that are bigger and also work just as well. One overkill example would be this one: http://www.pololu.com/catalog/product/708 (you would need one per axis)

      • Patrick Lim says:

        My engraver is actually an antique still using the DOS (not any windows OS) and using HPGL, therefore I need to overhaul the whole concept to run on the Windows OS plateform, I need to check the voltage of the stepper motors inorder to change. Thanks for your informations

      • dewy721 says:

        Your welcome, I put up a FAQ section in hopes that it helps you (and others) along the way. Good luck.

  2. walgri says:

    Hello,

    is there a noticeable speed improvement over outputting step and dir signals through the parallel port ?

    I am building a cnc router based con DC servos (PID managed by the drivers, not by LinuxCNC) and I woundn’t want to get other external step+dir generator).

    Thanks

    • dewy721 says:

      Parallel ports are generally faster (provided you’re using a suitably fast PC).

      Emc2Arduino is really meant for those that:
      1. Have no parallel port available. (Newer PC’s or Virtual Machines for example.)
      2. Have an existing CNC that needs expansion.
      3. Want to toy around with CNC’s (or even robotics) but without buying dedicated hardware.

      PS. Sorry for the delay in response. (PC Upgrade complete.)

      Dewy

  3. aabajian says:

    Hey this is a great idea, and I can’t believe how similar your setup is to my own. I *just* bought a quadstepper from SparkFun along with the Mega 2560. I spent the past week trying to get the quadstepper to work with a parallel port on an old comp (running LinuxCNC). Eventuallly gave up, wired the quadstepper to the Mega 2560, and voila, the motors turning perfectly. Was disappointed that I couldn’t use LinuxCNC, until I found your site! Going through your code now.

    • dewy721 says:

      Fantastic! I hope it works out for you. I wired mine up using the digtal pins 22 through 53. That way I can still have all my communications pins and analog pins for other things. Heck I can still slap a shield on there as well. Like an L-298 motor shield and still have interrupts leftover for encoders. Cheers!

  4. Walgri says:

    Hi, just to let you know that Emc2Arduino nicely compiles and uploads to a ChipKit Max32, once digitalWriteFast2 is replaced with digitalWrite (as you suggested), digitalReadFast2 with digitalRead and after removing the digitalWriteFast header.

    Still not tested on the machine though.

  5. Flying says:

    Fantastic project!

    A quick question:

    How is the performance on circles? From reading your code it seems to me that this causes a lot of commands to be send and to be processed by the arduino?

    • dewy721 says:

      In a word: slow. (We’re hoping to fix that in the next release.) It does work fast enough to be useful for direct drive (belt or rack/pinion) driven systems, however screw driven machines are we be frustratingly slow.

      Currently: The command load on the Arduino is exactly the same as it would be in moving in diagonal movements. For every position update it has to do float math, compare it, then move if out of position. It has to do this for each axis in motion. Its very costly.

      Problem: Excessive MPU overhead, while the CPU-side is under utilized.

      Reason: Computational ‘Heavy Lifting’ is currently located on the wrong side of the fence.

      Solution: We are in the process of off loading the math over to the computer side of things. Thus, freeing up the AVR’s limited processing power so that it has only to contend with basic stepper movements, compare input pins and issue responses (when required).

      We’re working on it:
      Compared to previous incremental changes, where as only small changes are made then released in a fast and furious manner. We are now in the process of over-hauling the conceptual implementation of the code to me more resource efficient, resulting in a huge speed boost overall. But it will take some time to put forth the next release, as it will be a lot of work for a hobbyist venture.

  6. Daniel Dumitru says:

    Hi,
    I was thinking to run EMC2 on a Raspberry Pi and connect this raspberry with arduino on plain serial port (getting rid of usb connection). What do you think ?
    What should be configured on EMC to send gcodes over serial port ?

    Kind REgards,
    Daniel

    • dewy721 says:

      If you can get LinuxCNC to run on it then you may very well be able to do it.
      EMC2Arduino uses pySerial for the data link. It ‘should’ be a transparent change, once you specify the proper port in the 9axis_arduino file.

      Good luck! Post some pics/vids if you get it going.

  7. martin says:

    Hi,

    Did you include the lcd? I can’t see on the .ino some line (library, …) about the lcd.

    Regards

    Martin

    • dewy721 says:

      Not yet. At the moment we’re working on a new release (complete rebuild). Rest assured LCD support has not been forgotten, as soon as the dust settles we will be adding it back in.

  8. wasteinc says:

    just wanted to say thank you , that way I can use elcheapO ULN2003 drivers with emc2

    • dewy721 says:

      If you planning on using uni-polar steppers yep. If you can’t find a ULN2003 locally an NTE2018 will do the exact same but with slightly better power ratings.

  9. John Spencer says:

    Hi

    I ran across this project when looking for alternatives to powering a mini-mill with grbl. The LinuxCNC interface was just what the doctor ordered.

    It’s currently running on a RAMPS 1.4 board driven by a mega256, but we’ll be changing to a custom made board running an ATmega32U4 soon.

    Our custom board has an onboard LCD, touchpad and SDCard reader, so we’re expecting to do a little extra development.

    It’s been a few months since your last update. Has there been any more progress?

    Thanks for your good work!

    John

    • dewy721 says:

      Yes, actually I have been working on a HAL2Arduino implementation. Its essentially a breakout interface for LinuxCNC. That way people can access any combination of input and output pins listed in the HAL Integrator Manual all from the comfort of the Arduino platform.

      It also currently has automatic usb port scanning, multi-threaded clustering of multiple arduinos, arduino2arduino communications, all with checksums and buffering.

      Its still a work in progress.
      At the moment, I have the protocol and a bare framework in place, just need figure out how to script-up an end-user friendly way of configuring the .hal/.ini files for the host. Currently its all “roll your own” config files. (Big headaches for users.)

      But in a nutshell yes, I have been making progress although mainly in the area of building a new foundation for the next generation of EMC2Arduino, which will end up being built on HAL2Arduino framework, which I will also offer for those that just want the protocol for other things.

      • Bob Powers says:

        Hey dewy721,

        I’m working with John on the above project. Really getting some promising use out of the current version, so thanks heaps for all your hard work!

        Sounds like you’ve got big plans. Is there any way I can help out? I don’t see any code up at github, but if there’s a TODO list and a repo somewhere, I’d be happy to poke around and see if I could contribute.

        Cheers,
        Bob

      • dewy721 says:

        Yeah! There is plenty to do, I think I have a functional grasp of python and the arduino IDE. But I’m still having trouble with free-handing a good .hal file setup for final stage testing and development.

        Here’s the process chain and where I get stuck…
        Using python:
        PASS = Scan for & query all connected Arduinos for firmware, version, unitID, listOfAxises, and listOfCommands.

        PASS = Dynamic generation of hal.component pins based on data collected from any/all arduinos running the firmware.

        In LinuxCNC config files:
        Bang head to continue = Hand make a working custom.hal file for initial testing. Even if pins names are completely known in advance.

        Once I get this scratched out, I’ll be on a roll.

        In the mean time I’d be glad to email you a copy of what I’ve got so far if you’d like a look at it.

      • Bob Powers says:

        Sure mate, I’d be quite happy to have a look at what you’ve got so far. As John mentioned, we’ll be looking at SD card and LCD integration, so I’m glad to share those items as we progress with them as well.

        GitHub profile (https://github.com/rdpowers) should have all my contact details. Thanks again.

      • dewy721 says:

        It’s in the mail. đŸ™‚

  10. itsemurhaaja! says:

    Hello and thank you, very interesting project!
    Im new with arduino and I have problem with the arduino code. I dont know how to setup the pins to the code i wanna use for x y and z axes..
    you know any good simple tuto about it?

    • dewy721 says:

      Actually if your new to the Arduino then there are plenty of examples all over the net. Such as, Element14’s excellent video tutorials http://www.youtube.com/watch?v=fCxzA9_kg6s

      Once you have the basics of Arduino in general then you will need to know where (at least) the ‘step’, ‘dir’ pins for your stepper motor driver circuit are found. Next connect them to the arduino and modify the code under the sections labeled ‘// step pins’ and ‘// dir pins’

      Alternatively,
      If you have an Arduino Mega 2560 you can use the default pins listed as follows:

      stepPin0 41 (X-Axis)
      stepPin1 40 (Y-Axis)
      stepPin2 35 (Z-Axis)

      dirPin0 43 (X-Axis)
      dirPin1 42 (Y-Axis)
      dirPin2 33 (Z-Axis)

      Hope this helps.

      • Itsemurhaaja! says:

        Ok, I think this helps!
        Thanks for fast reply and good luck with this project!

      • DonaldVH says:

        Hi,

        I bought a 6040z mainbody (3x stepper) and a ramps1.4 ultimate kit (5x stepper drivers, end stops, lcd), which should mean, at least for me an almost complete hardware kit. Need still connecting a spindle and sort other secondaries out… onto the interesting stuff :

        I am completely fan of your efforts, and in trying to learn stuff, do stuff, make stuff, i am trying to get around the concept of arduino and others. For now I have the hardware required but I’m kind of hesitant to connect everything up and wait for smoke to come out, so regarding pinning : i have some questions :
        “stepPin0 41 (X-Axis)”
        “stepPin1 40 (Y-Axis)”
        “stepPin2 35 (Z-Axis)”

        “dirPin0 43 (X-Axis)”
        “dirPin1 42 (Y-Axis)”
        “dirPin2 33 (Z-Axis)”

        I have found this in the code and could change it around but

        *Question1*
        I am wondering what kind of Arduino Mega 2560 “plug on” adapter you are using to do the actual controlling of the stepper drivers.
        *end Question1*

        I have been plowing through to the RAMPS1.4 files. Btw this is a arduino mega 2560 plug on board. In the reprap wiki files I found the following definitions :

        “// For RAMPS 1.4”
        “#define X_STEP_PIN 54”
        “#define X_DIR_PIN 55”
        “#define X_ENABLE_PIN 38”
        “#define X_MIN_PIN 3”
        “#define X_MAX_PIN 2”

        “#define Y_STEP_PIN 60”
        “#define Y_DIR_PIN 61”
        “#define Y_ENABLE_PIN 56”
        “#define Y_MIN_PIN 14”
        “#define Y_MAX_PIN 15”

        “#define Z_STEP_PIN 46”
        “#define Z_DIR_PIN 48”
        “#define Z_ENABLE_PIN 62”
        “#define Z_MIN_PIN 18”
        “#define Z_MAX_PIN 19”

        The point is where I am getting confused is which plug on board you are using and how pin portA portB portC portD, … match to “54” and sorts.

        I did find the following links

        and

        and
        http://arduino.cc/en/Main/ArduinoBoardMega2560
        –> i am figuring out that
        – X_step = port A0
        – X_dir = port A1

        This is confusing me a lot because the above specifies that pin 54, pin 55 are used for X_step and X_dir respectively, while the arduino mega board 2560 only has pin numbering for its arduino 2560 mega header up to 53 digital pins…

        The only conclusion I can come up with purely by reasoning ( not knowing how to fine tune google or whatnot ) is that the analog pins come directly after the digital pins (numbering wise).

        *Question2*
        Is the previous paragraph true?
        *end Question2*

        *Question3*
        Where can I find a url reference for more information about the logic regarding the pinning?
        *Question3*

        I have found references for emc2arduino for arduino uno boards on this webpage,
        *Question4*
        Which plug on board would you be using together with the arduino uno / http://www.arduino.cc/en/Hacking/PinMapping168 ?
        *end Question4*

        Many thanks, awesome effort
        Would not know where to start if I had to do it from scratch like you did
        Regards!

  11. DonaldVH says:

    Ok … nevermind … by posting the previous, and thinking my post through, and looking stuff up more directed, … , a very heavy coin fell upon me :
    http://arduino.cc/en/Hacking/PinMapping2560
    –> clearly specifies that this device in total has 100 pins, and that pin 54 and pin 55 are in fact
    54 PC1 ( A9 ) Digital pin 36
    55 PC2 ( A10 ) Digital pin 35

    Sorry for wasting your time and clogging up the blog.
    Cheers!

    • dewy721 says:

      Wow, you’ve been busy. đŸ™‚ Well I’m glad you got the pin mapping sorted out.
      It seems you have self-answered questions 1&2.

      As for question 3. Yes, the Uno can be used a small/simple 3-axis CNC controller.
      For that you would need a total of 9 digital pins for the motion control (step, direction & enable for each axis).

      The six analog inputs would be good for min/max limits switches.

      That should leave 3 digital pins for other uses, like power supply control, coolant pumps, warning lights etc.

      Question 4: I use the Quadstepper found at: https://www.sparkfun.com/products/10507 but in theory, any stepper controller that allows 5v logic level input should work.

      • DonaldVH says:

        Hey dewy721,

        Many thanks for your infos!
        I made some led breakout boards to replace with the stepperdrivers, and to get some insight into the jog x-10000 y10000 z33333; commands, translating into ‘dir’ and ‘step’ pin pulses, and it is paying of.

        The only thing confusing me at some point, but all cleared out now was that while jogging it takes its final destination as a command.

        Also yesterday I have made a test. I connected my ramps1.4 to a voltage+current controlled psu. This was with an actual stepperdriver in place and a small steppermotor and it simply works (tested it only on X axis) , without white smoke coming off of the electronics… which is excellent. I see the current limit set on the polulus translate linearly on the power nets of my psu, also excellent!

        Anyhow, each week I have, (in a good week) i have 3 evenings where I can spend 1 hour at night to do stuff on my machine, and I hope to transistion to my actual ball screws and linear motion equipment soon. Endstops still do need figuring out.

        I have to say that I like
        – emc2arduino (really?) đŸ˜‰
        – RAMPS1.4
        – polulu shield ( the current control for stepper driver really hit the spot )

        I think I will be making a from scratch page for myself / blog to have info for myself and if written well enough I will let you know. In my opinion it is useful to have a from scratch build log for people to reference to build there own.

        Many thanks for all yours dewy721, it has already been of great help.

      • dewy721 says:

        Your very welcome! Indeed if you should make a good howto blog about it by all means, please let me know. Vids welcome too. đŸ˜‰

    • James says:

      Hi,
      Can you help me? I will like integrated EMC with Arduino+Ramps 1.4+LCD.

  12. tiipataa says:

    Hello!
    I cant download .ino file to arduino

    error message is
    EmcArduino_07b:888: error: ‘digitalWriteFast2’ was not declared in this scope

    What am I doing wrong?

  13. DonaldVH says:

    Hi,

    Thanks for your previous interactions, and in moving forward I had some questions that came to mind after being able to jog for an actual inch !!! Hell yeah !!!

    Question :
    When jogging eventually (when equipped with min/home + max switches) a min/home/max will occur. And this is also nicely showing in the serial console that such an event occurs : e.g. x0 –> x1 , or x4 –> x5. When looking at your code it shows better what is going on under the hood but I have a question regarding this : simplifying your code :

    And when taking an example that when the switch is open there is 5v present on the right pin, and when the switch is closed there is ~0V present on that pin.
    pinning configuration : –> false = ground trigger signal
    –> xMinPinInverted false, xHomePinInverted false, xMaxPinInverted false

    Resolving 5v -> a logical True -> switch is open
    Resolving 0v -> a logical False -> switch is closed
    –> using section near this line in code as translator
    (

    if(xMinState != xMinStateOld){xMinStateOld=xMinState;Serial.print(“x”);Serial.print(xMinState);}
    if(xHomeState != xHomeStateOld){xHomeStateOld=xHomeState;Serial.print(“x”);Serial.print(xHomeState+4);}
    if(xMaxState != xMaxStateOld){xMaxStateOld=xMaxState;Serial.print(“x”);Serial.print(xMaxState+1);}
    )

    –> this gives me the following truth table
    not @ x min = “x1”
    @ x min = “x0”

    not @ x home = “x5”
    @ x home = “x4”

    not @ x max = “x2”
    @ x max = “x1”

    The reason I am asking is that I have not actually fixed the limit switches to the machine because of fear of destroying stuff ( ballscrew ) , so I am reading trying and figuring stuff out as I go… and because of that I may not necessarily throughly understand everything.

    In trying to correspond my truth table to the ‘9axis_arduino’ file :
    if(key == “x0”):
    c[‘xMinLmt’] = 1 –> I agree : @ x min = “x0”
    if(key == “x1”):
    c[‘xMinLmt’] = 0 –> I agree : not @ x min = “x1”
    c[‘xMaxLmt’] = 0 –> I DISagree : not @ x max = “x2”
    if(key == “x2”):
    c[‘xMaxLmt’] = 1 –> I DISagree : @ x max = x1
    if(key == “x4”):
    c[‘xHome’] = 0 –> I DISagree : not @ x home = “x5”
    if(key == “x5”):
    c[‘xHome’] = 1 –> I DISagree : @ x home = “x4”

    dewy721 : am I going crazy in the new years period or am I missing something ? If you can find the time to respond I’d appreciate it greatly!
    Have you used all three xMinLmt, xMaxLmt, and xHome in an actual machine ?

    Kind Regards,
    Donald

  14. DonaldVH says:

    Hey dewy721,

    Having thought too long about the stuff before, it was pimping time.
    I have been changing my code just slightly, to make xmin xmax completely separate :

    if(xMinState != xMinStateOld){xMinStateOld=xMinState;Serial.print(“x”);Serial.print(xMinState);}
    if(xHomeState != xHomeStateOld){xHomeStateOld=xHomeState;Serial.print(“x”);Serial.print(xHomeState+4);}
    if(xMaxState != xMaxStateOld){xMaxStateOld=xMaxState;Serial.print(“x”);Serial.print(xMaxState+2);}

    –> now xMaxState + 2 , instead of xMaxState + 1

    Also had to change
    original code # if(xMinState && !xMaxState)stepper0Goto=pos_x*stepsPerInchX*2;
    if(xMinState && xMaxState)stepper0Goto=pos_x*stepsPerInchX*2;

    But then also I found an issue that when jogged upto a limit switch, I found I could not go back to a more centre position. (stepper0Goto does not get set when a limit switch is actually hit)

    My changes below : ( also adding allowMoveAxisname = False , to the global variables as booleans)
    //original code # if(xMinState && !xMaxState)stepper0Goto=pos_x*stepsPerInchX*2;
    // trouble found when over limit and unable to start moving again towards centre

    // disable moving by default, only allow moving when valid condition present
    // if no Min and no Max switch is hit, allow moving

    // if Min switch is hit, check that movement is towards the centre,
    // if towards centre allow move, if over limit pos, disallow move

    // if Max switch is hit, check that movement is towards the centre,
    // if towards centre allow move, if over limit pos, disallow move
    allowMoveX = false;
    allowMoveX = (xMinState && xMaxState);
    if(!allowMoveX)
    {
    if(!xMinState && ( (pos_x*stepsPerInchX*2) > stepper0Pos) ) { allowMoveX = true; }
    if(!xMaxState && ( (pos_x*stepsPerInchX*2) this way debugging limit switches is easier, and cleanly separated, like all the axis are cleanly separated in the first place.

    I still do need to run my setup against linuxcnc – emc2, will report back to you.
    I do very much appreciate the availability of emc2arduino and I hope I can contribute in some way when I have completed my electronics + mechanics iterations.

    Regards,
    Donald

  15. DonaldVH says:

    In my previous post a portion of the code is gone … below the stuff that got copy pasted badly and that are missing.

    allowMoveX = false;
    allowMoveX = (xMinState && xMaxState);
    if(!allowMoveX)
    {
    if(!xMinState && ( (pos_x*stepsPerInchX*2) > stepper0Pos) ) { allowMoveX = true; }
    if(!xMaxState && ( (pos_x*stepsPerInchX*2) < stepper0Pos) ) { allowMoveX = true; }
    }
    if(allowMoveX) {stepper0Goto=pos_x*stepsPerInchX*2;}

    9axis_arduino file
    # Set min limit triggers
    if(key == "x0"):
    c['xMinLmt'] = 1
    # Clear limit triggers
    if(key == "x1"):
    c['xMinLmt'] = 0
    # Set max limit triggers
    if(key == "x2"):
    c['xMaxLmt'] = 1
    # Clear max limit triggers
    if(key == "x3"):
    c['xMaxLmt'] = 0
    # set home switches
    if(key == "x4"):
    c['xHome'] = 0
    # unset home switches
    if(key == "x5"):
    c['xHome'] = 1

    • dewy721 says:

      Let me grab a copy of your code and look it over. Maybe I could start weaving it into HAL2Arduino.

      Have you had a chance to look at HAL2Arduino? It breaks out all of EMC’s hal interface to the Arduino to give you a lot more freedom to play with.

      An example would be encoder feedback to host for fully closed loop control.

      It’s more or less the on-coming overhaul to Emc2Arduino.

  16. LCY says:

    Halo,

    possible to make a simple “I/O plus some analog input and pwm (analog) output” package?
    programming are really BIG HEADACHE for me đŸ˜¦

    its impractical to have so many parallel port just for i/o pins that doesnt need realtime performance, and use mesa card are just overkill for the same purpose.

    sorry for my bad english

  17. alex says:

    Hi,
    I’m Alex and I’m following your precious work since few time, have you ever thinked about a modular master slave arduinos architecture?
    I mean a master arduino interfaced via serial line to the hal that communicates through i2c bus to the slaves.
    In this way you would be able to use a single arduino for heavier computation processes (such a single axis management, why not a closed loop servo) or occasional operations (spindle speed setup or cooling activation) connected to a bus that’s much faster than a serial line.
    Controlling a slave is quite simple, you just have to send data over the bus to specific addresses of a specific device ID (there are several code examples,probably just an attiny is suitable) .
    But I suppose you already know what I’m talking about.
    Improvements would be a lot, for example detecting a device specs simply reading a variable, adding a further axis just connecting a new slave on the 4 wire bus, the same for an i2c display controlled by the master node…. and a lot,lot more.
    Is the hal2arduino release near?
    We are so curious!
    (sorry for my english, an horrible tablet keyboard is getting the situation worse)

    • dewy721 says:

      Hey Alex!
      I do have an initial offering of HAL2Arduino but its currently just a bare communication bus, however it does handle single and multi-arduino setups, it has bidirectional communication and support for every HALpin I could find in the linuxCNC documentation. It even handles arduino to arduino messaging and allows for user made custom commands too.

      That’s the good news. The bad news is that it has at least 40~70ms latency between command and response. Which is fine for general IO, stuff like pumps/control panel buttons etc. (non-timing sensitive operations). But horrendous for axis movement and feedback controls.

      Opportunity:
      I’m back in school (after 20+yrs) and my days are becoming very busy. HAL2 Arduino needs a home, and someone clever (or resourceful) enough to continue developing it. For, If the world has to wait on me it will be awhile yet.

  18. ChC says:

    Hi

    I need to say that Emc2Arduino is a killer. Keep up the good work dewy721.

    I’m running my DIY CNC machine with easydrivers through an arduino. The movement part works great, but I have a slight problem with min/max switches.

    I have figured out so much that all the max switches are normally closed circuits although min switches are normally open circuits. Is there some purpose for that?

    So the real problem is when I drive the let’s say X axis and trigger a max switch, LinuxCNC then alerts that X max is triggered and shuts down the machine.
    I am really new to this arduino thing, but I think arduino should drive X axis back a little. But I’m not seeing that happening.

    Now I can’t move any axis when the switch is triggered. It doesn’t help if a manually untrigger the switch, LinuxCNC still won’t start the machine. I think this is because Emc2Arduino sends min/max switch states only when it is receiving commands. Only thing that works is exit LinuxCNC then manually move the machine and startup LinuxCNC again and that’s not so convenient although it will save the machine from crashing.

    Is the sketch working properly as it should? Is there some setup either in the sketch or in LinuxCNC that I haven’t yet discovered?
    What should I do, just settle the way it is, or could it be modified so that it acts like I would want it to?

    • dewy721 says:

      First of all, thank you. That’s very kind of you.

      For your limit switches. You should be able to reverse the value of the following lines:

      #define xMinPinInverted false
      #define yMinPinInverted false
      #define zMinPinInverted false

      Setting them to true should fix the min switch problems for you.

      As far as LinuxCNC refusing to move when it gives the a warning message, that is the proper behavior of LinuxCNC when a “hard limit” switch is tripped.

      LinuxCNC has its own set of soft limits that it will allow you to bring an axis back from. Those limits are defined in the my-mill.ini file. Hard limits are an emergency safety catch to “panic stop” LinuxCNC when the soft limits have been exceeded.

      Solution: Edit my-mill.ini and change the settings that LinuxCNC thinks it should have to move around in. It should be set slightly smaller than your physical/hard limits.

      “What should I do, just settle the way it is, or could it be modified so that it acts like I would want it to?”: Keeping working with it you doing great! Just a few more small adjustments and It should be perfect. đŸ™‚

    • DonaldVH says:

      Hey Chc,

      I have been trying to get my head around the behavior of both Emc2Arduino + linuxCnc,
      for the past weeks and I must say I have come accross the same issues you were seeing. (reference this blog : January 12, 2013 at 1:50 pm)

      I was testing max – min limits when I saw that behaviorally Emc2Arduino locks up the movement in one axis –> When that axis hits a min/max limit.

      I thought this wasn’t completely valid so I tried changing Emc2Arduino such that it would be able to at least move back to the centre ( this would be useful in the case of a hobby project, not related to linuxCnc )

      The way I have come to understand is that min/max limits are ABSOLUTE limits. They are not to be joked around with let alone teased.
      They are there to tell you that something went seriously wrong and that a fundamental setup in your assumptions is not in check with reality.
      What I was trying to do can be compared to the following :
      – Suppose you own a house (cnc machine)
      – In the house are a lot expensive house hold appliances (cnc machine + milling spindle + work piece)
      – Suddenly the house catches fire ( you hit a ABSOLUTE ‘min’ or ‘max’ end stop )
      – What do you do?
      — You SHOULD get out of the house immediately and save your life ( stop any movement of the cnc machine preventing damage to machine or unwanted milling on your workpiece )
      — You COULD get out of the house, but then remember that you left your wallet, your laptop, your tv, your precious A, your precious B, your precious C (restart moving your cnc machine possible causing unwanted milling operations + damage your cnc machine because your ballscrew is srewing itself to pieces)

      – When the house has been fire – extinguished, you recover what you can. (you manually jog the cnc machine back to a position without hitting the workpiece, without breaking any end mills such that after removing the workpiece, your cnc machine can home itself, and you have been able to conclude why the machine was able to hit the ABSOLUTE end stop, and that you have been able to run a checklist and have been able to come to a conclusion why it did so you can prevent it)

      This last step might require Emc2Arduino to support allowing the user to manually move an axis to a more central position when a max or min ABSOLUTE limit switch was hit, instead of disabling any movement on that axis.

      Bottomline:
      Typically it is an undesirable situation to have gotten into.

      Too much words have I used to explain, but it might clear stuff up and it may lay foundations for newbies like myself in the future to come.

      Kind regards,
      Donald

    • ChC says:

      Thanks Dewy721 and Donald for the replies.

      I got the min switches inverted.
      And what comes to those hard limits, Donald made me realise that hitting a hard limit is a serious failure, nothing to play with. It’s safer to play with the soft limits so I will do like Dewy said and give LinuxCNC a slightly smaller table dimensions.

      • dewy721 says:

        Glad we could, help. Best of luck to you. đŸ™‚

      • DonaldVH says:

        I think it is okay to hit the limit switches as a means to learn your own machine.
        By all means, you have to know that they would work in case all hell comes burning down on you.

        But in regular mode of operation it is undesirable to hit the min/max.

        In the weekends I had some problems didn’t know what was happening really, needed time to properly diagnose.

        Yesterday night I found one min limit switch stuck @ 0 which caused my own code additions I fixed in to cause movement only in one direction ( towards maximum ).

        Just pressing it a few times resolved it ( it is a brand new contact switch, no prior usage )
        Perhaps my debug mounting approach with hot glue was interfering…
        Eventually I found it by adding extramendous reporting of current pos , desired pos, allowMove, min max home button states, which revealed the error on the limit switch.
        This I did with an ‘#if defined #endif’ which can easily be compiled out of the main code to gain performance.

        Also had a malfunctioning polulu stepper driver breakout board (never tested it prior).
        Any component you are going to use should be tested to prior mounting.

        –> to come to the following point.
        I do think there is a need to provide specific user features to test for example one axis in all of its conditions, helping debug move forward faster. How this could be described / defined I am not going into, but I am convinced at some point such features will help debug a dying machine to diagnose what is going wrong. And maybe fix it in an earlier stage.

        Happy hacking,
        Donald

      • dewy721 says:

        Sounds like a good idea, and I have been playing with #ifdef in some prototype HALmods but I noticed that #ifdef only seems to reference the main .ino file for definitions. If you try to later define something (from within a mod file) it just won’t be observed by the compiler.

        So #ifdef although a neat compile time option, isn’t recursive.

        I have been pondering Arduino-only config, and using the host-side python scripts to read/compare/modify the linux cnc configs to match. All automagically. But while I’m tinkering with it adding a simple debug loop would be cake.

      • DonaldVH says:

        [Completely off-topic rant … I’ve got some trouble with cabling of limit switches, need a rewire fix as well as a motivation boost to rewire … sigh.]

        On a positive note/question/endeavor :
        1) What kind of cables do you use for your stepper power wiring
        2) What kind of cables do you use for your limit switching wiring

        For now for limit switching I disapprove full copper twisted pair as a means of recuperation of the miles of wiring lying about my house.

      • dewy721 says:

        Steppers, depends on amperage. If you have short cable lengths and less than 2amps, I’d just use some re-purposed Cat-5 cable. With 4 pairs of wires, each pair of wire can handle 2amps fine.

        Big stepper motors? Go with 16-gauge 4-wire consumer grade trailer hook-up wire. Should be good for 10amps@20ft, or 15amps@10ft.

        For sensors, the problem may be related to electrical noise. The AVR’s internal pullup resistors should be sufficient for most environments. But high-voltage stepper wires can induce ‘fake’ signals if the signal (limitSwitch) wires are too close to each other along parallel paths.

        As for sensor wire choice, again I usually use Cat-5, if needed you can ground wire the 4 white/striped wires on both ends to give shielding. That leaves four noise-insulated colored wires to play with.

        If you plan on machining next to your Tesla coil however. You might want to consider something more extreme like multi-core coax, copper tape/pipe shielded wiring or full-on optical fiber sensor leads with the actual sensors housed within shielded cabinet along with the AVR(s), your computer and preferably yourself. đŸ™‚

        Almost forgot, if your planning on heavy-use/long-term reliability, use finely stranded wires wherever lots of flexing is involved. For this, standard “Monster Cable” brand speaker wire is made specifically for that kind of teenager-grade abuse. The strands are superfine and the insulation is abrasion resistant doesn’t dry out and crack over time. They have it in ranges from very small 22gauge all the way up to 0gauge-3awg (thick as your thumb).

        Motivation: CNC something really important to you, if the machines has a ‘spaz’ fault. You’ll be motivated, one way or another. đŸ˜‰

  19. DonaldVH says:

    With regard to limiting motion or not …
    a) If you are using physical limit switches it is not desirable to over step that limit. Thus allowing movement to center is still the right path I believe. If you try to overstep these you will actually break something because it is in the path of a platform that moves around.

    Having put homing switches, and having discarded the min + max limits just trying to get my machine working I have come to the following conclusion for soft limits :

    b) When setting a soft limit you probably don’t even have anything mechanically in the way. You do want linuxCNC to at least notify you about a soft limit hit, but in my case at least having a soft limit impede movement ( yes trying to overstepping soft limit ) only made homing far less left painful. This is because the soft limit is always relative to your home position. To me it did not anymore make sense to have the soft limit impede movement.

    Just saying.

    • dewy721 says:

      True, but the soft limit motion impediment is part of LinuxCNC’s way of doing things. I don’t have a way of change that behavior from within EMC2Arduino. If LinuxCNC hits a soft limit it will actually stops sending any movement commands to the Arduino.

      I too, wish it would allow a method of backing off of the soft limits.

  20. Bill says:

    Trying to get Emcarduino 07b to compile but I keep getting /home/ubuntu/arduiino-1.0.3/libraries/digitalwriteFast/digitalWriteFast.h.1:23: error: WProgram.h : no such file or directory. Then something about, In function ‘void jog ( float nine occurances) Then I get the not declared in this scope for digitalreadfast and digitalwritefast.

    I have dl’d the digitalwritefast.zip and extracted it to the arduino libraries as well as replacing digitalwritefast2 and digitalreadfast2 with digitalreadfsat and digitalwritefast.

    Aftering unzipping digitalwritefast.zip this gives me a digitalwritefast folder with: bonus folder digitalwritefast.h keywords.txt and a readme. In the bonus folder is a: digitalwrite folder with: digital_write_macros.h keywords.txt readme.txt wiring.h wiring_digital.c

    What am I doing wrong

    BTW I really like the idea of sticking it to those who say you cant use USB for cnc.

  21. Bill says:

    Additional to the post above I was looking thourgh my arduino libaries and came across a users folder in which is a folder called raine001 in which is a folder called digitalwritefast. This folder has digitalwritefast.h digitalwritefasttestmegxa3.pde didtalwritefatstestuno.pde keywords .txt progprog.py. Has this anything to do with emc arduino ?

    • Bill says:

      A lot of problems solved, it was a tuoch erratum digitatum, I put digitalreadfast not digtalReadFast and the same with write. Those two caps made all the difference. Now to find out why I still have the WProgram.h no such file or directory.

      • Bill says:

        Sorry for all this clutter guys, but I have now discovered where the users folder came from, it was from the previous release with the mega upgrade. I have now got the program to compile by commenting out the reference to WProgram.h in the digitalwritefast.h. I did read some mention in an earlier post about removing a header, is this the one and is it ok to leave it out.

      • dewy721 says:

        *Thinking back* Yes, I believe so. Sorry for the confusion.

        Also the digitalWriteFast (and digitalWriteFast2) commands are actually just macros that replace any instance of digitalWriteFast or digitalWriteFast2 with PORT commands at compile time. Effectively they are just speed tweaks for newbs like me. Optionally, you can replace them with the stock commands and it will still work, just not as fast. The newer 32bit MCU’s like the Maple/UNO32/Due/etc. are plenty fast enough to do away with it entirely. (the digitalWriteFast library is incompatible with 32bit MCU’s anyway.)

        On Tue, Feb 19, 2013 at 12:19 PM, Emc2Arduino

      • Bill says:

        Duuurrrr my brain hurts, trying to get this thing to work and its driving me nuts. My machines not built yet so its all a bit of a lash up. Basics for the machine are x 300mm, y 600mm and z 150mm travel, all dimensions are ish, depends on how it turns out when built. Run the step config wizard with those specs. I’m not sure if I put the right info into it, as well as the rest of the 7 step set-up

        Machine units, are set to mm and jitter to 11500 other units are default.

        I ticked the box for custom Hal and only left 3 axis step/direction and e stop used

        In the Axis config, motor steps are 200 Driver step set to 2 (present drivers only do full and half step) Pulley teeth 1:1 screw pitch set to 1, I will be using threaded rod at the mo I’m going to use 6mm x1 thats why screw pitch is 1. Max vel set to 1 Max accel set to 30 (default) home location 0 and table set x to 0 – 300 y 0 – 600 and z as -150 – 0.

        When I run home in the Axis prog I can watch the GUI moving and about 12 secs later my LED for that axis starts to blink. I was playing with it last night with motors hooked up but I could not get any speed from them other than about 1 step per second which seems to be what the LEDs flash at. I have an LED hooked up to pin 13 but it is on or off I never get any other flashing other then when up loading to the arduino no matter what I set the min step time to.

        So what am I doing wrong or what have I not properly. I dont understand how we communicate with the arduino when the Axis prog uses the parrallel port.

        BTW as regards table movement is it set as 0 to +max or -min to +max with 0 in the middle. I read somewhere that Z axis is positive so to me that means it is set to high above the table at 0 then use negative numbers to move towards the work then that would mean x and y are the same but

        What do SCALE, FERROR, MIN_ERROR mean in the my-mill-ini

      • dewy721 says:

        Well, lets see here…

        The 12second delay between the GUI and the arduino is very unusual. There should not be any delay beyond several milliseconds. Is the PC your running LinuxCNC able to run it smoothly? (No noticeable lag.)

        How LinuxCNC communicates with the Arduino: This is accomplished through a hack of sorts, its a background script written in python. (the .py file) This script just relays some variables back and forth between the two systems. The tool chain works like this: LinuxCNC python script arduino. By this point the role of the parallel port is reduced to just a vestigial leftover. Kind of like your appendix.

        Your head hurts; Oh, how I can relate to that… I had a non-stop migraine for the whole month that it took me to write the code while I had to learn about the four separate API’s involved, investigating some arcane, far-flung and forgotten code written by strangers, just to find out how to get one API to talk to the next one, then the next pair, then the next pair. Just to shoestring the whole project together. Oh, the headaches. <:)

        SCALE, FERROR, MIN_ERROR, machine parameters, etc. I know you have a lot of questions, honestly the best way to answer them is by helping you through the build step by step. This way you'll pick up on some of the finer points, right at the moment they can be directly applied.

        Ok, first: Do you know what the max speed your steppers will run at while under some physical load, for example the finger pinch test? If not; A simple "back and forth" sketch may be needed to finger it out. đŸ˜‰

        Let me know and I'll put one together, if needed.

        Kind regards, Duane Bishop

        On Mon, Feb 25, 2013 at 10:38 AM, Emc2Arduino

  22. DonaldVH says:

    Bill,

    I think you might have the DIR / STEP pins mixed up in your pinning.
    Do check them from arduino chip upto the actual stepper driver with an ohms-continuity measurement.

    I have used leds as well to check DIR/STEP pins and have not had your issues.
    What kind of electronics are you using ?

    Regards

  23. Bill says:

    Where to start. Linuxcnc is running on an acer one laptop with a jitter time of approx 1150, thats with web browser open and running a screen saver. Arduino is a Mega 2560 clone

    I have run a stepper program through the arduino and the motors run as the sketch tells them i.e they accelerate up to a speed and then de-ccelerate to stop and then reverse direction. All I do after this is up load the arduino07b sketch, I know the setup is right so it must be something I’m doing /not doing with the step config wizard.

    The motors are powerMax ll 1.8′ bi=polar 1500rpm similar spec to a NEMA23.

    Drivers are Pacific Science 5210 full and half step 20,000 pulses/sec, min pulse length 500ns. Then a load of stuff in the data sheet about set up and hold times which are all min 1us.

    Playing around last night I opened the serial monitor and I could see the e1 change to e0 and back again as it toggled the estop switch (ok I admit its a bit of wire into the A1 and gnd connection on the arduino) When I toggled the power switch I got a p1 then when I hit start or home an axis get a load of letters and numbers come up on one line then stops. I know that at least there is some communication going on and I would imagine that e0/1 and p1 are correct.

    At the moment I am just using LEDS (red for step and yellow for direction),as I manged to kill one of my three drivers and I dont wnat to risk the others just yet even though I will be using different drivers in the actual machine. I can see the dir leds change by running the linux gcode but it is this long delay from start to actually seeing action in the leds that seems to be the problem.

    Q. is there two way comms between emc and the arduino? as I only seem to see Tx light flashing on the arduino while emc is running through the g code

    • dewy721 says:

      Yes, the link is bi-directional.

      The step config wizard actually just sets up a stock (parallel port) driven machine. The only part that matter to emc2arduino is that the machine size parametersset in both the arduino sketch and the wizard match each other. Assigning pins just adds some lines in the .hal file that just links physical parallel port pins to the program variables (inside LinuxCNC). They have nothing to do with the Arduino pin config.

      You’ll still need to edit the arduino sketch and change *those* settings to match your hardware. ie: pins, step timing, machine size (if not using limit switches.)

    • DonaldVH says:

      Bill,

      I think your best path forward is (at least at some point I did, your thoughts are free)
      – concentrate on 1 axis
      – use a serial console and do a ‘jog x1000000;’
      – ‘jog x0’
      –> if this works ok
      – jog upto a home / min limit / max limit
      -> and check that emc2arduino is sending 2 characters back, for example x0

      If this works move on to your other axis.

      –> by doing this you are trying to check pinning + stepsPerInch + limit switches

      As long is this does not work straight out of your serial console ( which you can start from within the arduino sdk ), it might not make sense to concentrate on linuxCNC.

  24. Bill says:

    Well we have some sexsuss, When I tried to alter the sketch this morning I went to the folder where it was and it wasnt there. Clicked on the wrong folder I thought, no it was the right one just no code. Went back to desktop and clicked through the files till I got to the 07b folder and lo and behold there is my 07b.ino file also in this folder was another folder called 07b which is where I first went to find my .ino file. Anyway long story short is somehow I had another folder in the 07b where my 07b.ino was saved to, which was the one I was using to play with, but after this morning performance I was having to use the 07b.ino that was in the folder above and now it seems to work as it should. LEDs light up as soon as click home and stop flickering when the GUI stops. Took the bull by the horns and hooked two motors, ran the GUI andf the motors responded as in sequnce with the LEDs. Pressed the run button and the motors moved and changed direction with the GUI.

    It would seem that the extra folder was throwing in a delay in the processing and screwing things up. At least now I know it works I can get buliding the rest of my machine and get some proper switches in then I should be able to stop banging my head against the exceeded limit warnings and stuff.

    • dewy721 says:

      Good deal. I’m glad you found the hangup.

      • Bill says:

        Banging my head again, this time its the switches. What I want is to have an led on when the axis is in limits then change to another led when it hits the limit switch. I have wired a switch up so that in limits its normally closed with the led lit, when it hits the limit it closes the normally open contacts thereby changing the led to another colour, how do I wire it to the arduino so that it detects the change of switch state, can you point me to any wiring diagrams, I have had a look on the net but I havn’t found anything I can use.

        Bill

      • dewy721 says:

        The limit switches are better wired as to be normally closed, that way if a wire breaks or looses contact the machine throws a fault instead of missing the signal to stop.

        Switch wires: N.Closed=Arduino, N.Open=LED, COM=Ground.

  25. Bill says:

    I think I must be missing something hre. I did find a wiring diagram
    http://reprap.org/wiki/Mechanical_Endstop#Optional_LED
    just after I posted my last message. Is that the type of connection you meant. I wired it up like that and selecteds pin 29 and 27 for the x axis in the emc07b but when I active the switch nothing happens, although I must mention that this is just with the GUI and no motor hooked up. Will I see any change in the GUI ? or does it need a motor to be connected.

    • dewy721 says:

      You don’t need any motors connected to test it. BUT Linux should popup a little warning box in the lower left if you bump a limit switch (not a home switch).

      So your correct in thinking you’ll only need a switch attached to test limits.

      That diagram uses the COM lead of the switch for the signal input wire. Also the resistor is not needed since the Arduino already has them built in.

      Let me draw up a diagram right quick….


      Switch Diagram

  26. Bill says:

    mmmmm wired it up like that and nothing happens apart ftom the led lights up I have on the n.o. leg when i trip the switch.

    Just to refresh min set to pin 29 max set to pin 27 in emc07b real min set to true real max set to false.

    • dewy721 says:

      That should be correct. If you set xMinPin to 29 and xMaxPin to 27 then you should have a min limit and a max limit for the x axis.

      Note: Every once in awhile, the serial link between LinuxCNC and EMC2Arduino does not establish correctly.

      To spot this, just keep an eye on the TX/RX LEDs on the Arduino. They should flash rapidly whenever the machine moves, also they should also blink just once for each time a switch changes position, with the exception of E-Stop. That one will send a signal over and over until E-Stop has been canceled.

  27. Bill says:

    That that seems to be my problem I dont see any flashign of the Rx led and the L pin 13 led is on continous. Only response I can see in the serial monitor is e0 or e1, p0 or p1 depending wwhat I do to the emergency or power switch. There are a few others that appear when I first start emc but I can remember what they are, I know there is an h in there. Was checking your my mill ini against mine and you have home search vel, home latch vel, and home seq that I dont have in mine, is that because you have home switches setup and I dont?

    • dewy721 says:

      The ‘home search vel’ = speed to move when searching for home.
      The ‘home latch vel’ = speed use to back away from the switch, (looking for the exact ‘click-off’ position.)
      The ‘home seq’=homing sequence, each axis waits for its turn to move. 0=first axis to move, 1=2nd axis to move and so on.

      Without these entries, I think it might have a hard time figuring out ‘how’ it should move in the first place. Therefore never talks to the Arduino?

  28. Bill says:

    Well a bit further forward and a bit back. Can see the numbers and letters comming up in the serial monitor but when I try to home an axis it overshoots by twice what the limit is i.e. limit 300 it goes to 600.002. All axis do the same so I am wondering if it is anything to do with the microstepping. I have had them assigned to pins and now they are all assigned to -1. I did this as I thought it would default to full step but looking at the figures it would seem to be half step. I’m back to using virtual switches at the mo till I get this limit thing sorted.

    BTW is there a list of what the codes are in the serial monitor and what their state is i.e off=0 on=1 etc.

    • dewy721 says:

      That’s probably because the steps per inch is off by a factor of 2. If you change the microstepping modes, you’ll also need to change the steps per inch.
      ie: If normally (at fullstep) you have 200 steps per inch and then you decide to switch to 1/16th step then your new steps per inch would be 200*16=3200 steps per inch.

      Whenever you adjust one, you have to adjust the other to reflect the change.

      List of codes: Nope, but to see what they do just open up the 9axis_arduino file with a text editor.
      lines 259~431 are all the keys used.

  29. Bill says:

    Micro stepping is as set in the wizard which is 2 as you guessed. Current drivers are only half or full, I assume that if I halve the scale factor in the my mill ini or select 1 in the wizard then that will set the stepping to full or the 200 steps that my motors have. More assuming, if the driver has a 1/16 step mode then you can select any of the options up to that figure by selecting the pins assigned to the micro steping in the emc07b, are they selected by driving them high or low to give on or off or whatever state you designed them to be.

    • dewy721 says:

      True, but the microstepping function is setup for setting the step mode for specifically Sparkfun’s QuadStepper board. (Only one that I have to work with.) I have been considering removing that bit of code for the sake of simplicity. Most people only set their step mode once, during the machine’s initial setup and they usually hardwire them at that.

  30. Bill says:

    Well I can run it sort of, I can get the table to move back and forward with g code or just running the linuxcnc mill code even had the gantry moving till I blew two of my drivers up. That’ll teach me to use a lash up wiring, but my main problem is speed. It I go above 69mm/min I start to miss steps, if I run the accel stepper code I came across on the net for testing (I think its by the same guy whos code you are using in the Hal2Arduino, it moves much faster than 69mm/min and sounds much better. Is this because the commands are comming straight from the Arduino and not via it

    Specs are nema 23 motors running at 24V with drivers capable of 2Amps, did a reading and its pulling from 1.6 to 1.9 Amps

    I’m using 8mm threaded rod with a 1.25mm pitch. Latency in step config wizard is set at 15400 it could be a bit faster but I backed it off a bit. Base period comes out at 25900nS and a max step rate of 38610Hz. Given those reading what do you think my speed should be like, or how can I get it faster apart from a coarser thread ptich, or is this the best I can do with this set up.

    Getting micro switches fitted at the mo and a bit of confusion has sprung up in the 07b code. If using real switches min and home limits are to be set to true but the max says set to false which it is already by default. Should this be set to true if using real switches, or is the setting as false correct.

    • dewy721 says:

      Two drivers? Ouch! I sorry for your loss. The driver I have is safety limited, but it too is a 2amp max @ <30vdc (I run it at 1.5a@27vdc w/heatsinks) driving NEMA-23 motors as well.

      You got accelStepper ported into EMC2Arduino? NICE! đŸ™‚ I really need to upgrade that bit to save you guys the headache.

      If your using a real switch, yes. It should then be set to true.

      • Bill says:

        Must point out I havnt got accel stepper ported I was just uploading it to the Arduiino and running it as a stand alone sketch. It just starts accelerates, de-celerates, stops then reverses repeatedly, but the motor runs much faster then it does in Axis via the Arduino. I’m going to have a play with the Hal2Arduino today see how that peforms, not much more I can do with the 07b really until I get some more drivers.

  31. Bill says:

    Gone back to this version as I cant get the hal2 version to give me any replies from the arduino. Now I’ve got a weird problem with this version.

    Created a pcb file with the ulp for Eagle and loaded it into the EMC. To start with it was shown outside the limits box so I altered my machine limits from 0 to max limit, to minus limit to plus max limit, now the pcb shows well inside the EMC limits box. When I run the program it starts and goes for a bit then I get a joint1 and joint2 on limit switch error. If I do a manual jog I can jog pass the place where it throws the error at me but when I press run it will get to the same place and throw the error again. Whats really weird is the joint 2 error as that does not move at this point it is already at the setting it needs to be if it said all three switches then I would understand that as they are all on one pin. Setup is still on breadboard and all limits are set to one pin (27) and work as they should if I force a switch error i.e. pull the wire out. Any thought on to what might be going on.

    • dewy721 says:

      It sounds to me like a momentary break in the circuit, check for a common wire between joint1 & joint2 and look it over for loose connections/broken wires. Try moving the machine to nearly the position it faults at and then wiggle the wires to see if the fault pops up. (If so, its just a wire/connection gone bad.)

      Oh wait!
      From wait you stated, it sounds as if you altered the limits in the my-mill.ini file. Did you also adjust them in the Arduino code as well? Otherwise it will act that way.

      • Bill says:

        Yah I fell foul of the need to change the code but got it second time, thats the only real bug bear with this system is the number of places you need to change things.

        I should have been a bit more specific, this is not in the machine its just my Arduino strapped to a breadboard with a few leds and hook up wire. My limit swiches in this setup consist of a wire from pin 27 to ground which I pull to simulate a switch break, I dont have vibration or any stray magentic influences from the motors to cause any problems so we can rule that out. I have run a couple of other cnc programs with this setup and they all worked as they should which makes me wonder if its something in the gcode that the Eagle ULP created, although looking at it it looks ok but it happens at the same place every time.

        I did run a couple of the other files the ULP created these were drill.tap’s and they worked ok its just the etch.tap that’s giving me pain and of course its the most important one.

        If you want a copy of the .tap’s and my mill setup just let me have an addy and I’ll send it to you and see if you can reproduce it.

      • dewy721 says:

        Actually, I’m in the middle of a semester of college so I have a full plate. (Hence why I’ve not pumped out code recently.)

        Can you run that tap file on your regular machine?

  32. Bill says:

    I have run it on my big machine through NCPlot which runs in windows and it ran all the way through to the end. Because this only happens with this program I’m thinking it might be one of those obscure glitches that only happen once in a blue moon and only on certain machines and no matter what you do it wont run but everythigng else runs ok.

    OK just ran the drill.tap file and it threw a joint1 error so I’m going to have a play with the settings in the ULP and see if that makes a difference.

    • John Spencer says:

      I have run into this before. I have a vague recollection that it might be related to feed rate, so try dropping that down.

      I also built an alternative version of emc2arduino that might help, but it’s optimised for a leonardo and only two axis so it might not work at all. You can try it at https://github.com/CCHS-Melbourne/HackCNC

      John

      • Bill says:

        I had another thought and that it might be the gcode ULP that was causing the problem so I exported the file as dxf and imported it with the NCPlot then used the gcode creator to make the gcode only problem was it didnt add an end program at the end of the file, so I had to add one maually.

        Ran the gcode with EMC and the same problem switch limit errors. Altered the 07b sketch to virtual limit switches and the code is running as we speak, nothing done to the EMC that wasnt done to the other attempts just the change of sketch to virtual switches.

        John I did think it might have been feed rates etc so I did drop them on a couple of attempts but it still threw the same errors in the same place. I’m going to let this program run to the end then try again with the ULP gcode see if it will run with the virtual limit switches.

      • Bill says:

        Well both programs run through to the end on virtual switches but as soon as I enable the real switches it throws error at me although the NCPlot doesnt do track isolation. I did think it might be because I had altered my table settings to negative and positive values with zero in the middle so I changed them back to zero to max positive still get the errors with real switches.

        BTW John we share the same surname, small world itsnt it.

      • dewy721 says:

        Thanks John! I was scratching my head over that one. <:)

  33. dzeus says:

    Hi, I’m trying to use Emc2arduino but I have actually some problems , My stepper driver Step/dir input are inverted (logic low) and I couldn’t find a way to set step/dir as inverted in the Arduino code

    I have also uploaded HAL2Duino I found it more easy to set up driver pin (inversion) however when jogging the stepper motor doesn’t stop when I release the keyboard key and continue running (turning) for a while, also the X axes motor run much more faster then Y motor although I’m using the same setup (same driver, same motor and same value are given in the Arduino code and my-mill.ini file too )

    Can you please advise me how to invert pins for Emc2arduino and how to solve the Hal2arduino problem (I’m using Arduino Mega2560 R3)

    Thanks

  34. dewy721 says:

    Well, for Emc2Arduino you can invert the dir pins by changing dirState0,dirState1,etc from true to false.

    For HAL2Arduino, whats happening is that your keyboard input is probably jogging the position faster than the steppers can actually move. Therefore, when you stop pressing the key the steppers are still playing catch-up. You can verify this by trying very short jogs, the steppers should stop very responsively, however if you hold the key for several seconds then you’ll see the steppers running for a bit longer then the key press. Just slow down the jog speed to correct it.

    As for X moving faster than Y (both have identical hardware.) Double check the step mode for each by jogging X,Y by the same amount, and count the revolutions for each stepper motor. If the ratio between X:Y is 2:1, 4:1, 8:1, or 16:1 its most likely a step mode is reduced on Y.

    Otherwise if you get something weird like 8:5 or 3.5:1 or some other ratio than the 1/1, 1/2, 1/4, 1/8, or 1/16 step modes, then perhaps a stepper is being over driven. An easy test for this is to check the output torque. If you can stall it easily with your fingers, it being driven too fast. Remedy with either higher supply voltage, or slow down the rate of speed that the stepper is intended to run at.

  35. Bill says:

    After much wailing and gnashing of teeth I am moving forward, a bit. Number of steppers I have destroyed is getting embarrasing, blowing my Mega 2560 really hurt and blowing my little netbook I was using to run the software really really hurt. Little netbook is now fixed with an increase of memory as a bonus bit I think my Mega is well dead. EMI suppression bead let out some magic smoke and now the whole board doesnt work, I think the Mega 8u2 got fried. Drivers are an ongoing process as I’m waiting for some replacement chips to arrive or afford some different drivers.

    I have got a Mega 1284 chip and was wondering what would it entail to get this to work with emc2.ve tried to run it but get “cant find something to do with digital write fast” so I’m assuming that its because the 1284 chip is not defined in the digitawritefast. So what would be involved in getting it in there or should I just splash out on a new Mega2560 ?

    • dewy721 says:

      What? Wait, how did you fry a stepper motor? Those are pretty robust. The Arduino (at least the official one) has a 500ma poly fuse to block “over-current” situations from harming the PC at all. The 8u2 if I recall, is only used as a USB to serial interface emulator. It should for all intents and purposes be transparent to the whole operation. All the chips on the 2560 are surface mount and not easily replaced. I’m not familiar with the 1284 chip. What EMI suppression bead? The one on the laptop power pack? In theory that component should never smoke as its just a little ring of ferrite with some wires looped through it. UNLESS… A wire got pinched and shot 12v volts up the 5v wire. Its the only way I can think of, that could ever possibly blow up that much stuff.

      I think a new mega2560 would be better than piece-mealing it back to life with a 1284 just to discover something else is blown.

  36. Bill says:

    Sorry missed a word, driver. I’ve gone through a few some due to me playing and not watching what I was doing and some that did not work or only worked for a short time. I’ve decided that I’m going to get some tb6560 drivers they are good for up to 3.5A burst

    Re the EMI bead, it next to the USB port on the mega 2560 designation L1 in the eagle files component list. Answers to a question on the Arduino forum brought the response that it might have been back EMF from the driver that killed everything even though the drive had diodes.

    The Mega 1284 chip is similar to the Mega2560 chip but not as many I/O lines 32 instead of 54 and only two serial uarts insted of the 2560’s four. This chip seems to be older than the 2560 and the price drop on the 2560 seems to have left the mega1284 on the shelf so there does not seem to be much development on them.

    Porting ic’s into the arduino IDE is way beyond my skill level so I’ll just have to get another 2560 when funds allow.

    • dewy721 says:

      Oh, that makes more sense. On my setup the drivers main DC power input is separated from the arduino. They share a common ground so signals wires have a completed path.

      Here’s how mine looks.

      Enlarged View.
      In real life the softly bowed wires are replaced by header pins. This way, the quadstepper board can be plugged in like an extension shield with only five “fly” wires; one ground wire and four ‘EN’ (enable) wires.

  37. Bill says:

    Thanks for the pic Dewy, my set up was similar to yours, with Mega 2560 powered by the USB. I think I’ll give up on the Mega1284 its just too much hassle. I can see the device on tty/ACMO witha dmesg in the terminal but when I run EMC it disappears. Maybe I can use this chip in my Tri-copter instead of the 2560.

    • dewy721 says:

      Tri-copter? Drones? I’ve always been curious about those. But not $400 curious. :-/

      • Bill says:

        http://www.multiwii.com/ The real expense is the RC gear but once youv’e got that then the cost comes down a lot. http://www.hobbyking.com are good for all the other bits and the RC gear as well, only draw back is if an item is on back order then any order you have with that in it will sit on the shelf until the item comes into stock. Oh and some items may be duff on receipt so to get a refund you have to return said item for inspection at your expense then any refund is put into your account as credits

Leave a reply to DonaldVH Cancel reply