Best way to "copy" a digital signal - Page 1
Forum section: electronics / beginners

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 17, 2022, 10:42:49 am
content: Hey thereSimple noob question: I have a digital signal at 3.3V. I want to make an exact copy (timing is key, so the copy needs to be done electrically) to send to an external port, without disturbing the original signal.The original signal is an open-drain signal from an MCU, and it might be connected to something pulling it up (when open) at around 1.7V or so. The "copied" signal can also be open-drain.Thanks!Simon

author: voltsandjolts
author_rank: Unknown
timestamp: October 17, 2022, 11:13:05 am
content: Well, the 'exact' requirement is inadequate specification. I doubt you mean femtosecond precision on the edge positions but allowable error determines the complexity of reproduction. Being open drain suggests edge timing is not critical, tens or even hundreds of microseconds perhaps.For a temporary experiment, some scopes can record a frame and playback through their sig gen. Otherwise some firmware is likely required for an mcu. What tools do you have?

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 17, 2022, 11:28:13 am
content: What I take from your question is that you need to attach something additional to a signal without loading it and as such distort the original signal.You can use a 74LVC125 single gate to buffer the signal for routing it to another device. These buffers have high input impedance. Draws at max 20 micro amperes from your original signal, and are fast to not cause a big delay on the edges.

author: voltsandjolts
author_rank: Unknown
timestamp: October 17, 2022, 12:49:09 pm
content: Doh, yeh, pcprogrammer has it right, ignore my post...my bad for skim reading.The tri-state output of the 74LVC125 can be used as an open drain too (within bounds of supply rail).

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 17, 2022, 02:28:15 pm
content: Thank you both. Yes that sounds about right. So basically any buffer would work as loading the output would not affect the original signal if I understood wellWhat about doing it without an IC, just with a transistor, would you go for a NPN or a CMOS?

author: Terry Bites
author_rank: Super Contributor
timestamp: October 17, 2022, 02:32:22 pm
content: That will have slow rise and fall times relative to the input and worse than a a regular gate- willl that be an issue?You could lose sync with other edges.The term you are looking for is "buffering"

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 17, 2022, 02:35:24 pm
content: It depends how "slow"But like voltsandjolt said the original signal is open drain, running at 5mA when operating so the edges are not super quick anyways.And the signal is generally quite "slow", under 50kHz.And Terry thanks for the term - yes buffering that sounds about right

author: ledtester
author_rank: Super Contributor
timestamp: October 17, 2022, 04:23:30 pm
content: The 74LVC125 (SN74LVC125A) can operate at 1.7V. Of course, you would need a 1.7V rail to use it. The OP said the original open-drain output would be pulled up to "1.7V or so" so it is possible such a rail exists.

author: Mechatrommer
author_rank: Super Contributor
timestamp: October 17, 2022, 04:36:26 pm
content: Quote from: voltsandjolts on October 17, 2022, 11:13:05 amQuote from: voltsandjolts on October 17, 2022, 12:49:09 pmyou are not wrong.. 1ns propagation delay can be considered "not exact" depending on specification.Quote from: simonlasnier on October 17, 2022, 02:28:15 pmgoogle "buffering with transistor"... wrt attached picture, the lower the pull up resistor the better... we are not sure how hard you are going to load the buffer and how much % input loading is considered acceptable nor your exact intention (specification). ymmv.

author: ledtester
author_rank: Super Contributor
timestamp: October 17, 2022, 05:41:24 pm
content: A question for the OP:Quote from: simonlasnier on October 17, 2022, 10:42:49 amWhen you say "might be connected" are you saying you want to copied signal to work even if there is nothing connected to the open-drain signal?And what is the nature of this 1.7V -- is it a power rail or how do you come up with that voltage?

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 17, 2022, 07:10:23 pm
content: Quote from: simonlasnier on October 17, 2022, 02:28:15 pmA N-channel MOSFET would be the better choice, but it inverts the signal, so you would need two to get the job done. A NPN BJT needs base current and loads your signal. To make either work there has to be a pull up on your open drain MCU output. If it is left open it won't work.But there are multiple of single gate choices available in the 74LVC range. Also with open collector / drain outputs. These are very small packages and easy to integrate on a board.

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 17, 2022, 10:18:54 pm
content: Thank you guys - as always super useful to ask on this forum!Quote from: ledtester on October 17, 2022, 05:41:24 pmYes exactly. There might be something connected, then it will be pulled up. Or there might not be, then it will stay open drain. Either way I would like to be able to copy the signal.And the 1.7V comes from the fact that the "pulling up" (when connected) is going from a 3.3V through a resistor and an LED. There is no 1,7V rail, only a 3.3V.So I have 2 issues:* when connected, 1.7V is too low for a CMOS input with a 3.3V rail* when not connected, the signal needs to be pulled up to be copied I guess?I'll experiment with simulators and see what's possible, also reading about all what you guys mentioned, thank youIf you have more ideas I'm also happy to hear them.

