Arduino Forum

Using Arduino => General Electronics => Topic started by: tim77777 on Jun 29, 2018, 08:08 am

Title: currrent limiting
Post by: tim77777 on Jun 29, 2018, 08:08 am
Hi, I am using a pro mini, 5V 16MHz and am op-amp circuit that together draw about 30mA of current.

The power supply for the mini comes from a TRS socket in another device, 5v -Ring; 0v -shield. The tip feeds into an A/D convertor on that other device and comes from a PWM pin on the mini. So, when the mini is plugged into the other device via its TRS socket, the mini is powered, and provides a PWM signal to the other device.

However, when a plug is inserted into the TRS socket, the tip and ring are temporarily shorted out which brings the system down on that other device. I have put a resistor in series with the ring (150ohms) which limits the current and stops the other device shutting down, but it also drops the voltage to the pro Mini to 3.3 volts, as expected. And also drops the voltage to the op-amp circuit which stops it working properly.

At 3.3Volts does the pro-mini automatically drop back to 8MHz?

Any ideas about how I can fix this without redesigned the op-amp circuit?
Title: Re: currrent limiting
Post by: PaulRB on Jun 29, 2018, 09:08 am
No, the Pro Mini will not automatically drop to 8MHz. It may continue to work at 16MHz but there is no guarantee. Thr brown-out detector in the ATmega may just continually cause resets.

Using a resistor is not a suitable way of providing 3.3V power to the circuit.

Perhaps you should explain what the "other device" is and what is normally plugged into its TRS socket. Why does/did that not also cause a short?
Title: Re: currrent limiting
Post by: ChrisTenone on Jun 29, 2018, 09:09 am
Perhaps you should get a 3 volt mini. And an op amp that works at 3 volts as well.
Title: Re: currrent limiting
Post by: PaulRB on Jun 29, 2018, 09:14 am
Perhaps you should get a 3 volt mini. And an op amp that works at 3 volts as well.
I don't see how that would avoid the OP's problem, Chris. There would still be a short circuit as the plug is inserted into the TRS socket. The OP tried to limit the short circuit current with a resistor, but that won't provide the Pro Mini with a stable supply, even if it is a 3.3V version.
Title: Re: currrent limiting
Post by: tim77777 on Jun 29, 2018, 09:58 am
the pro mini does seem to work ok at 3.3 volts, but maybe the 8mHz 3.3 volt version would be more reliable. The 3.3 volts with a resistor in series was just a coincidence relative to the resistor size required to limit to 30mA.

the opamp circuit is attached. How can I modify that to work at 3.3 volts. It is ok at 5 volts, but the amplitude from pin 7 is pulsating when operating at 3.3 volts.

The TRS socket is currently only used for this purpose, and for an analog potentiometer. The series resistor is not a problem for the potentiometer though.

Why won't the supply be stable with a resistor in series?
Title: Re: currrent limiting
Post by: ChrisTenone on Jun 29, 2018, 10:34 am
I don't see how that would avoid the OP's problem, Chris. There would still be a short circuit as the plug is inserted into the TRS socket. The OP tried to limit the short circuit current with a resistor, but that won't provide the Pro Mini with a stable supply, even if it is a 3.3V version.
You are right Paul. I had interpreted the problem as the voltage dropping from the resistive fix, and the op amp not working properly. I hadn't really considered the mini's current requirement, which is the real problem. Fixing the power glitch is surely the way to go.
Title: Re: currrent limiting
Post by: PaulRB on Jun 29, 2018, 11:34 am
Quote
Why won't the supply be stable with a resistor in series?
Because the current drawn by the circuit won't be constant. It will vary from moment to moment depending on what the Pro Mini is doing. And because of Ohm's law, the voltage drop across the resistor will also vary.
Title: Re: currrent limiting
Post by: PaulRB on Jun 29, 2018, 11:51 am
I get why the short circuit was not a problem with the analog pot. The full resistance of the pot would have been between the jack's ring and shield, so 1K, 10K or whatever.

