Please help me reverse engineer these buttons...

Hi,
I am trying to figure out how a set of buttons interfaces with the microprocessor - an STM8S 003K3T6C (datasheet)

I am familiar with simple button config - you pull GPIOs high or low with the button and detect the change.

I don't understand what is going on with this circuit at all... I want to know so I can bypass the push buttons and control it programmatically using an external MP.

There are 6 buttons that control e.g. power on/off, fan direction, raise / lower a hatch etc.

I have traced them back to these pins on the microprocessor:

Fan Direction:
Button 1 connects 10 -> 32
Button 2 connects 8 -> 32

Hatch up/down
Button 3 connects 10 -> 2
Button 4 connects 8 -> 2

Button 5 connects 10 -> 28 (Sensor on/off)
Button 6 connects 8 -> 28 (Power on/off)

So there is a pattern, either 10 or 8 is connected to 32 or 2 or 28

Supply to the processor is 3V.

If I measure each pin to ground, I get:
10 & 8 are 0.514V
32 & 2 & 28 are 1.03V (~= 2 x 0.514V)

What i was hoping was that 10 and 8 were high & low!

Can anyone explain to me how this circuit might work? And how can I bypass the push buttons?

Thank you

Most probably these buttons are multiplexed with no static signals noticeable. A scope or logic analyzer will tell you more.

I'd use optocouplers to simulate key presses.

Hi, thanks very much for your help.

I have measured between each pin and found the following. I still don't understand it, but I am hoping you do!

Could you elaborate on how you would use optocouplers? Is an optocoupler preferable over a programmable switch? Thank you

Optocouplers have no problems with signal levels, shared lines and other dependencies. Collector to the high voltage pin, emitter to the low voltage pin, that's all for the switch replacement.

If you measure the pins against GND I'd expect some active low driven pins and some passive pins with pullups.

Thank you so much.

Can you suggest a through hole IC that would be suitable?

So for the replacement of button 1, I would have the Collector connected to pin 32 (1.03V) and the Emitter to pin 10 (0.514V)?
And then my external microprocessor activates the optocoupler by pulsing across the anode/cathode?

"If you measure the pins against GND I'd expect some active low driven pins and some passive pins with pullups."
Is there an idiot's guide to doing this?

Thanks for your patience

If you are curious then search for an Arduino button matrix project - in general it's the same with any controller.

Thank you, will get some optocouplers and try it out.

DrDiettrich:
If you are curious then search for an Arduino button matrix project - in general it's the same with any controller.

The optocouplers worked! Thanks so much.

One last question- is there any reason why I can't have a single current limiting resistor on the ground end of the arduino side of the optocouplers as opposed to individual current limiting resistors for each optocoupler?

Hi,
Can you post a circuit diagram please.

Do you have a at any stage more than on opto activated at at time?

Thanks.. Tom... :slight_smile:

TomGeorge:
Hi,
Can you post a circuit diagram please.

Do you have a at any stage more than on opto activated at at time?

Thanks.. Tom... :slight_smile:

Thank you very much for your help, sorry for the crap picture. It is possible that they might be activated at the same time e.g. at bootup but only for a matter of milliseconds

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.

You need to attach your image file first.

Tom... :slight_smile:

Hi, not sure what is going on? I can see the image fine regardless of whether I login. It's the same method I used for the other images?
Sorry if i have done something wrong.

Hi is this any better? Thanks for your patience

Circuit

Hi,
OPs circuit

Tom... :slight_smile:

If you are only going to drive one output high at a time, then Yes, you can connect the opto's in parallel and share a common current limit resistor.

On the other hand resistors are cheap and small. You should learn why, if you were ever going to activate more than one opto, each opto LED would need its own. Resistor.

Then you might decide to put them on in there “just in case”.

a7

alto777:
On the other hand resistors are cheap and small. You should learn why, if you were ever going to activate more than one opto, each opto LED would need its own. Resistor.

Then you might decide to put them on in there “just in case”.

a7

Thanks everyone. Could you give me a worst case scenario of what can happen?

All I can think of the is that there might not be enough current to activate all the optocouplers?

Or that 6 x 3V/8.6kohm = 2mA will flow at a maximum or am I missing something?

I don't particularly want to mimic button presses simultaneously but it's not disastrous if it happens from that point of view.

Is there a risk of burn out?

Thanks for any assistance

Hi,
The one resistor will do what it is supposed to do, limit the current.

When more than one opto is activated the limited current will be shared to a certain degree between the parallel opto LEDs, so they will be duller or not able to activate the opto output.

Tom... :slight_smile:

Thanks for clearing that up Tom! And thanks to everyone for all the help, much appreciated :slight_smile: