Author Topic: Two channel ucurrent powered by USB  (Read 1443 times)

0 Members and 1 Guest are viewing this topic.

Offline mh0520Topic starter

  • Contributor
  • Posts: 13
  • Country: us
Two channel ucurrent powered by USB
« on: April 13, 2026, 09:48:16 pm »
I am working on building a version of the µcurrent that will be connected to an MCU so that the readings can be measured out over USB. I need this to make two measurements completely independently so I will be duplicating the µcurrent circuit on the board. Currently, my hand built version uses 2 2032 coin cells to power each channel but I would like to increase the supply voltage to get more range out of the measurement.

Additionally, I would really prefer to be able to power the current measurement circuit using the 5 V generated from USB power using a voltage regaulator on the MCU board already.

My question is, is this even practical to do in the first place? What would I need to do in order to power the µcurrent using the 5 V from the USB port?

One idea that I had was to use the µcurrent circuit essentially the same as it is but connent its power pins to outputs of another voltage regulator configured to output +2.5 V and -2.5 V. This seems like it should work but I'm sure I'm not thinking all the details through here.

The other option would be to take the 5 V that already exists and tap off of it with 2 additional regulators that would provide some isolation. Again, I think that this should work but I also assume that I'm probably overlooking some things here as well.

I know that I could use two separate external 5 V supplies but I'm trying to avoid having to do something like this. I would consider an approach like this if I could at least limit it to requiring only a single external supply that is used to generate two isolated outputs but if I have to use two external supplies it feels like I may as well stick with the coin cells.

Are there any other suggestions or approaches that I could consider?
« Last Edit: April 13, 2026, 09:52:04 pm by mh0520 »
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 19222
  • Country: us
  • DavidH
Re: Two channel ucurrent powered by USB
« Reply #1 on: April 13, 2026, 10:24:38 pm »
An inverter to convert +5 volt USB to isolated +/-5 volts is easy enough.  Coilcraft even makes transformers for this.  Tight regulation is not required.

If galvanic isolation is not required, then a charge pump will be good enough to convert +5 volt USB to -5 volts.
 

Online wraper

  • Supporter
  • ****
  • Posts: 19502
  • Country: lv
Re: Two channel ucurrent powered by USB
« Reply #2 on: April 13, 2026, 10:38:51 pm »
I'm not sure if you fully realize that if you connect it to USB, it no longer will be floating if laptop or PC is connected to mains socket, and how huge of a detriment it is. High chance to blow up DUT, uCurrent and computer too. It would be nowhere as easy and safe to use as one connected to a battery powered multimeter. Not to say USB is a very significant noise source which may be an issue when you measure tiny currents. Also dual channel means these channels will not be isolated, which again very severely limits its use and more so increases chance to blow up things. You could use USB isolator but it won't fix the issue with channel isolation. You could implement isolation in the meter part, but then it would severely increase complexity.  IMHO the best option would be to build two single channel devices each using USB isolator. Or if you do it with virtual COM port, then you could isolate UART using optocouplers or cheap digital isolator.
« Last Edit: April 13, 2026, 10:56:18 pm by wraper »
 

Offline mh0520Topic starter

  • Contributor
  • Posts: 13
  • Country: us
Re: Two channel ucurrent powered by USB
« Reply #3 on: April 13, 2026, 11:09:43 pm »
I'm not sure if you fully realize that if you connect it to USB, it no longer will be floating if laptop or PC is connected to mains socket, and how huge of a detriment it is. High chance to blow up DUT, uCurrent and computer too. It would be nowhere as easy and safe to use as one connected to a battery powered multimeter. Not to say USB is a very significant noise source which may be an issue when you measure tiny currents. Also dual channel means these channels will not be isolated, which again very severely limits its use and more so increases chance to blow up things. You could use USB isolator but it won't fix the issue with channel isolation. You could implement isolation in the meter part, but then it would severely increase complexity.  IMHO the best option would be to build two single channel devices each using USB isolator. Or if you do it with virtual COM port, then you could isolate UART using optocouplers or cheap digital isolator.

Okay, a lot to digest here...

So, currently, I use two separate circuits, each powered by a 2032 coin cell. Currently both of these circuits are connected to an MCU which is used to measure the voltage on the ucurrent circuit.

Is this, in and of itself, a risky setup if I am not using any sort of USB isolator between the MCU board and the PC and the PC is connected to mains power?