(https://forum.arduino.cc/index.php?action=dlattach;topic=555626.0;attach=264146)
So this is the input to the Arduino's analog pin? And an Arduino PWM output pin connects to the mysterious "other device" through the tip of the TRS jack & socket?

Short-circuit issues aside, have you tested that the A/D input of the "other device" will accept the PWM signal? Normally some low-pass filter is required to change the PWM signal into an analog voltage to achieve that.
Title: Re: currrent limiting
Post by: tim77777 on Jun 29, 2018, 01:30 pm
Mysterious, ha :-).

Yes the input from an audio source goes through to A0 on a Pro mini, the frequency of the source is detected and written via analogWrite to an output pin. This gives a varying pulse width proportional to the frequency.


I have a series resistor and cap to ground after that, that changes the PWM to DC.

The varying DC is fed on to the tip of the TRS socket on the other device, read by an A/D, and used for .... mysterious purposes.
 
Title: Re: currrent limiting
Post by: tim77777 on Jun 29, 2018, 01:39 pm
Because the current drawn by the circuit won't be constant. It will vary from moment to moment depending on what the Pro Mini is doing. And because of Ohm's law, the voltage drop across the resistor will also vary.
I see. It seems to work OK. What sort of problems can I expect?

Title: Re: currrent limiting
Post by: tim77777 on Jun 29, 2018, 01:54 pm
You are right Paul. I had interpreted the problem as the voltage dropping from the resistive fix, and the op amp not working properly. I hadn't really considered the mini's current requirement, which is the real problem. Fixing the power glitch is surely the way to go.
Yes, after disconnecting the power to the mini only, the amplitude becomes stable. So, the op-amp is not the problem.

Even with the pulsating the application is still working though, I suppose because it is a function of frequency, and so the amplitude variation is not a problem. Though it will be in the future because I need to establish the input level at sometime for clipping and to cut out noise.
Title: Re: currrent limiting
Post by: tim77777 on Jun 29, 2018, 02:03 pm
It was in line with requirements to do things this way, but if I can't get a somewhat stable supply, the proMini will need to have its own supply, and that's out of line with the requirements. An additional external supply is not doable.

Even if I use a different type of jack to prevent the ring/tip short, there still needs to be some protective current limiting to stop a user shorting something.

Is there a way the regulated 5volt supply from the external device, can be made suitable?
Title: Re: currrent limiting
Post by: wvmarle on Jun 29, 2018, 03:01 pm
Maybe you should indeed go to 3.3V for your Pro Mini (and run it at 8 MHz), but then using a linear regulator such as the AMS1117-3.3 which has short circuit protection built in (the current is limited to 1.1-1.2A).
Title: Re: currrent limiting
Post by: PaulRB on Jun 29, 2018, 04:14 pm
Maybe you should indeed go to 3.3V for your Pro Mini (and run it at 8 MHz), but then using a linear regulator such as the AMS1117-3.3 which has short circuit protection built in (the current is limited to 1.1-1.2A).
Two reasons why not, I suspect:

The OP needs to avoid the short circuit in the first place. Even if the regulator protects itself, the Pro Mini and the op-amp circuit, the 1A+ surge could damage the mystery device, or cause it to shut off to protect itself. Also, could the jack tip touch 5V while the ring touches 0V? That would cause parasitic, reverse-polarity powering of the Pro Mini?

Secondly, I'm guessing the Pro Mini will be doing FFT, so may need to run at the full 16MHz rather than 8.

Here's a simple idea: put a dpst toggle switch into the circuit to isolate the 5V & 0V from the TRS socket. Plug in, then switch on. Switch off before unplugging. Or is that not sufficiently idiot-proof?

Can the mystery device be re-wired internally so that the jack tip is 5V and the ring is the a/d input? That might avoid the short circuit problem.

If not, and the toggle switch idea is not suitable, maybe something with a fet, that powers on the circuit once 5V is correctly connected?

Title: Re: currrent limiting
Post by: tim77777 on Jun 30, 2018, 01:30 am
thanks for that.  Using Autocorrelation rather than FFT, so perhaps 8MHz would do.


Toggle switch. OK for me, but yes a user might muck that up, as could I occassionally.


I don't think rewiring would help, 5v tip, wiper on ring. or 5v on ring, wiper on tip, would still be shorted.

