Tuesday 27 December 2016

Testing an inductive proximity sensor

Let's take at the sensor I got from +Richard Jørgensen. As I mentioned, it's a LJ12A3-4-Z/BX, and came with this little extra print board to pull it down to 5V:

Now I don't have all my normal stuff with me, but I found a 12.6V battery in a drawer, which should be enough to power it. Plus it has an LED in it to show when it's detecting something. So if I just wire it up right (maybe reusing part of that board), I should be able to get it to light up.

According to this video, the wiring is: Brown = Vin, Black = Signal, Blue = Gnd, and I can just use a 9V battery with Brown on + and Blue on -. Didn't work with the 12.6V battery, but I don't know the state of that. With a fresh 9V, it works! It detects the copper tape at about 2mm distance, nice. I guess the '4' in the name is the maximum sensor distance (at full voltage?), which is nice for keeping it somewhat away from the bed.

There's an Instructable on how to enable auto-leveling with Marlin. I don't think I want the full auto-leveling to adjust for the shape of my bed just yet, just getting the height right is the important part. Plus I think I would rather work to get a level bed than have the print adjust, I expect a properly flat bed gives a better result than adjusting the Z axis during printing.

I'll clearly need a mount. I've been pondering various sneaky magnetic ways to raise and lower the sensor, though with the measurement distance being so long, I can probably just mount it close to the nozzle and still avoid crashes. There's this one by DanielBull which is just an add-on, or he has a full X carriage with a built-in probe mount. I'm not about to change out my carriage, that's a larger operation, though it might eventually be useful in order to properly mount an E3D and bed fan and probe. My one concern is that the probe would come loose enough during printing that it starts to offset itself. We'll see.

This video goes through the process very nicely. He warns against using PLA, since it melts at fairly low temperature. Maybe that's a good time to use that sample of PETG I got.

Marlin only supports three-point and grid levelling (tramming). Given that I need to put copper tape on the bed to measure it (unless I switch to an aluminium bed instead of glass), I can't have the points be on the middle of the bed. 

Do I want to replace the normal Z-endstop, or use the option to have them both on one input? I'm thinking the latter is more complex and prone to weird interactions. Some talk on how to connect to a Melzi here and here. Since this is an NPN, I shouldn't need extra components, which is nice (though I do like the PNP feature of a failed sensor counting as being triggered).

Fun with FreeCAD

On to the FreeCAD tutorials, starting with something basic, and taking notes.

Having auto-constraints on is rather nice. However, it can lead to oddities - at the 26mm length constraint, my design flipped out and only became orderly once I deleted the coinciding constraints and then added them back with Undo. Wut?

Scrollbars within scrollbars don't work well on Mac at all. Also, the Macbook Air has a delete button, but not backspace, so deleting items is tricky. But aha! You can use Fn-Delete to delete. And, as soon as I delete one of the lines in the tutorial object this way, FreeCAD crashes. Delightful.

"Now in the Combo View, click on the OK button" - yeah, well, there isn't one. ITYM "Close".

Non-dialog panels that have an OK button is one thing - having several that differ between "Ok" and "Close" is annoying - but it gets really confusing when you can make all manner of other changes in the meanwhile. OTOH, I don't like modal dialogs.

Ah, joy. Random "Overconstrained" errors. For some reason my sketch is rotated 90 degrees compared to the normal axis, so trying to set horizontal length on something that looks horizontal gives a conflict with the verticality constraint. This program could do with better error messages for some common constraint conflicts, e.g. "A vertical line cannot have a horizontal length". But why it's rotated I do not know, the axes look just fine. I tried reconstructing the initial model in a few different ways, but it always switches to XZ plane when adding a sketch on the back.

Curious. The "Angle" property of the sketch is 240 degrees, but degrees of what? 240 is the XZ plane, 120 is the YZ plane, and 0 is the XY plane. I still don't see the property that defines which way is up. Regardless of Axis properties, the coordinates are clearly (y,x) format. Bizarre.

The next picture does indeed show the element standing on end, there's just no explanation of why this happens. Nor is there an explanation of things like having to press 'Esc' to get out of a given tool. Maybe that's in the very beginners intro.

I like that the view buttons cause a little animation, makes it easier to understand. In OpenSCAD, clicking one just snaps to that view, which in some cases is indistinguishable from other views.

I like how the tutorial starts out by saying it's using Auto Refine, but that they recommend not doing that. Do as we say, not as we do. So now my sketch looks different, hopefully it won't behave differently.

External geometry selection requires holding Cmd, but internal selection doesn't. Confusing? Slightly. Mentioned in the tutorial? Nah.

I am amused by the final step: Call out to OpenSCAD to get rid of the extra lines.

For my Macbook, the Touchpad navigation is pretty nice once I get used to it, especially the click-less panning. There's just something odd about exactly when the Shift press is registered, probably related to what happens to have focus. Using just Shift and Alt, I can avoid clicking entirely to change my view.

I'll have to try designing a few "real" things, but it does look like there are objects more easily defined in FreeCAD than in OpenSCAD - things where constrained relations are the defining features in particular.

Monday 26 December 2016

Christmas doodling

Over the holidays, I've AFP (Away From Printer), so doing some thinking and reading up. +Richard Jørgensen showed me around FreeCAD a bit. It looks nice, definitely easier for some kinds of models, and the Bezier support is promising.

He also gave me an inductive proximity sensor (LJ12A3-4-Z/BX) he'd switched away from in favor of a bottom Z end-stop. I would like to use this for the auto-calibration, to take care of the frame size changes. I have a piece of copper tape from him, too. Now I just need to hook it up to appropriate power (comes with a hacked-up 5V adapter), feed it into the controller, and add applicable firmware support. 

Problem is the controller is out of inputs. I could theoretically put it on the same input as the existing Z-stop and somehow switch between them - or can the Marlin firmware understand that a Z-endstop input is both ends? Looks like it can (from https://github.com/MarlinFirmware/Marlin/blob/RC/Marlin/Configuration.h#L635):

// Enable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN to use the Z_MIN_PIN for your Z_MIN_PROBE. // The Z_MIN_PIN will then be used for both Z-homing and probing.

We did his first print with the E3D hotend, switched from a mk7. While the old one was working fine, the surface quality improved a lot, and temperature setting was lower. E3D rocks!

We also both want to do a bed fan duct. I keep thinking that two separate pieces with tubes between them would reduce a lot of the mounting problems inherent in combinations of different hotends, X beds, mount points, and fans. I haven't seen a design like that, though.

Playing around with FreeCAD some more shows a quirky interface, some weird errors, and a whole new way of thinking about geometry compared with OpenSCAD. On the bright side, it does have proper, if less nicely done than in Dia, Bezier curves. Now if I can make the Bezier curves partake in constraints, I'm all set. Unfortunately, it looks like the constraint solver isn't keep on distance-from-curve constraints. Also, constraining is only inside sketches, which can't be right. More tutorials are needed.