Posts

Showing posts from April, 2020

LG 2011 front loader washing machine buttons don't work: repair (Model wm2140cw)

Removable top
This 2011 washing machine has served us well thru one child's worth of cloth diapers. But while it still cleans, the front panel buttons have gotten somewhat less responsive (in particular the "play/pause" button which we use every single time, natch).

After I got the top off the hard part started
Unfortunately the front panel is somewhat time consuming to remove. You need to remove the top of the washer. To do this, you need to remove two screws from the back of the washer. These attach a pair of plastic standoffs to the top and body of the washer. You can leave the standoffs attached to the top. Then just push the top back, it should slide fairly freely. Then you can lift it off.

Now, getting the front panel off. This part was the tricky bit. Two screws from the front under the detergent door (green circles), and one from the back (red circle). But there are these three tabs (red circles) that also hold it on, which make the screws kind of unnecessary. I'm still unsure what exactly I did to make it all give way. MAYBE some upward prying, maybe some prying on the tabs themselves (one broke). Maybe it just had pity on me after I cut myself (or, could it be that blood sacrifice is required?).
Once you get here it's easy

Actually I'm sure it wasn't so bad. Just very annoying and at least 10 minutes of futzing. Now the rest is pretty obvious and in no time I'm looking and the circuit board.

The buttons are fairly standard; on ebay I found them under the title Tact Switch Push Button 6*6*5 6mm*6mm*5mm 2pin Through Hole SPST-NO.

Of course I didn't know that's what I was going to need ahead of time so rather than wait for them to be delivered from china I did my favorite repair "hack" and stole a less used button from the same panel (the signal volume) and swapped them (soldering iron required, of course). I actually swapped several, since the temp control button was also getting a little iffy.

For reassembly, I skipped the internal screw that hend the panel down. Seems secure enough without it, and it appears that I could  get the thing apart now without taking the top off.


Circuit board: what I actually wanted to work on


All the buttons seem to be pretty nicely attached to this removable plastic bit screwed to the panel. I didn't lose a single one. I didn't even try that hard. 



Raspberry Pi ADC (measure analog voltages) using ADS1115

The raspberry pi only has digital inputs. With a capacitor and careful timing you can use that to measure analog voltage, but not with any temporal accuracy. Here I'm using an addon board (using an ADS1115 chip) which can take 860 samples a second with up to 15 bits of resolution.

Steps:

(1) set up i2c bus to connect to ADC

https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c

(2) characteristics of ADS1115 discussed here

http://www.bristolwatch.com/rpi/ads1115.html

(3) This link describes the wiring in pretty good detail and suggests that it's better to power the chip using 3.3v not 5v.

https://leanpub.com/rpcanalog/read#leanpub-auto-analog-to-digital-conversion-adc

(4) The actual wiring I used (breadboard):

https://alantechreview.blogspot.com/2020/04/photodiode-wiring-example-and-resources.html

(5) and now on the pi with the ADS1115 hooked up (5v power). black tube contains a photodiode

100k resistor is hidden inside the blue tape under the ADC board.



Here's some C code, stolen and modified. 

#include
#include
#include
#include
#include     // read/write usleep
#include     // exit function
#include   // uint8_t, etc
#include // I2C bus definitions

#include

long long microsec() { // since epoc
    struct timespec spec;
    clock_gettime(CLOCK_REALTIME, &spec);
    return ((long long) spec.tv_sec *1000000LL) + (spec.tv_nsec / 1.0e3); // Convert nanoseconds to microseconds (1.0e6 would give milliseconds)
}

// Setup to use ADC0 single ended

int fd;
int asd_address = 0x48; // Note PCF8591 defaults to 0x48!
int16_t val;
uint8_t writeBuf[3];
uint8_t readBuf[2];
float myfloat;

const float VPS = 4.096 / 32768.0; // volts per step

/* Signal Handler for ^C */
void sigint_handler(int sig_num)
{
    printf("\n User provided signal handler for Ctrl+C \n");
  // power down ASD1115
  writeBuf[0] = 1;    // config register is 1
  writeBuf[1] = 0b11000011; // bit 15-8 0xC3 single shot on
  writeBuf[2] = 0b10000101; // bits 7-0  0x85
  if (write(fd, writeBuf, 3) != 3) {
    perror("Write to register 1");
    exit (1);
  }
    exit(0);
}

/*
The resolution of the ADC in single ended mode 
we have 15 bit rather than 16 bit resolution, 
the 16th bit being the sign of the differential 
reading.
*/

