4

I am making a device that measures temperature and vibrations and records the values onto an SD card. It will be a standalone device.

The hardware used: - Arduino Uno - PCF8523 RTC clock - MAX3186 + PT100 RTD temperature sensor - Adafruit data logger shield - Typical bare piezo sensor

For the vibrations, a piezo sensor is used. Because it can produce a signal in two directions, I decided to use a voltage divider to offset the signal from GND. Two 5.1K resistors are connected from the piezo negative terminal to 5V and GND. A 1M resistor is placed in parallel with the piezo sensor. The positive terminal is connector to analog input 0.

Piezo circuit

The sensor is read 100 times per data point, the maximum and minimum values are stored and the final value is set to be the difference between the two (two times the amplitude).

USB

9V wall adapter

When the system is powered via a laptop USB port, the resting value has a jitter of a few bits. When a 9V wall adapter powers the arduino, the jitter is +/- 30 bits. Any small vibrations disappear in the noise.

USB with piezo

USB with piezo

9V with piezo

9V with piezo

9V without piezo

9V without piezo

I would like some help to find the best way forward.

edit 29-10 17:53 Added better plots

edit 30-10 17:53 Added plots for 2.5V and 3.3V lines

  • Have you got an osci to check if the 5 V from Arduino Vcc is smooth or "rippled"? Did you use the AVRef Voltage reference? This should be stable. How long are your wires? Can you shorten them for the sensor and the resistors to make the antenna minimal? A schematic and a photo of you setup would be helpful. ;-) – Peter Paul Kiefer Oct 29 '19 at 16:55
  • @PeterPaulKiefer Sorry I don't have a oscilloscoop to check. I'm using the default analogread, I haven't changed the reference settings. Wire to piezo is roughly 75 cm and shielded, shield is not connected to GND at the moment. Strange thing is that the whole set-up is exactly the same for both plots but when powering the arduino with 9V I get the huge jitter issue. I've added a schematic for the piezo. – YouKnowNothingJohn Oct 29 '19 at 17:12

2 Answers2

4

The 9V wall adapter is in most cases a switched power regulator with a high frequency. That's like a radio transmitter direct beside the wire. So there is nothing mystical, when the smooth USB Voltage does not show problems but the "radio transmitter" does.

There are two ways the power supply can impact: over radio wave or as ripples over the regulated Voltage of your Arduino.

I asked myself, which one it is (or even both)? If you use the extra regulated analog voltage reference (AREF) as the +5V on your Voltage divider, it would be more likely that the problem comes through the air. Then it would help if you activate the shield of the wire by connecting it to GND.

If a rippled supply voltage is the problem, you have to smooth it. Perhaps with a low pass filter (a big Elko between Vcc and GND).

Perhaps you have a solenoid iron core. Then you can wrap the wire to the piezo sensor a few times around it (near the A0 Pin). This technique is often used in computer power supplies to prevent the switching frequencies from escaping to the public power lines.

Peter Paul Kiefer
  • 1,798
  • 7
  • 10
  • To be clear, I'm using the regular 5V Vcc for the voltage divider. Is there a better, regulated voltage I can use on the board? I was under the impression that the Aref pin can only be used to supply an external reference. Can I use that pin to get a regulated 5V as well or have I misunderstood? How about using the 3.3V? – YouKnowNothingJohn Oct 29 '19 at 20:00
  • From my measurements, I know that the regular Vcc is poorly stabilized. If the power supply has ripples, often I found attenuated ripples in the Vcc also. The VREF is a special pin that be programmed to provide a reference voltage for the ADCs. see https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference/ . What I meant was connecting the VCC to VREF and set the analog reference to EXTERNAL. Than the voltage reference and the VCC have ripples. Because the digital value is obtained by comparing both voltages the error might be cleared. But it is just an idea. ;-) – Peter Paul Kiefer Oct 30 '19 at 09:26
  • You can also build a external stabilized voltage add it to VREF and set the reference voltage to EXTERNAL. And you have to use this Voltage for your piezo reference. But it's only needed if the problem is caused by ripples on VCC. If the problem is cause by EMI you must try to filter the piezo voltage before it reaches the A0 input. I'm busy this morning, so I add just two comments. In the evening I'll edit my answer to order the information. My English is not very well, so I might be fairly unclear. ;-) – Peter Paul Kiefer Oct 30 '19 at 09:35
  • Peter, not a problem, you have been very helpful so far! I now get what you mean with supplying Vref with Vcc. I did some tests on the voltages, I connected 5V to A1 and 3.3V to A2 and did the same measurements. I took 100 samples and show twice the amplitude (difference between min and max values). USB https://imgur.com/rmhgnRB 9V https://imgur.com/MQEMvc9. I think a potential solution might be to use the 3.3V from the datalogging shield as it looks to be very stable! Although strangely, the 5V plots don't show a huge difference between the two power sources... – YouKnowNothingJohn Oct 30 '19 at 11:35
  • Actually, I have done the plots again and they now look like this. USB: https://imgur.com/ImOdHyC. 9V: https://imgur.com/JWyaxo2. I'm not sure where the difference comes from but these seem to make sense. So judging from these plots, I should have no issues running the piezo with the 5V via a voltage divider. I'll see if I can also measure the voltage after the divider. – YouKnowNothingJohn Oct 30 '19 at 12:57
  • 1
    Here are some plots of the 2.5V line with and without piezo. USB with piezo: https://imgur.com/mIbWWd4. 9V with piezo: https://imgur.com/JoxX7BS. 9V without piezo: https://imgur.com/buD1Fc0. Strange... – YouKnowNothingJohn Oct 30 '19 at 13:20
  • The last plots are definitely a hint, that the problem depends an the long wire to the piezo. If you remove it the signal is smooth. Have you tried to ground the shield? – Peter Paul Kiefer Oct 30 '19 at 13:28
  • A new plot gives even more insight... 9V with and without piezo: https://imgur.com/qEnOS7T. I manually connected a new, short wired (40 mm) piezo to the circuit and then disconnected it again. You can see the effect on the 2.5V... – YouKnowNothingJohn Oct 30 '19 at 13:53
  • A another plot where I connect and disconnect the long wired piezo, looks very similar. 9V source. https://imgur.com/TK63aF7 – YouKnowNothingJohn Oct 30 '19 at 14:02
  • Sorry it has been getting late and I'm too tired to edit the Answer as promised. But I'm a bit irritated from what I see in the new plots. Shorten the wires increases the effect. It seems as if the power supply sends out waves and the piezo receives them, Perhaps it acts like a crystal oscillator, I've never heard of such effect before. Perhaps that's a well known behavior or I misinterpreted it wrong, but it's sure, we are beyond my limits. From what we know now, this is a question for the electronics forum in SE. – Peter Paul Kiefer Oct 30 '19 at 21:07
  • Peter thank you so much for your patience and help. I have finally found a solution for my problem and it turns out that connecting the shield from the piezo wire to Arduino GND was enough. I feel silly for not trying this before, I set my sights on voltage ripple because the USB connection did not have any problems with noise. I actually made a mistake with the short wired plots, I redid these in a proper way with a connector and didn't see the jitter.... – YouKnowNothingJohn Nov 01 '19 at 11:18
  • You're welcome. I'd expect that you tried out the grounding, because you did not mentioned it again. So it's a bit of my fault also. I should have asked you one more time. In the beginning that solution was my favorite. But the conversation was very interesting and I had some new ideas of how the used e.g. a second UNO the simulate a very low frequency oscilloscope. I've learn much, and now it's my turn to thank you. – Peter Paul Kiefer Nov 01 '19 at 11:45
1

In addition to what Peter Paul Kiefer suggests, you will also want to place an RC low-pass filter, between the piezo transducer, and the analog input.

You mention that you'll be sampling this value 100 times per second. So the cutoff frequency, for the filter, should be set to 50 Hz (the Nyquist frequency).

  • 1
    I don't think the OP takes samles with 100 Hz. He only said that he takes 100 Samples to choose the maximum and minimum values from it. I believe he take it at the highest rate that's possible. I thought about low pass filters too, but as he used the piezo for shock detection I expect a part of the frequency spectrum (of the piezo pulses) in the same range as the EMI. So it's definitely worth a try, but I don't expect good results. – Peter Paul Kiefer Oct 31 '19 at 08:44