All posts by Per Magnusson

Reviving a Dead Mains Timer

It is that time of year when one puts electric advent stars and candlesticks in the windows. I usually use timers to control them, but this year I ran into a problem. Some of my timers were of the type “EverFlourish EMT757A”, probably bought at Clas Ohlson:

Back side of timer
Back side of timer

Despite having a notoriously bad user interface (that forces me to google the user manual each time I want to use them), the timers, that had been laying in a drawer since last season, showed an entirely blank LCD display, even when connected to a mains outlet. I guessed that an internal battery just need to be charged, so I left them connected for a day to allow them to be charged up. The display however remained blank.

Hmm. I had encountered similar timers before that needed the internal battery to be replaced, so I decided to have a look inside to determine if this was the case again. It turned out that the screws used to keep the units together had tamper proof tri-wing heads. Fortunately, I happened to have bits that fit this kind of head, so this did not deter me.

Tri-wing screw head
Tamper proof tri-wing screw head
Tri-wing bit
Tri-wing bit

I found that there was indeed a tiny chargeable NiMH battery inside the unit (the green component with white corrosion on the side, close to the center of the picture below). Despite the unwanted corrosion, I found that the battery was actually charged to 1.3 V or thereabout, which is fine for a NiMH battery. Maybe it did not need to be replaced after all?

Opened mains timer
Opened mains timer

But why then was the display dead?

I put the timer back together again and had another look at the front. Pressing any of the normal buttons did not result in any reaction, but there was also a tiny little recessed button marked RESET. I used a pen to press it and voilà! The display came to life!

The timer has been brought back to life.
The timer has been brought back to life.

Stupid me to not try this before I disassembled the unit.

I suppose the reason the timer behaves like this is that the processor controlling the display probably does not have a proper power on reset circuit. So when the supply voltage is ramped very slowly, as it is when it is powered from a battery that is trickle charged from a state of being completely dead, the processor does not jump into action properly, even after the supply voltage reaches its proper level.

Electronics Podcasts

I regularly listen to a number of podcasts and below is a list, along with some comments, of the electronics related ones.

I find that the podcasts provide inspiration, insight and knowledge about tools, projects, parts, companies, people and resources in the world of electronics. I first learned about many of the building blocks, components and development tools I use in my hobby projects through these podcasts.

The Amp Hour

I guess this is the longest running electronics related podcast I know of, started in 2010. “An off-the-cuff podcast about electronics designs, and anything electronic industry related.” Chris Gammell and Dave Jones (of the EEVblog) chat weekly either with each other or guests about industry news, hacker/maker/open hardware stuff or other things mostly related to electronics. Chris works for Parts IO and teaches the online course Contextual Electronics while Dave is an opinionated and quite successful youtuber. If I need to pick a favorite electronics podcast, this is it.

Embedded

Started in 2013 this is another weekly show, but slightly more geared towards embedded software than electronics, although some of the guests are more into electronics. Elecia and Christopher White discuss between themselves or with guests about “the how, why, and what of engineering, usually devices.” The guests include “makers, entrepreneurs, educators, and normal, traditional engineers.” Both Elecia and Christopher are embedded software consultants in Silicon Valley. Well worth a listen if you are into electronics or embedded software.

The Spark Gap Podcast

“A podcast discussing the nuts and bolts of embedded electronics, the systems that use them, and the community that surrounds them.” Started in 2014 and hosted by Karl and Corey. Episodes often have a specific theme and occasionally features guests. This podcast recently came back from a five month hiatus and hopefully new episodes will continue to appear reasonably regularly.

MacroFab’s Engineering Podcast

MacroFab describes themselves as “The World’s First Self-Service Cloud Manufacturing Platform” and seem to specialize in small volume PCBA manufacturing. The weekly podcast was started in 2016 and is hosted by Parker Dillmann and Stephen Kraig who are engineers at the company. They mostly talk enthusiastically about projects they are working on (they seem to do a lot of fun projects, often with unclear connection to the business) and discuss industry news. The program can be quite inspirational and does not feel like an ad for MacroFab.

A little warning might be in place. Of the podcasts listed here, I get the impression that this is the one on which the hosts are most likely to sound relatively sure about something that is utterly wrong.

SolderSmoke Podcast

SolderSmoke is mostly about home-brew HAM radio. Hosts Bill Meara, M0HBR, and Pete Juliano, N6QW, discuss their radio projects and issues they run into. This is the show for anyone who is interested in home-brew radio or perhaps HAM radio in general.

The Engineering Commons Podcast

This bi-weekly podcast is only occasionally about electronics and more often about other aspects of engineering and being – or becoming – an engineer. It was co-founded in 2012 by Chris Gammell of The Amp Hour, but he left the program a few years ago. Today the show is hosted by the other co-founder Jeff Shelton (a mechanical engineer) as well as Adam (civil engineer), Brian (electrical engineer) and Carmen (also an electrical engineer).

PCB Tech Talk

This podcast was started by Mentor Graphics in 2015 and was hosted by John McMillan for 10 episodes before it abruptly ended for unknown reasons. It contained some useful information and insights for PCB layout designers, but also tended to push Mentor’s tools and brand. It distinctly felt like it was produced by a company as opposed to the other podcasts on this list which are run by more or less independent enthusiasts.

Fixing Sportident Thermal Printer Issues

The youth section of my orienteering club has a Sportident thermal printer connected to an SI station for use on trainings. This has worked fine for a few years, but for some reason it started printing garbage and I was asked to have a look at it.

I had never used the printer before, but I started troubleshooting. The SI station had old firmware, so I updated that using Sportident Config+, but this did not help. At first I did not get the printer to print anything, but that turned out to be because I had failed to realize that the SI logo was actually a hidden power button one has to press briefly to turn the printer on or off. After the printer was powered on, it did indeed print garbage when I tried to print the contents of an SI card.

The printer is a Martel MCP7830-242 printer with a serial port and I was able to find a manual for it. It turns out a customized manual is also available from Sportident. I suspected the problem might be that the printer was set up to use an incorrect baud rate and I first tried to set the SI station in its two possible states, namely 4800 and 38400 bauds, but that did not help. The manuals have instructions on how to change the baud rate on the printer and according to those instructions, one should keep the power button pressed a couple of seconds until the LED starts blinking, then one should press the button four times and wait for the LED to blink four times (this enters the baud setting mode), then press the button six times to select 4800 baud. Unfortunately this did not help and the printer still printed garbage.

I then decided to talk to the printer from a PC and I wrote a small Python script to try to send commands to it at different baud rates. After some fiddling around, the printer started responding, but at the unexpected baud rate of 600 bauds!

The Python code is shown at the end of this post in case someone is interested.

I retried the baud rate setting, but still with the result of getting the printer to accept 600 bauds. A note above the tables in the manual says one should do a single button press to select 19200 bauds, but the table says the button should be pressed five times. This made me try to press the button three instead of six times (4800 comes two steps after 19200 in the table) and after this, the printer started working at 4800! So the correct sequence for setting the baud rate to 4800 is this:

  1. Printer is off
  2. Hold down the button for a few seconds until the LED starts flashing.
  3. Press the button 4 times.
  4. Wait for the LED to flash 4 times.
  5. Press the button 3 times.
  6. Wait for the LED to flash 3 times.
  7. Done!

After I got it all to work I realized that one can check the mode of the printer in the following way:

  1. Printer is off
  2. Hold down the button for two seconds.
  3. The printer prints its status, including the baud rate.

If I had known this from the start I might have solved this much quicker.

Below is the Python code.


#! /usr/bin/python

"""
com-port-sender.py

Rev 0.1, 2016-09-28
Per Magnusson, Axotron, axotron.se/blog

This code is public domain and comes with absolutely no warranty. Enjoy!

Send some data on a serial port to test a Martel/Sportident MCP7830 printer.
"""

from __future__ import print_function
import serial
import serial.tools.list_ports
import sys
import time
import msvcrt
import struct


# Look for a COM port that might have a serial port adapter connected
portfound = False
ports = list(serial.tools.list_ports.comports())
for p in ports:
    print(p)
    print(p[1])
    if "Prolific" in p[1]:
        print("Found port on " + p[0])
        if not portfound:
            portname = p[0]
            portfound = True
            print("Using " + portname)
        else:
            print("Ignoring this port, using the first one that was found.")

if portfound:
    ser = serial.Serial(portname, 4800, timeout=0.1)
else:
    print("No good serial port found. Exiting.")
    time.sleep(10)
    sys.exit("No good serial port found.")


def to_printer(ser, data):
    for b in data:
        print("{:d} ".format(ord(b)), end="")
    ser.write(data)
    print("")

def send_ESC(ser):
    to_printer(ser, b'\x1b') # 27 == ESC

def send_NULL(ser):
    to_printer(ser, b'x\00')

def set_sweden(ser):
    send_ESC(ser)
    to_printer(ser, b'R5')

def set_mode_default(ser):
    send_ESC(ser)
    to_printer(ser, b'!\x00')

def reset_printer(ser):
    send_ESC(ser)
    to_printer(ser, b'\xff')

def reset_printer2(ser):
    send_ESC(ser)
    to_printer(ser, b'@')

def printer_self_test(ser):
    send_ESC(ser)
    to_printer(ser, b'\xfe')

def printer_move_fwd(ser):
    send_ESC(ser)
    to_printer(ser, b'J\x08')

def printer_print(ser):
    send_ESC(ser)
    to_printer(ser, b'd\x01')

def print_something(ser):
    to_printer(ser, b'abc\x0d\x0a\x0c')


#set_sweden(ser)
#printer_self_test(ser)
#reset_printer(ser)
#reset_printer2(ser)
#set_mode_default(ser)
#printer_move_fwd(ser)
#to_printer(ser, b'abc\x0d\x0a\x0c')
#printer_print(ser)

rates = [300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200]

for rate in rates:
    print('baud: {:d}'.format(rate))
    ser.setBaudrate(rate)
    print_something(ser)
    time.sleep(5)

ser.close()