Welcome! Log In Create A New Profile

Advanced

Piezoelectric disks for Z contact detect and bed levelling

Posted by leadinglights 
Piezoelectric disks for Z contact detect and bed levelling
March 04, 2016 05:34AM
Piezoelectric sensors seem to be a good candidate for bed leveling and Z height setting as they have a exceptional output, they are very cheap and quite rugged.
I saw the Youtube video of Njål Brekke piezo sensors and thought that it may be worth trying these in the opposite sense that he uses them: sense the release of pressure under the bed adjusting nuts rather than the increase in presure that Njål uses. In the drawing below the piezoelectric disk sensor is between the pressure pad and the carriage. (see also in photo at the end)

Simulating a bed contact at only 1mm/second I get an output from the bare transducer of 8V (thats not a missprint) with a total movement in contact of 100um. Photo below show the 8V output from a single contact. Vertial scale 2V/cm, Horizontal 50ms/cm

This is a train of pulses increasing from 0 to 220µm in steps of 20µm. Vertical scale 5V/cm, Horizontal 1 second/cm.

Five contacts with a spring putting a pressure increasing from 20 grams to 100 grams. Vertical scale 1V/cm, Horizontal 1 second/cm

As far as price goes, I used 27mm piezo disks from ebat ay £5.48 for 10. In general handling these are pretty robust and once installed they should be pretty bullet-proof.

Like many things, they are not without their problems:
  • Piezoelectric sensors are dynamic, the actual moment of contact is sensed and if the nozzle is already in contact with the bed that won't be sensed.
  • Nozzle contact methods are not universally liked as fragile bed surfaces can be harmed by nozzle contact - especially as the nozzle should be hot to avoid solid plastic giving an unreliable reading.
  • Unlike switches and FSRs (force sensitive resistors) they can't be connected in a "wired or" configuration. Geometric effects mean that some places on the bed will result a "three legged table" effect with the output from one sensor cancelling the other two.
It is this last problem that is the only thing that is stopping this from being a fully working system at the moment. I will put it all on Thingiverse once I have that one cracked

Photo below shows a carriage with three sensors and an amplifier.


Mike
Re: Piezoelectric disks for Z contact detect and bed levelling
March 04, 2016 06:59AM
That's very nicely thought out. You're getting 8 to 10V signal straight from the disk? If so, what's the purpose of the amplifier?
Re: Piezoelectric disks for Z contact detect and bed levelling
March 04, 2016 07:31AM
The peak and is reached only after about 100ms. Ideally the first couple of milliseconds should be used where it may be only a few 10s of millivolts. There is also three sensors connected in parallel and this attenuates the signal to about 33% of the single transducer value. The amplifier is actually a voltage amplifier with a gain of about 5 and a bandwidth from <1Hz to 2kHz followed by a comparator.



The high voltage is actually a bit of a problem. Hitting one of these quite firmly can give up to about 90V - enough to give the MCU a bit of a headache. I have a bunch of diodes on the same PCB to protect the circuitry from just that happening.

Having said the foregoing, the circuit is a bit of overkill. I am not sure how much it can be simplified but I think keeping the diodes and input resistors or something similar would be a good idea.

Mike
Re: Piezoelectric disks for Z contact detect and bed levelling
March 04, 2016 08:35AM
Hmm, that's really interesting stuff. My electronics is pretty basic, but I imagine clamping the input with a zener diode would be a good start. Ah, but the voltage swings both sides, so your diode arrangement makes more sense.

Perhaps keep the three channels independent to avoid the attenuation and see how quickly a comparator kicks in with 1V threshold. If I remember correctly the comparators use an open collector output, so you could get logical 'or' for free against an input pin with internal pullup. I'm not sure that you need ms response times for typical probing speeds against a sprung bed - plenty of give in the system to handle a little travel. Making sure you never miss the pulse might be a little more worrying - perhaps have a normal Z-min endstop set ~1mm below the probe contact height as a safety net?
Re: Piezoelectric disks for Z contact detect and bed levelling
March 04, 2016 09:22AM
I think that I will keep the three channels separate to get over the "three legged table" effect. Three comparators with open collector outputs can be "wired or" together. I seem to remember such a beast with powerful built-in input protection.

A bit more speculative is to use a single sensor on only one leg but with an active full-wave circuit so that upside-down pulses from the side furthest from the sensor are picked up. Although there would be no usable sensitivity from parts of the board, there may be enough left to get a worthwhile bed level.

The drawing below shows what I mean by the "Three legged table". With three sensors the outputs from the three sensors can cancel - but it also means that a single sensor could give almost all that you need.



