Author Topic: Scale down a +/-25V analog signal, but with only 5V power?  (Read 589 times)

0 Members and 1 Guest are viewing this topic.

Offline simonlasnier

  • Frequent Contributor
  • **
  • Posts: 293
  • Country: dk
Scale down a +/-25V analog signal, but with only 5V power?
« on: June 22, 2021, 09:54:09 am »
Hi all :)

I have been asking before (see https://www.eevblog.com/forum/beginners/use-tvs-diode-to-clamp-analog-voltage/ ) about how to clamp an analog voltage and with your very appreciated help, I ended up with the following circuit (attached).

The analog voltage source is a piezo sensor (a drum pad which is hit) which I have not much control over. Hitting is softly generates a pulse with low voltage, and trying with a few sensors it seems hitting it hard can make the pulse go to 50Vpp.

Inside the MCU I want to be able to make the difference between a soft hit and a hard hit, for now I am using:
1) a comparator to check if the voltage is above 0.6V
2) the ADC to check if the voltage reaches 3.3V

If 1) is activated I know there is a hit, and then 2) decides whether the hit is soft or strong.

This works fine in theory, and in practice it is actually decent but because the range is so little compated to the 50Vpp of the sensor, you have to hit the pad very softly to make sure the hit is not detected as "strong". In other words, trying to tap a rythm, like "H S S S H S S S H" (H=hard hit, S=soft hit), it is quite easy to make the soft hits just a bit too strong and then they are detected as hard hits.

So I was thinking - to improve the sensitivity I need to scale (with an opamp f.x.?) the analog input from 50Vpp to like 5Vpp - but my whole board runs at 3.3V, from an LDO converting USB 5V. I guess an opamp with rails at 0V and 5V would not like very much a signal that is 50Vpp?  ::)

What do you guys think, do you maybe have other ideas on how to detect the soft and hard hits (ideally without too much extra hardware on the board)?

Thank you!!

Simon
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 9233
  • Country: de
Re: Scale down a +/-25V analog signal, but with only 5V power?
« Reply #1 on: June 22, 2021, 10:58:04 am »
With a capacitive signal source one can use a capacitive divider: just add a capacitor (e.g. 10 nF range)  in parallel to the piezo. How much depends on the piezo capacitance. This will however also slow down the decay. Depending on the sensor one may want a high values resistor parallel to the sensor to get a defiend DC level in a more defined time.

For the protection part one ideally would have an additional resistor just before the ADC input of the µC.
As shown the extra diodes for clamping are in parallel to the µC internal diodes - so if the internal diodes have lower forward votlage they would still take most of the hit. 
 
The following users thanked this post: simonlasnier

Offline tooki

  • Super Contributor
  • ***
  • Posts: 6571
  • Country: ch
Re: Scale down a +/-25V analog signal, but with only 5V power?
« Reply #2 on: June 22, 2021, 04:09:26 pm »
With a capacitive signal source one can use a capacitive divider: just add a capacitor (e.g. 10 nF range)  in parallel to the piezo. How much depends on the piezo capacitance. This will however also slow down the decay. Depending on the sensor one may want a high values resistor parallel to the sensor to get a defiend DC level in a more defined time.

For the protection part one ideally would have an additional resistor just before the ADC input of the µC.
As shown the extra diodes for clamping are in parallel to the µC internal diodes - so if the internal diodes have lower forward votlage they would still take most of the hit.
In parallel? A capacitive divider is just like a voltage divider: two caps in series, and the output is the center.
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 3335
  • Country: pl
Re: Scale down a +/-25V analog signal, but with only 5V power?
« Reply #3 on: June 22, 2021, 05:36:55 pm »
Draw a schematic of your series version and explain how it works :P
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 15852
  • Country: gb
  • 0999
Re: Scale down a +/-25V analog signal, but with only 5V power?
« Reply #4 on: June 22, 2021, 05:53:12 pm »
With a capacitive signal source one can use a capacitive divider: just add a capacitor (e.g. 10 nF range)  in parallel to the piezo. How much depends on the piezo capacitance. This will however also slow down the decay. Depending on the sensor one may want a high values resistor parallel to the sensor to get a defiend DC level in a more defined time.

