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

Differential IR height sensor, Attemptin' Clone....ain't sure of success...now stage 10

Discussion in 'Mods and Upgrades' started by jim3Dbot, Aug 25, 2015.

  1. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    23,912
    Likes Received:
    7,338
    A larger negative number should be further from the bed... a smaller negative number closer to it and a positive number (technically) below the bed surface.

    I suspect this is part of the reason current branches Marlin ditched M565.

    Given your behavior I suspect your 'zero' detection (when the probe is 'on the bed') is off .
     
  2. danzca6

    danzca6 Well-Known Member

    Joined:
    Jul 27, 2015
    Messages:
    2,161
    Likes Received:
    1,077
    Thanks Mark. Yeah I get that. It is truly confusing. Now if I want to set the Z offset in the firmware instead, exactly what variable is that? Might be worth a shot. Also, I need to know why some are disabling the Z_SAFE_HOMING switch in the firmware. I didn't and that is the dangling variable in my mind with this. I need to do it and run through my scripts again. It just wasn't clear to my why. I know in configuration.h it is just telling the machine to home Z in the center of the build area, but there must be more magic sauce behind that setting in the firmware based on the description. Those using a servo based probe use it from what I am reading online. Maybe since our probe is reading above the nozzle tip, that there is something with having it set that is throwing things off. The results I got last night were against logic. At least against the way things work to my knowledge. That was the most frustrating part.
     
  3. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    23,912
    Likes Received:
    7,338
    I had an actual leveling probe for a bit a while back (one someone else developed) and this adds some complication to the firmware config. Things like Z probe offset suddenly matter (since in the regular way of auto-leveling a Robo the nozzle is the probe so 'offset' is Zero). I finally converted both of my beta units to using the stock approach to auto-leveling :)
     
  4. mark tomlinson

    mark tomlinson ༼ つ ◕_ ◕ ༽つ
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    23,912
    Likes Received:
    7,338
    and frankly, having haunted the Marlin dev group the autoleveling code was in flux for a long time and there were (heated) arguments over how things should work. With the current dev/RC branch I suspect most of this is sorted.
     
  5. WheresWaldo

    WheresWaldo Volunteer ( ͠° ͟ʖ ͡°)
    Staff Member

    Joined:
    Feb 18, 2015
    Messages:
    5,905
    Likes Received:
    3,593
    @danzca6 are you actually saving the value in EEPROM before turning off the printer, if not and there is something other than firmware values in that area of memory, it will override whatever you flash, as EEPROM setting are not overwritten in a new flash of Marlin. Plus Z Offset and ABL are severely retarded in Marlin 1.0.0.
     
  6. danzca6

    danzca6 Well-Known Member

    Joined:
    Jul 27, 2015
    Messages:
    2,161
    Likes Received:
    1,077
    I FINALLY GOT IT!!!

    Ok, want to document what changes I had to make to the firmware to get this to work. Now I have the R1+ with the new leadscrews as most of you know. I am using the ROBO3DR1PLUSV1 firmware. Those with the new R1+PLUS have a different firmware. So this may or may not fully apply to yours, but please keep reading and maybe I will get you close. Now I found out tonight that some of you that are live with Jim's IR may have the leadscrew upgrade, but updated your current firmware by hand instead of getting Robos new version. Thank you @jbigler1986 for sharing your firmware. Now as you may already know from posts above, with the IR you should have a positive Z offset when setting it in gcode and a negative value only when setting it in the firmware. Don't set it in both. Pick one or the other.

    I was seeing an odd pattern that the more positive I went with M565 Z#.# I would get farther from the bed. So I went to zero and then negative to see if I could get what I needed. Now if I went negative with M565 Z-#.# all of a sudden I started getting the nozzle going up again. Getting into the code I proved my theory. There are safeguards in this version of firmware to keep the nozzle from going into or past the bed and looks for the z offset being positive and will switch it to negative on you. Programmers...haha. These safeguards weren't in JB's. So I found each (3 total) and commented out the safeguards. That was it. Now things are working the way they should. Below is all the changes from stock I did with the ROBO3DR1PLUSV1 firmware. I hope that this saves someone else nights of frustration that I went through this week. It's late, so I hope I get everything straight. Sorry for the long post and any fat finger errors. Note there are two files needing updates in the firmware. Configuration.h and Marlin_main.cpp as highlighted and underlined below.

    Here are the basics for incorporating the IR. I highlighted the changes with comments needed in each block and tagged it with IR. Comments are not needed, but encouraged when modifying firmware. My IR is mounted 25mm to the right of the nozzle tip and you will need to adjust yours based on how you mount it.

    I'd share my mount, but sadly, I did not buy Jim's IR. I got the one from filustruder awhile back and just now got to installing it. My holder has a cover for the electronics so no contacts are exposed. The cover will be different for Jim's board since the components are not exactly the same or laid out exactly the same. There are plenty of good ones for Jim's board already.

    Configuration.h
    Code:
    // The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
    const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. //robo
    const bool Y_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. //robo
    // IR: Need to change next setting from true to false so Z is triggered when IR probe turns on 
    // instead of when one of the Z endstop turns off like stock autoleveling
    const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. //robo
    const bool X_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. //robo
    const bool Y_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. //robo
    const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop. //robo
    
    Code:
    // set the rectangle in which to probe
    // For IR mounted on right or left of extruder (account for full offset of probe so you don't hit X endstop if possible)
    #define LEFT_PROBE_BED_POSITION 30    // IR: Changed from default (15) to 30 to account for PROBE setting adjusted +25 mm
    #define RIGHT_PROBE_BED_POSITION 220  // IR: Changed to 220 to put the IR closer to the edge default (205)
    // For IR mounted in front or back of extruder (account for full offset of probe so you don't hit Y endstop if possible)
    #define BACK_PROBE_BED_POSITION 230
    #define FRONT_PROBE_BED_POSITION 20
    
    Code:
    // these are the offsets to the probe relative to the extruder tip (Hotend - Probe)
    // In relationship to the nozzle,  if probe is right X is +, if probe is left X is -,
    // if probe is front Y is +, if probe is back Y is -.
    #define X_PROBE_OFFSET_FROM_EXTRUDER 25 // IR: Distance Mini IR is from nozzle (original value 0)
    #define Y_PROBE_OFFSET_FROM_EXTRUDER 0   // IR: Mini IR is pretty much on same setting as nozzle tip for Y
    #define Z_PROBE_OFFSET_FROM_EXTRUDER 0
    
    There are some folks that are commenting out the definition for Z_SAFE_HOMING and I don't see any point to do this. Based on the comments in the firmware, it should stay. I searched my firmware and no benefit. I actually like the way it works better than having it undefined. Those with older firmware versions may need it, but you do not with this version.
    Code:
    #define Z_SAFE_HOMING   // This feature is meant to avoid Z homing with probe outside the bed area.
                            // When defined, it will:
                            // - Allow Z homing only after X and Y homing AND stepper drivers still enabled
                            // - If stepper drivers timeout, it will need X and Y homing again before Z homing
                            // - Position the probe in a defined XY point before Z Homing when homing all axis (G28)
                            // - Block Z homing only when the probe is outside bed area.
    

    Now for the safeguards. Caution...this may void your warranty...LOL! This is just to keep the Z offset from going negative when using the IR since the IR is, or should be, mounted above the nozzle tip.

    Marlin_main.cpp
    Found in the set_bed_level_equation_lsq sub routine and really the only one needed, but the other 2 can be commented just to keep things equal. ** Notice all but ONE line is commented out here, not all.
    Code:
    // put the bed at 0 so we don't go below it.
    // IR: Comment out this logic to leave the Z offset positive
    //if (zprobe_zoffset < 0)
    //{
    current_position[Z_AXIS] = zprobe_zoffset; // in the lsq we reach here after raising the extruder due to the loop structure
    //}
    //else
    //{
    //current_position[Z_AXIS] = -zprobe_zoffset; // in the lsq we reach here after raising the extruder due to the loop structure
    //}
    
    Found in the set_bed_level_equation_3pts sub routine, ** Notice all but ONE line is commented out here, not all
    Code:
    // put the bed at 0 so we don't go below it.
    // IR: Comment out this logic to leave the Z offset positive
    //if (zprobe_zoffset < 0)
    //{
    current_position[Z_AXIS] = zprobe_zoffset; // in the lsq we reach here after raising the extruder due to the loop structure
    //}
    //else
    //{
    //current_position[Z_AXIS] = -zprobe_zoffset; // in the lsq we reach here after raising the extruder due to the loop structure
    //}
    
    Found around line 1413. ** Notice all but ONE line is commented out here, not all
    Code:
    // IR: Comment out this logic to leave the Z offset positive
    //if (zprobe_zoffset < 0)
    //{
    current_position[Z_AXIS] += zprobe_zoffset; // in the lsq we reach here after raising the extruder due to the loop structure
    //}
    //else
    //{
    //current_position[Z_AXIS] += -zprobe_zoffset; // in the lsq we reach here after raising the extruder due to the loop structure
    //}
    
    Now flash your firmware and add an extra step to open a gcode command window (use Cura, MatterControl, or some other gcode command window to connect to the printer) and send command M502 and M500. This version of the firmware has EEPROM writing enabled and you want to flush and reset anything still stuck in the EEPROM. Thank you @WheresWaldo for schooling me on that gem.

    Last step is figuring out your z offset. I use the M565 Z#.# command in my start.gcode in Cura. Whatever software you use will be similar. I first started with M565 Z0.0. I loaded a small stl that has no use but to just get a start to a print going. Started the print. It will home the Z, then go through the 9 point autolevel, and finally start the print. I canceled the print right at this point. You just want the nozzle at the Z height that a print will would start at. I then send an G92 Z0 to zero out the Z. Send a M114 to confirm. Take a sheet of printer paper and place under the IR. Slowly lower the Z axis using the software controls until the nozzle is snug with the paper. Go back to your command window and send another M114. The Z offset will be a negative number. Mine was -1.7. So my next round was to use M565 Z1.4 and dialed in the first layer until I was happy. This method at least gives you a safe place to start tweaking your offset. Remember, we removed the safeguards. Slow and steady wins the race here.

    That's it. The IR is awesome. No more bed boogers and smashed filament in the hotend. No more walking up stairs when the endstops act up. It's just a thing of beauty. G29 results are so predictably reliable with the IR. Only saw it very about .01 mm all the times I did it. I actually used the G29 readouts to level my X axis manually. Now I am so close to level without any autolevel. No more dial gauges. Now that the nozzle doesn't contact your bed, you can get a little more brave and play with some of the settings to make your autolevel routing faster. @Marquis Johnson thread Amazon Sain Smart Lead Screws has a great video and settings in post #5 to get you going. Beware when changing the DEFAULT_AXIS_STEPS_PER_UNIT that you use a value appropriate to your leadscrews. Robo's upgrade screws are TR8*4 and should be a value of 800. Marquis is using TR8*8 screws and 400 is correct for that. These changes make the autolevel routing freaky fast. I LOVE IT!

    I really hope this helps someone. Let me know if you have any questions. Special thank you to Jim for this great IR project and helping with my wiring, MK for getting me hooked and for your initial mount, JB for the use of his firmware and being there to help out understand this, to Waldo for his gcode and firmware expertise, and NFO, MG, and Mark fielding my crazy questions. I know I am leaving someone out. Thank you to everyone.

    Happy printing friends.
     
    #186 danzca6, Dec 5, 2015
    Last edited: Dec 5, 2015
  7. jim3Dbot

    jim3Dbot Active Member

    Joined:
    Jun 1, 2015
    Messages:
    246
    Likes Received:
    124
    Eureka..........Damn...........Eureka............Got'it.........

    After close to 2 weeks of frustrating research & trials, the mini IR is bootin' in 4 seconds.......and running faster. My code-challenged brain can now rest..........I have averaged ten+ hrs for 2 weeks each day......on a firmware issue, someone in the know would of completed in minutes....damn & eureka.......in short and I mean short version......the ATtiny45 boots up in Studio 6.2 with the fuses set at default 'CKDIV8'...........this means; the clock frequency of 8mhz is divided by 8 which results.........1mhz. Now......I have been saying...wait 30 seconds for the LED to blink twice.........wondered why so long...........Perusing the atmel & avr sites late last night......I noticed the ATtiny45 u-processors will be set at 1mhz unless you revise boot-loader to 8mhz. Waking up in the middle of the night started thinking.....maybe my 1 elephant.......2 elephant.....//.....30 elephant was really 32 elephants........AND maybe the five second boot-up is really 4 seconds (elephants) then 32 divided by 4 = factor of eight......therefore I am running boot-up eight times slower...........

    I have been tryin' to compile via arduino....too many errors........tried to boot in AVRdude......failed..........Studio is the answer.....

    I've upgraded this post to 9.5 cause, cause, cause it deserves it..........

    I have been ignoring this & shoutbox cause, cause, I needed to...........Lookin forward to stage ten...........Take Care...Jim
     
    #187 jim3Dbot, Dec 6, 2015
    Last edited: Dec 6, 2015
  8. danzca6

    danzca6 Well-Known Member

    Joined:
    Jul 27, 2015
    Messages:
    2,161
    Likes Received:
    1,077
    Jim

    Congrats on breaking through and persevering. Let me know when you are back online selling these again. Feels good doesn't it? You do great work man.
     
  9. jim3Dbot

    jim3Dbot Active Member

    Joined:
    Jun 1, 2015
    Messages:
    246
    Likes Received:
    124
    Danz........I think we were both beatin' ourselves up for days..........I knew you would figure it out........sometimes that is the only way...........this forum will always, at minimum, point you in a new direction when you are outta ideas.......I'll be shipping to @Printed Solid this week............Hey.....Take Care
     
    Printed Solid likes this.
  10. Printed Solid

    Printed Solid Volunteer Admin
    Staff Member

    Joined:
    Feb 21, 2013
    Messages:
    1,605
    Likes Received:
    1,003
    I'm certainly looking forward to trying it out on my printer!
     
  11. danzca6

    danzca6 Well-Known Member

    Joined:
    Jul 27, 2015
    Messages:
    2,161
    Likes Received:
    1,077
    Yeah, I think i'll buy one of yours Jim to see how it differs from the one I bought elsewhere. I'd like to see if they both give the same readings and how the sensitivity is in comparison. I'd also like to see if I can model my mount cover to work with yours and if my firmware changes work for both. Still very odd that you guys had to disable safe homing. I'd like to see the firmware you are using to see what is in there that would mess you up. The version I have doesn't have anything referencing that variable that would cause issues. I know I'll find a use for two someday. Maybe I should put two on my Robo. LOL! I might be building something soon that could benefit from another IR to autolevel. These things are so cool. Very curious to work with yours
     
  12. jim3Dbot

    jim3Dbot Active Member

    Joined:
    Jun 1, 2015
    Messages:
    246
    Likes Received:
    124
    Let me say, thanks to the betameisters & their perseverance working with this project. Although all the IR's, I built, will function well, they require careful tweaking........most are successful, others not so much. This third rendition by far functions the best. The Sharp GL480, pink type, 26 degree viewing angle, performs better than the 18 degree Osram SFH4141 IR Emitter. The Sharp part is pink, to help block ambient IR..........I really have not seen the pink color to have a noticeable effect. The greater viewing angle reduces the trigger point from the bed, typically 2.5 - 3mm, reducing spurious or false triggers. The Osram part, triggers reliably 5 to 7mm distance from the Robo bed, IF tweaked correctly. However, I cannot locate a distributor in the USA. Farnell, (newark) of Great Britain stocks as others in GB, such as Little Diode.........cost to here, not so good, hence the swap. I will be testing 26 degree clear IRs, later this month, from a local distributor. I received 200 pieces of the 'pinks' one day after shipping 15 more of the IRs. Damnit. Having said that, if you have received an IR without the 26 degree pink emitters, tweak it, if required, and will be fine......however, absolutely, no problem with receiving any or all back, I will swap the IR emitters to GL480...check trigger level & 4 sec. boot-up then return....probably the way I would go, just sayin'........To keep you somewhat up to date.....Following will be a barrage of postings starting today...............HEY! Have a great New Year........keep on printing...............jimmy
     
    danzca6 and Puff like this.
  13. jim3Dbot

    jim3Dbot Active Member

    Joined:
    Jun 1, 2015
    Messages:
    246
    Likes Received:
    124
    DSC08568.JPG Snafu turns Fubar.....................from Fiasco.......

    Successfully flashed one mini, about a month ago to faster boot..........then updated Atmel's Studio 6.2 to their new Studio 7......Now....
    Olimex Development Board does not connect with Studio 7.......tried one zillion methods to 'no avail'.......Olimex does not offer the new firmware.....However.......ultimately I was steered to some fellows site that offered a few files that was 'supposed' to make this thing compatible, a few days later......Not. In the process of updating Olimex'es'es firmware, one needs to stick a pin in the little hole in the top of the case to clear the residing firmware......okay, worked......But.....having done that before the failed firmware download, leaves me with a pretty case void of software.....Damnit..........With my own perseverance, I ordered an Atmel-ICE Development Board......and downloaded the appropriate firmware, for Studio 7. Okay, that went well, Sorta......Received the ICE, then realized my USB A male to 'mini' USB B male cable.....needs to be an USB A male cable, (standard) to a 'micro' USB B male cable And, the 10 pin to 6 pin cable, I constructed for the other programmer, 0.1" pitch now requires a 0.050" pitch.......https://www.digikey.com/product-detail/en/ATATMEL-ICE-CABLE/ATATMEL-ICE-CABLE-ND/4753382............

    Now in the process of 'all this' I managed to corrupt my Win7 operating system.....that's no surprise to me........something about Vbrun.dll, don't quote me on that.......so searching for that file to repair my 'taking one for the gipper' left me with more 'issues'. Mr. Gates has been hounding me for months to upgrade to Win10......Okay you win Bill...lay it on me..........

    Appears we are ready..........Not so fast..........launching Studio 7..........building new project, that's what atmel calls compiling.....entering programming mode for Tiny45 micro.......revising oscillator speed for 4 second boot...Error....."No Voltage Present"....cannot program........Hmmmm.......after a short while.............all day.........I find the Olimex receives device target power from the USB port but, the ICE, requires an external power supply for the target device...........Hey, no problem........Damnit...........Let us see...we need 3.3 to 5vdc..........my computer desk now needs room for a 5volt power supply.........I had an old 6 volt AA battery holder which I shorted out one position.....now I have a 4.5volt battery holder.......two hours later.............success!
     
    #193 jim3Dbot, Jan 5, 2016
    Last edited: Jan 5, 2016
  14. jim3Dbot

    jim3Dbot Active Member

    Joined:
    Jun 1, 2015
    Messages:
    246
    Likes Received:
    124
    Here's some stills, video later.......

    Assembly Drawing DSC08554.JPG

    Components

    DSC08557.JPG There's 3,000 resistors in that bin! ...size of your fingernail. DSC08558.JPG

    IR Emitters GL480 'pinks'

    DSC08570.JPG
    More SMT (surface mount) components, e'nuf for 10 boards

    DSC08553.JPG

    Micros on anti-static foam, solder paste, scored bare boards

    DSC08552.JPG

    Stencil, note 10 boards aligned along left side, tinned copper
    pads showing thru laser cut stencil. I know 'flash'.....

    DSC08560.JPG
    Flipped some panels sandwich'in 10 brds. These are the boards under the stencil in previous photo....Places stencil over an even plane.........

    DSC08559.JPG

    SMT Oven....Place on shuttle, left side...into oven...start reflow profile...shuttle out right side....you can solder over 100 pcb's in 240 seconds.

    DSC08563.JPG

    Oven target temp. 450F, now at 302F...Preheat/activation time 100sec then time b total cycle time 240sec.

    DSC08562.JPG

    DSC08566.JPG

    Completed SMT reflowed panel. Rework required on this panel, 6th brd, R3 shifted, 13th brd, C3 shifted, 14th brd, micro shifted...looks as if I bumped left corner placing in oven.....normally boards have no problems..........

    DSC08564.JPG
     
    Mike Glass and Mike Kelly like this.
  15. Mike Glass

    Mike Glass Active Member

    Joined:
    Dec 29, 2014
    Messages:
    268
    Likes Received:
    123
    Awesome work Jim, Quality is great, I plan on swapping my out this weekend or sooner, will let you know how it goes.
     
  16. jim3Dbot

    jim3Dbot Active Member

    Joined:
    Jun 1, 2015
    Messages:
    246
    Likes Received:
    124
    Question from member: Does mounting on side of carriage have an effect on the trigger distance..........

    IMO only

    Here's my thought.........Best location is a three part answer....get as close to the nozzle as possible, without frying the IR......and Get as close to the bed as possible...........and mount parallel to the X axis, Notice big Box, Deltas, and the mini K mounts parallel........ I'm thinkin'........If the extruder is positioned midway along the X axis.....there will be a downward bow that will vary according to your extruder weight. If the IR is mounted in that plane, (front), the distance will not change in relation to the nozzle...........however, if mounted on the side.....the further from the nozzle, the error distance will increase, like a teeter totter........nozzle down, IR up..............The problem would worsen with dual extruders......and greater distances from the nozzle tip.

    I have not tested this.......just sayin'.......Now, I am not fond of the front location....it's hard to see the nozzle tip, meh all over again.
     
    #196 jim3Dbot, Jan 11, 2016
    Last edited: Jan 11, 2016
    Mike Glass likes this.
  17. jim3Dbot

    jim3Dbot Active Member

    Joined:
    Jun 1, 2015
    Messages:
    246
    Likes Received:
    124
    After interrupting 'counting the sheep' last night........Auto Bed Leveling would take care of, if any appreciable, deflection in the x axis rods.
     
  18. Puff

    Puff New Member

    Joined:
    Sep 4, 2015
    Messages:
    10
    Likes Received:
    8
    I've changed my mind and agree with you both.
    My 2cents is that you've put in an offset and thus the probe will probe where the nozzle will eventually be.
    I've tried both methods and being able to see the nozzle do its thing made me go back to mounting on the side.(That and I melted Jim's sensor, mine is bigger and only fits on the side)


    Sent from my iPhone using Tapatalk
     
  19. jim3Dbot

    jim3Dbot Active Member

    Joined:
    Jun 1, 2015
    Messages:
    246
    Likes Received:
    124
    Hi Puff, Yeah I was talking to myself, above............If you have extra of the GL480's, solder in my board, if all other parts are fine...it will work like a champ....is your friend from Indiana making the long haul anytime soon?
     
  20. Puff

    Puff New Member

    Joined:
    Sep 4, 2015
    Messages:
    10
    Likes Received:
    8
    Good thing I agreed with you then. :)
     

Share This Page