voltage dividing digital signal into LMV331 comparator input

Go To Last Post
18 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys, 

I've got an ATtiny1617 running on 3v. I have a 5.1v digital signal which from a proprietary protocol which transitions between 2.1V low and 5.1v high. I want to feed this into the attiny as a digital input.

My current thought was to feed the signal through a voltage divider before feeding the voltage divider output to a LMV331 comparator. However, I can't see any specifications on the LMV331 datasheet to allow me to work out whether this will be OK for the required signal speed. 

Ideas?

Bevan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What is the bit rate?

 

What is the transmitter? That is, what kind of load can it drive?

 

Is it a 1:1 communications link (1 transmitter, 1 receiver, only) or is it some kind of multiplex (1 tx to many rx or many tx to 1 rx)?

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Thu. May 23, 2019 - 05:20 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bevanj wrote:

an ATtiny1617 ...feed the signal through a voltage divider before feeding the voltage divider output to a LMV331 comparator.

 

Doesn't the t1617 have three internal comparators?

 

 

Each AC can have it's own Vref. Divide down your signal with a pair of resistors and feed to an AC. Feed the AC with a suitable internal reference. Job done. 

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

Last Edited: Thu. May 23, 2019 - 05:42 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Brian is correct.

 

With a simple resistor divider, if you attenuate 5.1V down to 3V (a ratio of 3/5.1 = 0.588), then the 2.1 volts will be attenuated to 0.588 * 2.1 = 1.24V. A comparator will easily "slice" that with a comparison voltage of 2.1V.

 

The internal comparator will be fast enough for almost any sane (relative to the MCU clock) bit rate.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't have the bitrate handy, but will throw a scope at it again tonight. From memory it is fairly fast. 

Brian, I can't use any odd pin. The proprietary protocol I'm working on is incredibly similar to SPI, and in turn I am using the dedicated Attiny SPI pins.

The Attiny is behaving as the slave, so I need to plumb the 2.1v/5.1v clock signal into the applicable SCK pin. Will doing what I have described above with an external comparator (like the LMV331) work? I can feed the comparator a reference of 2.5v, and then feed the comparator output to the Attiny SCK pin? 

Last Edited: Thu. May 23, 2019 - 07:54 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Actually, looking at the LMV331 datasheet: https://www.ti.com/lit/ds/symlink/lmv331.pdf

Do I even need the two voltage divider resistors before the comparator? From what I can see, there are no restrictions on the + or - input with respect to Vcc. The only restriction is they must be within +/-5.5v of each other. Does this sound right?! 

Can I run the LMV331 comparator off 3v, then have the - ref at 2.5v, then the 2.1V-5.5V signal into the + pin without damaging things? 

Bevan

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bevanj wrote:

Brian, I can't use any odd pin. The proprietary protocol I'm working on is incredibly similar to SPI, and in turn I am using the dedicated Attiny SPI pins.

 

 

Have you used all your pins? You could route externally. Or, and I have no idea if this is possible, use the LUTs or Event System.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bevanj wrote:
I have a 5.1v digital signal which from a proprietary protocol which transitions between 2.1V low and 5.1v high.
Subtract 2.1V.

Difference Amplifier (Subtractor) Circuit (Rev. A)

via Analog Engineer’s Circuit Cookbooks | Op Amp Circuits | ADC Circuits | TI.com

if unable to access TI.com, try

AN990 Analog Sensor Conditioning Circuits - An Overview (page 4)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One (potential) problem with your external comparator is speed. Most low power comparators are relatively slow. With a 5V power supply, the switching delay with over-drive that you are likely to have is 0.3us. 

 

BUT, if you power it from 3.3V, the delay  will be longer, closer to 0.4us. 

 

According to the Absolute Maximum Ratings, no  input can exceed Vcc. So, if you power it from the same  supply as your micro, then you still have to attenuate the signal. If you do attenuate, then it is still quite adequate to switch the comparator. You MIGHT have to compensate the voltage divider depending on the resistance values you use and depending on the capacitance at the node connecting to the comparator input (and the signal speed).

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Thu. May 23, 2019 - 03:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also, look at level shifter parts....you have a 3V swing & 3V micro, the signal just needs shifted down.   

You could almost get away with using 2-3 diodes & resistor to gnd, to simply drop the voltage by about 2 V

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


You can make a level shifter with a FET, like a 2n7000, and two resistors.  I use 5.1k on the 5 V side and 3.3 k on the 3 volt side, because I use them mainly for I2C and those are good values for the pullup resistors.  Many level shifter breakout boards you can buy use 10K for both.  The fancy ones use special chips designed for level shifting.  This is an old standby circuit.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As far as I can tell, those "level shifters" ONLY shift the logic-high. This would not work well where the input logic low is 2.1 while the out side Vcc is 3.3.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You may be right.  I have only used them for shifting I2C and UART between 3.3 V and 5 V, and they seem to work fine for that.  As you say, probably not good for TTL.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

not very elegant ...but crudely gets the job done (for 3.3V logic)

 

output taken at R5...should easily trip 3.3V logic

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. May 26, 2019 - 05:21 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Here is another way to do it if you want to play with transistors

    The gate threshold should be 1V or less. You can play with the resistors for more current if you can afford in order to minimize the MOSFET capacitances impact. The MOSFETS never enter saturation so it should be fast.

You need to calibrate R1 and R2 in such a way that the output high to be about 3V. The circuit, or at least the right part of the red curve should be close to the ATTiny IC to avoid trace capacitance.

 

    Both this schematic and the one presented by avrcandies have low hi-low transition performance because are based on a resistor to ground. This schematic offer a high impedance to the input signal. You can find cheap dual mosfet parts like in SOT363 or even smaller. Than add two resistors. Another advantage is that if the 3V power is down, the output is limited by R1, so no impact on the transmitter.

 

To speed up the hi low transition, you can add one more transistor, one resistor and one cap like in the picture below:

It becomes probably not practical these days with so many ICs that can do better. There must be some fast comparators out there.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First, use a resistor- Schottky signal diode combination  to remove the data voltage that is higher than the Vcc for the AVR.  Now your data signal switches between 2.1V and ~3.5V (which I'm going to assume is OK even though it is about 10% above the 3.3V Vcc).  

 

Use a two-resistor voltage divider to get a +2.8V from the 3.3Vcc.  Feed this into one pin of the internal Analog Comparator of the Tiny1617.   Feed the modified data signal into the other Analog Compare pin.  Use a timer to measure the time between the rising and falling edges reported by Analog Comparator Output.  Use the application software to reconstruct the data sequence from the timer's measured values between transitions.

Last Edited: Sun. May 26, 2019 - 08:39 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bevanj wrote:

I've got an ATtiny1617 running on 3v. I have a 5.1v digital signal which from a proprietary protocol which transitions between 2.1V low and 5.1v high. I want to feed this into the attiny as a digital input.

That's a 3V swing, so you just need to move the zero point.

Choices are a simple divider, that centres on the AVR digital threshold, or you could look at a LED as a 2V zener. (see #14 above, for a more-parts variant)

Then you just need a LED+(eg) 22k to gnd

LED capacitance gives speed-up and couples MHz digital and the pull down defines a logic 0.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Interesting idea to use an LED as a sort-of-Zener, and

you can also see when data is being received!

 

--Mike