Notifications
Clear all

Shifting, Magnifying Voltages

18 Posts
4 Users
9 Reactions
281 Views
Inq
 Inq
(@inq)
Member
Joined: 3 years ago
Posts: 1929
Topic starter  

I'm not even sure these are the correct terms for what I want to do... it's just the way I think of it.  I'm also not sure if it's even possible with circuitry... I'm just hoping ignorance is not bliss in this case.

Question

Can voltages be shifted and scaled-up and even if they go into a negative voltage, say 1.875V goes to -3.3V and 3.125V goes to 3.3V.  The equation for this is a simple line:  

y = mx + b

Vout = 5.28 * Vin - 13.2

 

Details (only if you want to know why I'm asking) 😆 

Although this question is related to the topic:  Help with high current Hall Effect sensor (HSTS016L) I believe it justifies a separate topic for a more generalized usage.  Here is the problem:

HSTS016L

The sensor outputs an analog voltage based on the amount of current it senses.  In the case of this version, it ranges from 1.875V when sensing -200A to 3.125V when sensing +200A.  If set up on a 3.3V microcontroller, with a 10bit A2D pin, it is only going to return values to the software from 582 to 970.  This is a crappy resolution of:

Resolution = 400 Amps / (970 - 582) = 1.03 Amps/unit

To improve this, I used the only method I know will work.  I got a 16bit ADS1115 A2D board.

image

As I need 4 channels anyway, this is a pretty good solution.  The problem with this solution is even though this is a 16 bit device, it accepts voltages in this case of -3.3V to 3.3V and returns a signed 16 bit integer (-32768 to 32767).  The sensor : AS1115 only returns 1.875V : 18618 to 3.125V : 31029, so the resolution is improved to:

Resolution = 400 Amps / (31029 - 18618) = 0.032 Amps/unit

This is probably good enough for my purposes, but I wanted to explore alternatives.

  1. I could go to a 24 bit A2D board, but those jump up in price significantly.
  2. Using some cheaper components can sensor voltage be shifted and scaled?  If they can to the same range that the AS1115 A2D converter accepts then the resolution is greatly improved to:

Resolution = 400 Amps / 65535 = 0.0061 Amps/unit

Is #2 possible?

 

Thanks,

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
Quote
(@davee)
Member
Joined: 4 years ago
Posts: 1959
 

Hi Inq,

  Just some basic principles for now ... choosing components and detailed circuits will take longer.

RE: Can voltages be shifted and scaled-up and even if they go into a negative voltage, say 1.875V goes to -3.3V and 3.125V goes to 3.3V.

  Yes.

  --------------------

  Measuring voltages is a bit like measuring heights. A voltage is always measured with respect to another point on the circuit. For convenience, we often define a point on the system as being at 0V, and maybe call it something like ground or earth, but the choice of point is arbitrary.

This means that sometimes, it is possible to shift a voltage, by inserting a 'known' voltage source in series, so that the combined voltage is the algebraic sum of the two sources. (Think of climbing (or descending) a ladder, so that your feet are now at different 'ground' level.)

---

An 'everyday' example would be a torch/flashlight powered by three 1.5V cells in series, to provide a summed voltage of 4.5V.

However, if the user inserts one of the cells 'backwards', the algebraic sum becomes  1.5 + 1.5 - 1.5 = 1.5 (V), so that the bulb only receives 1.5V

There are occasions, this principle can be beneficially applied, but in the torch case, it relies on each cell being an independent source of 1.5V. A common circuit situation will only have a single voltage source, of say 5V, with a 'fixed' 0V reference point, so it may be difficult or impossible to contrive the required 'known' voltage source.

In some cases, a second isolated voltage source, possibly including an isolating transformer may be created, to provide this additional voltage source. However, this is usually more appropriate when the required voltage is also a substantial power source for something.

--

However, this principle is often used in electronic circuits, albeit it may be 'disguised', such as a resistor and capacitor connected in parallel, with the average voltage drop across the resistor being an effective voltage source.

---

The other common approach to shifting a voltage is based on an operational amplifier (op-amp). A basic op-amp has inverting (-) and non-inverting (+) voltage inputs. When the op-amp is connected in one of conventional arrangements, using resistors, then the output will be proportional to the algebraic difference of the input voltages.

A 1st glance to find an article discussing this, from TI https://www.ti.com/lit/an/sloa097/sloa097.pdf

includes:

image

R1 and Rg2 form a potential divider, to provide a 'known voltage source', as a fraction of Vref, which is applied to the inverting terminal. This means that if the voltage at the junction of R1 and Rref is 1.5V, then it will subtract 1.5V from the voltage applied to Vin, the non-inverting input. Thus, it is acting as a voltage shifter.

An 'upmarket' version of this principle uses three op-amps, to form an 'instrumentation amplifier'.

e.g. from Wikipedia ... https://en.wikipedia.org/wiki/Instrumentation_amplifier

Op Amp Instrumentation Amplifier.svg

This circuit can be built from 3 op-amps, or bought as a single device.

------

So far, I have only discussed shifting the voltage. The other aspect is scaling it, i.e. multiplying it by a known factor, which may be greater or less than unity.

To reduce the voltage, say changing 0-5V range to 0-3V range, by multiplying by 0.6 (or dividing by 5/3 1.67), the simplest solution is a potential divider, based on two resistors. In some cases, a potentiometer is used, preset to provide the required divider fraction. ( https://en.wikipedia.org/wiki/Voltage_divider)

-----

To increase the voltage, say changing 0-2V range to 0-3V range, by multiplying by 1.5, then an operational amplifier can be used by choosing the appropriate resistors.

Wikipedia introduces this topic on page https://en.wikipedia.org/wiki/Operational_amplifier_applications, with the section:

image

--------------------

By now, you will have realised that shifting the voltage and multiplying the voltage, may be combined into a single circuit block, possibly just using one op-amp, but the choice of resistor values, etc. tends to interact with each other. This is discussed in my TI reference above, https://www.ti.com/lit/an/sloa097/sloa097.pdf

So, at least for the first 'paper' design, I suggest you regard them as two circuit blocks, the first shifting the voltage, the second setting the gain, and then consider whether they can be combined.

--------

So sorry, if you were hoping for a simple 'build this circuit answer', but I hope this provides a few clues as to where to find the answers for any such project. Hopefully, I will get around to putting some more specific ideas on paper.

-------

I do not mean to insult your intelligence and experience, but maybe as a useful comment for another reader with less experience, I'll add a reminder that as with practically every measurement task, there are 'cheap and cheerful' tools, that may be good enough, and others with more finesse, precision and cost. This applies to op amps, resistors, voltage references and so on. So you need to have some ideas as to what you are looking for.

In particular, in some cases, looking for small changes is more important than the absolute values, and vice versa. Getting a reasonably monotonic readout scale to (say) 12 or more bits precision is one thing. Getting absolute values to say 10 bits accuracy, implies 1 in 1024, or 0.1% is a different matter. Maintaining 0.1% accuracy, when the temperature of the measuring system varies by 20 degC, is even harder.

--------

Best wishes, Dave


   
Lee G, Inq and huckOhio reacted
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 6 years ago
Posts: 2330
 

@inq

As Dave explains you can shift a voltage up or down and magnify a voltage (amplification) using an OP amp or in ye old days a transistor.

Before ICs came along building an operational amplifier out of discrete components was one of the circuit projects I remember doing.

You might also consider monitoring battery temperature.

Forgive me if you have already searched the internet for suggestions. It is common to get an "answer" in the form of links.

This one looks similar to your project and same sensor.

https://www.utgjiu.ro/rev_ing/pdf/2022-2/10_Grofu%20BATTERY%20CAPACITY%20TEST%20SYSTEM.pdf

https://www.robotics.org.za/HSTS016L-10A


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 3 years ago
Posts: 1929
Topic starter  

Aside,

It is very frustrating on the forum when I take hours to write a reply (arguable with life interruptions... pet the dog, kiss the wife and coffee) to finally hit the "ADD REPLY" button and get the message that, "Something went wrong with your entry."  Hitting backspace simple returns you to the Login screen with a complete loss of your work.  When I was last here (seems like years ago) I always remembered to copy to the clipboard before hitting the button.  This time I forgot... my sailor's mouth got a full workout.

 

Hey Dave,

Glad you chimed in.

Posted by: @davee

Measuring voltages is a bit like measuring heights. A voltage is always measured with respect to another point on the circuit. For convenience, we often define a point on the system as being at 0V, and maybe call it something like ground or earth, but the choice of point is arbitrary.

It always bothered me to hook up high voltage and/or high current device's ground to these little 3.3V project's ground.  That is something I still need to unlearn.

Posted by: @davee

However, if the user inserts one of the cells 'backwards', the algebraic sum becomes  1.5 + 1.5 - 1.5 = 1.5 (V), so that the bulb only receives 1.5V

You mean... a black hole doesn't open up by putting a battery in backwards??? 😆 

Posted by: @davee

So sorry, if you were hoping for a simple 'build this circuit answer', but I hope this provides a few clues as to where to find the answers for any such project. Hopefully, I will get around to putting some more specific ideas on paper.

Oh no... This is what I wanted.  "Teach a man to fish..."

Posted by: @davee

In particular, in some cases, looking for small changes is more important than the absolute values, and vice versa. Getting a reasonably monotonic readout scale to (say) 12 or more bits precision is one thing. Getting absolute values to say 10 bits accuracy, implies 1 in 1024, or 0.1% is a different matter. Maintaining 0.1% accuracy, when the temperature of the measuring system varies by 20 degC, is even harder.

I want to re-iterate.  Even with my constrained resolution, I'm getting far better data than what the LiFePO4 battery gives me now.  A data point is created after about 10K samples.  The BMS simply tries to predict SOC based on voltage which is a complete waste of time even if it is human configurable with "way-points" in a piece-wise interpolation.  It's really surprising they didn't do something with the built-in shunt to change the prediction based on current (time) and past current (electric) history.  Here is some of the data I'm getting with the project now.

image

I plan on using some AI techniques to learn these normal issues along with idiosyncrasies of specific installations.  Noting in my curves, I have decided step midway through the cycle.  This is because one of my cells is not quite as good as the others.  I've mitigated it as best I can with an active balancer, but it would be nice to get predicted SOC even with this system.

The end-project is a hybrid-battery bank manager for my sailboat... or could be used in an RV or home battery backup system.  I've been studying the works of:

Posted by: @davee

may be combined into a single circuit block, possibly just using one op-amp, but the choice of resistor values, etc. tends to interact with each other. 

So, at least for the first 'paper' design, I suggest you regard them as two circuit blocks, the first shifting the voltage, the second setting the gain, and then consider whether they can be combined.

Let me study the references you supplied and heed your warning and see if I can come up with a circuit.  

VBR,

Inq

 

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
Lee G reacted
ReplyQuote
Lee G
(@lee-g)
Member
Joined: 4 years ago
Posts: 81
 

@inq 

(Aside) You’re not the only one. Although I don’t post that often, seems every time I do, I have to retype it in because “something went wrong…”. This old sailor has used some “very colorful’” language (albeit, under his breath) too… Glad to see you posting again.

Regards, Lee


   
Inq reacted
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1959
 

Hi @Lee & @inq,

  The roulette situation when you hit 'Add Reply' has caught me out before as well. I have been known to make a copy in Notepad++ before hitting that particular button.

A few empirical (and maybe inaccurate) observations ... Bill (@dronebot-workshop) may be able to provide some authoritative advice (I apologise in advance, for any confusion or workload this message causes.) :

  1. The risk seems higher when the Forum has been continuously logged into for a couple of days. I am guessing there is a login expiry time of around 3 days. Deliberately Logging Out and back in again, every couple of days may improve the odds of success. Also, the transition time seems near to Midnight, UK (my local) time.
  2. If you remember, before hitting the button, try the "Save Draft" and "Preview", to check if the Preview has what you expect ... in particular check the last few edits, since it may have stopped playing nicely, part way through the time you have been typing.   If the last edit is missing, then Add Reply WILL FAIL.
    • Select and Copy your message into the clipboard. 
    • If you are feeling paranoid, paste a copy into Notepad++ or similar.
    • I am pretty sure you can open a new Browser tab, log in to the forum, and paste it into the empty reply box, etc., hit Save Draft, Preview and Add Reply in the new tab, whilst maintaining the original text in the tab, so that if (say) Copy fails, you can still have another try.
  3. If you hit Add Reply and it fails, then you may be able to recover some of the text.
    • Log in to the forum, go to the 'Leave a Reply', and try clicking the "Revisions" button, that lurks between Preview and Save Draft. If it shows any of your text, then you can click to copy it back to the (empty) Leave a Reply window, ready for you to continue editing it. It will probably not be your complete typing effort, but it may be a substantial amount, presumably depending on when the forum logout occurred.
  4. I have also suffered the forum's PM system playing the same trick ... but it doesn't have the Preview system, and hence the comments in 3. do not apply.

Best wishes, Dave


   
Lee G reacted
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 3 years ago
Posts: 1929
Topic starter  

Posted by: @davee

A 1st glance to find an article discussing this, from TI https://www.ti.com/lit/an/sloa097/sloa097.pdf

includes:

image

R1 and Rg2 form a potential divider, to provide a 'known voltage source', as a fraction of Vref, which is applied to the inverting terminal. This means that if the voltage at the junction of R1 and Rref is 1.5V, then it will subtract 1.5V from the voltage applied to Vin, the non-inverting input. Thus, it is acting as a voltage shifter.

OK... I downloaded the referenced TI document and started reading through it.  It sounds exactly like what I need.  This does both the scaling and shifting.  It even talks in the same linear equation of the line that I outlined above.  Hey!... If you can't be good, at least be lucky. 😆 

I've plugged in the values I think I am supposed to and it walks me down to Section 4.  It has the same picture you posted above, so I'm feeling good about my understanding.  Then it says...

Choose Rf (may be suggested on data sheet). Rf = ______

Now, I hit a wall.  I take a WAG that the data sheet refers to one for an Op Amp.  So I go to Amazon and search for "Op Amp".  I get a bunch of hits for what looks like (to me) IC chips.  They have 8 legs.  The schematic only has 3, so I'm expecting something that looks like a transistor.  Now, even if further enlightenment says I need 8, how does one (meaning THIS OLDE BOY) pick one.  And even if I pick one, something on that data sheet MAY give me a suggestion.  

This sounds very close to using the Rectal Extraction method.  🤨 

Still reading in that TI reference, it says they have an Excel Calculator.  Beside the fact that I can't find it on their website, it seems TI needs a real JavaScript developer to put that into a web page and it would automatically walk into the pertinent 1 of 4 subsections and then spit out the recommended resistors AND the TI Op Amp model number.  Maybe they need someone that understands technical information and marketing!

Now!  I know you wouldn't just throw me to the wolves like this, so I read on in your treatise and I re-run into:

Posted by: @davee

By now, you will have realised that shifting the voltage and multiplying the voltage, may be combined into a single circuit block, possibly just using one op-amp, but the choice of resistor values, etc. tends to interact with each other...

So, at least for the first 'paper' design, I suggest you regard them as two circuit blocks, the first shifting the voltage, the second setting the gain, and then consider whether they can be combined.

It was a little nebulous for me the first time, but now I understand this paragraph. 🤪 

 

So I back-up (forward in your treatise)...

image

Rearranging their equation:  Vout =  Vin (1 + R2/R1) and plugging in my m value from above.

Vout / Vin = 5.28 = 1 + R2/R1 

R2 = 4.28 * R1

Picking the Resistors

I understand from my use of voltage dividers, I can use any magnitude of resistance values.  Low ones cause more current to flow and high ones sip power.  Too much current might blow out the ESP pin and too low a current might not move the pin's value enough.  I found by trial and error that I can use ones in the 100K range successfully.  Does the same logic apply here?

Finding the Offset value = -13.2

I think I'm cooked for tonight.  I'll try finding something like the TI document for just shifting tomorrow.

VBR,

Inq

 

P.S.

Posted by: @davee

Maintaining 0.1% accuracy, when the temperature of the measuring system varies by 20 degC, is even harder.

Off the (y = mx + b) portion of this problem.  The sensors themselves have temperature compensation for their output.  Are you saying that if the Op Amp temperature varies, that it too needs temperature compensation?  If so, I think this is a non-starter.  If I need the higher resolution, I'll just go the expensive route with the 24 bit A2D converter.

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 3 years ago
Posts: 1929
Topic starter  

Posted by: @davee

Hi @Lee & @inq,

  The roulette situation when you hit 'Add Reply' has caught me out before as well. I have been known to make a copy in Notepad++ before hitting that particular button.

 

Ctrl-A, Ctrl-C, before Add Reply is your friend.  The Clip-Board will store it just fine.  If it fails, re-login and Ctrl-V in the editor.  On a Mac, you're on your own.

 

But I forgot this time around.  Senior moment not to be repeated. 😉 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
Lee G reacted
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1959
 

Hi @inq,

  Ctrl-A Ctrl-C is indeed normally your friend, but on a couple of occasions, the subsequent Ctrl-V was certainly not my friend. 

I am pretty sure it is just my bad keyboard style, probably assisted by precariously balancing a laptop on my knees, but something went wrong. Possibly the mouse focus point moved away from the selected text, a few milliseconds before the Ctrl-C action occurred.

Hence, if it is a 'longer' note, I sometimes take out double insurance!

I thought you would probably know about the various tricks, but I added my tuppence worth of comment, in case it happened to anyone else.

Best wishes, Dave


   
ReplyQuote
Lee G
(@lee-g)
Member
Joined: 4 years ago
Posts: 81
 

@inq & @davee

The ctrl-A, ctrl-C, and ctrl-V sequence works on MacOS too. I typically write my replies up in a “sticky note” (like a 'post-it' note) that MacOS has, and copy/paste into the reply window on the forum. Saves having to re-type if something goes wrong.

@inq,  Ah yes, senior moments… I seem to be having more and more of those these days!!  Must be something in the water (nothing to do with me turning 80 in a month or so). 😊 

We're kinda off-topic of your original post, so I'll end it here.

Regards, Lee


   
Inq and DaveE reacted
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1959
 

Hi @inq,

  Your rate of work leaves me out of breath, trying to catch up with the reading, let alone replying, so this will be a short and possibly totally erroneous suggestion, as by the time I have tried to suss out the details, it will be ancient history.

I notice you found the ADS1115 A/D, and had some success with it, which is actually a rather complex chip, but "just perhaps" it has more of the cleverness to sort more of your requirement than you realise. My only concern is that sometimes the cleverness hides some details I haven't twigged, and I certainly haven't read most of the 51 page datasheet, let alone tried to use it.

Anyway, here goes for the suggestion to test out.

This particular A/D comes with an op-amp, actually labelled PGA Programmable Gain Amplifier, to precede the A/D, so that instead of inputting a single voltage line, plus ground, it is also possible to input a differential signal over a pair of input wires, and get it to measure the difference in voltage.

If I have managed to convey my understanding of the sensor in my last post in the other thread https://forum.dronebotworkshop.com/postid/50989/, then you will realise you need to measure the difference in voltage between the "Vout" line and the "Vref", where Vref is 2.5V and Vout is in the range (2.5 - 0.625) V = 1.875V to (2.5 + 0.625V) = 3.125V

The absolute voltages of these two pins stay within 1.8V to 3.2V, which must be checked against the allowed voltage input to the AD1115, to avoid magic smoke.

The data sheet from https://www.ti.com/lit/ds/symlink/ads1115.pdf on page 6 says:

This parameter expresses the full-scale range of the ADC scaling. No more than VDD + 0.3V must be applied to the analog inputs of the device.

and page 15 adds:

For example, with VDD = 3.3V and FSR = ±4.096V, only differential signals up to VIN = ±3.3V can be measured.

So hopefully, the sensor Vout and Vref will stay within the range 0 to 3.3V, and meet this requirement.

As for actually measuring the differential voltage, then the difference should always stay within the range -0.625V to + 0.625V

Page 15 of the data sheet includes:

image

Suggesting a range choice of +/- 1.024V might be suitable.

-----------------

Note that this approach means that two analogue input pins are used for each A/D channel, so that 1 chip can only provide two channels. However, the ADS1115 modules on AliExpress are only about £1 each.

Furthermore, the data sheet page 31 documents how to connect up to 4 ADS1115s to a single I2C bus, so it does not require any more ESPxxxx I2C pins to use two separate ADS41115s.

----------

At the suggested range, 1 bit corresponds to about 30 microV, so it will be sensitive to noise, etc., and inevitably the low-cost boards do not implement the best approaches. In particular, page 39 suggests a simple RC filter across each differential pair. With a little care, it should be possible to implement such a filter, albeit it will not have an ideal PCB layout. Hopefully it will be good enough.

For a starting point, I would try something like 10k resistors and 100nF capacitors.

Related to this, I have a small concern that an output from the sensor, assuming it powered by 5V, may momentarily exceed 3.3V at power on. (I don't know that it will ... just a possibility, because I don't know what the internal circuits is.)

The ADS1115 data sheet on page 13 says:

Electrostatic discharge (ESD) diodes connected to VDD and GND protect the ADS111x analog inputs. Keep the
absolute voltage of any input within the range shown in Equation 3 to prevent the ESD diodes from turning on.
GND – 0.3V < V(AINX) < VDD + 0.3V (3)
If the voltages on the input pins can potentially violate these conditions, use external Schottky diodes and series
resistors to limit the input current to safe values (see the Absolute Maximum Ratings table). Overdriving an input
on the ADS1115 can affect conversions taking place on other inputs. If overdriving an input is possible, clamp the
signal with external Schottky diodes.

The RC filter mentioned above can provide the resistors, just add Schottky diodes between the chip input and +3.3V, with diode connected to conduct if the input pin voltage exceeds 3.3V. To check the diodes were not causing a problem, I would be tempted to get it working without diodes, and then add diodes and check there is no change in the readings.

Failing to add diodes to an early prototype invites a small risk of chip failure, but you might regard that risk as acceptable, as replacement whilst it is still a bench test, is inexpensive.

--------------

Obviously, this is just an outline proposal, and I have probably missed lots of points.

Best wishes, Dave


   
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1959
 

Hi Inq,

  My replies are currently heading in two directions, the first using "classical" op-amps, the recent one, suggesting the A/D converter might have a built-in op-amp that will save adding an external one.

I think the second option is worth investigating, but meanwhile I'll try to answer a couple of points about op-amps from https://forum.dronebotworkshop.com/postid/50982/

if not for this project, maybe for another one!

A 'minimal' 'full' Op-amp  would need 5 pins. Two signal inputs, on signal input, positive power and negative power. 

In practice, there are lots of variants on this theme. A 'classic' is the 741, discussed in 

Wikipedia https://en.wikipedia.org/wiki/Operational_amplifier, apparently designed in 1968, and still on sale on AliExpress at a few cents each, in bags of 10. The original chip was packaged in a circular metal can, whilst the current version is 8 pin DIL

330px Generic 741 pinout top

In addition to the 5 pins already mentioned, there are a couple of offset pins that can be connected to preset potentiometer to offset a small voltage 'error' at the input. For many applications, the error can be ignored, and the potentiometer is not required. More modern designs have reduced this error to the extent that there is no provision for an external adjust.

This means devices like LM358 can fit two op-amps into the same package

image

Digital logic electronic chips have tended to adopt standard voltages, etc., so that designers can mix and match with a fair degree of impunity. Op-amps are perhaps the nearest equivalent to that standardised block circuit, but reality means that more care and understanding is required, but for many applications, they can still be a lot easier and more effective than resorting to individual transistors, etc. That said, there is more than I can even list to think about here. We can return to this later, if needed...

-------

I confess I only glanced at that TI reference ... I can easily agree that a spreadsheet would achieve the same calculations more quickly, but I presume they were trying to describe the underlying principle. Starting with a spreadsheet, and reverse engineering into why it had that formula, etc., whilst doable, sounds even more painful! If your project looks like it is needed, I'll revisit it.

---------

All electronic components change their characteristics with temperature. Some are worse than others. In many cases, the changes can be hidden, or offset, reducing the overall effect. The starting point, which I am certain everyone is familiar with in other fields, is to set down some sensible expectations. The strength of a bar of material might lessen with temperature, so figure out what temperatures it is likely to experience, how much force is likely to be applied to it, how much it can be allowed to bend and so on. Too many people, including 'electronic engineers' expect 'perfect' components, whilst even a piece of wire has intrinsic resistance, capacitance, inductance, all of which will be affected by environmental changes like temperature.

Having set down sensible expectations, it is then a game of trying to match reality with the hopes and dreams. Often the difficult part, for someone trying to answer questions, is obtaining a realistic set of expectations.

So when I suggest something will drift with temperature, that doesn't necessarily mean it will be a problem. If the current measurement drifts by 0.1% when the temperature falls -10degC, but the effective battery capacity intrinsically falls by 50% at the same temperature, which is more important in determining the capacity of the battery to drive the motor?

Best wishes, Dave


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 3 years ago
Posts: 1929
Topic starter  

Posted by: @davee

Your rate of work leaves me out of breath

Maybe we're wearing each other out... I see I'm two posts behind in this thread.  You're a machine! 😊  Your brain works on this stuff like its child's play.  I've got to put a fork in it for tonight.  I'll try to catch up with you tomorrow... but its a struggle.  

Just a casual 10,000 foot observation from this Noob... All these Op Amp schematics make it seem like all Op Amps are the same and totally controlled by external resistors.  Yet, I see many different versions on Amazon.  I feel like I'm opening a door that I should hide behind.

VBR,

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
(@davee)
Member
Joined: 4 years ago
Posts: 1959
 

Hi @inq,

  If I am a machine, it is one of those broken ones, that has been rusting in a dark, damp corner for years ... at some point I am likely to be taken away for recycling. 🤔 

------------

  Don't worry about the rate of what you are doing ... take your time, and it will all fall in place.

  Op-amps are a bit of a conundrum ... all electronic parts have parameters and limitations ... max voltage, max current, available rate of change, and so on. And this also applies to op-amps; typing opamps into Mouser's search bar suggests over 3000 products.

However, the concept of an opamp dates back to before 'digital' computers became common. That is, machines were designed and built to solve certain equations, and 'simple' circuit blocks including differential amplifier, adder, integrator and differentiator

differential amplifier

image

adder

image

differentiator

image

integrator

image

 and so on.

A complete PID computing circuit can be built by combining the above elements, for something like an optimised heater control system, without a digital processor or line of software!

The 'beginners' approach is to assume the actual op-amp has set of 'perfect' properties, such as infinite gain, no current flows in or out of the inputs, infinite (and invisible!) voltage power supply so that the output pin can swing to any voltage, infinite frequency response with no delay between an input change and the corresponding output change, etc.

Then, assuming you have such a device, it is possible to define amplifiers, integrators and so on, whose characteristics are completely defined by the small number of external resistors, capacitors, etc. shown in diagrams like those above.

Of course, finding a small electronic package that meets this specification is harder than finding a perpetual motion machine, so there are 1000s of 'best attempts', each one tending to aim to be good at one or more cases or applications.

Although the origins are based on analogue computing, the concept is used much more widely, including audio and radio applications, etc. For example, a 'treble' or 'bass' control circuit can be based on an op-amp a mix of resistors and capacitors to build an amplifier whose gain varies with frequency.

A 2-second Google suggested this 'bass boost' circuit from https://electro-dan.co.uk/electronics/bassboost.aspx

image

Note, by chance, the author followed common practice of not showing the power lines ... that doesn't mean it will work without them! Also, the capacitor C2 and resistor R3 in parallel, connected in between the output and non-inverting input, the capacitor providing the gain change with frequency effect.

Some op-amps will retain the generic 3 signal lines form, obviously with at least 2 power lines as well, others aim for more specific types of applications, and may have less or more pins, and may incorporate certain defining components within the package. For example, some applications require matched or precision resistors, which may be fabricated on the same silicon, and possibly be laser adjusted on the production line.

Given your need to use your Tonka toys in the better weather, etc., I hesitate to recommend you divert too much attention to the subject, but if you see an opportunity, you might find it interesting to start by looking at the type of beginner's approach I just mentioned, to get a better feel for what is involved.

Although there are always ways of making magic smoke, op-amps are fairly resistant to mistakes, albeit applying a too high voltage, or reverse connecting the power, is unlikely to end well. Specialist, high performance devices can be correspondingly expensive, but ubiquitous general-purpose devices can be down to 10 for a $1.

Best wishes, Dave


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 3 years ago
Posts: 1929
Topic starter  

Posted by: @davee

All electronic components change their characteristics with temperature. Some are worse than others.

To bring these two topic together, I ran your tests and have agreeable results - https://forum.dronebotworkshop.com/postid/51010/

Am I being too optimistic to think that by using the Vref in this differential way, that at least any thermal effects of the Hall sensor will be eliminated by the Vref also moving so that the difference is always accurate consistent?

Posted by: @davee

Having set down sensible expectations, it is then a game of trying to match reality with the hopes and dreams. Often the difficult part, for someone trying to answer questions, is obtaining a realistic set of expectations.

Relativity - I totally agree on setting expectations.  What I, in the southern US, call too cold to be outside, a Canadian would be out bare-chested running around enjoying the heat wave.  😆 

For the project at hand, I have no more accurate a device to measure current than the shunt in the battery's BMS.  If my surmise about the thermal effects is valid, then it would be a better justification of using the differential version that the resolution improvement from 15 to 60%.  But my anal-retentive nature likes that also.  😉 It is definitely worth the use of a second ADS1115.

Either way, I will be adding calibration ability to the software side.  Even though the use of the system my warrant 200A occasionally, that is the exception, not the rule.  The more critical determination will be in the sub 10A range when someone is trying to stretch the battery on a sailboat with limited charging options.  Being able to truly show zero when the user knows no current is flowing and to mark data points at other known, but low current levels might require a curve fitting algorithm or at least a piece-wise linear interpolation algorithm. 

The end result is to be able to predict a remaining time at the current utilization.  To give an analogy, many car trip computers will show mileage remaining at the current cruise speed.  If one floors it for some longer than prudent time, and then returns to cruise speed, the computer understandably shows a shorter remaining time.  The BMS fails miserably at this analogy since it only uses voltage to show SOC.  

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Page 1 / 2