A FET. OK, sounds good. I don't know how to do that other than saying that when the tip shorts to the ring the FET turns on and provides 5 volts. It would also need to switch off when the ring and tip is shorted again when the plug is removed. Is that possible? and how?
Title: Re: currrent limiting
Post by: tim77777 on Jun 30, 2018, 03:22 am
what if I put the resistor in series with the A/D input rather than the 5 volt line. Does that cause a problem for reading analog signals?
Title: Re: currrent limiting
Post by: Smajdalf on Jun 30, 2018, 07:40 am
Where exactly is the resistor connected in your original design? Before the jack in the mysterious device providing power or on the Arduino side?
From your description I think it is on the Arduino side. In that case I don't understand how the resistor may protect against mechanical short circuit caused by plugging Arduino in/out. My guess is the problem is caused by inrush current when empty filtering caps of Arduino are connected to power. (Test: the problem occurs only during plugging in or during plugging out too?)
If I am right replacing the resistor with a MOSFET that "slowly" turns on (limiting inrush current but providing minimal resistance afterward) will solve your problem.
Title: Re: currrent limiting
Post by: PaulRB on Jun 30, 2018, 09:13 am
Quote
when a plug is inserted into the TRS socket, the tip and ring are temporarily shorted out which brings the system down on that other device.
Can you explain this again in more detail please? The socket will have 3 sprung contacts designed to make contact with the tip, ring and shield of the jack. When the short happens, is it caused entirely by the tip of the jack, or are the ring and shield also involved somehow? What is the path of the short circuit current, starting from the 5V socket contact, where does it flow to get to 0V?
Title: Re: currrent limiting
Post by: tim77777 on Jun 30, 2018, 09:21 am
thanks, but the resistor is before the jack, and the short from tip to ring resets the device, whether the plug is going in or out. So, it is shorting 5Volts to the A/D on the device. Which causes it to reset.

Will having a resistor in series with the A/D cause a problem?
Title: Re: currrent limiting
Post by: tim77777 on Jun 30, 2018, 09:34 am
Can you explain this again in more detail please? The socket will have 3 sprung contacts designed to make contact with the tip, ring and shield of the jack. When the short happens, is it caused entirely by the tip of the jack, or are the ring and shield also involved somehow? What is the path of the short circuit current, starting from the 5V socket contact, where does it flow to get to 0V?
The short is caused by the tip of the plug as it pushes through the ring connection and touches the tip connection before it exits the ring connection. The short is directly between the regulated 5V line, and the A/D input. I don't see the shield as having a part in it. I can simulate the problem by jumpering from 5V to the A/D input.

Which of course makes no sense now that I write it, as the 5v line should be able to touch the A/D. The short must be between the ring the shield, but i don't see how that can happen. I better get in close and see what is happening. thanks
Title: Re: currrent limiting
Post by: PaulRB on Jun 30, 2018, 09:35 am
So the tip of the jack touches the 5V contact in the socket and the ring of the jack touches the 0V contact in the socket?