Mike
Re: Piezoelectric disks for Z contact detect and bed levelling
March 08, 2016 07:56AM
It now all works very well and is exceptionally sensitive. Maximum deflection of the build stage at the corners is less than 0.05mm and contact pressure is less than 50gf maximum.

Repetier firmware reports an occasional "g29 leveling failed!" which I am investigating. Most likely causes are the mechanical or electrical noise.

The STL for the printable parts and a description, construction notes, schematics and even a Gerber file for the PCB will be found on Thingiverse at [www.thingiverse.com]
There is also a short video of one of my printers doing a bed mapping pogo-dance on Youtube at [www.youtube.com]

If anybody wants to pick this idea up and run with it please do. I would quite like to know how you get on but otherwise it is licensed under the full weight of the WTFPL - full details at at [www.wtfpl.net]

Mike
Re: Piezoelectric disks for Z contact detect and bed levelling
March 08, 2016 08:14AM
That sounds very good, and the video looks like magic. Definitely on the (embarrassingly long) todo list! Love the license, but couldn't you have found something a bit less restrictive? smiling smiley
Re: Piezoelectric disks for Z contact detect and bed levelling
March 08, 2016 08:29AM
I'm wondering if it would be useful to add a timer circuit so that the pulse duration at contact could be adjusted?

(Great write-up by the way - many thanks for all your work on sharing this)

Edited 1 time(s). Last edit at 03/08/2016 08:31AM by JamesK.
Re: Piezoelectric disks for Z contact detect and bed levelling
March 09, 2016 04:19AM
I don't think that the contact time is a problem. Generally the output will go low on contact and remain low for some hundreds of milliseconds or until the pressure falls - which only happens when the nozzle is lifted. Looking carefully the height map shows amazing repeatability, within ±10µ over many clean runs but variations of as much as ±300µ on a few spots. This behavior almost shouts mechanical causes and this may be a peculiarity of my printer: The adjusters are not mounted on the edges as almost every other printer has, but well in from the edges. My present guess is that this turns the build stage into a big overhead pendulum and the software is sampling at the wrong time - mechanical dynamics are much more difficult than simple electronics.
Two runs. Close points in green and very different in orange

The bed doesn't seem to be depressed any further on the bad ones. I haven't yet checked the Z carriage for stickiness but normal prints have shown no evidence of this.
I will fit another set of piezos and amplifier to my Rostock to see if this also has any problems

Mike
Re: Piezoelectric disks for Z contact detect and bed levelling
March 09, 2016 06:39AM
That's interesting. Do the 'bad' squares always occur at the same coordinates, or does the pattern vary randomly from run to run? I see Repetier has a setting for taking multiple readings at each spot, I wonder how that would affect things? Of course it might just cover up a problem that would be more interesting to understand and fix. Is there a test g-code to take multiple probe readings at a point and report the variation? (Looks like I was thinking of M48, sadly Marlin specific)

I ordered some parts last night so that I could have a go, but it will likely be quite a while before I get started. I ordered a couple of sizes of piezo discs as the 27mm look a bit big for attaching to my skeleton carriage. I'm guessing that the output signal probably scales proportional to the area of the sensor, so I may need to boost the amplifier gain to compensate for the smaller piezo. I ordered some quad op-amp and comparator packages so that I could play with independent channels, hopefully that will pick up a bit of gain again. Fun smiling smiley

How important is the adjustable pre-load? I was wondering if I could simplify the mount a little. I tend to run my bed springs close to coil bind, so I anticipate a lot of pre-load on the mounts - is there such a thing as too much pre-load on the piezo cells for this usage?

Edited 1 time(s). Last edit at 03/09/2016 06:40AM by JamesK.
Re: Piezoelectric disks for Z contact detect and bed levelling
March 09, 2016 07:14AM
While they do change a little, the 'bad' squares do seem to be in the much the same pattern. There are quite a lot of possible sources of the randomness, slop in any of the linear bearings, sticktion in the Z carriage, dynamic movement in the frame caused by movement of the X and Y carriages and movement from the outside world - not to mention electrical noise. I am planning to put in a patch panel so that I can see step and direction pulses from each of the axes as well as the amplifier output and the comparator output. I have only limited time to spend on it at the moment so it may be several weeks before there is much more progress.

I am pretty sure that smaller piezo disks will be fine. You shouldn't have to increase the gain at all even with smaller disks. I am fairly sure that I will drop the gain from 5 to 2 next time I get at the amplifier.