For the protection part one ideally would have an additional resistor just before the ADC input of the µC.
As shown the extra diodes for clamping are in parallel to the µC internal diodes - so if the internal diodes have lower forward votlage they would still take most of the hit.
In parallel? A capacitive divider is just like a voltage divider: two caps in series, and the output is the center.
The idea is to use the piezo's capacitance as one of the impedances in the divider.

Why not just use a resistive divider?

Bias the ADC input to half the supply voltage, with a potential divider and connect it to the piezo, via a suitable resistor, which will reduce the voltage further.

An op-amp buffer might be still needed to reduce the impedance seen by the ADC pin.

 
The following users thanked this post: simonlasnier

Offline simonlasnier

  • Frequent Contributor
  • **
  • Posts: 293
  • Country: dk
Re: Scale down a +/-25V analog signal, but with only 5V power?
« Reply #5 on: June 23, 2021, 07:12:32 am »
Thank you all for the replies!! 8)

@Zero999: this is super interesting, I did not think about using a simple voltage divider! I am a bit confused though how you could get *exactly* 3.3Vpp on the output...  :o
But it doesn't matter I get the idea.

I am not really interested in centering the voltage, I can just clip the bottom part of the pulse (code-wise it is easier if the resting voltage is 0V). So all I need are two resistors to divide the voltage, or maybe even one since the piezo already has a high impedance.

The MCU actually has an internal pull-down resistor which can be set to 400k or 10k. Unfortunately I cannot use these as resistor divider since the voltage would be clamped by the diodes *before* it would be divided by the voltage divider.

@Kleinstein: I would love to hear more about that - I cannot really see how it works though :D Just FYI the pulse is about 300Hz and last about 30ms - see image here: https://www.eevblog.com/forum/beginners/analog-signal-50vpp-into-3-3v-mcu/

For the protection diodes you are right, but these diodes are only here because the MCU does not have an internal diode to VDD. The current should not be a problem since the piezo already has a very high impedance (40k'ish) and there is the extra 1.8k resistor before.
« Last Edit: June 23, 2021, 07:22:42 am by simonlasnier »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 15852
  • Country: gb
  • 0999
Re: Scale down a +/-25V analog signal, but with only 5V power?
« Reply #6 on: June 23, 2021, 10:59:34 am »
Thank you all for the replies!! 8)

@Zero999: this is super interesting, I did not think about using a simple voltage divider! I am a bit confused though how you could get *exactly* 3.3Vpp on the output...  :o
But it doesn't matter I get the idea.
R1 = R2, so the voltage on U1's input will be half the supply voltage.

C1 blocks any DC path on the input. It probably isn't necessary, as the piezo will have a high DC impedance, but some manufacturers recommend not biasing it as DC, which is why included it.

R1 and R2 from the lower part of a potential divider, with R3 being the upper part. The supply voltage has a low impedance, so the values of R1 and R2 are in parallel, as far as the signal is concerned.

Put that into the potential divider formula and we get:
Vout = (Vin*R1||R2)/(R3+R1||R2)

R1||R2 = 51k/2 = 25.5k

Vout = (25*25.5k)/(360k+25.5k)

Vout = 637.5/385.5 = 1.65V

Because the peak AC signal voltage is 1.65V and the DC bias is 1.65V, the output will swing between 0V and 3.3V.

Quote
I am not really interested in centering the voltage, I can just clip the bottom part of the pulse (code-wise it is easier if the resting voltage is 0V). So all I need are two resistors to divide the voltage, or maybe even one since the piezo already has a high impedance.

The MCU actually has an internal pull-down resistor which can be set to 400k or 10k. Unfortunately I cannot use these as resistor divider since the voltage would be clamped by the diodes *before* it would be divided by the voltage divider.

Yes, you can use that resistor. Move D8 to D9's position and get rid of D9. Increase R23 to get the correct divider ratio, depending on the required ratio and the value of R24. Now the voltage at the MCU's input will be clamped to 3.3V, not the input to the potential divider.

