Screen Rotation Support for ESP_8_BIT_Composite Arduino Library

I’ve had my head buried in modern LED-illuminated digital panels, so it was a good change of pace to switch gears to old school CRTs for a bit. Several months have passed since I added animated GIF support to my ESP_8_BIT_Composite video out Arduino library for ESP32 microcontrollers. I opened up the discussion forum option for my GitHub repository and a few items have been raised, sadly I haven’t been able to fulfill the requests ranging from NTSC-J support (I don’t have a corresponding TV) to higher resolutions (I don’t know how). But one has just dropped in my lap, and it was something I can do.

Issue #21 was a request for the library to implement Adafruit GFX capability to rotate display orientation. When I first looked at rotation, I had naively thought Adafruit GFX would handle that above drawPixel() level and I won’t need to write any logic for it. This turned out to be wrong: my code was expected to check rotation and alter coordinate space accordingly. I looked at the big CRT TV I had sitting on my workbench and decided I wasn’t going to sit that beast on its side, and then promptly forgot about it until now. Whoops.

Looking into Adafruit’s generic implementation of drawPixel(), I saw a code fragment that I could copy:

  int16_t t;
  switch (rotation) {
  case 1:
    t = x;
    x = WIDTH - 1 - y;
    y = t;
  case 2:
    x = WIDTH - 1 - x;
    y = HEIGHT - 1 - y;
  case 3:
    t = x;
    x = y;
    y = HEIGHT - 1 - t;

Putting this into my own drawPixel() was a pretty straightforward way to handle rotated orientations. But I had overridden several other methods for the sake of performance, and they needed to be adapted as well. I had drawFastVLine, drawFastHLine, and fillRect, each optimized for their specific scenario with minimal overhead. But now the meaning of a vertical or horizontal line has become ambiguous.

Looking over at what it would take to generalize the vertical or horizontal line drawing code, I realized they have become much like fillRect(). So instead of three different functions, I only need to make fillRect() rotation aware. Then my “fast vertical line” routine can call into fillRect() with a width of one, and similarly my “fast horizontal line” routine calls into fillRect() with a height of one. This invokes some extra computing overhead relative to before, but now the library is rotation aware and I have less code to maintain. A tradeoff I’m willing to make.

While testing behavior of this new code, I found that Adafruit GFX library uses different calls when rendering text. Text size of one uses drawPixel() for single-pixel manipulation. For text sizes larger than one, they switch to using fillRect() to draw more of the screen at a time. I wrote a program to print text at all four orientations, each at three different sizes, to exercise both code paths. It has been added to the collection of code examples as GFX_RotatedText.

Satisfied that my library now supports screen rotation, I published it as version 1.3.0. But that turned out to be incomplete, as I neglected to update the file

Sony KP-53S35 Power Amplifier Parts

A 21-year old Sony KP-53S35 TV we disassembled occupies a sweet spot for this curious electronics learner. It’s old enough that there are still discrete components we can look at, and new enough that information for those components can be found online. Here are two examples:

A Philips TDA6106Q is the most sophisticated looking component on the circuit board attached to the business end of the CRT. Datasheet says it is an amplifier, taking input voltage signal (0 to 8V) and amplifying it to a much higher voltage. (0 to 250V) It can handle signals almost up to 6 megahertz. The output pin of this chip can be traced to pin 8 of the tube. Best guess: this is how beam intensity is modulated to create a picture as the beam swept across the screen.

Philips TDA6106Q IC

Components with big heat sinks always draw attention – they tend to be the most powerful components on the board. Either because they are doing a lot of complicated work, or that they are handling a lot of power. The circuit board with the power supply and high voltage transformer also had a pair of these STK392-110 units. The fact there were only two was curious: almost everything in a rear projection television comes in threes, one for each tube, what purpose would a pair of something serve?

STK392-110 convergence control amplifiers

Looking up STK392-110 gave us the answer on both fronts: they are high power amplifiers used for the purpose of controlling color convergence. The high power (over 100W) explains the heat sinks, and convergence control explains why there’s only two of them. If we’re working to make sure all three colors converge at the same places on screen, we could leave one color alone and just adjust the other two.

This seems to be a commodity part used by many rear projection televisions, and their high power handling meant they do burn out. As a consequence there are replacement modules still available for purchase at very affordable prices. Unfortunately the market is large enough for there to be counterfeit items as well.

Lissajous Curve Is An Ideal CRT Learning Project

Lissajous curve with shorter exposure

It was satisfying to see our CRT test rig showing Lissajous curves. [Emily] and I both contributed components for this cobbled-together contraption, drawing from our respective bins of parts. While the curves have their own beauty, there were also good technical reasons why it makes such a great learning project for working with salvaged cathode ray tubes. Mainly for things we don’t have to do:

Focus: We weren’t able to focus our beam in our first work session. We couldn’t count on sharp focus so we appreciate that Lissajous curves still look good when blurry. Thankfully, we did manage better focus for better pictures, but it was not required.

Modulation: To create a raster image, we must have control over beam brightness as we scan the screen. Even if doing arcade vector graphics, we need to be able to turn the beam off when moving from one shape to another. In contrast Lissajous curves are happy with an always-on dot of constant brightness.

Deflection: To create a raster image, we’d need a high level of control over the tube’s deflection coils. We’d need to create a constant horizontal sweep across the screen, as well as scanning vertically. HSYNC, VSYNC, all that good stuff. In contrast driving deflection coils for Lissajous curves require far gentler and smoother coil changes.

Geometry: Unlike modern flat panel displays, CRT can have geometry distortions: pincushion, trapezoidal, tilt, they’re all annoying to adjust and correct in order to deliver a good raster image. Fortunately, a Lissajous curve suffering from geometry distortions still look pretty good and allow us to ignore the issue for the time being.

There is a long way to go before we know enough to drive these tubes at their maximum potential. For one thing, it is running at a tiny fraction of its maximum brightness level. The tube’s previous life in a rear projection television was a hard one, visible in the above picture as a burned-in trapezoid on its phosphor layer. Driven hard enough to require liquid cooling, it would be so bright to be painful to look at and that’s when the beam is scanning across the entire screen. A Lissajous curve covers only a small fraction of that screen area. Concentrating a full-power beam in such a small area would raise concerns of phosphor damage. As pretty as Lissajous curves are, I don’t want them permanently burned into the phosphor. But we don’t have to worry about it until we get beam power figured out.

CRT Test Rig Produced Lissajous Curves

Last night’s CRT exploration adventures with [Emily] produced beautiful Lissajous curves on-screen that looked great to the eye but were a challenge to capture. (Cameras in general have a hard time getting proper focus and exposure for CRT phosphors.) Here’s a picture taken with exposure time of 1/200th of a second, showing phosphor brightness decay in a simple curve.

Lissajous curve with shorter exposure

Due to this brightness decay, more complex curves required a longer exposure time to capture. This picture was taken with a 1/50th second exposure but only captured about half of the curve.

Lissajous curve with longer exposure

Our test setup was a jury-rigged nest of wires. Not at all portable and definitely unsafe for public consumption. It required a space where everyone present are mature adults who understand high voltage parts are no joke and stay clear. (And more pragmatically, if an accident should occur, there will be other people present to call for immediate medical attention.)

CRT Test Rig angled view

Our beam power section consisted of two subsystems. The first is a battery that supplies low power (8 volts and less than 1 watt) to heat the filament. Using a battery keeps it electrically isolated from everything else. The second subsystem supplies high voltage to drive the CRT, and we keep a respectful distance from these parts when powered on.

CRT Test Rig beam power system

Connected to the tail end of the tube is the connector we freed from its original circuit board, wired with a simplified version of what was on that board. Several pins were connected to ground, some directly and others via resistors. The two wires disappearing off the top of the picture are for the heated filament. Two wires for experimentation are brought out and unconnected in this picture. The red connects to “screen grid” (which we don’t understand yet) and the black connected to an IC which we also don’t understand yet.

This is a rough exploratory circuit with known flaws. Not just the two wires that we haven’t yet connected to anything, but also the fact when we connected its ground to transformer’s ground, the tube flared bright for a fraction of a second before going dark. We only got a dot when connecting transformer ground to the filament heater negative, which was unexpected and really just tells us we still have a lot to learn. On the upside, something in this circuit allowed our “focus” wire to do its job this time, unlike our previous session.

CRT Test Rig tube wiring

But that’s to be figured out later. Tonight’s entertainment is our beam control section, which sits safely away from the high voltage bits and we can play with these while our tube is running.

CRT Test Rig beam control system

Controlling vertical deflection is an old Tektronix function generator. This is a proper piece of laboratory equipment producing precise and consistent signals. However, its maximum voltage output of 20V is not enough to give us full vertical deflection. And since we only had one, we needed something else to control horizontal deflection.

That “something else” was a hack. The big black box is a “300W” stereo amplifier, procured from the local thrift store for $15. Designed to drive speaker coils, tonight it is driving a CRT control yoke’s horizontal deflection coil instead. It was more than up to the task of providing full deflection. In fact, we had to turn the volume down to almost minimum for tonight’s experiments. A cell phone running simple tone generator app provided input signal. Not being a precision laboratory instrument, the signal generated was occasionally jittery. But enough for us to have fun producing Lissajous curves!


Gathering High Voltage Components of Sony KP-53S35

Now that we got a blurry dot on screen of picture tubes we removed from a Sony KP-53S35 rear projection television… it is encouraging for us to keep going and see how much further we can go. There are two main avenues of investigation: (1) How to make a better and tighter beam, and (2) how to control direction of that beam.

To help experiments on making a better and tighter beam, we’re going back to the harvested pile of parts. A control box with three knobs labeled “focus” seems promising. It also has three other knobs labeled “screen” whose purposes we’re not sure about. This box had been mounted with the knobs facing forward such that a technician can access these knobs while looking at the screen.

HV Subsystem 3 - focus and screen adjust front

The back side of this box has a few wires. Most significantly, a pair of wires went to each of three picture tubes. In this picture, we still see the wire pairs for the green and blue tubes attached. The empty spots are for the red tube, removed before this picture was taken. The yellow, brown, and upper left corner black wire is unknown. The red wire in the lower left is connected to the high voltage transformer.

HV Subsystem 2 - focus and screen adjust back.jpg

Pulling the camera back shows the system in a little more context.

HV Subsystem 1 - wires

Close-up pictures were then taken for each of the three picture tube PCBs for future reference.

Our earlier experiment used a transformer purchased off Amazon intended for something else – we had hoped its voltage would be close enough, and it was. Now for the best beam we want to get the correct voltage by using the original transformer which generated the voltages for these tubes. It lives on one of the two main circuit boards that had lived at the bottom of the television. This board is where the power cord connected, so it has the power supply and everything relating to high voltage. The transform is still attached to an unit that distributes voltage to the three picture tubes.


The transformer isn’t expected to be terribly delicate, so the cheap hot air gun will be deployed. But before that, a picture of its PCB footprint was taken for possible future reference.

HV Subsystem 5 - transformer footprint



Cheap Seats At The Hot Air Gun Show

At a recent SGVTech meetup, newcomer Amir had lots to offer. One item that I picked up on was his assertion that a cheap Harbor Freight heat gun can be a low-cost alternative to fancy electronics hot air rework stations. I have one of those cheap hot air guns in my garage! Designed for home improvement projects like paint stripping, it is a big crude tool. I wouldn’t use it to assemble surface mount devices or anything I actually care about until I get a better idea of what I am doing. I’ll learn to handle it by disassembling parts that are either robust, or that I don’t care about.

The very next week, I got the chance to put that idea to the test when [Emily] and I felt inspired to try lighting up a CRT. The original driving electronics are no longer functional due to us crudely tearing them out of the TV, but the tube and a few associated accessories are still intact. To help us play with the tube, we thought it might be a good idea to remove a CRT socket to make it easier to access our tube’s pins. This is the ideal situation for testing the heat gun – a big socket should be robust enough to take the heat of a clumsily applied hot air gun much better than something delicate. This TV is also old enough to predate ROHS and lead-free solder, so we expect the solder to flow relatively easily.

I aimed the hot air gun at the solder joints at low setting. After a minute of inactivity, I turned it up to high. About a minute after that, we could see solder starting to melt. A few more seconds after that, all solder on the socket melted enough for us to remove it.

CRT socket removed from PCB

This was much faster and easier than individually undoing solder joints using a soldering iron and a solder removal tool. And the mission was successful: our newly freed socket made it easier to probe terminals and to make experimental connections with alligator clips.

CRT pin probing with socket

Old TV Picture Tubes Lights Again

When we tore apart an old rear projection television a few weeks ago, I did not expect those picture tubes would ever light up again. We took everything apart quickly within the narrow time window, so we didn’t have time to be careful to keep the electronics driving those CRTs intact. Those electronics are in pieces now, and in that writeup, I said the tubes were beautiful glass work and I hoped to display them as such in the future.

Well, there has been a change in plans.

On the same day as that teardown, [Emily] was gifted an old non-functioning camcorder. She has since taken that apart, too. The first component to see reuse was its tiny black and white viewfinder CRT. And as she dug deeper into the world of old CRTs, [Emily] came across this YouTube video by [Keystone Science] going over the basics of a cathode-ray tube and shared it with me. We were inspired to try lighting these tubes up again (without their original electronics) at yesterday’s SGVTech meetup.

The first step was to straighten out the pins at the rear end of our salvaged CRTs – they got a bit banged up in transport. A quick web search failed to find details on how to drive these tubes but probing with a meter gave us a few candidates for exploration.

Probing CRT pins

  • A pair of wires had around 8 ohms of resistance, highest of all wire pairs that gave a reading. This is likely the heating filament.
  • A few other wire pairs gave readings we didn’t understand, but several of them had some relation to a common pin. The common pin was thus our best candidate for cathode pin.

We knew the anode is connected to the side of the CRT, so now we have all the basics necessary to put a blurry dot on screen. A bench power supply was connected to the eight ohm load, and a few seconds later we can see a dull glow. Then a high voltage transformer was powered up across our anode and candidate cathode.

RPTV picture tube and transformer

After a bit of debugging, we have our blurry green dot! We proceeded to power up the other two tubes, which gave us a blue dot and a red dot. The colors look good to us, but apparently they’re not quite the right colors because during our TV disassembly we saw some color filters on the red and green tubes. (The blue tube had no color filter.)

During the course of the evening, the quality of our dot varied. Most of the time it was a blur approximately 5mm in diameter. On one occasion it bloomed out to 3cm diameter and we didn’t know what had caused it. Likewise, we had a pinpoint bright dot for a few seconds not correlating to any activity we could recall. As far as driving a CRT, we know enough to be respectful of the high voltage involved, but obviously we still have a lot more to learn. It’s just as well we don’t know how to focus the dot, because in the absence of sweep, a constant bright focused dot would likely burn a hole in the center of the screen’s phosphor layer.

A first step towards moving the beam was to put some power on the magnetic deflection yokes. These coils of wire were hooked up to a function generator, and we were able to get movement along one axis. Its maximum output of +/- 20V could only deflect a small fraction of the screen size, but it was something.

We didn’t have a second function generator on hand, but we got movement along another axis using magnets. They were taped to a shaft that was then put into a cordless drill. Holding the spinning drill near the control yoke induced movement along the other axis. Combined with the function generator, it allowed us to make a few curves on screen.

RPTV Red curves

Tinkering projects with visual results are always rewarding. With this success, there might yet be life ahead for these tubes as something other than pretty glass. A search found a hobbyist’s project to drive a CRT for an XY vector arcade monitor. That project page also linked to an excellent description of vector CRTs as used in old Atari arcade machines. Lots to learn!