If yes, and if I understand correctly you are suggesting that I really should be using two separate MCUs which each use a USB isolator when connecting to the PC. 

It seems like generating the +/- 2.5 V that I need wouldn't necessarily be that difficult but that that's the least of the concerns in terms of creating robust setup.

I could also go another route and just try to find a better battery option than using disposeable coin cells. I'm thinking that maybe if I was able to find a rechargeable battery pack in the range of 4.5 V to 5 V that that might be a better option. It would still run on battery when being used but it would get me higher voltage and be more convenient then needing to replace coin cell batteries.


 

Online wraper

  • Supporter
  • ****
  • Posts: 19502
  • Country: lv
Re: Two channel ucurrent powered by USB
« Reply #4 on: April 13, 2026, 11:27:10 pm »
Is this, in and of itself, a risky setup if I am not using any sort of USB isolator between the MCU board and the PC and the PC is connected to mains power?
Yep, especially considering you add a series shunt, usually on high side and not just connect GND as with oscilloscopes (which is risky too, but not as complicated). If the device is earthed, you already have a problem. And even if it isn't, Y capacitor in SMPS powering DUT may be enough to blow up sensitive circuits.
Quote
If yes, and if I understand correctly you are suggesting that I really should be using two separate MCUs which each use a USB isolator when connecting to the PC.
Can be done in different ways. You could also add a third MCU or USB/UART converter that talks with measuring MCUs through isolated interface. Then those could be simpler stuff with no USB.
 

Offline mh0520Topic starter

  • Contributor
  • Posts: 13
  • Country: us
Re: Two channel ucurrent powered by USB
« Reply #5 on: April 14, 2026, 12:00:22 am »
Can be done in different ways. You could also add a third MCU or USB/UART converter that talks with measuring MCUs through isolated interface. Then those could be simpler stuff with no USB.

So, my goal is to be able to read the voltages measured on each of the two ucurrent circuits over a USB port. I have the two separate ucurrent circuits and you've convinced me that I probably should stick with some sort of battery supply since using anything wall powered sounds like it could be a huge risk to the rest of the system. So, I guess I'll move on from that.

What would be the simplest setup that would allow me to safely measure the two voltages and transmit it over USB? Currently I'm using a single off-the-shelf MCU evaluation (cost is ~$20) that is using the MCU ADCs to measure the voltages and then transmit this over a COM port to the PC. If I need to try to keep the cost to aroudn the same $20 mark, are there any off-the-shelf options that would allow me to implement this correctly? I'm possibly able to do some level of PCB design at a later point in time but I was hoping to keep that to the ucurrent circuits and I don't currently have enough time to spin a board, especially if I have to include MCUs directly on the board. That could come later but not right now.
 

Online wraper

  • Supporter
  • ****
  • Posts: 19502
  • Country: lv
Re: Two channel ucurrent powered by USB
« Reply #6 on: April 14, 2026, 12:23:48 am »
Quote
Currently I'm using a single off-the-shelf MCU evaluation (cost is ~$20) that is using the MCU ADCs to measure the voltages and then transmit this over a COM port to the PC.
One of the simplest and cheapest variants would be something like CH340 on USB side + paralleled optocouplers like PC817 from UART to both channels (in both directions, 4 optocouplers in total). Then PC software asks particular MCU to send the collected data. Both MCU can use the same FW and recognize the address they should respond to by wiring some GPIO pin. Another variant could be adding an optocoupler between channels (one MCU acts as a master that requests another MCU to send data, thus synchronizing them) and use paralleled single direction communication to the PC. Then you could simply see the data in terminal with no special SW.
« Last Edit: April 14, 2026, 12:32:21 am by wraper »
 

Offline mh0520Topic starter

  • Contributor
  • Posts: 13
  • Country: us
Re: Two channel ucurrent powered by USB
« Reply #7 on: April 14, 2026, 01:36:25 am »
Quote
Currently I'm using a single off-the-shelf MCU evaluation (cost is ~$20) that is using the MCU ADCs to measure the voltages and then transmit this over a COM port to the PC.
One of the simplest and cheapest variants would be something like CH340 on USB side + paralleled optocouplers like PC817 from UART to both channels (in both directions, 4 optocouplers in total). Then PC software asks particular MCU to send the collected data. Both MCU can use the same FW and recognize the address they should respond to by wiring some GPIO pin. Another variant could be adding an optocoupler between channels (one MCU acts as a master that requests another MCU to send data, thus synchronizing them) and use paralleled single direction communication to the PC. Then you could simply see the data in terminal with no special SW.