int readval()
 {

  if (read(fd, readBuf, 2) != 2)  // read conversion register
{
  perror("Read conversion");
  exit(-1);
    }
    return readBuf[0] << 8 | readBuf[1]; // could also multiply by 256 then add readBuf[1]
 }

int main() {

 signal(2, sigint_handler); // runs until ^c,  this allows ADC cleanup 

 nice(-20); // as high priority as possible

    // open device on /dev/i2c-1 
  if ((fd = open("/dev/i2c-1", O_RDWR)) < 0) {
    printf("Error: Couldn't open device! %d\n", fd);
    exit (1);
  }

  // connect to ADS1115 as i2c slave
  if (ioctl(fd, I2C_SLAVE, asd_address) < 0) {
    printf("Error: Couldn't find device on address!\n");
    exit (1);
  }

  // set config register and start conversion
  // AIN0 and GND, 4.096v, 128s/s
  // Refer to page 19 area of spec sheet
  writeBuf[0] = 1; // config register is 1
//                76543210 
  writeBuf[1] = 0b11000010; //  continuous, ANC0,  amp gain 
  // bit 7 flag bit for single shot not used here
  // Bits 6-4 input selection:
  // 100 ANC0; 101 ANC1; 110 ANC2; 111 ANC3
  // Bits (3-1) Amp gain. Defaults to 010, here we use 001, see P.19
  // Bit 0 Operational mode of the ADS1115.
  // 0 : Continuous conversion mode
  // 1 : Power-down single-shot mode (default)
                //76543210
  writeBuf[2] = 0b11100101; // bits 7-0  0x85
  // Bits 7-5 data rate default to 100 for 128SPS. 0=8, 111=860
  // Bits 4-0  comparator functions see spec sheet.

  // begin conversion
  if (write(fd, writeBuf, 3) != 3) {
    perror("Write to register 1");
    exit (1);
  }

  sleep(1);


  // set pointer to 0
  readBuf[0] = 0;
  if (write(fd, readBuf, 1) != 1) {
    perror("Write register select");
    exit(-1);
  }
  
long long t;
int count = 0;

int buf[100];
float delta[100];
t = microsec();
while (count < 100)
  {
  buf[count] = readval();
  delta[count]= (microsec()-t)/1000.0;
  count++;
  }
for (int i = 0; i < 100; i++)
  {
  printf("Raw %i \t@ %3.3fms \t volts: %3.3f\n",buf[i], delta[i], buf[i]*VPS );
  } // end while loop

  close(fd);

  return 0;
}


changing raspberry pi zero i2c baud rate: what actually works

The syntax is fragile; an extra space breaks it, so just copy and paste into /boot/config.txt.

#100kbps, slow, default
dtparam=i2c_arm=on
dtparam=i2c_arm_baudrate=100000

#400kbs, "fast"
dtparam=i2c_arm=on
dtparam=i2c_arm_baudrate=400000

#1.2mbs, "high speed"
dtparam=i2c_arm=on
dtparam=i2c_arm_baudrate=1200000


You may see elsewhere that you can check the baudrate with these commands, but they don't work for me:

cat /sys/module/i2c_bcm2708/parameters/baudrate
cat /sys/class/i2c-adapter/i2c-1/of_node/clock-frequency

While you cannot verify the baudrate setting directly, you can time how quickly data can be read from /dev/i2c-1. I can read 100 bytes in 7ms at 1.2mbs "high speed" talking to an ADS1115 adc (note: it's sample rate is lower than that, but the currently digitized value can be read that fast).

Starcraft 2 installer stuck on "Downloading new files": fix!

Installing starcraft 2 just wasn't going anywhere: it was stuck on Downloading new files no matter how long I waited.

The logs suggested an infinite timeout (C:\ProgramData\Battle.net\Setup\s2_2\Logs):

E 2020-04-22 21:01:34.815206 [Main] {3f30} Downloader - {3f30} ERR (d:\buildserver\bna-2\work-git\bootstrapper-repository\contrib\contrib\bnl_dl2\fetcher\source\fetcher\httpfetcherimpl.cpp, line 392): HTTP: connection failed for host 137.221.106.19:1119: NET_CANCELED

The solution: somehow my spectrum-supplied router had gotten the firewall enabled, even though I had turned off the Windows 10 firewall long ago. THANKS SPECTRUM (/TWC). Setting the router firewall to "low" (allow all traffic) fixed the problem instantly.





Photodiode wiring example and resources

Being fairly new to circuit design I had to collect several resources to help me get started wiring a photodiode to a raspberry pi.  I used a so-called reverse bias configuration, where the shorter of the two pins on the photodiode is driven by +5v, and then voltage across a 100k resistor in series after the photodiode is the measurement point. Zero light gave millivolts, and the "flashlight" from my phone gave nearly 5V. An ADC is required to read the voltage with any precision, to get started I just used a voltmeter.

This is perhaps the most useful circuit diagram.

This was also helpful.

Which pin is which on the photodiode?

A nice affordable photodiode from my favorite electronic component store.


Adventures of the quarantined repairman: the kitchen scale fix (WH-B05)

New button, old plastic
This scale has been with us for 10 years and while it still measures accurately, it fails in another key function: turning on. The power switch takes more and more aggressive pushing to bring it to life. I found that an identical scale could be purchased from ebay for about $4, and my time is worth something so I got it. Unfortunately, the identical scale wasn't.

Same appearance, same model number, but different behavior: significant lag between changing the weight and changing the display. I'm guessing they decided that the occasional noise on the least significant digit was too annoying. It was "better" to use a noise rejection algorithm that prevents the display update until the new measurement has been significantly different from the old one for several seconds. Unfortunately this means that using the scale to measure something like flour or water (yes, I'm making bread) is an exercise in frustration. When you finally get 300g of water poured into the beaker, you find out 2 seconds later that it's really 330g of water. Ugh.

So, time to fix the old scale. Simple, hopefully. I've got two "identical" scales, perhaps I can reuse the new button on the old scale? No luck. It's nothing like "identical" inside, though there are enough conserved design features that I suspect the new one was evolved from the old one.

Solution 2: add a new button. Problem is getting exactly the same button as the old one is required if it's going to fit and work. So I used a random button from some old junk, and attached it on the outside of the case, running wires to the critical point in the circuit that need to be shorted to turn it on.
Cue the pictures. I got a new button from an old car cassette player. The buttons were surface mounted, and at first I tried to desolder them. Ouch, 4 points of contact and no space under the button makes this very tricky. Solution: cut the switch off with some of the circuit board still attached. Gives me more surface to glue to. 

Now I can solder two wires to the circuit board, and bend them under and hot glue the mess into a relatively monolithic blob on the side of the scale. Two holes in the scale allow for the wires to get inside. Then it was relatively simple to wire them to the pcboard: it had test points for gnd and p1 (the switch, apparently).

Source of my "new" button
The end result is not pretty. But it works nicely. Better than original, since the switch I used is from a high quality SONY tape deck. And you thought cassettes were dead!

plenty of space inside to run the wires



Counterfeit PS1 Memory cards or Genuine?

I have two PSOne (in color scheme at last) memory cards that didn't work, so I took them apart to see if there was anything obviously wrong. There wasn't. But I was quite surprised how different they looked on the inside. 

One had a big SONY emblazoned on the flash chip itself, the other had no mention of Sony anywhere. The PC boards certainly looked like different kinds of layouts, different pcboard dye, etc, and one was taller than the other. Since both were dead I can't speculate about the "crappy" counterfeit quality. 

Certainly I expect Sony made several iterations of their 128KB memory cards over the many years the PS1 was sold, but since these are both PSOne colored I assume them to be from that relatively short era at the end of the life cycle of the PSX.

PS: the PSone was named in contrast to the PS2, and was a smaller but genuine full-fledged PS1 console made by Sony and sold concurrently with the PS2. Sometimes it's called the PS1mini, creating confusion today since it's entirely different than the ARM based emulator sold a decade(plus) later to retro enthusiasts who didn't know better.

So what do you think? Do I have One, Two(!) or zero counterfeit memory cards?

Controlling the raspberry pi Zero built-in LED: via BMC pin or led0

The activity LED on the pi PCB is normally driven by "disk" activity but you can control it directly.  The PiZero broadcom pin number for the LED differs from the other models so you may tear out your hair if you want to control it from wiringPi or other programming libraries, but from the command line it's called led0 just like all other pi boards.

Command line:

Put LED under manual control:
echo none > /sys/class/leds/led0/trigger 


turn on led:
echo 0 >/sys/class/leds/led0/brightness

turn off led:

echo 1 >/sys/class/leds/led0/brightness

Yes, that's backwards from what you would expect. The LED is active-low and the designers didn't encapsulate that detail.

What if you want to control it from a library like WiringPi? Then you need to know the broadcom (BCM) pin wired to the LED. On the Zero (w) it's pin 47. You can test this for yourself at the command line:

gpio -g blink 47

If you have a non-zero pi, try BCM pin 16. I only deal in zeros, so I cannot confirm.