Here's some websites which can help you calculate potential dividers.
https://www.random-science-tools.com/electronics/divider.htm
https://jansson.us/resistors.html
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 6571
  • Country: ch
Re: Scale down a +/-25V analog signal, but with only 5V power?
« Reply #7 on: June 23, 2021, 12:37:21 pm »
Draw a schematic of your series version and explain how it works :P
”my” series “version”? Google “capacitive divider” and you’ll find it. Looks just like a resistive voltage divider, but with caps instead of resistors. It’s a standard thing, not an invention of mine.
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 6571
  • Country: ch
Re: Scale down a +/-25V analog signal, but with only 5V power?
« Reply #8 on: June 23, 2021, 12:38:52 pm »
With a capacitive signal source one can use a capacitive divider: just add a capacitor (e.g. 10 nF range)  in parallel to the piezo. How much depends on the piezo capacitance. This will however also slow down the decay. Depending on the sensor one may want a high values resistor parallel to the sensor to get a defiend DC level in a more defined time.

For the protection part one ideally would have an additional resistor just before the ADC input of the µC.
As shown the extra diodes for clamping are in parallel to the µC internal diodes - so if the internal diodes have lower forward votlage they would still take most of the hit.
In parallel? A capacitive divider is just like a voltage divider: two caps in series, and the output is the center.
The idea is to use the piezo's capacitance as one of the impedances in the divider.
Sure. But that wouldn’t be putting a cap in parallel with it, it’d put it in series.  :-//
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 15852
  • Country: gb
  • 0999
Re: Scale down a +/-25V analog signal, but with only 5V power?
« Reply #9 on: June 23, 2021, 01:52:12 pm »
With a capacitive signal source one can use a capacitive divider: just add a capacitor (e.g. 10 nF range)  in parallel to the piezo. How much depends on the piezo capacitance. This will however also slow down the decay. Depending on the sensor one may want a high values resistor parallel to the sensor to get a defiend DC level in a more defined time.

For the protection part one ideally would have an additional resistor just before the ADC input of the µC.
As shown the extra diodes for clamping are in parallel to the µC internal diodes - so if the internal diodes have lower forward votlage they would still take most of the hit.
In parallel? A capacitive divider is just like a voltage divider: two caps in series, and the output is the center.
The idea is to use the piezo's capacitance as one of the impedances in the divider.
Sure. But that wouldn’t be putting a cap in parallel with it, it’d put it in series.  :-//
That's subjective.



 

Offline simonlasnier

  • Frequent Contributor
  • **
  • Posts: 293
  • Country: dk
Re: Scale down a +/-25V analog signal, but with only 5V power?
« Reply #10 on: June 23, 2021, 02:35:33 pm »
R1 and R2 from the lower part of a potential divider, with R3 being the upper part. The supply voltage has a low impedance, so the values of R1 and R2 are in parallel, as far as the signal is concerned.
Ha this is the part I missed (R1 also being part of the divider), it makes perfectly sense now thank you ;D

Yes, you can use that resistor. Move D8 to D9's position and get rid of D9. Increase R23 to get the correct divider ratio, depending on the required ratio and the value of R24. Now the voltage at the MCU's input will be clamped to 3.3V, not the input to the potential divider.
Yes thank you that would work you are right - but then what about the ESD protection?

(... I actually started this message about 2 hours ago, then experimented in LTSpice since and found out the following...)

I made the math and actually simply changing the internal resistor (R24) from 400k to 10k does what I need!! Hurra - no hardware change needed  ;D ;D

That attenuates the signal already by a lot, since the piezo has a high output impedance.
See the attached schematics. I could have R2 of about 15k, then the "top" of my range is the 50Vpp, but actually even with R2=0, the range expanded to about 36Vpp (i.e. you need to hit hard enough to generate 36Vpp for the hit to be detected as "hard").

I will test this in real life and see how it works  8)
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 15852
  • Country: gb
  • 0999
Re: Scale down a +/-25V analog signal, but with only 5V power?
« Reply #11 on: June 23, 2021, 03:52:12 pm »
R1 and R2 from the lower part of a potential divider, with R3 being the upper part. The supply voltage has a low impedance, so the values of R1 and R2 are in parallel, as far as the signal is concerned.
Ha this is the part I missed (R1 also being part of the divider), it makes perfectly sense now thank you ;D

Yes, you can use that resistor. Move D8 to D9's position and get rid of D9. Increase R23 to get the correct divider ratio, depending on the required ratio and the value of R24. Now the voltage at the MCU's input will be clamped to 3.3V, not the input to the potential divider.
Yes thank you that would work you are right - but then what about the ESD protection?
Via the suppression diode.


Quote
(... I actually started this message about 2 hours ago, then experimented in LTSpice since and found out the following...)

I made the math and actually simply changing the internal resistor (R24) from 400k to 10k does what I need!! Hurra - no hardware change needed  ;D ;D

That attenuates the signal already by a lot, since the piezo has a high output impedance.
See the attached schematics. I could have R2 of about 15k, then the "top" of my range is the 50Vpp, but actually even with R2=0, the range expanded to about 36Vpp (i.e. you need to hit hard enough to generate 36Vpp for the hit to be detected as "hard").

I will test this in real life and see how it works  8)
Be careful, LTSpice assumes voltage sources are a low impedance at all frequencies. In reality, your piezo transducer will be open circuit, at DC.

And I don't see why you're using both a comparator, as well as an ADC? Normally you use one or the other.
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 6571
  • Country: ch
Re: Scale down a +/-25V analog signal, but with only 5V power?
« Reply #12 on: June 23, 2021, 05:11:43 pm »
With a capacitive signal source one can use a capacitive divider: just add a capacitor (e.g. 10 nF range)  in parallel to the piezo. How much depends on the piezo capacitance. This will however also slow down the decay. Depending on the sensor one may want a high values resistor parallel to the sensor to get a defiend DC level in a more defined time.

For the protection part one ideally would have an additional resistor just before the ADC input of the µC.
As shown the extra diodes for clamping are in parallel to the µC internal diodes - so if the internal diodes have lower forward votlage they would still take most of the hit.
In parallel? A capacitive divider is just like a voltage divider: two caps in series, and the output is the center.
The idea is to use the piezo's capacitance as one of the impedances in the divider.
Sure. But that wouldn’t be putting a cap in parallel with it, it’d put it in series.  :-//
That's subjective.


Ohhh, ok, that makes sense now. Thanks for spelling it out for me!
 

Offline simonlasnier

  • Frequent Contributor
  • **
  • Posts: 293
  • Country: dk
Re: Scale down a +/-25V analog signal, but with only 5V power?
« Reply #13 on: June 25, 2021, 11:51:28 am »
Yes thank you that would work you are right - but then what about the ESD protection?
Via the suppression diode.
Ok that makes sense - also after a 150k resistor clearly there is no much current left so I think ESD is not an issue anymore :)

For other reasons (mainly because I am using the same input for other purposes), I decided to use the piezo impedance as voltage divider, with the internal 10k pull-down. I tested in practice now, and it works beautifully - the solution was so simple ha ha  ;D

I also experimented a bit by adding an extra capacitor to GND (C1), just after the 1.8k resistor, like some of you guys suggested! That also works very well and reduces the range even more. But I still want to be able to reach the "strong" hit (i.e. to create the 50Vpp you need to hit really hard) so I do not think that is necessary.

With C1=0, I need an input pulse of about 2x17.5Vpp to reach the threshold of 3.3V. With C1=68n, I need about 2x23Vpp to reach the threshold of 3.3V.

In any case - thank you all for the very helpful answers, as usual! See you for my next question ;)
 

Offline redben

  • Contributor
  • Posts: 21
  • Country: ch
Re: Scale down a +/-25V analog signal, but with only 5V power?
« Reply #14 on: June 25, 2021, 12:37:10 pm »
This thread is so informative ! I would never have thought that resistors inside the MCU might be used this way.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf