Author Topic: Why would a button connected to a MCU be switching a 16KHz signal?  (Read 1219 times)

0 Members and 1 Guest are viewing this topic.

Offline mchahnTopic starter

  • Newbie
  • Posts: 7
  • Country: us
I am adding wifi to an old thermostat.  I'm using an esp32.  Luckily there are test points next to each button in the thermostat so I'll have no trouble attaching wires. 

Several of the switch inputs have the usual design of a switch with a pullup such that the output goes to zero when the switch is pressed.  I can simulate a press by just pulling the output down with a gpio pin

However, there are some snap-action dome switches that are baffling me.  Even though they are domes they just make a connection between two wires like any switch.  When the switch is open the output is low.  When the switch is closed the output shows a 16KHz square-wave.  At first I thought that it my be a capacitive-touch sensor.  But that makes no sense since the switch is making a normal electrical contact.

I'm not sure how to simulate a press on this.  I could drive the output with a gpio pin using a square wave.  But this makes me nervous since I don't understand the circuit I'm dealing with.

Does anyone have a clue why the switch has the square wave?
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8276
Re: Why would a button connected to a MCU be switching a 16KHz signal?
« Reply #1 on: March 02, 2024, 05:40:00 am »
They may be multiplexed and you're seeing the scanning frequency. A relay may be the best way to simulate pressing them.
 

Offline mchahnTopic starter

  • Newbie
  • Posts: 7
  • Country: us
Re: Why would a button connected to a MCU be switching a 16KHz signal?
« Reply #2 on: March 02, 2024, 05:49:36 am »
They may be multiplexed and you're seeing the scanning frequency.
Interesting.  I'm going to have to give some thought to this so I can figure out what is going on.

A relay may be the best way to simulate pressing them.
Unfortunately I only have access to one side of the switch, the side I'm calling the output.  Luckily the output does change when I press the switch.  That side could have been a ground.

I can defnitely detect when the switch is pressed which is half the battle.  I'd really like to be able to simulate a press though so I could remotely press the button.
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3711
  • Country: nl
Re: Why would a button connected to a MCU be switching a 16KHz signal?
« Reply #3 on: March 02, 2024, 07:18:42 am »
Post some pictures of the inside of the thermostat and especially the part with the dome buttons. It might be a scanning matrix and to simulate these you can use analog switches like in the 4066 ic. Another option is to use the IO of the ESP32 directly, but requires the matrix to be on the same voltage level.

Old stuff probably works on 5V, so the latter option won't do unless using level converters.

A matrix scan has a couple of outputs going into the matrix and a couple of inputs coming from the matrix. To simulate a specific key press your system has to make a connection between it's so called scan line and the data line.

Take a look here for more info on how it works.

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 3722
  • Country: us
Re: Why would a button connected to a MCU be switching a 16KHz signal?
« Reply #4 on: March 02, 2024, 05:47:37 pm »
Is it a 50/50 duty cycle square wave or is it a pulse train? How many buttons are there like this?  If it is something like a 3x4 numper pad, you would expect the duty cycle of the pulse to be 25% or 33% not 50%.  I wouldmt expect a scanning for fewer buttons than that.

If it's a scanning multiplexer you are going to have a hard time simulating it without access to the other side of the switch or being able to synchronize with the scan rate.  If you had access to both sides of the switch a MOSFET would do the job easily.
 

Offline mchahnTopic starter

  • Newbie
  • Posts: 7
  • Country: us
Re: Why would a button connected to a MCU be switching a 16KHz signal?
« Reply #5 on: March 02, 2024, 06:00:27 pm »
Post some pictures of the inside of the thermostat
Unfortunately every signal goes immediately into a 4-layer board so there isn't anything to see.

It might be a scanning matrix and to simulate these you can use analog switches like in the 4066 ic. Another option is to use the IO of the ESP32 directly, but requires the matrix to be on the same voltage level.
It is all 3.3V so using the esp32 gpio is no problem.

But it does not appear to be a matrix. 

I have one test point per button and that point puts out a wave only when that specific button is pressed and not when any other button is pressed.  In other words there is never more than one test point active.  If it was a matrix then multiple points would be on one row heading into the mcu and I would get a signal on more than one test point when only one button is pressed.

This still leaves me wondering why there is a wave instead of a simple level.

So I can detect when a specific button is pressed.  Now I'm just left with the press simulation problem.
 
When I get the esp32 gpios conected I'll try driving those points.  I'll check immediately to see if the signal is ever anything other than 3.3V or ground.  I know from experience that two drivers conflicting causes an intermediate voltage so I'll know if it is safe to drive.  If safe then I can try sending various waveforms in.

Wish me luck.
 

Offline mchahnTopic starter

  • Newbie
  • Posts: 7
  • Country: us
Re: Why would a button connected to a MCU be switching a 16KHz signal?
« Reply #6 on: March 02, 2024, 06:06:47 pm »
Is it a 50/50 duty cycle square wave or is it a pulse train?
It is close to 50/50 but not exactly.  Maybe 60/40.  And that signal is unchanging the whole time the button is pressed.