For controlling the LED0 from C/C++ code I've found two libraries, here's the examples/docs for both: (pigpio) http://abyz.me.uk/rpi/pigpio/cif.html and (wiringpi) http://wiringpi.com/examples/blink/.  Don't know which I would use yet. There's at least one thread suggesting pigpio has better latency.

In any case, using wiringpi:

#include
int main (void)
{
wiringPiSetupGpio ();
  pinMode (47, OUTPUT) ;
  for (;;)
  {
    digitalWrite (47, HIGH) ; delay (500) ;
    digitalWrite (47,  LOW) ; delay (500) ;
  }
  return 0 ;
}


Note: pi zero only has one LED, despite having a led1 in the filesystem path.

fixing infinite apt-get install timeout on raspberry pi

For some reason the IP6 address of the archive causes connection problems and infinite timeouts connecting. The solution is to force IP4, which you can make permanent.
 
Two methods. 1st method is best because it also fixes wget

sudo nano /etc/sysctl.conf
append the following lines to turn off ipv6:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
run sudo sysctl -p to take effect or just reboot.

2nd method, apt-get only

echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4

Repairing bad button on Sanwa optical trackball wrist rest MA-TB42BK

New Sanwa optical trackball mouse wrist rest black MA-TB42BK

These trackballs are the only game in town if you want a trackball centered below the keyboard where you can drive it with your thumbs. I used to use a keytronic lifetime keyboard that had an integrated trackball but it was always needing to be cleaned (yes, it dated from the mechanical period!). This is better because it's optical, altho not without its flaws, most notably the DPI is too high, aka the cursor moves too fast per revolution of the ball. You can turn down sensitivity in windows to compensate but there aren't enough steps on the scale to get a setting that isn't either a bit too fast or a bit too slow.

But this is not a review. This is a quick discussion of fixing a bad button on the trackball. After owning it for about 2 years the left "mouse" button started to act up - at first it would register a double click when there was just one, but after a while holding down the button would intermittently produce several clicks over the period of a second. Definitely not usable. Clearly the microswitch wasn't making good contact. Disassembling the trackball wasn't hard - the electronics are entirely in the little box in the center, which makes a bit of a tight fit, but eventually you get enough unscrewed that you can just lift it out, as shown. (blue tape is my addition, to be explained below).


After bit more disassembly, you get to this stage: a single circuit board with 3 micro switches soldered on. These switches can be hard to desolder, as they have 3 pins though the board. The first time I tried it took me 2 hours to remove two switches (the left and middle) and swap them. My usual technique of desoldering one pin at a time and rocking the component (usually a capacitor) doesn't work when there are three pins.  But part of that time was also having to re-solder the USB cord to the board.  The wires are all immediately adjacent to the left switch and are very thin, so with enough heat applied to the microswitch the USB wires will come loose. Save yourself some trouble down the line and put tape on each side so that they can't pull loose, or fatigue in two. 


The good news is that even after two hours of overheating the board and prying on the microswitches I hadn't damaged the board and everything worked. My middle mouse button now worked as poorly as the left had (because it was now driven by the old microswitch from the left side) but no loss, I never use the middle button. The bad news was that about a year later the "new" left microswitch started to fail too.

Bad batch, or cheap components, but either way there wasn't another unused microswitch to swap it with. Ebay listed some microswitches for mice, but none specifically for this model or Sanwa in general, and it seemed like a bit of leap that all mice/trackballs would use the same size switches. What to do? Should I pull the trigger on a slow boat from china that might not solve my problem, or even if they fit, last even less long than the Sanwa switches? Inspired by the slim possibility that all mice used the same microswitches, I pulled out an old Kensington Orbit trackball (gen 1) that had been hacked to bits in an attempt to DIY a trackball centered below the keyboard (short story: it worked, but not ergonomically). Sure enough, the micro switches were the same size, and had the same pin spacing! The great thing about this is I trust kensington to have used higher quality microswitches than sanwa or (especially) random ebayer.

This time the replacement went much faster, in part because I have a much nicer soldering setup, with a soldering station that can really put out the heat. Instead of doing one pin at a time, I just held the tip sideways and pressed on all three pins at once after preheating them individually. Pop! Out in less than a minute, each. After sucking the solder out of the pinholes it was easy to stick the new(er) microswitch in and solder it in place. The only hang up that lost me 20 or so minutes was that some USB wires detached again because of how difficult it was to do a quality solder job on them the first time. Really paid the price for not taping them in the first time (or gluing).

The first time I did this repair (taking 2 hours) I really regretted the time spent. The 2nd time, it was quick and easy. Now that these go for $50 and up, it was financially worth it, too, not to mention the moral plus of avoided waste.

Email me

Name

Email *

Message *