Welcome! Log In Create A New Profile

Advanced

Ultrasonic Z-height sensing?

Posted by Radian 
Re: Ultrasonic Z-height sensing?
February 22, 2014 06:55PM
I previously reported that the transducer signal has a large dependency on temperature. With some software adjustments to the probing procedure to look at differences rather than absolute values, I have found a way to get homing reproducible to about 0.05mm over the range 30 to 75C. There is a tendency to home slightly too high at higher temperatures. In order to allow this to be corrected, I'm considering adding a provision in the G31 command to specify a temperature at which the calibration was done and a temperature coefficient.

Of course this is using just one transducer. I will need to test it with several instances of the transducer before I am sure that this works. I expect the sensor module will need a mechanism to adjust the drive frequency to suit the particular transducer, since these transducers have quite a wide tolerance on the centre frequency.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Ultrasonic Z-height sensing?
February 23, 2014 04:57PM
Interesting, my pesky +ve homing offset was proportional to temperate as well.

I'm currently working with a series resonant oscillator circuit driving the transducer - my thinking being that forcing it to operate at a fixed frequency when it's resonant frequency varies so much with temperature and range doesn't make too much sense. Once it's free to resonate at whatever frequency environmental conditions dictate, extra information becomes available for interpretation. Obviously we now have resonant frequency, but the effects of temperature also shift this around - although to a lesser degree than range. Amplitude remains available for proximity but is now much better linearised against operating temperature. What's new is pulse width which also varies with proximity. So far I've only played around with a circuit on breadboard, next I will have to get it onto Ormorod and tabulate some readings.

The problem I see here is that this is a rather analogue solution - albeit a simple one (two transistors so far) yet the analogue sampling using the Duet PCB is shot through with noise. I guess this might be time to disable the on-board switcher and run 5V from the ATX.


RS Components Reprap Ormerod No. 481
Re: Ultrasonic Z-height sensing?
February 23, 2014 05:30PM
With a bit more work, I now have a circuit and software that homes accurately to a height that varies with temperature as expected due to the variation on the speed of sound. I think I was wrong about the resonant frequency varying with temperature, what I think is varying is the Q-factor.

The height variation can be compensated for in software. The expected variation is a little over 7.575um/K, or about 0.1mm per 13 degC. Unfortunately, the air temperature above the glass takes a few minutes to catch up with the bed thermistor temperature. So for accurate results, it will be necessary to hold the bed temperature steady for a few minutes before homing.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Ultrasonic Z-height sensing?
February 25, 2014 12:16PM
I set up a rig to see if the resonant frequency varies with temperature and it certainly does appear to. Firstly, here's the complete circuit I made to drive the ultrasonic transducer:



This oscillator circuit tracks the resonant frequency, producing around 8V pk. across the transducer. Zener D2 subtracts a constant from the peak to get within the A/D range. D3, R3, C3 hold the peak for sampling by the Duet. Note that the temperature coefs. of D2 & D3 cancel each other out quite nicely. This circuit does have an inductor which seems to be most people's least favorite component but it does a great job of increasing the drive voltage to the transducer and hence gives a bigger voltage difference between the first two constructive peaks - which is what I'm using as a direct substitute for the standard IR signal - so the bigger the swing the better.

To separate the effect of heating around the transducer from the heating of the drive circuit for this test I put the sensor on the end of some wires and mounted it on a Meccano platform simulating the heated bed



The sensor is held above the bed at a fixed height corresponding to the range at which the maximum constructive return occurs. The frequency counter then records the resonant frequency for a range of temperatures obtained by heating the metal plate with a hot air gun from below. I found it very important to prevent any air movement while letting the plate cool from around 100deg. down to room temperature. The air temperature near the face of the transducer (always close to half the bed temp.) was measured with a thermocouple and these are the frequencies vs. temperatures I recorded:



