Is switch 2 (emonGLCD) "slow"?

Is Switch 2 on the emonGLCD supposed to be slow to change back from the on to off state? Technically this may be a software or a hardware question, I don't know at the moment.

On my unit it seems to take between 5 and 6 seconds to go back from on to off (after I've released the button).  Pressing the button initially changes the state pretty much immediately.

But switches 1 and 3 are pretty much instant to register the release.

I had been mucking about with the code to change the backlight status from being time based to using one of the switches to toggle it. 

Initially I used switch 2, but I had lots of issues and when I put a diagnostic routine in it was apparent that when I clicked the switch and set it HIGH, it took ages to go back LOW again after I released it.  Typically between 5 and 6 seconds to revert.

Eventually I tried using switch 3 instead, it toggled immediately.  Similarly when I monitored switch 1 it toggled immediately.

Is this normal, or do I have a "mutant"?

 

BTW, I have switch 3 doing the toggle backlight thing quite well now.

 

Thanks

David

Robert Wall's picture

Re: Is switch 2 (emonGLCD) "slow"?

I have not noticed a problem. Are you using the 'tester' sketch - that has minimal code behind the switch operation and should help you to distinguish between the code taking time to change the display and any problem with the input.

Is anything connected to the Jeeport?

Have you checked the value of the pull-down resistor (R8 - 10 k) and the soldering of the switch, resistor and input pin?

Does the switch sound and feel the same as the other two when you operate it?

If you have an oscilloscope, can you see if the voltage switches cleanly as the switch is pressed and released?

baileydau's picture

Re: Is switch 2 (emonGLCD) "slow"?

I was using the SolarPV sketch.  But I've now tried the Tester sketch as well and it seems to have the same results.  It takes several seconds for the "UP" do disappear after I release the button, whereas "Enter" and "Down" go away fairly soon after release.

No, I haven't added anything to my unit.  It's pretty much bog standard.

R8 measures 9.9 k in-situ.  The soldering seems OK.  The switch is at a bit of a Jaunty angle (not watching that it had moved before I soldered it), but apart from that it looks good.

The switch itself feels the same as the other two.

I don't have an oscilloscope, but I have checked with a multi meter.  With all 3 switches the resistance across the 2 pins is a few ohms with the button pressed and it jumps back up to "big numbers" as soon as it's released (typically 4 M Ohm or so if it's going to show anything other than OL).  The numbers do bounce quite a bit, but I *think* that's my DMM and me trying to make contact with the pins.

To me it seems strange that it stays "on" for a long time.  I would have thought if I'd done anything wrong in the assembly, it would be more likely not to make contact / come on easily or at all, rather than stick on.  

Sergegsx's picture

Re: Is switch 2 (emonGLCD) "slow"?

maybe try to use a small wire to open and close the circuit instead of the pushbutton, just to discard the pushbutton.

I havent looked at the tester sketch, but why not just use the simplest possible code, just a Serial.println(DigitalRead(x));

maybe remove the pushbutton, and measure between solder points

good luck

Robert Wall's picture

Re: Is switch 2 (emonGLCD) "slow"?

That has ruled out all the obvious things. As a final test, if you have a suitable switch you could try tacking that in parallel, or even just short across the contacts with your screwdriver. If it responds correctly, I think it's either contamination inside the switch or a mechanical problem. It's Rapid Electronics part 78-1154, or you could try emailing the shop and they might send you a replacement.

baileydau's picture

Re: Is switch 2 (emonGLCD) "slow"?

The screwdriver trick is a good idea.

I've just tried it.  Same results.  It appears the switch definitely isn't the cause.  

Could it be the chip, or its connections or something?

Again, I'm having trouble comprehending how it can stick on rather than not work.

Robert Wall's picture

Re: Is switch 2 (emonGLCD) "slow"?

This is weird. When you press the switch, it connects the digital input to the supply rail. When you release it, the 10 K resistor pulls the input down to ground. The obvious way for that to take a long time is for there to be a capacitor holding a charge that takes time to leak away. There's only one problem with that idea - there isn't a capacitor on the board big enough to account for a 5 or more seconds delay. What voltages do you measure on the input pin (or the switch for that matter) when it's pressed and not pressed? It should be a solid Vcc (3.3 V give or take the regulator tolerance) pressed and a solid 0 V not pressed.

One final thought: is the PCB faulty and there's a bridge to an adjacent track somewhere? I can't see that giving these symptoms, but I'm running out of ideas.

baileydau's picture

Re: Is switch 2 (emonGLCD) "slow"?

Ah, now we might be onto something.

When I measure the voltages across the switches I get:

S1 Open: 3.3 V, Closed: 0 V

S2: Open: < 0.25 V, Closed: 0 V (Sometimes as low as 1.7 V Open)

S3 Open: 3.3 V, Closed: 0 V

So it looks like it may be a dodgy connection.  Unfortunately, I have fully assembled my unit, so the LCD is in the way of doing pretty much anything.  About the only thing I can try is giving the pins of the switch itself a bit of a touch up (even though the *look* OK).

I've tried touching the PCB pads rather than just the switch legs, but same result.  To me, that would indicate the issue is "upstream".

NB.  I tried mucking about with the SolarPV sketch and I set the emonGLCDV1.3 define.  That caused S2 to be "on" all the time.  From what I can tell that was from the digitalWrite(switch2, HIGH) statement.

Robert Wall's picture

Re: Is switch 2 (emonGLCD) "slow"?

"S2: Open: < 0.25 V, Closed: 0 V (Sometimes as low as 1.7 V Open)"

That's definitely showing the problem. What sort of meter are you using? I presume a high impedance DMM?

Referred to ground then, you're seeing Open: 1.6 V to 3.05 V (should be 0 V); Closed, 3.3 V (corrrect). 

As far as I can see, the 3.3 V doesn't go particularly close to that track except at the switch and the Jeeport. Those areas are worth a very careful look before you do anything drastic.

It still leaves the switch as a suspect. If the contacts are not parting, that would give these symptoms. Is it possible for you to remove it without damaging the pcb? You will probably need to melt all 4 pads simultaneously. If you think the risk of damaging the board is too great, you could cut the track between the switch and R8 on the basis that it's easily repairable with a fine wire between those pads. If a wire then between Vcc and R8 works cleanly, it's the switch. (And you've still got to get it out.)

baileydau's picture

Re: Is switch 2 (emonGLCD) "slow"?

Yes the DMM is a decent quality, but old one (a very old Fluke 25 unit)

Actually my measurements were across the switch pins.  So the opposite of the way you described.

(NB.  The lower figure was actually 0.17 V, not my typo of 1.7 V)

I've done some other measurements from the various pins to GND (on the JeePort)

+ve on S2 3.3 V (open or closed)

-ve on S2 Open 0.17 V Closed 3.3 V

So it definitely looks like the switch is always making a partial connection.

Unfortunately as my unit is fully assembled, I don't think I'd be able to remove the switch.  The back two stabiliser pins are under the Backlight / LCD.  The switch pins are *just* accessible.  

 

baileydau's picture

Re: Is switch 2 (emonGLCD) "slow"?

Whoo hoo!  

Don't know what I did, but it seems "fixed" (for variable definitions of fixed).  I was just fiddling around in the area.  Not doing anything in particular.

It now releases immediately.  Although it now sometimes takes a couple of goes at detecting the initial press, but it's mostly OK.

Checking the voltages, they are now 3.3 V / 0 V as they should be.

I do have my switch status display area on all of the screens, so I can see if it has detected the press or not.

Thank you for your assistance.

Robert Wall's picture

Re: Is switch 2 (emonGLCD) "slow"?

I don't like that! It really sounds like a faulty switch. My money would be on it coming back sooner or later. (The clue is "Although it now sometimes takes a couple of goes at detecting the initial press".)

Anyway, I'm glad it's sorted for now and you know where to look if it does misbehave in the future.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.