From the point of view of the Arduino, the PWM output pin gets connected to 5V (via the low pass filter's resistor) and the VCC pin gets connected to 0V. At this moment, the Arduino's GND pin is floating? Or is it also touching the 0V contact the socket?

I can't picture how the short is happening now...
Title: Re: currrent limiting
Post by: tim77777 on Jun 30, 2018, 09:42 am
ok got it. There is an extra contact, a switching contact, connected to the jack tip, I have it soldered to ground to keep the output at zero when nothing is connected. So, now when the plug tip contacts the jacks ring and tip it creates a short to ground via the switching contact, and then shortly afterwards the switching contact is opened.
Title: Re: currrent limiting
Post by: tim77777 on Jun 30, 2018, 10:34 am
and so that tells the problem, but doesn't solve it. I could put a resistor of some value between that switching contact to keep the output steady when nothing is plugged in, and that would stop the shorting problem. But then there would still be a live 5V and ground on the cable plugged into to the socket, that a user could accidentally short.
Title: Re: currrent limiting
Post by: PaulRB on Jun 30, 2018, 10:35 am
So, instead of a direct ground connection there, put a resistor to ground, 10K or something.
Title: Re: currrent limiting
Post by: PaulRB on Jun 30, 2018, 10:40 am
Quote
there would still be a live 5V and ground on the cable plugged into to the socket, that a user could accidentally short.
How would that happen? Unless the user opens the Arduino box and starts tinkering?
Title: Re: currrent limiting
Post by: tim77777 on Jun 30, 2018, 11:59 am
Because the cable is removable. TRS jack on the Pro mini box, and TRS jack on the other device.
 
Title: Re: currrent limiting
Post by: PaulRB on Jun 30, 2018, 12:13 pm
I don't get it. How can the short now happen (once you fix the switching connector with a resistor). How can the user cause a short, what touches what exactly?
Title: Re: currrent limiting
Post by: tim77777 on Jun 30, 2018, 04:03 pm
A user can short the ring 5v to the shield. The resistor is between the tip and the switch when in the closed position. Once the plug is inserted the resistor is doing nothing.
Title: Re: currrent limiting
Post by: PaulRB on Jun 30, 2018, 04:44 pm
If the jack is one third of the way in, the tip is touching the 0V contact and the ring and maybe the shield are also in contact with 0V. No problem there.

If the jack is two thirds of the way in, the tip is touching the 5V contact. The ring and shield might be touching  the 0V contact. I'm not sure if that is a problem or not. In theory, the PWM pin of the Arduino is high impedance, but on the other hand, it is at a higher voltage than the VCC pin, so current could follow back to the VCC pin, which is connected to 0V, or to the GND pin, which is also connected to 0V. But there is also a resistor between the jack tip and the PWM pin, so it won't be a short.

But I think what you are saying is that just before that "two thirds" position, the tip of the jack can sort the 5V and 0V contacts in the socket? If so, there's nothing the Arduino circuit can do to prevent that, it would happen just the same with the potentiometer. Any protection will have to be done behind the socket in the mystery device, I think
Title: Re: currrent limiting
Post by: Smajdalf on Jun 30, 2018, 06:57 pm
If you are able to modify the device providing power you may add a current limiting to the power lines. You may use a dedicated circuit or a fast dirty way may be using an IC with current limiting built in - such as an op amp "buffering" the 5V or linear regulator with very low dropout.
Title: Re: currrent limiting
Post by: tim77777 on Jul 01, 2018, 12:23 am
If the jack is one third of the way in, the tip is touching the 0V contact and the ring and maybe the shield are also in contact with 0V. No problem there.

If the jack is two thirds of the way in, the tip is touching the 5V contact. The ring and shield might be touching  the 0V contact. I'm not sure if that is a problem or not. In theory, the PWM pin of the Arduino is high impedance, but on the other hand, it is at a higher voltage than the VCC pin, so current could follow back to the VCC pin, which is connected to 0V, or to the GND pin, which is also connected to 0V. But there is also a resistor between the jack tip and the PWM pin, so it won't be a short.

But I think what you are saying is that just before that "two thirds" position, the tip of the jack can sort the 5V and 0V contacts in the socket? If so, there's nothing the Arduino circuit can do to prevent that, it would happen just the same with the potentiometer. Any protection will have to be done behind the socket in the mystery device, I think
thanks but what i am saying is a user can connect the shield to the ring either on purpose or accidentally by plugging it into something not designed for it or by connecting the two together for whatever reason. TRS is a common socket and theoretically they can plug it into anything. Unlike a ac/dc plug power adapter, both the neg and positive are exposed via the TRS plug.
Title: Re: currrent limiting
Post by: allanhurst on Jul 01, 2018, 12:27 am
Perhaps you could consider a different power connector which doesn't momentarily short out....  there are  lots.

Allan
Title: Re: currrent limiting
Post by: MarkT on Jul 01, 2018, 12:29 am
Replace that connector - TRS or TRRS is not suitable for power at all.

In fact its not suitable for anything really - an accident of history, made particularly bad
by their common use for audio where the only sensible kind of connector is one that connects ground
before signal - unless you like full-volume mains buzz everytime a connector is plugged and unplugged!
Title: Re: currrent limiting
Post by: tim77777 on Jul 01, 2018, 09:25 am
I see. well thanks for all that. Seems like the only solution is to have a fixed cable with the arduino unit, and a TRS on the other unit. It has to be TRS because of the other things that can plug in to it. The fixed cable is not perfect as it limits a users distance. Perhaps it should be short anyway. What distance can I run the arduino's filtered PWM signal over.

Thanks for all the help, as it helped me work through the issue with the short when inserting the plug. I can remove the resistor in series with the 5V line and adequately run the pro mini and opamp circuit now, and run other things being developed that will plug into this expandable system.
Title: Re: currrent limiting
Post by: PaulRB on Jul 01, 2018, 11:09 am
Here is an idea:
(https://forum.arduino.cc/index.php?action=dlattach;topic=555626.0;attach=264412)

Look at the type C socket above.
Quote
This three-conductor jack has two isolated SPDT switches. They are activated by a plug going into the jack, which disconnects one throw and connects the other. The white arrowheads indicate a mechanical connection, while the black arrowheads indicate an electrical connection. This would be useful for a device that turns on when a plug is inserted, and off otherwise, with the power routed through the switches.
You could use the switch activated by the tip to isolate the 5V supply until the jack is fully inserted.
Title: Re: currrent limiting
Post by: PaulRB on Jul 01, 2018, 11:32 am
Jalco js5077 (https://www.rapidonline.com/pdf/20-1399.pdf)

(https://forum.arduino.cc/index.php?action=dlattach;topic=555626.0;attach=264415)

(https://forum.arduino.cc/index.php?action=dlattach;topic=555626.0;attach=264421)

5V to terminal 5. Terminal 6 to terminal 3. This would connect 5V to the ring but only once the plug is fully inserted.

Terminal 8 to A/D. Terminal 7 to ground via 10K. Terminal 9 to Terminal 2. This would replicate the switch in your current socket, giving a steady zero reading to the A/D while no plug inserted.

PS. Sorry if I have given some rather confusing explanations earlier in the thread. I had thought for years that "jack" refers to the plug. But I just found out it refers to the socket!
Title: Re: currrent limiting
Post by: tim77777 on Jul 01, 2018, 01:55 pm
Well that is a great solution. Space is tight, but it might fit.

Any idea on how far the PWM signal from the arduino can be transmitted?
Title: Re: currrent limiting
Post by: PaulRB on Jul 01, 2018, 02:13 pm
Well, you are not transmitting the PWM signal, you are transmitting the analog voltage output by your low pass filter. Assuming that does not change very rapidly, then it should transmit quite a long way. A long wire will have some resistance and capacitance, of course, and that will affect the signal measured by the A/D, but I suspect it will be fine for quite a few metres.
Title: Re: currrent limiting
Post by: tim77777 on Jul 16, 2018, 12:56 pm
back on this again. Going around in circles.

How can this be done.

I have 5 volts coming out of an enclosure and entering another enclosure through a patch cable. The voltage needs to be current limited so that a user does not inadvertently short the supply as the patch cable and the various devices that can attach to it are designed to be plug and play and so it is quite possible that a user might plug something unexpected in, or do something to short the supply.

At times the 5v is simply across a potentiometer, with the wiper feeding back to the other enclosure, and for that application the limiting resistor is not a problem. However, the five volts is sometimes used to power an op-amp and uC circuit (about 40mA total) that doesn't like working through the series resistor.
What actually happens is that the output of the op-amp circuit , which is configured with some gain and a 2.5v swing around zero, starts to pulsate. The uC circuit seems to work ok, though I guess it is unstable.

What about a charge  pump, would that make any difference, or what else can be done.
Title: Re: currrent limiting
Post by: ChrisTenone on Jul 16, 2018, 02:38 pm
back on this again. Going around in circles.

How can this be done.

I have 5 volts coming out of an enclosure and entering another enclosure through a patch cable. The voltage needs to be current limited so that a user does not inadvertently short the supply as the patch cable and the various devices that can attach to it are designed to be plug and play and so it is quite possible that a user might plug something unexpected in, or do something to short the supply.

At times the 5v is simply across a potentiometer, with the wiper feeding back to the other enclosure, and for that application the limiting resistor is not a problem. However, the five volts is sometimes used to power an op-amp and uC circuit (about 40mA total) that doesn't like working through the series resistor.
What actually happens is that the output of the op-amp circuit , which is configured with some gain and a 2.5v swing around zero, starts to pulsate. The uC circuit seems to work ok, though I guess it is unstable.

What about a charge  pump, would that make any difference, or what else can be done.

The problem is the connector, not the current, right?

Why not use a different connector, one that cannot be shorted?
Title: Re: currrent limiting
Post by: allanhurst on Jul 16, 2018, 08:13 pm
Hear hear! ( along with other contributors)..........

Allan
Title: Re: currrent limiting
Post by: tim77777 on Jul 17, 2018, 12:19 am
because there is no space for another connector, and it wouldn't make enough difference anyway, because the other end of the cable could still be shorted.

it needs to be current limited.
Title: Re: currrent limiting
Post by: PaulRB on Jul 17, 2018, 12:41 am
Some voltage regulators have built-in short-circuit protection. Maybe you could use one of those to supply power to the user's device instead of the arrangement you have now?
Title: Re: currrent limiting
Post by: tim77777 on Jul 17, 2018, 12:58 am
thanks. but the hardware is already set. There is a AMS1117 that has short circuit protection, but the system will still shut down if there is a short, as it would even with a better suited regulator.
Title: Re: currrent limiting
Post by: allanhurst on Jul 17, 2018, 03:17 am
If you won't consider a more appropriate connector, I fear I/we can't help you any further unless you want to go to the extent of foldback current limiting. Lab power supplies have this, but it involves extra complexity, not just a choice of chip.

It could be done.


Allan
Title: Re: currrent limiting
Post by: tim77777 on Jul 17, 2018, 03:50 am
thanks, but its not a matter of consideration. The enclosures are drilled, painted and printed, the hardware is set, PCBs done, components soldered. It's all done and dusted except for the final assembly and, except for this significant add-on feature, if it can be made to work.

The software of course can still be changed, and some minor hardware can be added to the supplying enclosure, provided it doesn't take up too much room and it is physically stable enough when soldered and hanging of a pin on the TRS connector. In that scenario, a small current limiting resistor is OK.

It doesn't sound like there is much else that can be done within the supplying enclosure.

There is plenty of scope for hardware changes in the receiving enclosure.

I know this might not be the usual way, but what if I sized the limiting resistor such that half the voltage was dropped across it and used a 40mA charge pump in the receiving device. I don't think the current for the uC and opamp circuit varies much, so things should remain stable. If the uC and opamp circuit is drawing 40mA, then can I assume the input resistance is 125 ohms?

Do charge pumps only double the voltage or are there fractional options.

If so, then I size the limiting resistor at 125 ohms/ 250mW and use a 40mA charge pump in the receiving device. Unorthodox, but would it work.

Title: Re: currrent limiting
Post by: allanhurst on Jul 17, 2018, 04:10 am
That's horrendous.

Can't you modify the supply side to be foldback limiting as I suggested? I'll hack out a circuit if you'll give me your psu specs/design.

Allan
Title: Re: currrent limiting
Post by: tim77777 on Jul 17, 2018, 04:16 am
Horrendous or not, would it work?


I don't know what foldback limiting is.

PSU design. It just a AMS1117 with 9 volts in, 5 volts out. Bypass caps on both sides.
Title: Re: currrent limiting
Post by: MarkT on Jul 17, 2018, 01:47 pm
I don't know what foldback limiting is.
Its not a state secret...  Its covered in a wikipedia article.
Title: Re: currrent limiting
Post by: allanhurst on Jul 17, 2018, 03:06 pm
Are you using a fixed or adjustable version of the AMS1117 ?

Allan
Title: Re: currrent limiting
Post by: Smajdalf on Jul 18, 2018, 06:55 am
Every current limiting circuit will cause a voltage drop. You need either some voltage headroom or complicated circuit. But If you can access the 9V voltage directly it should be easy. You can try adding an additional AMS1117. Since it has dropout less than 2V it should have at least 7V at its input to provide 5V. So you can use the 2V for a current limiting circuitry. A 2V/40mA=50 Ohm resistor between 9V and AMS1117 input should work well to not influence output when current is less than 40mA but limit the current to some reasonable value in case of a short circuit. But ofc. it is quite crude (and possibly another regulator with smaller internal current limit would be more suitable). You may Google for "current limiting" and look on images for plenty of circuits - nearly any should provide voltage drop around 1V and current limiting good enough.
Title: Re: currrent limiting
Post by: tim77777 on Jul 18, 2018, 08:06 am
Are you using a fixed or adjustable version of the AMS1117 ?

Allan
fixed