How many buttons are there like this?  If it is something like a 3x4 numper pad, you would expect the duty cycle of the pulse to be 25% or 33% not 50%.  I would not expect a scanning for fewer buttons than that.
Six buttons.  A 3x2 matrix would only save one connection which would be unlikely.

So all this again points to it not being a matrix.
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 3722
  • Country: us
Re: Why would a button connected to a MCU be switching a 16KHz signal?
« Reply #7 on: March 02, 2024, 06:12:50 pm »
Maybe for some reason they needed DC isolation and the button signals are capacitively coupled?

Are the signals for each button the same frequency?  Maybe it was intended to be or originated from some frequency modulation  signalling like touch tone phones?  Maybe for communication between thermostats in a multi zone setup over the existing thermostat wiring?
 

Offline mchahnTopic starter

  • Newbie
  • Posts: 7
  • Country: us
Re: Why would a button connected to a MCU be switching a 16KHz signal?
« Reply #8 on: March 02, 2024, 06:23:46 pm »
Maybe for some reason they needed DC isolation and the button signals are capacitively coupled?
I thought the same thing.  Most MCUs have capacitive touch sensor inputs. Maybe the top part of the dome doesn't touch the bottom part.  Or maybe it is an unreliable connection.  The dome has to be made of spring metal which may not make good contact.

Are the signals for each button the same frequency?  Maybe it was intended to be or originated from some frequency modulation signalling like touch tone phones?
Again, I would see a signal on multiple test points.  Also I don't see why anyone would go to that trouble.  I don't see a reason.  But I will check the frequencies.

Maybe for communication between thermostats in a multi zone setup over the existing thermostat wiring?
This is not the case.  The only connections to the outside world are the 24VAC lines driven by relays.
 

Offline pcprogrammer

  • Super Contributor
  • ***
  • Posts: 3711
  • Country: nl
Re: Why would a button connected to a MCU be switching a 16KHz signal?
« Reply #9 on: March 02, 2024, 08:06:45 pm »
Unfortunately every signal goes immediately into a 4-layer board so there isn't anything to see.

That does not sound like an old thermostat. Still pictures would be nice because we love pictures.  :)

If every key has it's own test point and there is no coupling found between the keys then it might indeed be that there is a capacitor in play. Can you post a picture of what the signal you see on the scope looks like.

If you have a signal generator you can test if the key press is seen when you apply a 16KHz signal to the test point. Use a series resistor of say 100 Ohms to protect the generator and the thermostat.

When this works, then you can simply output this 16KHz signal from your ESP32 to simulate the key press.

Offline mchahnTopic starter

  • Newbie
  • Posts: 7
  • Country: us
Re: Why would a button connected to a MCU be switching a 16KHz signal?
« Reply #10 on: March 03, 2024, 01:14:41 am »
That does not sound like an old thermostat. Still pictures would be nice because we love pictures.  :)
I shouldn't have said old.  It is only a few years old but I got a newer one so it was old to me.  It has all the fancy programming stuff.  If I get everything to work then it will be the new one.

Can you post a picture of what the signal you see on the scope looks like?
It is a plain digital signal from 0 to 3.3 volts.  It is up for 40ms and then down for 20 ms.  This repeats as long as the key is held down.  Sorry to disappoint but I'm too lazy to take a pic.

If you have a signal generator you can test if the key press is seen when you apply a 16KHz signal to the test point. Use a series resistor of say 100 Ohms to protect the generator and the thermostat.
I don't have a signal generator but I could whip out an eps32 signal if I took the trouble.  My PCB with the esp32 and all the interface circuitry is due soon.  It would be easiest to just use that.

When this works, then you can simply output this 16KHz signal from your ESP32 to simulate the key press.
I sure hope so.

In case anyone is interested I'll describe the complete setup. 

I've soldered fine wires to all the test points.  The points were only about one mm square pads so it was quite hard to do. Halfway through I figured I couldn't do it and I would probably also kill the unit but everything worked well at the end.

My custom board is due in next week.  It has the esp32 with direct gpio connections to each test point that I can sense and also hopefully drive.   

The board also has the 24vac signals G, W1, W2, Y1, Y2, and C connected to io circuitry.  The ac signals are half-wave rectified to a giant cap which then drives the input to an opto-isolator.  The output of the isolator then goes in to more gpio pins.  These are only sensed, I don't need to drive them.

I'll post the final results here.  I bought the minimum of five boards so I will have 3 or 4 left.  If anyone wants to also wire up a thermostat I'll give away free boards.  The design is very general and would work with any thermostat.

Wish me luck. 
 

Offline mchahnTopic starter

  • Newbie
  • Posts: 7
  • Country: us
Re: Why would a button connected to a MCU be switching a 16KHz signal?
« Reply #11 on: March 05, 2024, 11:49:34 pm »
In case anyone cares, I'm giving up on controlling the buttons on the thermostat.  I can't simulate a press and detecting a physical button press is unreliable.  It turns out the buttons use a very high impedance which means it probably is a type of touch sensor.  I'll still use my custom board to monitor the 24vac system control activity over wifi.

Thanks everyone for the help.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf