1. Got a question or need help troubleshooting? Post to the troubleshooting forum or Search the forums!

Mike Kelly's Solenoid Auto-Level for Stock R1

Discussion in 'Mods and Upgrades' started by Mike Kelly, Dec 13, 2014.

  1. Mike Kelly

    Mike Kelly Volunteer

    Joined:
    Mar 11, 2013
    Messages:
    6,967
    Likes Received:
    2,276
    Merry Christmas and Happy Holiday!

    I've designed a custom fan shroud that replaces the stock one on the RoBo3D to work with the solenoid auto leveling. It should work great! Enjoy!

    Click the picture to be taken to the how to post

    [​IMG]
    Click here

    ___________________________________________________________








    [​IMG]



    For a while now I've been interested in a non-contact or low contact approach to bed leveling. The nozzle touching the bed approach seems to work fairly consistently, but I'm worried about hot nozzles touching sensitive build plates to come.

    I've been following the work of ThantiK on google+. His company DeltaMaker has a solenoid probe for autoleveling. https://plus.google.com/104012815742569035024/posts/es6J8EEocmq


    [​IMG]

    I did take a new approach for it. He used a long lever arm switch where I figured out if you put the switch at an angle you could activate it properly and highly repeatably.

    [​IMG]

    For the solenoid I used this one from sparkfun: https://www.sparkfun.com/products/11015 Adafruit sells a very similar one as well.

    [​IMG]
    [​IMG]


    You need to use a mosfet circuit similar to this: http://i.imgur.com/Bbs3Mmg.png

    [​IMG]

    With a voltage converter to turn 12v into around 5v. http://www.ebay.com/itm/301120877446?_trksid=p2059210.m2749.l2649&ssPageName=STRK:MEBIDX:IT


    While you're on ebay you should get some jst 2.0 ph connectors for the solenoid: http://www.ebay.com/itm/121357773068?_trksid=p2059210.m2749.l2649&ssPageName=STRK:MEBIDX:IT

    The firmware modifications took a while for me to understand but with the help of ThantiK and @donhuevo I was able to nail down the changed needed for it to work.

    You first need to enable automatic bed leveling if you haven't. This should be custom configured for your own printer. With it the Z_Probe offset

    uncomment #define PROBE_SERVO_DEACTIVATION_DELAY 300

    uncomment #define NUM_SERVOS and set the value to at least 1

    Then uncomment
    #define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
    #define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 0,0} // X,Y,Z Axis Extend and Retract angles

    I set all the angles to 0, but you need to enable that from some remnant code

    Now is where things get dirty, you need to go into marlin main and look for engage_z_probe

    You can uncomment the engage_z_probe and replace it with this code:

    static void engage_z_probe(int d = 100) { //lower z probe
    digitalWrite(Z_PROBE_PIN, HIGH);
    delay(d);
    }

    then do the same for retract_z_probe:

    static void retract_z_probe(int d = 100) { // raise z probe
    digitalWrite(Z_PROBE_PIN, LOW);
    delay(d);
    }



    You can look at my complete code here: https://www.dropbox.com/s/jg0yzoku6szbadt/MK_Probe_Level_Dual_12-13.zip?dl=0
     
    #1 Mike Kelly, Dec 13, 2014
    Last edited by a moderator: Dec 24, 2014
    9 people like this.
  2. Galaxius

    Galaxius Well-Known Member

    Joined:
    Jan 18, 2014
    Messages:
    632
    Likes Received:
    342
    That's a much better auto leveling system. Something else to add to my to-do list.
     
  3. Ziggy

    Ziggy Moderator
    Staff Member

    Joined:
    Feb 20, 2013
    Messages:
    707
    Likes Received:
    530
    IMO you will have a consistent, low maintenance z probe. No more fiddling with your z nuts.
     
  4. donhuevo

    donhuevo Active Member

    Joined:
    Mar 29, 2014
    Messages:
    138
    Likes Received:
    100
    a thing of beauty!
     
  5. Dbeal

    Dbeal Active Member

    Joined:
    Jul 10, 2014
    Messages:
    110
    Likes Received:
    84
    This is nice, when can you come install this on my printer Mike? JOKING
     
  6. Mike Kelly

    Mike Kelly Volunteer

    Joined:
    Mar 11, 2013
    Messages:
    6,967
    Likes Received:
    2,276
    hmm I should design a fan shroud that integrates this for all the hexagon printers out there
     
    2 people like this.
  7. Flavio

    Flavio New Member

    Joined:
    Oct 18, 2013
    Messages:
    17
    Likes Received:
    23
    I have designed a new FAN adapter for Hexagon extruder...

    if anyone is interested, download it here
     
  8. Mike Kelly

    Mike Kelly Volunteer

    Joined:
    Mar 11, 2013
    Messages:
    6,967
    Likes Received:
    2,276
    In celebration of the season I designed a fan shroud inspired by the stock robo3d one but adds solenoid probing functionality.

    [​IMG]

    After getting the circuitry and wiring done attaching the fan shroud should take less than 5 minutes. Here's how:

    Assembly:

    Begin by printing the new fan shroud. Download here

    [​IMG]

    or click the link below

    Any material is fine and prints without support. I suggest at least 50% infill to give it a good amount of strength since you want to minimize any flexing that could distort you calibration.

    The links for the solenoid and switch are above, but here they are in order of what you need:

    1x $4.95 - Solenoid switch: https://www.sparkfun.com/products/11015
    1x $0.184 - $0.513 Per ($1.84/10 slow boat or $6.16 from Prime) Sub Micro Switch

    2x~M2- 8mm screws for the switch, could take from existing Z switch
    2x M2 - 4mm Self tapping screws $0.563 per ($7.04/25): http://www.mcmaster.com/#96817a840/=v5zsno These are the ones I used but there are many options out there. I think stainless steel is a must as securing into the solenoid was difficult.


    With the part ready the first step is to secure in the solenoid with the 2 M2-4mm screws from the back

    [​IMG]

    With the solenoid in place you will then want to attach the switch using any screw around 2mm and at least 8mm in length. It will require tapping into the switch itself but that should be fine.

    [​IMG]

    The final step is wiring it. As the switch is held down during homing, and a release of the solenoid triggers the switch.

    We will be using the Normally Open (NO) pins on the switch, do not wire to the Normally Closed (NC) pin on the switch. This switch plugs into Z_min on your ramps board, replacing your old Z-min switches

    For wiring up the solenoid as I suggested above get a set of these:

    http://www.ebay.com/itm/121357773068?_trksid=p2059210.m2749.l2649&ssPageName=STRK:MEBIDX:IT JST 2.0 PH 2 pin connectors. They will work directly off the solenoid so no need to cut wires. This is optional.


    There are 4 screws holding in the existing 25mm fan, begin by removing them and placing them aside. Be careful when handling the fan to not put too much force on the wires and carefully stow it somewhere.

    There may then be another screw that holds the stock fan shroud like this:
    [​IMG]

    Unless your fan shroud is held on by friction

    There is a captive nut on the other side of this screw point so be sure to hold that in place and not lose it while removing the screw.

    You will then take the new fan shroud solenoid probe assembly and reattach it the same way

    [​IMG]

    The final step with the fan shroud connected to the carriage is to reattach the fan and make sure it still works.

    Electronics:

    On the circuitry end of the spectrum there's a basic circuit that needs to be made:

    [​IMG]


    The mosfet can optionally be replaced with a solid state relay that works with 5v DC.

    For the mosfet I used the same version that comes on the Ramps board because I had it on hand. There's certainly other options.

    $1.54 MOSFET STP55NF06L
    $0.18 1N4001 - For a diode I used an 1N4004 but you could probably just as well use a LED and a 100ohm resistor.
    $0.10 10k Resistor 1/4W 5% tolerance

    $1.20 per ($11.98 total ) Step down power converter



    Firmware:


    I have provided pre-modified firmware available for Download here

    Robo3d with 5/16" Rods

    Robo3d with M8 Rods

    or click the link below

    The firmware consists of a few main changes, by order of what you need to do:


    Z_Probe_Offset:

    In configuration.h there is a variable Z_Probe_Offset that needs to be adjusted.

    This can be done two ways.

    The first is to modify the firmware value. Your value should be somewhere between 1 and 1.5, you will need to calibrate this yourself.

    Code:
      #define Z_PROBE_OFFSET_FROM_EXTRUDER 1.0
    
    The second is to use the M565 command in the start gcode, eg

    Code:
    G28 ; Home all axis
    M565 Z1.0 ; Z probe offset of 1.0mm, adjust for your printer
    G29 ;Run autolevel routine.
    
    X and Y Offsets

    The Y and X probe offset values will be set as such

    Code:
    // these are the offsets to the probe relative to the extruder tip (Hotend - Probe)
      #define X_PROBE_OFFSET_FROM_EXTRUDER 24.7
      #define Y_PROBE_OFFSET_FROM_EXTRUDER 21.5
    
    Uncomment
    Code:
    #define PROBE_SERVO_DEACTIVATION_DELAY 300
    Enabling Servos:

    At the very bottom of configuration.h you need to enable service by uncommenting:

    Code:
    #define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
    Setting to at least 1

    Then uncommenting
    Code:
    #define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
    #define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 0,0} // X,Y,Z Axis Extend and Retract angles
    
    Setting the angle to 0


    In pins.h you need to add a new value:
    Code:
    #define Z_PROBE_PIN  63  //  IO pin, 5v, extend and retract touch probe
    
    Using the Pin 63 as our control pin. You can change this for any other digital output.

    Place this between
    Code:
    
      #define SDPOWER  -1
      #define SDSS  53
      #define LED_PIN  13
    And

    Code:
    #endif
    
      #if MOTHERBOARD == 33 || MOTHERBOARD == 35 || MOTHERBOARD == 67 || MOTHERBOARD == 68
      #define FAN_PIN  9 // (Sprinter config)
      #else
    Also in Pins.h you need to set the Servo0_Pin to 63 from 11

    Code:
    #ifdef NUM_SERVOS
        #define SERVO0_PIN         63
    
    The biggest revision is modifying Marlin_Main.cpp with these calls:
    Code:
    static void engage_z_probe(int d = 100) {  //lower z probe
      digitalWrite(Z_PROBE_PIN, HIGH);
      delay(d);
    }
    
    static void retract_z_probe(int d = 100) {  // raise z probe
      digitalWrite(Z_PROBE_PIN, LOW);
      delay(d);
    }
    Commenting out the old engage and retract commands



    That should be everything you need to do to get running! Again the only thing you need to add is the Z_offset, everything else is done for you.
     

    Attached Files:

    #8 Mike Kelly, Dec 24, 2014
    Last edited by a moderator: Feb 28, 2015
    3 people like this.
  9. John Rygg

    John Rygg Active Member

    Joined:
    Feb 21, 2013
    Messages:
    111
    Likes Received:
    31
    wonderful design . Any holders for the E3D ?
     
  10. Mike Kelly

    Mike Kelly Volunteer

    Joined:
    Mar 11, 2013
    Messages:
    6,967
    Likes Received:
    2,276
    Hmm no it would be harder to fit a 30mm fan. I suppose its possible but could be more challenging to do.

    V5 or v6?
     
  11. Ziggy

    Ziggy Moderator
    Staff Member

    Joined:
    Feb 20, 2013
    Messages:
    707
    Likes Received:
    530
    Mike,

    When these 12v solenoids are switched on the armature moves very quickly and has a fair amount of mass and therefore momentum. I don't know if the glass bed needs to be protected in some way if the probe engages close to the bed??

    There is probably a benefit if the solenoid power could be reduced or controlled in a way that reduces the momentum. What do you think? Would that be worthwhile?
     
  12. Mike Kelly

    Mike Kelly Volunteer

    Joined:
    Mar 11, 2013
    Messages:
    6,967
    Likes Received:
    2,276
    Well they're 5v solenoids. You can adjust the power by reducing the voltage. It's also a good idea to increase the distance from the bed, but the solenoid activation distance is only 3.5mm so mine activates far from the bed.

    Momentum? Of the what? Not sure what you mean really
     
  13. Ziggy

    Ziggy Moderator
    Staff Member

    Joined:
    Feb 20, 2013
    Messages:
    707
    Likes Received:
    530
    It was just that I bought one of the relays (whether it's a 12v or 5v type doesn't make much difference to the actual operation). When I tested it I thought the iron armature moved so fast and with such force it could crack the bed if it were too close when it was turned on. No big deal of course if it never gets that close. Another option would be to control the current through the relay to slow it down.
     
  14. Mike Kelly

    Mike Kelly Volunteer

    Joined:
    Mar 11, 2013
    Messages:
    6,967
    Likes Received:
    2,276
    I think that's part of the reason Marlins autolevel will raise the nozzle before homing or doing autolevel. I believe its 5mm.

    But yeah I wouldn't have even considered that if you didn't mention it
     
  15. Koji Nakano

    Koji Nakano New Member

    Joined:
    Dec 23, 2013
    Messages:
    7
    Likes Received:
    0
    Hi Mike,

    Should Z_PROBE_PIN 63 be connected to RAMPS1.4 AUX-2 D63 ?
     
  16. Mike Kelly

    Mike Kelly Volunteer

    Joined:
    Mar 11, 2013
    Messages:
    6,967
    Likes Received:
    2,276
    Yes it plugs into pin 63 on the Ramps and the ground right next to it
     
  17. Koji Nakano

    Koji Nakano New Member

    Joined:
    Dec 23, 2013
    Messages:
    7
    Likes Received:
    0
    I can't make a solenoid move.
    The voltage of Pin63 was checked by an oscilloscope.
    The voltage goes out 5 V, but on time is shorter than 1sec.
    Some comments, please.
     
  18. Mike Kelly

    Mike Kelly Volunteer

    Joined:
    Mar 11, 2013
    Messages:
    6,967
    Likes Received:
    2,276
    You're using a mosfet and alternative power source? The ramps can't provide enough current to drive the solenoid by itself.
     
  19. Koji Nakano

    Koji Nakano New Member

    Joined:
    Dec 23, 2013
    Messages:
    7
    Likes Received:
    0
    I'm checking movement of solenoid using solenoid with DCDC-Conv and MOSFET.
    12V was being input to DCDC-Conv and 3V was being input to Gate of MOSFET.
    DCDC-conv and solenoid use the same product.
    MOSFET uses FS70SMJ-06.
    (VDSS is 60V and the ID is 70A.)

    11A terminal for RAMPS and DCDC - conv are connected and 12V is being supplied by ROBO3D.

    When a microswitch isn't turned on(short),
    does output times of G63 (5V) become shorter than 1sec?
     
  20. Mike Kelly

    Mike Kelly Volunteer

    Joined:
    Mar 11, 2013
    Messages:
    6,967
    Likes Received:
    2,276
    If you use the g-code command

    M42 P63 S255

    can that enable the solenoid?
     

Share This Page