So, when you say 4 octocouplers, are you are referring to one for each of the following paths:

CH340 UART -> optocoupler -> MCU1 measuring voltage from uCurrent circuit 1
CH340 UART <- optocoupler <- MCU1 measuring voltage from uCurrent circuit 1
CH340 UART -> optocoupler -> MCU2 measuring voltage from uCurrent circuit 2
CH340 UART <- optocoupler <- MCU2 measuring voltage from uCurrent circuit 2

Also, does it matter that the system will consist of a single PC which may be connected to mains power and that all other parts of the system will be powered over USB from that single PC? I'm not sure if it matters that all of the other devices will be powered from the single PC and not from the mains power directly.
« Last Edit: April 14, 2026, 02:04:18 am by mh0520 »
 

Online wraper

  • Supporter
  • ****
  • Posts: 19502
  • Country: lv
Re: Two channel ucurrent powered by USB
« Reply #8 on: April 14, 2026, 02:06:07 am »
MCU can measure on request or do it on its own pace and only send already collected data on request. If channels are optically isolated, it does not matter what is powered from what.
 

Offline mh0520Topic starter

  • Contributor
  • Posts: 13
  • Country: us
Re: Two channel ucurrent powered by USB
« Reply #9 on: April 14, 2026, 02:29:35 am »
MCU can measure on request or do it on its own pace and only send already collected data on request. If channels are optically isolated, it does not matter what is powered from what.

I'm still not quite sure how to achieve the isolation that you're describing but I will need to think through that to unerstand where in the system I would need to insert the 4 optocouplers as you suggested.
 

Online wraper

  • Supporter
  • ****
  • Posts: 19502
  • Country: lv
Re: Two channel ucurrent powered by USB
« Reply #10 on: April 14, 2026, 02:56:56 am »
RxD and TxD, two connected in parralel on CH340 side. Each LED emitter (on TxD) should have it's own series resistor. Only one pull up for RxD.
 

Offline mh0520Topic starter

  • Contributor
  • Posts: 13
  • Country: us
Re: Two channel ucurrent powered by USB
« Reply #11 on: April 14, 2026, 03:38:02 am »
Okay, thank you for the clarification, I think I understand now.

Just so that I'm clear, my current implementation uses a single MCU to measure both voltages from the ucurrent and each ucurrent circuit is powered from it's own coin cell battery. If the ADCs on the MCU are used to make the voltage measurement differentially, is it still necessary to use two separate MCUs? The ADCs can be configured for either a single-ended or differential measurement and I am using a differential measurement. I'm wondering if this makes any difference at all. Also, I currently have the GND on the DUT MCU board and the GND on the Current Measurement MCU board shorted to each other.

I'm attaching a quick block diagram sketch that might help. In the sketch the dashed line boxes are intended to show the two MCU boards. Each MCU board is connected to the PC via USB and connected to each of the two ucurrent circuits as shown in the diagram.

Would you still recommend that each ucurrent circuit has their on measurement MCU which is then connected to the PC via these optocouplers?

If I would need to isolate the measurement MCUs from the rest of the system using the optocouplers would I also need to power these via battery? If yes, could I use the same battery that is being used to power the ucurrent or would each measurement MCU require another dedicated battery resulting in four batteries in total now?
 

Online wraper

  • Supporter
  • ****
  • Posts: 19502
  • Country: lv
Re: Two channel ucurrent powered by USB
« Reply #12 on: April 14, 2026, 03:45:02 am »
If I would need to isolate the measurement MCUs from the rest of the system using the optocouplers would I also need to power these via battery? If yes, could I use the same battery that is being used to power the ucurrent or would each measurement MCU require another dedicated battery resulting in four batteries in total now?
If you use the same battery, channels won't be isolated, so it would be pointless to use 2 MCUs to begin with. You could use isolated DC/DC converter modules to power channels from USB. However if you do so, their switching noise becomes a serious consideration. As you don't seem to have much of experience, sticking to batteries would be much safer bet.
 

Online TERRA Operative

  • Super Contributor
  • ***
  • Posts: 4091
  • Country: jp
  • Voider of warranties
    • Near Far Media Youtube
Re: Two channel ucurrent powered by USB
« Reply #13 on: April 14, 2026, 04:11:26 am »
Can you just replace the microcontroller with an ESP-32 or similar and use bluetooth?
You'll have a big airgap and maybe it'll be easier to use without the tether of a USB cable getting in the way.
Where does all this test equipment keep coming from?!?

https://www.youtube.com/NearFarMedia/
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 17256
  • Country: de
Re: Two channel ucurrent powered by USB
« Reply #14 on: April 14, 2026, 07:30:06 am »
It depends on the ADCs used, if one would need a separate µC for each channel.
There are a few ADCs that could directly convert and send the data via a seriel channel (may not be USRT). With this one may want a µC with USB interface at the PC side (e.g. Rasberry pico / ESP32 ?) to convert and combine the 2 non standard seriel signals.

Another option would be 1 µC per channel.  There are plenty of cheap µCs with a 12 bit ADC and oversampling could give a little extra resolution if needed. It depends on the required resolution and speed if this is sufficient.

The idea of 2 isolated UART signals to a UART to USB converter may be a bit tricky to avoid overlap. I would more consider a daisy chain way so that the µC with one channel combines it's own data with extra data from an isolated UART.  So the data would flow from channel1 to channel2 to  UART-USB converter.
One may not even need a channel back from the USB towards the measurement channels. If needed the control signal could run in a ring fashion with the control signals goind USB-USRT -> channel 1  -> channel 2. This would save 1  isolator (including the power it needs).

A slight challange would be the power for the isolators if high speed is needed.
 
The following users thanked this post: wraper

Offline PGPG

  • Super Contributor
  • ***
  • Posts: 1334
  • Country: pl
Re: Two channel ucurrent powered by USB
« Reply #15 on: April 14, 2026, 08:40:27 am »
So, currently, I use two separate circuits, each powered by a 2032 coin cell. Currently both of these circuits are connected to an MCU which is used to measure the voltage on the ucurrent circuit.

It is not clear what you have.
If the circuits are connected to the same MCU than they are not separate circuits!
If they measure what you need being not separate than may be they need not be separate.
If they need not be separate than they can be supplied from the same source as MCU.
 

Offline fchk

  • Frequent Contributor
  • **
  • Posts: 410
  • Country: de
Re: Two channel ucurrent powered by USB
« Reply #16 on: April 14, 2026, 08:48:33 am »
My suggestion:
foreach(uCurrent)
{
MCP3221 I2C single channel ADC
ADUM1250 I2C Digital Isolator
}
MCP2221A USB-I2C bridge.

Note that the MCP3221 is available with different I2C addresses. The full part number is MCP3221AxT-E/OT where x is a number between 0 and 7. Each chip needs to have a unique address.
 

Offline mh0520Topic starter

  • Contributor
  • Posts: 13
  • Country: us
Re: Two channel ucurrent powered by USB
« Reply #17 on: April 14, 2026, 06:45:48 pm »
If you use the same battery, channels won't be isolated, so it would be pointless to use 2 MCUs to begin with. You could use isolated DC/DC converter modules to power channels from USB. However if you do so, their switching noise becomes a serious consideration. As you don't seem to have much of experience, sticking to batteries would be much safer bet.

Thanks for this response. If I need to isolate everything, then I will use two separate batteries. I am just trying to avoid using disposable batteries if possible and if not, I want to at least to to make it easy to replace the batteries. In either case, I do plan to use separate batteries.

I had that same concern with the DC/DC converter. It may work but I was concerned that the extra noise could become an issue.

Assuming that I have separate batteries for each of the two ucurrent circuits, if the ADC inputs are differential is it still true that I would need a separate MCU to keep the measurements independent? I am assuming that the need for separate ADCs/MCUs is based on the goal of trying to keep the grounds for each of the two measurement circuits separate from each other (and from earth ground). By that, I mean that I need to make sure that the I_in-/V_out- net for ucurrent #1 is not connected to the same point as the I_in-/V_out- net for ucurrent #2.

  • If these measurements are made using a differential input ADC does this make it so that the two ucurrent circuits are not affecting each other?
  • Probably more importantly, even if that does keep the measurements independent is this potentially still a problem because it is still likely to cause damage to the system overall?
 

Offline mh0520Topic starter

  • Contributor
  • Posts: 13
  • Country: us