There is no real need to have an adjustment in the preload of the parallel mechanism, just to get it into contact. The rounded recess and polished dome screw were there simply to make sure that there is only one position of engagement. Again, the mount can be simplified but remember that if it is too stiff there will be less change sensed by the piezo while if too flexible then this will appear as unwanted vertical movement. The parallel mechanism allows downward movement but remains rigid until the bed spring pressure is overcome.

Just guessing with max pressure and the piezo disks but my guess is they are strong enough to take it and probably output until just before fracture point.

Mike
Re: Piezoelectric disks for Z contact detect and bed levelling
March 09, 2016 07:50AM
can you include the coordinates of the sensors in the table/image? Is there a relation between distance from the sensor and the point where the data is inconsistent?

Edited 1 time(s). Last edit at 03/09/2016 07:51AM by Frans@France.
Re: Piezoelectric disks for Z contact detect and bed levelling
March 09, 2016 08:31AM
The three sensors are at:-

P1 X=40, Y=50
P2 X=130, Y=90
P3 X=40, Y=140

Early on I did have a problem with the sensors which only happened because there was a bit of a mismatch, one sensor was giving nearly twice the output of the other two. Once I made sure the output was similar then the problem went away. I don't think that even unmatched piezo disks will give a problem if they are conventionally mounted towards the outer edges.

Mike.
Re: Piezoelectric disks for Z contact detect and bed levelling
March 10, 2016 07:54AM
Having just done several hundred M30 commands from Repetier Host, I do know some things.
  • Repeatability is tremendous - corners can vary up to ±20µm between runs in the same place but only quantization differences are found further in.
  • There is either mechanical noise or electrical noise causing sequences like M32 or M29 to fail. This is announced in the log by .
    11:31:08.046 : Error:z-probe triggered before starting probing.
  • The log shows nothing when there is reading that is wrong during an M32 sequence.
  • The flatness of the Ikea mirror that I put on as a build stage really sucks big time.
I will keep trying to isolate the electrical or mechanical problem before seeing if it has a software solution.

Mike
Re: Piezoelectric disks for Z contact detect and bed levelling
March 10, 2016 08:05AM
If the sensitivity is high the discs/amplifier will likely register vibration from movement of the axes, particularly the Y axis for a moving bed layout. I was wondering if that might cause problems during printing or if the software ignores any Z probe noise other than when probing. We might need to either de-power the amplifier when not probing or add an enable line (or reduce the sensitivity, but that seems a shame). There are before & after probing scripts that can be used to toggle a control line. What might be really annoying is if the software gets upset by false triggers caused by moves during probing - the only way around that might be to reduce sensitivity, or start hacking the repetier firmware.
Re: Piezoelectric disks for Z contact detect and bed levelling
March 10, 2016 08:28AM
I suspect that there is already a delay in the Repetier software between move and sampling but I want to understand the electrical and mechanical side as well as possible before asking Repetier for a tweak or software work.
Mechanically, the false triggering could be from the judder on the end of movement. Electrically there could be oscillation in the comparator - it was clean on the bench but being on the bench and stuck in the innards of a 3D printer are different things.

Mike
Re: Piezoelectric disks for Z contact detect and bed levelling
March 10, 2016 08:56AM
Hmm, if I have to add hysteresis feedback to those open drain comparators I ordered it will sure make or-ing them together messy. Hadn't thought of that.
Re: Piezoelectric disks for Z contact detect and bed levelling
March 10, 2016 09:15AM
I think that it is mostly mechanical. With only slow movements using a 3 point G29 I just got the following:

14:01:18.234 : Z-probe:9.63 X:40.00 Y:40.00
14:01:29.890 : Z-probe:9.68 X:140.00 Y:95.00
14:01:41.453 : Z-probe:9.58 X:40.00 Y:130.00
14:01:46.265 : Z-probe average height:9.63
14:01:46.265 : X:40.00 Y:130.00 Z:10.000 E:0.0000
14:03:11.109 : Z-probe:9.61 X:40.00 Y:40.00
14:03:22.718 : Z-probe:9.67 X:140.00 Y:95.00
14:03:34.281 : Z-probe:9.58 X:40.00 Y:130.00
14:03:39.093 : Z-probe average height:9.62
14:03:39.093 : X:40.00 Y:130.00 Z:10.000 E:0.0000
14:03:55.671 : Z-probe:9.61 X:40.00 Y:40.00
14:04:07.281 : Z-probe:9.68 X:140.00 Y:95.00
14:04:18.843 : Z-probe:9.58 X:40.00 Y:130.00
14:04:23.656 : Z-probe average height:9.62
14:04:23.656 : X:40.00 Y:130.00 Z:10.000 E:0.0000
14:04:52.859 : Z-probe:9.61 X:40.00 Y:40.00
14:05:04.468 : Z-probe:9.68 X:140.00 Y:95.00
14:05:16.031 : Z-probe:9.58 X:40.00 Y:130.00
14:05:20.859 : Z-probe average height:9.62
14:05:20.859 : X:40.00 Y:130.00 Z:10.000 E:0.0000
14:05:39.062 : Z-probe:9.61 X:40.00 Y:40.00
14:05:50.671 : Z-probe:9.68 X:140.00 Y:95.00
14:06:02.234 : Z-probe:9.58 X:40.00 Y:130.00
14:06:07.046 : Z-probe average height:9.62
14:06:07.046 : X:40.00 Y:130.00 Z:10.000 E:0.0000

Now very usable. Maybe a bit of polishing to do, probably only gain and some X and Y speed things.

Mike
Re: Piezoelectric disks for Z contact detect and bed levelling
March 11, 2016 12:03PM
I've been following this thread with interest, finding an accurate z-probe has been bothering me for as long as I've had my printer.

I've been playing with some 20mm piezo transducers and I think you might get a cleaner response by flexing the disk rather than squeezing it. I tried mounting my transducers over a hole so they were only supported by the edge and pressing on the centre and got a much sharper response than by putting them directly on a flat plane and squeezing. Unfortunately I don't have a DSO so I can't quantify my readings.

I need to gather some parts to build a sensor conditioning circuit then I'll be integrating these into my kossel mini.

Moriquendi
Re: Piezoelectric disks for Z contact detect and bed levelling
March 11, 2016 12:42PM
Interesting - that's certainly worth experimenting wtih. How did you observe the response without a scope?
Re: Piezoelectric disks for Z contact detect and bed levelling
March 11, 2016 12:56PM
Quote
Moriquendi
I've been following this thread with interest, finding an accurate z-probe has been bothering me for as long as I've had my printer.

I've been playing with some 20mm piezo transducers and I think you might get a cleaner response by flexing the disk rather than squeezing it. I tried mounting my transducers over a hole so they were only supported by the edge and pressing on the centre and got a much sharper response than by putting them directly on a flat plane and squeezing. Unfortunately I don't have a DSO so I can't quantify my readings.

I need to gather some parts to build a sensor conditioning circuit then I'll be integrating these into my kossel mini.

Moriquendi

You can see the response on a multimeter, even an old fashioned one will give a kick to the needle even though the piezo sees it as almost a short circuit.I don't think that lack of sensitivity is a worry as long as you are sensing a release of pressure - if you are attenuating the signal through a spring it may need amplification.

I have hooked the output of the amplifier to a logic analyser and while there is evidence of occasional oscillation, it resolves itself withing 30 us. Having said that, the mechanical sensitivity of the piezo disks is well into the region of rediculous. A 3.5 gram stainless steel ball dropped 4mm onto the build stage trips it every time although dropping it 3mm doesn't. A medium rap with the nuckles on the desk top 500mm away will also trigger it.

The recording below shows false triggering occuring on the top trace (amplifier output) during a move from X=160, Y=0 to X=0, Y=40. The pair of traces directly below are the Z steps and Z direction, then the Y steps and Y direction and finally the X steps and x direction.



I think that we are nearly there.

Mike

Edit: Just a quick point to stress that sensitivity is no problem. The piezoelectric ceramic used in a cigarette lighter is a close relative of that used in these disks and it jumps about 1mm so is about 3000V This does mean that you shouldn't forget to put some form of protection on the inputs of your amplifier.

Edited 1 time(s). Last edit at 03/11/2016 01:10PM by leadinglights.
Re: Piezoelectric disks for Z contact detect and bed levelling
March 11, 2016 01:54PM
Quote
JamesK
Interesting - that's certainly worth experimenting wtih. How did you observe the response without a scope?

I have an arduino program printing A0 to an LCD screen, very basic but allows you to see a little bit more than a multimeter.

LeadingLights, do you have any issues with stepper movements causing triggering? I've had several otherwise good Zprobe designs fail because they would trigger from the vibration of probing. This might be more of a problem with deltas as you're stepping three motors for Zaxis movements.

Moriquendi
Re: Piezoelectric disks for Z contact detect and bed levelling
March 11, 2016 02:02PM
Nice display from the logic analyser smiling smiley Which one do you use? I've been trying to persuade myself to replace my rather old PC scope (that has to connect to a printer port) with something a little more modern, and some of the combo scopes + logic analysers are very tempting. But usually you can get better, or at least more choice, from buying separates, and there are some very nice 4 ch scopes around these days (who'd have thought, four channel DSO's for reasonable money. That would have put a smile on my Dad's face!)

Moriquendi - clever idea to use an arduino.
Re: Piezoelectric disks for Z contact detect and bed levelling
March 11, 2016 02:21PM
@Moriquendi. Higher frequency noise from the motors is damped by the amplifier filter cutoff and problems are almost purely with movement noise from the X and Y carriages. There are a bunch of false triggers at the end of each X or Y travel and even more if both X and Y are active. I am fairly sure that just reducing the sensitivity a bit (a mosquito cough will trigger it at the moment) and by introducing a delay between the end of X or Y travel and the downward Z movement all should be well.

@JamesK. The logic analyser is a Saleae. it cost about £100 four years ago but is about $219 now. Their products page is at [www.saleae.com] It is well worthwhile downloading their software and manual to see what it can do.

Mike
Re: Piezoelectric disks for Z contact detect and bed levelling
March 11, 2016 02:54PM
Quote
leadinglights
@Moriquendi. Higher frequency noise from the motors is damped by the amplifier filter cutoff and problems are almost purely with movement noise from the X and Y carriages. There are a bunch of false triggers at the end of each X or Y travel and even more if both X and Y are active. I am fairly sure that just reducing the sensitivity a bit (a mosquito cough will trigger it at the moment) and by introducing a delay between the end of X or Y travel and the downward Z movement all should be well.
Mike

This is what bothers me, any (ok, any sensible movement) movement on a delta requires moving three axis, tuning that out has been a headache in the past. I'm assuming that the false triggers are a mechanical (vibration) issue rather than an electrical interference one?

Hopefully my better half will have taken my not so subtle hints and I'll be getting a Bitscope for my birthday.

Moriquendi
Re: Piezoelectric disks for Z contact detect and bed levelling
March 18, 2016 11:07AM
Quote
Moriquendi
....
This is what bothers me, any (ok, any sensible movement) movement on a delta requires moving three axis, tuning that out has been a headache in the past. I'm assuming that the false triggers are a mechanical (vibration) issue rather than an electrical interference one?
.....

Moriquendi

I eliminated electrical interference early on, the spurious triggering on a Cartesian printer is purely an artifact of the carriages in X and Y decelerating and the sensor output being sampled before the deceleration shake stops.
I have just done some preliminary trials on my delta with three 27mm piezoelectric disks and an improved amplifier design and I got no spurious reading whatsoever. I will put new data on Thingiverse when I have got it a bit more characterised but I am now no longer looking at other methods of bed leveling.

Mike
Re: Piezoelectric disks for Z contact detect and bed levelling
March 18, 2016 11:46AM
Sounds great - look forward to seeing what you did with the amp. Still waiting for my parts.
Re: Piezoelectric disks for Z contact detect and bed levelling
March 18, 2016 12:03PM
I reduced the gain from 5:1 to 2:1 and incorporated a bit of hysteresis. Also added an extra capacitor to the comparator and changed the LED driver to a P channel device as it is harder to pick up a LED flashing off than one flashing on.

PDF of schematic at .[www.dropbox.com]

Mike
Re: Piezoelectric disks for Z contact detect and bed levelling
March 18, 2016 12:06PM
Sounds good. I might try a full-bridge on the front end, but from what you've said it's probably unnecessary.
Re: Piezoelectric disks for Z contact detect and bed levelling
March 18, 2016 02:04PM
Both hardware and software filtering was crucial with my own FSR experiments at [www.tridimake.com]

Given your scope traces, can you just sample over a few ms (50-100 ms seems quite OK) and apply a vote to decide when the thing really triggers?
In my case I used a median filter on ~10 raw analog values, so as to discard outliers (mostly noise), and get a steady signal.

Also you may be able to physically dampen the vibrations that are most probably not in the same range as a real downwards push by the nozzle. I used neoprene pads with great success (though they expand with heat, which is no biggie if you tram the bed when everything is at temperature -- a good practice as you said would it be to avoid unwanted z offsets due to clogged hard cold plastic bits at the nozzle).

Edited 1 time(s). Last edit at 03/18/2016 02:05PM by jeremie.


Blog: [tridimake.com]
Designs: [www.thingiverse.com]
Profile: [www.linkedin.com]
Sorry, only registered users may post in this forum.

Click here to login