BTW. anyone is welcome to build the circuit above, which has the advantage of not needing any microprocessor firmware! The +3.3V, ground and output connections are identical to those found on the original IR board.


RS Components Reprap Ormerod No. 481
Re: Ultrasonic Z-height sensing?
February 25, 2014 12:40PM
Radian, that looks quite a nice circuit for those not wanting to use a microprocessor. Looks like the frequency change is about 1% over the 50C range you measured. How temperature-stable is the reading you get from it?

You might like to try that circuit with the ultrasonic sensor option (M558 P3) in my 57p-dc42 firmware. To improve discrimination between the first and second peaks, and to make my sensor less dependent on temperature, it tracks the minimum value returned from the sensor since the start of the homing process, then looks for the difference between the current value and the minimum so far to reach the threshold value you set with the G31 command. It also allows you to specify a calibration temperature and temperature coefficient, by adding T and C parameters to the G31 command.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Ultrasonic Z-height sensing?
February 25, 2014 05:15PM
Quote
dc42
How temperature-stable is the reading you get from it?

Unfortunately I haven't had the time to built it on to a circuit board yet - it's still on the breadboard!

I was just reading your new firmware topic - the Ultrasound options sound good, can't wait to try them out. But can you clarify for me what you mean about the threshold? Do you mean that the threshold value set by G31 should be obtained by recording the difference between max. and min readings found experimentally? Normally I would just find the maximum and set G31 a little bit below it (usually corresponding to the nearest round number of mm).

BTW, I've put the lid back on my venerable RS frequency counter now. It was 30 years old last year, and lately I've had to take off the lid and blow some hot air inside to get it going. Today I decided to find out why and it turned out a leaky battery had contaminated the underside of the PCB. Incredibly, this had oxidised away some of the solder joints so some components were lose. The affected solder wouldn't re-tin even with copious amounts of flux. I had to wind the iron up to 300C and heat the old solder while removing it with a fine wire brush. Anyway, that's fixed it properly now.


RS Components Reprap Ormerod No. 481
Re: Ultrasonic Z-height sensing?
February 25, 2014 06:00PM
Quote
Radian
But can you clarify for me what you mean about the threshold? Do you mean that the threshold value set by G31 should be obtained by recording the difference between max. and min readings found experimentally?

In z-probe mode 3, the primary reported G31 value is the difference between current and minimum raw sensor readings. The current sensor reading and minimum seen are reported as additional values (just as the peak reading for the modulated IR sensor was reported as an additional value).

I've enabled temperature parameters even for the unmodulated IR sensor setting (M558 P1), so you can use that if it suits you better.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Ultrasonic Z-height sensing?
February 26, 2014 05:14AM
Radian, did you attempt to measure the change in oscillation frequency as the probe moves towards the bed? It occurred to me that this may be another way of height detection. I was thinking of trying a one-transistor Colpitts oscillator (operating at the parallel resonant frequency of the transducer, rather than the series resonance that we are both using at present) and then frequency-counting in a microcontroller.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Ultrasonic Z-height sensing?
February 26, 2014 09:45AM
I wonder whether you could use the extruder thermistor reading (with the hotend cold) to aid in applying temperature compensation to the ultrasonic reading? I have noticed that if a cold nozzle is moved over a hot bed (e.g. to manually zero the Z height), the hotend temperature reading rapidly increases as the extruder is heated by the bed. Or perhaps use a figure derived from both the bed and hotend temperature readings. Sufficient accuracy might be achieved by empirically finding the correction figures for various temperatures and doing a table lookup in software.

Another method might be to do the height measurement only when the bed is cold, and then applying a correction that is dependent upon the bed temperature that is set - I should think that the difference in Z height between a bed at room temperature and the same bed after heating to a particular temperature will be constant. Not that there is a great deal of difference IME. If I zero the Z height with a cold bed, the nozzle will be about 0.1mm too low after the bed is at 110 degrees. If I wait till the bed has reached about 80 degrees before zeroing the Z axis however, it is still good enough to use when the bed has reached its print temperature of 110, so I should think that a few fixed correction factors for 2 or 3 temperature ranges would be sufficient.

Dave
(#106)
Re: Ultrasonic Z-height sensing?
February 26, 2014 09:49AM
Quote
dmould
I wonder whether you could use the extruder thermistor reading (with the hotend cold) to aid in applying temperature compensation to the ultrasonic reading? I have noticed that if a cold nozzle is moved over a hot bed (e.g. to manually zero the Z height), the hotend temperature reading rapidly increases as the extruder is heated by the bed.

In theory this is a vey good suggestion but i think i have read in another thread, that i can't find at the minute, that the hot end temp sensor is designed for the top end readings and the lower range of readings it gives can fluctuate and vary quite dramatically. If i come across the thread again i'll update this with a link. But if i am wrong please correct me.
Re: Ultrasonic Z-height sensing?
February 26, 2014 10:41AM
Quote
jy_oc_hx
Quote
dmould
I wonder whether you could use the extruder thermistor reading (with the hotend cold) to aid in applying temperature compensation to the ultrasonic reading? I have noticed that if a cold nozzle is moved over a hot bed (e.g. to manually zero the Z height), the hotend temperature reading rapidly increases as the extruder is heated by the bed.

In theory this is a vey good suggestion but i think i have read in another thread, that i can't find at the minute, that the hot end temp sensor is designed for the top end readings and the lower range of readings it gives can fluctuate and vary quite dramatically. If i come across the thread again i'll update this with a link. But if i am wrong please correct me.

It is inaccurate at the low end, but as far as I can see it is consistent (which is all we need as the inaccuracy can be corrected). I should think that an accuracy of +/- 5 degrees would be more than sufficient for this purpose.

Dave
(#106)
Re: Ultrasonic Z-height sensing?
February 26, 2014 10:56AM
I am applying corrections to the ultrasonic height calibration based on the bed temperature reading. This isn't ideal because the temperature at the top of the glass lags the temperature at the thermistor, but seems to be good enough. I may add a minute or so of dwell time in setbed.g between getting the bed up to temperature and z-probing.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Ultrasonic Z-height sensing?
February 27, 2014 09:17AM
Quote
dc42
Radian, did you attempt to measure the change in oscillation frequency as the probe moves towards the bed? It occurred to me that this may be another way of height detection. I was thinking of trying a one-transistor Colpitts oscillator (operating at the parallel resonant frequency of the transducer, rather than the series resonance that we are both using at present) and then frequency-counting in a microcontroller.

Yes the frequency does shift slightly if range is the only variable involved. The best shot at a Colpitts I've managed to build that works isn't any improvement over the series resonant feedback circuit above. The voltage swing isn't as big (~4V) and it requires two inductors (the one in the collector needs to be pretty big for this low frequency). Frequency-wise I don't think there's much in it but I'm currently modifying my rig to better compare the two.



If some of the component values look a bit odd, many of the calculated values didn't work and it took some fiddling to get this one up and running. I personally think Colpitts is better reserved for RF use unless you can spot any of my deliberate >cough< mistakes (For instance, the Ultrasonic transducer is itself a combination of series and parallel capacitance and inductance so it's a bit of an odd thing to jam in the feedback divider).


RS Components Reprap Ormerod No. 481
Re: Ultrasonic Z-height sensing?
February 27, 2014 10:22AM
Radian, I'm not convinced that circuit is a Colpitts oscillator at all. The designs I have used are similar to this . You might need to add an inductor in series with R3 for best results, and then probably a capacitor in parallel with R3. Even then it may well produce less voltage than your original circuit; but for producing an input to a frequency counter, it should be OK.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].

Re: Ultrasonic Z-height sensing?
February 27, 2014 01:48PM
I don't know what the definition of a Colpitts oscillator would be other than the use of a 180deg. phase shift amplifier and capacitive divider to shift another 180deg. to get things oscillating. Out of the two topologies I can only get the one I drew out above to work reliably... so far.


RS Components Reprap Ormerod No. 481
Re: Ultrasonic Z-height sensing?
March 03, 2014 04:12PM
From your topic Re: Anyone interested in a modulated IR sensor + fan control + illumination board?
Quote
dc42
One snag is that there has been a run on 10mm 40kHz ultrasonic transducers since I built the prototype, and neither Farnell nor RS has any in stock. This may delay the Kit 5s till sometime in April, unless I add £3 to the price and source more expensive ones from Mouser, or ship the Kit 5s without the transducer.

Are you using a Transceiver or a Transmitter? Receivers work pretty well too - AFAIK the only real difference is that transmitters have more mechanical damping to minimise ringing.

These suppliers also have a variety of devices:
Rapid Electronics
Conrad
CPC
(links to search results)


RS Components Reprap Ormerod No. 481
Re: Ultrasonic Z-height sensing?
March 03, 2014 05:12PM
Farnell have a few receivers left, and I already ordered one earlier today to try out. It will need to be driven at a different frequency because its resonant frequency is lower. I may need to find a way to configure the frequency from the Duet, unless I can get the on-board mcu to sense it automatically. However, enough people seem to be willing to pay a little more for me to order 10 or so from Mouser.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Ultrasonic Z-height sensing?
March 04, 2014 09:24AM
Hi dc42 - I've been using firmware version 0.57r-dc42 and can happily report that your modified Z homing sequence works well with the two-transistor Ultrasound circuit posted above. However, this is with the proviso that Homing is initiated when the nozzle is no more than 2mm above the bed. If the nozzle is any higher, homing always ends with the nozzle much higher than where it started from.

So, for example, I get a Zprobe reading of 880 at 4.5mm and the next high is 833 at 9.0mm. So I set the threshold as G31 Z4.5 P880. Then starting with the nozzle 1mm off the bed I initiate Home Z. This finishes with the nozzle 0.05mm off the bed. All good.

However, if I start homing from 5mm above the bed, it finishes with Z0 at 9mm off the bed. If I take it up to 4.5 (13.5 in reality) to see the Zprobe reading at this height it's 820, nowhere near the 880 threshold I set. So what caused it to trip there? Any ideas?


RS Components Reprap Ormerod No. 481
Re: Ultrasonic Z-height sensing?
March 04, 2014 10:12AM
Hi Radian,

I had similar problem when I was using unsuitable ultrasonic homing parameters. The modified homing sequence lowers at normal homing speed until 90% of the target Z probe reading is reached, then slows down and moves at most another 1mm. I could increase that 1mm to 10mm if you like, but z-homing from height would still be rather slow.

You might like to try the ultrasonic probe support in the firmware, by using the M558 P3 command. This monitors the minima that have been passed as the probe is lowered and looks for the difference between the current and minimum values, which provides better discrimination between the main peak and the next peak, and (for my sensor at least), lower sensitivity to temperature. See the section about cailbrating the ultrasonic transducer near the end of [miscsolutions.wordpress.com].

Edited 1 time(s). Last edit at 03/04/2014 10:13AM by dc42.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Ultrasonic Z-height sensing?
March 04, 2014 12:30PM
OK thanks dc42. I forgot to check your blog. I think I might be seeing a different response from the fixed frequency driver you're using (and I used before I settled on the resonant drive circuit). I quickly knocked out a python program to extract probe readings vs. height and pasted the output into a spreadsheet:



That's the result of 3 runs at the same temperature. The face of the Ultrasound source is 2mm above the tip of the nozzle. The plot is of nozzle height and the first maximum is at 4.5mm and the secondary peak happens at 9mm.


RS Components Reprap Ormerod No. 481
Attachments:
open | download - autozprobe.py (626 bytes)
Re: Ultrasonic Z-height sensing?
March 05, 2014 07:33AM
Hi Radian,

My sensor face is 3.05mm above the bed. The sensor had a grille on the front, so the actual piezo element is a few mm above the face. With the bed cold, I see the first peak (raw reading 870) at a nozzle height of 0.55mm, a broad minimum (410) at 3.4mm, the second maximum (670) at 4.9mm, and the second minimum (450) at 7.4mm. I use M558 P3 and G31 P600 Z1.0 T60 C0.003. So when homing from a height, the second maximum is 220 above the second minimum, and the first maximum is 460 above the first minimum. This gives plenty of discrimination between the two. I am driving the piezo at its series resonant frequency. The difference between the heights at the first and second maxima (4.35mm) represents half a wavelength.

If your first peak is at 6.4mm transducer face height and the second one at 11mm, then your half-wavelength is 4.6mm, and you should get another, larger peak at about 1.8mm face height if your transducer was lower. As this is such a low value, I suspect that your maxima correspond to my minima, and vice versa. This may mean that your oscillator is operating at the parallel resonant frequency, not the series one. Components L1 and C1 will also affect the resonant frequencies, as does the 4.7mH series inductor in my drive circuit. Does your oscillator still work if you increase L1 to 4.7mH and omit C1?

If you use M338 P3 instead of P2 then I think it should work for you, even though you a little less discrimination than I do.

PS - in my next firmware release, I will modify the fine z-homing to allow 10mm additional travel instead of 1mm.

Edited 1 time(s). Last edit at 03/05/2014 07:34AM by dc42.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Ultrasonic Z-height sensing?
March 06, 2014 11:42AM
Quote
dc42
If your first peak is at 6.4mm transducer face height and the second one at 11mm, then your half-wavelength is 4.6mm, and you should get another, larger peak at about 1.8mm face height if your transducer was lower. As this is such a low value, I suspect that your maxima correspond to my minima, and vice versa. This may mean that your oscillator is operating at the parallel resonant frequency, not the series one. Components L1 and C1 will also affect the resonant frequencies, as does the 4.7mH series inductor in my drive circuit. Does your oscillator still work if you increase L1 to 4.7mH and omit C1?

Yes it does, although harmonics start showing up in the waveform. With the two-transistor circuit driving the transducer, the reuslts are 180' out of phase when compared to direct-driving with the PIC chip. I've plotted both at different temperatures for comparison:



The upper four plots are the PIC chip drive, the lower four are the transistor oscillator circuit (raw Z-probe readings against height of nozzle in mm). For all plots, I mounted the Transducer on the hot-end assembly and put the electronics at the other end of the cable to eliminate temperature effects and to do both sets using the same transducer in the same location.

There sure is an awful lot going here. First up I can see that drafts are more of an issue at higher temperatures. The lower 100c plot was done with shielding to keep drafts to the minimum (It was the last run and I couldn't face re-doing all the others). One surprise is that the parallel resonant drive suffers from a greater reduction in the difference between minimums and maximums as temperature increases, and the fixed-frequency series resonant drive experiences a bigger spread of position over the same range of temperatures. Can you see anything I might be missing?


RS Components Reprap Ormerod No. 481
Re: Ultrasonic Z-height sensing?
March 08, 2014 03:31AM
Sorry, I did not fully understand - Is it ready for replication? or need further development?
Re: Ultrasonic Z-height sensing?
March 08, 2014 05:06AM
Hi karabas, good time for a summary so far: the two-transistor circuit I posted above [forums.reprap.org] has been Z-homing my Ormorod directly in place of the original IR sensor board since I put it together last week. I would say it's very reliable at low temperatures (<70c) but the effects of air temperature become more and more pronounced as it increases due to air movement.

The circuit makes use of a handful of cheap components that some people might already have at hand - so I had been hoping a few more people might try it and pool results. The transistors could be any general purpose amplifier for instance BC108 or 2N2222 as alternatives. The rest of the values need to be the same (5% tolerance or better) although L1 and C1 can be juggled a bit so long as the combination remains resonant at 40KHz (e.g. 3.3nF/4.7mH).

Ormorod uses the Z probe to home the X axis as well so a modification to the platform on the Z-motor mount may be required depending on where the Ultrasound transducer is fitted. dc42 shows an example of this kind of modification in the bottom photo of this post: [forums.reprap.org] Mine is a bit of bent Meccano that I'm too ashamed to show.

dc42 has rolled a superb all-in-one hot-end all-singing-all-dancing PCB that incorporates a driver for an Ultrasound source in addition to modulated IR sensing and other features but his Ultrasound driver and detection scheme are a little bit different to mine. Essentially though we are both using the fact that, at close range, a continuous wave from the source is measurably perturbed by constructive/destructive interference from it's reflection back from the bed surface. This can be seen in the earlier plots in this thread that look like a damped sine wave. Threshold detection can therefore be used to identify the occurrence of the peak and hence corresponding distance between moving hot-end and bed.


RS Components Reprap Ormerod No. 481
Re: Ultrasonic Z-height sensing?
March 08, 2014 12:35PM
What does happen at 120C? If I close my printer in a box to prevent side air moving will Z probe repeatable?
Re: Ultrasonic Z-height sensing?
March 08, 2014 02:47PM
I should point out that all the low-cost ultrasonic transducers I have looked at, and also the TCRT1000 IR sensor used in the original Z probe board and in my replacement, have an operating temperature range limited to 85C at the top end. So I can't recommend doing z-probing at bed temperatures much greater than this. For those printing in ABS, I suggest doing Z homing (and, if you want, bed-levelling) at 75C, and using one of the solutions discussed elsewhere on this forum to ensure that the bed height and level remain stable when the bed temperature is increased to 100C.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: Ultrasonic Z-height sensing?
March 10, 2014 06:10AM
Hi karabas, my printer has all original parts made in PLA so I've not dared use high bed temperatures even for testing. Air is a pretty good insulator though - if you could monitor the temperature at your IR sensor location (about 3mm above the bed) with the bed up at 120c that would be interesting to know. Otherwise we're just guessing really, but you would need to make sure the air was very still. I really have no idea if it would get above 80c. If you are using dc42's firmware (why would anyone not be using it?!?) your hot-end thermistor could tell us this temperature once it stabilized.

I think the maximum operating figure of 85c is somewhat generic for many commercial (non-industrial) specifications, it might not be the actual "brick-wall" for using the transducer. What really counts, as far as I've seen, is the movement of the air. If I fan the air around with everything at room temperature there's absolutely no detectable change to the probe reading. As I step-up the heat in the bed, the reading becomes more variable as I fan the air (introducing a mix of air masses ranging from ambient to bed surface). The hotter the bed the more pronounced the effect. However, inside a full enclosure, I would expect a far more settled reading. Natural Convection could make it take a long time to stabilize though.


RS Components Reprap Ormerod No. 481
Re: Ultrasonic Z-height sensing?
March 10, 2014 06:18AM
Have you tried ultrasonic at higher frequency, like 320kHz? That should have much lower dependency on temperature. Of course, it will be harder to determine how many wavelengths you are from the bed.
Re: Ultrasonic Z-height sensing?
March 10, 2014 06:39AM
Not so easy to get hold of a 320kHz source and as you say Flyskyhy, the wavelength drops to 1mm so finding the right maximum is going to be all but impossible. Echo timing might be a better proposition but the ring-down for this frequency would still be subject to too large a blindspot. 30mm seems to be the ballpark figure for commercial U/S range detectors.


RS Components Reprap Ormerod No. 481
Sorry, only registered users may post in this forum.

Click here to login