Re: Two channel ucurrent powered by USB
« Reply #18 on: April 14, 2026, 06:47:47 pm »
Can you just replace the microcontroller with an ESP-32 or similar and use bluetooth?
You'll have a big airgap and maybe it'll be easier to use without the tether of a USB cable getting in the way.

I am considering this as an option as well but I'm not 100% confident that I would be able to get the bluetooth working correctly in the next week or two. It is definitely something that I am considering in the future, though.
 

Offline mh0520Topic starter

  • Contributor
  • Posts: 13
  • Country: us
Re: Two channel ucurrent powered by USB
« Reply #19 on: April 14, 2026, 07:02:11 pm »
It is not clear what you have.
If the circuits are connected to the same MCU than they are not separate circuits!
If they measure what you need being not separate than may be they need not be separate.
If they need not be separate than they can be supplied from the same source as MCU.

Understood regarding your point about these not being truly separate. What I meant by separate was purely that I could remove one of the ucurrent circuits and the other would still function. My goal here is to try to minimize (if not remove entirely) the effect that one ucurrent has on the other and also to operate the whole setup in a way that it is reasonably easy to avoid and unsafe situations.

I did post a block diagram sketch in a later post but I'm reattaching it here to make it easier to reference. Hopefully that gives a little more information as to how the circuit is currently configured.
 

Offline mh0520Topic starter

  • Contributor
  • Posts: 13
  • Country: us
Re: Two channel ucurrent powered by USB
« Reply #20 on: April 14, 2026, 07:08:56 pm »
My suggestion:
foreach(uCurrent)
{
MCP3221 I2C single channel ADC
ADUM1250 I2C Digital Isolator
}
MCP2221A USB-I2C bridge.

Note that the MCP3221 is available with different I2C addresses. The full part number is MCP3221AxT-E/OT where x is a number between 0 and 7. Each chip needs to have a unique address.

I'm going to need to sketch this one out because I feel like this could be a good alternative to using a dedicated MCU for the measurements but I could be wrong here. Is that the intent? For this implementation, I would use the MCP2221A to receive the signals from the ADCs via their ADUM1250 isolator?
 

Offline mh0520Topic starter

  • Contributor
  • Posts: 13
  • Country: us
Re: Two channel ucurrent powered by USB
« Reply #21 on: April 14, 2026, 10:38:04 pm »
After thinking through this more while trying to create a better drawing, I believe it is worse than I initially thought in terms of being able to make these measurements independently as the reality is that one ucurrent circuit, "µCurrent 1" in the attached drawing, is measuring the total current of DUT1 and DUT2 and then the second ucurrent, , "µCurrent 2," is measuring only the current of DUT2.



Ultimately, given this updated diagram, the two questions that I have are:

  • Can this measurement be done safely as drawn? If yes, what changes are needed to ensure that nothing is blown up?
  • Will this measurement, as drawn (plus any changes required as a result of the previous question), provide accurate measurements?

I suspect that the answer to the first question may be no, in which case I will need to remove µCurrent 2 which is intended to measure only the current drawn from DUT2. If this is true and I remove the second measurement, then I suspect that changes will still be required to ensure that the system operates safely with the single measurement but this appears to be a much more manageable task.
« Last Edit: April 14, 2026, 11:36:29 pm by mh0520 »
 

Online wraper

  • Supporter
  • ****
  • Posts: 19502
  • Country: lv
Re: Two channel ucurrent powered by USB
« Reply #22 on: April 15, 2026, 01:17:58 am »
 

Offline mh0520Topic starter

  • Contributor
  • Posts: 13
  • Country: us
Re: Two channel ucurrent powered by USB
« Reply #23 on: April 15, 2026, 02:25:16 pm »


So, I take this to mean that the fact that the ADC on the MCU is configured as a differential input doesn't do anything to avoid this short from the supply pins on one board to the ground pin on the other board. Is that correct?

 

Online wraper

  • Supporter
  • ****
  • Posts: 19502
  • Country: lv
Re: Two channel ucurrent powered by USB
« Reply #24 on: April 15, 2026, 02:38:06 pm »
I just noticed that DUT is powered from 1.8V and MCU from 3.3V. This could work in this context. But the issue is that it's an extremely narrow use case that would only make sense if this is integrated into DUT itself. But in such a case it's an absolutely ridiculous way how to integrate current measurement into the device.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->