author: ledtester
author_rank: Super Contributor
timestamp: October 17, 2022, 11:18:52 pm
content: I'm sure you can solve the problem by having a weak pull-up on the input of the CMOS buffer gate.The weak pull-up (like > 10k) would be in parallel with the LED+resistor if it happens to be there. Being in parallel it won't affect the operation of the open-drain load. It will slow down switching time, though. How fast does the open-drain output turn on and off?Btw, even with the LED+resistor installed the drain voltage still could be close to 3.3V if the copying circuit draws only microamps.

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 18, 2022, 05:17:40 am
content: Another way of doing it is to use two buffers. One for the original output that is open drain and can be left unconnected and one for the copied signal. Then the output from the MCU can either be set to push pull and drive the buffers as is, or set to open drain and a proper pull up resistor has to be used.

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 18, 2022, 07:44:11 am
content: Thanks all. Yes I agree it seems a pullup would work.And sorry for the lack of info, I was convinced I put that up somewhere:The original signal runs at 5mA, we can "bother" it as long as we stay within the 5mA range (so I'd say max +/- 0.5mA is ok)the signal is about 50kHz and does not have very fast edges (obviously with the open drain)Quote from: ledtester on October 17, 2022, 11:18:52 pmI am not sure I understand that?

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 18, 2022, 08:06:52 am
content: Quote from: simonlasnier on October 18, 2022, 07:44:11 amWhat ledtester meant with this is that when the open drain output is turned on the voltage on the output will be very low. Depends on the current, but most likely below 0.2V. And when the output is turned of the voltage at the output will be very close to the supply voltage of 3.3V despite the LED and resistor. In this case it depends on leakage or input current due to the additional input connected to the signal, what the actual voltage will be.

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 18, 2022, 09:15:40 am
content: Quote from: pcprogrammer on October 18, 2022, 08:06:52 amThanks pcprogrammer. Are you speaking about the case when the loop is closed, i.e. the "connected" situation, i.e. we have 3.3V rail -> LED -> res (about 300ohm) -> open-drain output on MCU) ?If so then it's not the case, I just tried and I measured the following>* 1.7V when the open-drain output is OFF (i.e. 3.3V rail -> LED -> res -> open)* 0.6V when the open-drain output is ON ((i.e. 3.3V rail -> LED -> res -> output set to GND)The first one makes sense, since it is still going through the LED, or have I missed something?The second one must be because there is a 5mA current so the MCU cannot pull it all the way down to 0V (but 0.6V sounds like a lot??)

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 18, 2022, 09:52:00 am
content: Yes I was referring to the situation where the pin is connected.The 0.6V when the output is on might be a bit high, but still below 0.8V which is a threshold for standard TTL. For CMOS it is 1.5V, so not a problem.The 1.7V when the output is turned off is a bit strange, because that means there is some current flowing to bring the voltage down. Do the math and it will show that across the LED and resistor there is 1.6V. Not enough for the LED to illuminate, but still some current needs to be flowing.Edit: I did try it myself with just a LED and there is a voltage drop. Forgot the LED is a semiconductor which behaves differently. Not sure how this will impact things when a buffer is connected, but with an additional pull up resistor parallel to the LED with series resistor will solve this.

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 18, 2022, 10:18:42 am
content: Yea you're right that makes perfect sense actually. Oh I've always wondered why MCU datasheets had some pins that were "true open-drain", maybe this is it, a "true open-drain" will not draw any current?As I understood, an "usual" open-drain pin set to "high" will simply deactivate NMOS and PMOS output transistors. But I think the pin will still draw some residual current, with the protection diodes, the pull-down / up resistors (aren't these basically transistors inside an MCU?), and the NMOS/PMOS transistors, correct?

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 18, 2022, 10:44:40 am
content: Quote from: simonlasnier on October 18, 2022, 10:18:42 amCorrect, the internal pull up or downs usually are made with these. The picture you attached shows a pin capable of both push pull and open drain. In open drain mode the top P-MOS transistor will not be used. A "true open-drain" pin probably is just the N-MOS transistor and might even lack the option to enable pull up or down. If there is some residual current it will be very small.Another thing when measuring is that the DMM will also draw a tiny bit of current.

author: Saimoun
author_rank: Frequent Contributor
timestamp: October 18, 2022, 11:14:55 am
content: What's the DMM?Thank you all for the help. I thought it was really a matter a adding a simple transistor, I can see it requires a bit moreI'll see if I can simply find an unused pin on the MCU to send the copy, it does sound easier

author: pcprogrammer
author_rank: Super Contributor
timestamp: October 18, 2022, 11:45:34 am
content: A DMM is a Digital Multi Meter. I thought this was such an universal abbreviation that I did not write it outIndeed a free pin on the MCU would be the simplest solution

author: John B
author_rank: Frequent Contributor
timestamp: October 19, 2022, 08:11:08 am
content: SN74LVC1G17 and SN74LVC1G14 are good options which have a schmitt trigger input too. One is an inverting version, the other non-inverting. They operate down to 1.65V but the output drive strength is reduced to around +/- 4mA, down from around +/-30mA at 5V supply.

author: Kleinstein
author_rank: Super Contributor
timestamp: October 19, 2022, 08:37:17 am
content: A free pin and µC internal copy would be a near ideal copy.Usually there is no need to drive a LED connected to the same supply as the µC with a open drain signal, one could still configure the output as push pull. The PMOS part would short the LED when the LED is off, which does not change much (the LED may turn off a little faster, if it is a relatively slow LED, like an old red one).

author: Saimoun
author_rank: Frequent Contributor
timestamp: November 04, 2022, 01:56:24 pm
content: @Kleinstein: yes that is correct, but the LED was not the reason I chose to have an open drainSo I thought I could use a separate pin on the MCU, but actually the board is already quite busy and it would make things way easier to make a "hardware copy" (a buffer).But based on your replies it seems it is quite complicated to buffer the original signal, but I realized... I can simply start with the copySo, basically, now the signal I want to copy is a usual MCU GPIO output in push-pull, at 3.3V.The copy, though, has to:be open-drainbe able to handle at least 5mA current (the LED loop)not affect the original signalidealy be as close as the original time-wise (ideally within 0.1us or lower)Going through your answers, it seems a simple open-drain gate like the SN74LVC125A would do the job?CheersSimon

author: pcprogrammer
author_rank: Super Contributor
timestamp: November 04, 2022, 02:23:52 pm
content: The SN74LVC125A is a tri-state buffer and not really open drain.For that something like a SN74LVC07A is a better choice. But there are most likely more open drain buffers both inverting and not inverting, with schmitt trigger input or normal input. Nowadays probably also available in single gate packages.

author: Saimoun
author_rank: Frequent Contributor
timestamp: November 04, 2022, 06:49:34 pm
content: Thanks for the reply pcprogrammer.Actually I do not really care if it is inverting. Then I realized in this case maybe a simple BJT could work? Or would you recommend a CMOS?And for an open drain/collector, am I better off with an NPN or PNP?Just asking because I already have anNPN transistoron the board, so actually it would be great to reuse it.

author: pcprogrammer
author_rank: Super Contributor
timestamp: November 04, 2022, 07:31:57 pm
content: Hi Simon,sure, you can use a NPN BJT for it. Needs a base resistor to limit the current into the base. Emitter to ground and the collector is the output to connect the load. Other side of the load goes to the plus of the supply. This is an inverting solution, level wise. A "one" on the base means a "zero" on the collector, but the load will be on.Just make sure the transistor can handle the voltage as well as the current of what you are going to turn on and off.Regards,Peter

author: Saimoun
author_rank: Frequent Contributor
timestamp: November 05, 2022, 03:09:50 pm
content: Thanks Peter.If I want to drive more than one output with the same GPIO signal, I can just hook up multiple transistors, right?I attached my circuit with two options which I would say are pretty much equivalent, right?

author: pcprogrammer
author_rank: Super Contributor
timestamp: November 05, 2022, 05:43:22 pm
content: Yes, you can connect multiple transistors this way. Option 1 is better to use. This way there is no problem with differences in base emitter voltages.Mind you there is a limit to how many transistors you can drive with one gpio. Has to do with current during switching and of course the steady state current.