Help to replicate this circuit

Hi,

This is the last piece of the puzzle in my goal to replicate the keypad COMMS signals with an arduino 3.3V digital pin. The software side is working and the signal is output from one digital pin at 1.25kHz.

With my multimeter I found that COMMS pin is normally 5V, and is pulled low by the logic signal (via transistor controlled by pin RC7). It appears the transistor shorts the COMMS pin down to GND.

I'm thinking the arduino 3.3V pin could essentially replace the RC7 input in a similar circuit?
I'm just not sure about adding in resistors etc.. for safety.

Any tips much appreciated.

Here's a part circuit and pcb (I can post more but the size limit):





Hi,
Looking at your hand drawn circuit;
0V at the emmiter (2) cannot rise when button pressed unless your DMM is not measuring with respect to the 0V line.


Tom... :slight_smile:

Hi @TomGeorge,

Yes I see what you mean, I had the negative on the incoming 0V terminal where I perhaps should have used Vss ground pin.

It was only a flicker in the digital meter of a fraction of a volt, as the signal duration is only milliseconds. I should have been more clear :slight_smile:

I’m pretty sure I traced it out correctly though.

Thanks

877:
I’m thinking the arduino 3.3V pin could essentially replace the RC7 input in a similar circuit?

Yes.
Resistors as they are in the circuit are fine - the 100k one may not be needed, depending on where that is connecting to.
I assume this “comms” is some kind of high impedance output, i.e. not a direct 5V connection but with a good amount of resistance in place. Otherwise you’d create a short.

@wvmarle thank you. The 100K resistor goes off to a few places on the pcb, and I didn’t want to confuse things. It could be ignored I hoped.

It makes sense if the comms input is a high impedance at the main panel.

Would you think I need a diode at the base connection to prevent any signals going back into the Arduino pin? Or is the transistor effectively going to block any possible back signal anyway?

A BJT transistor can be seen as two diodes placed in opposite directions... the arrow in the symbol is one of them. So no way for current to flow from the collector (or the emitter) to the base. Just one direction.

Thank you that makes sense.

I have a few S8050 npn transistors which should be ok I think.

Final thing, it’s safe to connect this way?

3.3V to the gate from the Arduino
Keypads 5V to collector
Common the grounds

877:
3.3V to the gate from the Arduino

I think you mean the base, you should add a resistor in series remember that the npn transistor Collector-Emmiter current equals the base current times the transistor beta.

That's a BJT npn transistor.

It's not called a 'gate'. It's called 'the base'.

What is the purpose of pulling the COMMS line LOW (to GND).
Is that an Active Low input used as an Enable that you want permanently LOW ?

cheche_romo:
I think you mean the base, you should add a resistor in series remember that the npn transistor Collector-Emmiter current equals the base current times the transistor beta.

Yes I meant base :slight_smile: In the original circuit there is a 1.5K resistor so I might start with a 100K and work my way down..

raschemmel:
What is the purpose of pulling the COMMS line LOW (to GND).
Is that an Active Low input used as an Enable that you want permanently LOW ?

It's a NRZ signal, normally at 5V and pulled low to send the data bits. As mentioned above it seems to be connected to a high impedance terminal at the main panel, hence why it can be shorted directly to gnd.

I hope that is true anyway, I will be doing real life testing soon :slight_smile:

To test, connect a 1k resistor between COMMS and ground, and measure the voltage across that resistor. I expect you to see a very low voltage (use a digital multimeter), as in 0.1V or even less. Possibly you measure nothing (0V) even, as it's too low a voltage to measure. Such a result means it's perfectly safe pulling it to GND with a transistor.

Excellent idea thanks :slight_smile:

wvmarle:
To test, connect a 1k resistor between COMMS and ground, and measure the voltage across that resistor. I expect you to see a very low voltage (use a digital multimeter), as in 0.1V or even less. Possibly you measure nothing (0V) even, as it's too low a voltage to measure. Such a result means it's perfectly safe pulling it to GND with a transistor.

@wvmarle so I did as you said and it doesn't match unfortunately for me, I tried different values:

COMMS to GND voltage readings:
No resistor = 4.9V
50K = 4.64V
10K = 3.75V
1K = 1.15V
560R = 0.71V

I took a couple more photos of the main panel, where I took the voltage readings.

Any ideas?

I see. Those numbers show an output impedance of about 3.3k, fair chance that this is a pull-up resistor. Stronger than I anticipated, but still fine to connect straight to GND (it'd give a current of about 1.5 mA).

Connecting to GND (through a switch, or that transistor) should be perfectly safe, and very likely what the circuit designer intended to do. A ~10k base resistor will do fine for this.

Thank you! That's good news anyway.

There is an issue I am struggling to understand. If I connect the circuit as below, I get inverse logic.
i.e. pin 2 HIGH = comms pin LOW

It would be a real pain to invert the logic in my code, as it's all sequential hex bytes.

I'd like to build a test circuit first, could I use a 3.3k resistor as the load so i can check the output with my logic analyser?

I've been testing transistor circuits over the last few days with not much success, I always seem to have around 2.2V across the c-e junction in my tests..

(excuse sidewards view - iPhone does this for some reason!)

When pin 2 goes high (pick another pin! This way you're pulling low pin 2, and may not be able to boot the ESP properly - unless you're using a NodeMCU or WeMOS in which case I don't remember which are the special pins with their messed up numbering), the transistor switches on, pulling low the comms signal.
When pin 2 goes low, the transistor switches off, and comms goes high.

If you don't want inversion, you need a second NPN transistor, for a second inversion and a non-inverted result.

Ah thanks the pin 2 issue might explain why my transistor tests didn't work...

So I need something like this:

Can I ask how did you work out the pullup resistor was equivalent to 3.3k ?

877:
So I need something like this:

Yes, that should do.

Can I ask how did you work out the pullup resistor was equivalent to 3.3k ?

It's a voltage divider with your resistor. Source 4.9V (as measured with the open circuit), unknown resistor, your resistor, GND. You measured the voltage between the mid point and GND. Calculated values for the unknown resistance are 2.7k-3.3k, all pretty close together.

Thank you, that link is useful. I did know all this stuff but 20yrs makes you rusty!

I managed to thankfully adjust the code, so it works on breadboard with a single transistor.

Next to test the real thing!

Again thanks

Can I ask how did you work out the pullup resistor was equivalent to 3.3k ?

  1. VOUT = VSOURCE* (RSOURCE/(R2 +RSOURCE)

  2. Let VSOURCE = 4.9V
    Let VOUT = 3.75V
    Let RSOURCE = ?
    Let R2 = 10000 ohms

  3. 4.9V(R2/(R2 + RSOURCE)) = 3.75V

  4. 4.9V(10000/(RSOURCE + 10000)) = 3.75V

  5. 49000 3.75
    -------------------------------- = -----
    (RSOURCE + 10000) 1

  6. CROSS MULTIPLY

  7. 49000 = 3.75*(RSOURCE + 10000)

  8. 49000 = 3.75*RSOURCE + 37500

  9. SUBTRACT 37500 FROM BOTH SIDES

49000-37500 = 3.75*RSOURCE

11500 = 3.75*RSOURCE

  1. DIVIDE BOTH SIDES BY 3.75

3.75*RSOURCE 11500
---------------------------- = -------
3.75 3.75

  1. 3.75 CANCELS ON LEFT SIDE

RSOURCE 11500
---------------------------- = -------
1 3.75

  1. RSOURCE = 3066 (same value obtained using voltage divider link)

(not 3.3k)