Tuesday, January 11, 2022

Modding a Yamaha PS-3

I picked up a good-looking Yamaha Portasound PS-3 from Goodwill a few years ago. It's a nice sounding little keyboard, with 9 voices, percussion, and accompaniment. I'd been listening to a lot of Hidden Lands by Candy Claws, which uses a lot of 80s home keyboards, and the PS-3 gives a similar feel. I also have young kids and I'd like to get instruments into their hands as early as possible, and maybe circuit bend a few of them. Older toys are great for this as these days most similar noisemakers are keyboards wired directly to an inscrutable blob, very few points for modification. 

The only issue I could find with this otherwise pristine ~40 year old keyboard was a constant high pitched whine in the background whenever a key was pressed, not super loud, but it was always there. Looking online, this was a common complaint with this keyboard. I decided to fix it, and in the process found that this keyboard had a ton of potential for mods, about as far away from the inscrutable blobs as possible, this thing had discrete tone generation, filter, and VCA circuits!

In this post I'll give a basic theory of operations of this keyboard, provide some ideas for modifications, and describe what I've done so far to my own keyboard. Hopefully this can help guide someone else who picks up one of these keyboards and wants to try tinkering. I found a lot of good resources, but nothing that tries to tie everything together as I've attempted here.

Theory of Operations

First off, I wouldn't have much idea how to approach this thing if someone hadn't posted the PS-1, PS-2, and PS-3 Service Manual a few years back. Find that here (send me a message if that link goes down). Additionally, all of the mods I eventually did do came directly from Evil Turtle Productions, who did the work and gave a good writeup of the keyboard function without the benefit of having the full schematic. 

One note about the schematic, it doesn't always have the correct designator names, so double check your board before removing components. In particular, I think Tr4 is mislabeled.

Tone Generator

The main voice, bass accompaniment, and percussion sounds are generated by an ASIC, YM1104. This IC also scans the keyboard and adjusts its output based on various inputs, such as the voice or percussion selection switches. The main voice is generated by the MO1 (4' square) and/or MO2 (8' square) signals. These are square waves an octave apart which are sent to two buffers. The first buffer just takes the MO2 square wave and generates the Flute and Clarinet voices. The second buffer mixes the MO1 and MO2 signals to create a stair step or crude saw shape. This shape is used alone or in combination with the output of the first buffer to create the rest of the voices. 

Looking at the switching circuitry and the description in the service manual, the Tone Generator has 5 unique output settings:

  1. Organ, Clarinet (sustained)
  2. Flute, Brass (vibrato small)
  3. String (vibrato large)
  4. Piano, Harpsichord, Guitar (plucked)
  5. Vibraphone (Tremolo)

Attack and decay also vary based on the Tone Generator setting. 

Voices are selected by the user through a series of DPDT switches. When a voice button is pressed, a GPIO is toggled in the Tone Generator and the selected voice circuitry is switched to the input of the Mixing Amp. This allows the Tone Generator to change its waveform to one of the above settings and allows different signal shaping circuitry to be engaged depending on the selected voice.

Voice Shaping 

Voices are shaped mostly using discrete components, some just use passive elements to form low-pass and high-pass filters. The Brass and Guitar voices are sent to the VCF IC, IG02612. The operation of this filter is pretty opaque, but it looks to be very similar to the IG02610 VCF IC of the Yamaha CS01 monosynth. In fact, it looks like a pin-for-pin match.

PS-3 Filter IC IG02612


CS01 Filter IC IG02610

In the PS-3, resonance is most likely set by the 2.2K resistor between K-OUT and K-NF. The VCF receives a cutoff frequency envelope from an envelope generator, triggered by the YM1104. I don't know if the trigger is sent on every note press, or if it's only sent when either the Brass or Guitar settings (2 or 4 above) are selected. 

The Vibraphone voice is unique in that it passes through a VCA IC, which is modulated by the Tone Generator. This VCA IC is the same as what's used in the CS01, IC02602.

Mixer and Amp

The Mixing Amp receives the selected voice waveform and mixes it with the output of the selected rhythm and Automatic Bass Chord (ABC), if enabled. After that, the signal us passed through the master volume pot and sent to the power amp.

Power and Support

The whole board is powered from 9 volts (or 9-12 wall adapter). The circuitry uses a positive ground, which I have not seen on most modern electronics. I'm sure there's historical reason for using this, but to me it just makes figuring out what's going on in the schematics that much harder. 

The board has a -9V and -2V regulator circuit, which is the first thing one should look at when troubleshooting noise. The Tone Generator receives a 531 kHz clock, which can be tuned with a trimmer.

Other Stuff

I haven't spent much time on the Rhythm or ABC sections, I don't think these parts are particularly interesting. I've actually removed these functions from my own PS-3.

What's Possible

Above I pointed out that the VCF and VCA ICs are equivalent to what's used in the CS01, to me it feels like the obvious direction for Yamaha was to make a paraphonic successor to the CS01 and I'm a little shocked they didn't just go all the way.

It should be straightforward to rearrange the signal path such that the mixed M01 and M02 output are routed through the VCF and VCA. The existing LFO is pretty limited, but you could make a new one with just a few components and route it to the VCF or VCA as well. A rudimentary adjustable LFO could be made using the output from the Tone Generator to the Tempo Lamp, but I'm not sure it saves that much in parts or wiring vs a simple dual-op triangle/square setup. 

Depending on the trigger behavior, one could make a real ADSR routable to the VCF or VCA. However, the most likely behavior there is that the envelope receives a pulse when a key is pressed, rather than a real Gate signal that stays active when a key is held. Attack and Decay controls are probably possible, however. Alternatively, to have something truly unique, replace the existing Voice Selection switches with 5 individual ones to allow any of the above 5 settings to be sent through the VCF/VCA. This might make up for the lack of VCA envelope, particularly since the Sustain switch could still be used. Speaking of sustain, the Service Manual alludes to the C1-C8 RC network controlling the sustain behavior, those values could be played with by someone more willing to risk damage to the Tone Generator

One industrious modder made this monster, I think the only things they kept from the PS-3 was the Tone Generator, keyboard, and maybe VCF: "circuit bent" yamaha ps-3

What I've Done

Here are the basic changes I made:

  • Replace electrolytics
  • Add filter cutoff and resonance
  • Add mix control to M01 and M02 waveform
  • Remove ABC and Rhythm controls

I didn't do anything nearly as extensive or impressive as in the above video, but I definitely expanded its function. First off, addressing the whine. This was a 2.7 kHz noise that I could hear whenever a key was pressed, and could be made louder or quieter using the volume knob. I also noticed the whine when the rhythms were playing, which told me 1, that it was upstream of the mixer, and 2, that it was upstream of the voice shaping circuity (since the rhythm bypasses all of that). That left the Tone Generator. From modding Gameboys, I knew that noise making processors will start to whine if the power supply isn't stiff enough, so I just started looking for electrolytic caps on the power regulators and replacing any I found. I think the biggest change came from replacing the caps on the -2 V regulator. These parts dry out or leak over time, so that's a typical first step when troubleshooting any old circuits. Anyway, the noise is mostly gone. More capacitance on the -9V, -6V, or -2V rail may improve performance even more, but I'm pleased with where it is now. 

Next, I added filter cutoff control. To do this, I removed the 47 kOhm resistor from the VCF envelope generator to the VCF IC. I could have adjusted this to allow the envelope to stay and add an Envelope Depth control, but I don't really care much for the Brass or Guitar voice (Vibraphone's where it's at). See Evil Turtle's site for a simple envelope depth control. Instead, I wired a pot to control the cutoff voltage signal anywhere from -9V to ground. There's also a current-limiting resistor in there for good measure. I actually didn't add a pot for this one, rather I hijacked the Rhythm Volume control since it was about the value I needed, had a ground connection, and had a spot for a current-limiting resistor right by it. I just had to remove one of the connecting wires as well as the jumper that joins the ABC Volume and Rhythm Volume pots. Then I added a wire to bring -9V where I needed it. 

To get resonance control, I replaced the 2.2k resistor by the VCF with a 10k pot. I tore out the Tempo pot to make room for the 10k pot. This also required cutting away some of the plastic on the keyboard chassis since the stock pots are circular and the pot I added was more 'U' shaped. Not very difficult. Since the new pot is threaded, it doesn't need to be mounted to the board with the rest of the pots. The resonance control actually worked the opposite to what I expected, low resistance between K-NF and K-OUT lowers the resonance, and higher resistance increases it. 

Last, I tore out the ABC volume pot and added a 10k pot to mix the M01 and M02 waveforms. The stock PS-3 has the mix set with an 8.2k and 3.9k which controls the relative amount of each waveform sent to the second buffer. I rewired this so M01 and M02 are on opposite lugs of the pot and the wiper is the input to the buffer, this allows me to set the output to all 8' square wave, all 4' square wave, or anywhere in between, including the original crude saw setting. 

After all of that, I cleaned up my wiring and arranged everything so that the case could close back up (not easy!). I decided to rip out all of the battery wiring, C cells suck and I have a USB->12V converter I originally bought for my CS Reface (which frustratingly doesn't work with the Reface, but that's another story). This way I can just power the board with a USB powerbank. It also means that I have the whole battery compartment which could be used to house an internal powerbank or daughterboards for future modifications, pretty sweet since the rest of the chassis is so cramped.

Conclusion

I ended up with a cool toy keyboard that has a little more character than it started, while still maintaining its portability and basic form factor. The resonance control is probably way to sensitive and should be fine tuned. I think I may start re-routing the signal path, adding the potentiometer to mix the square waves pretty much makes the 8' buffer redundant, so I can probably cut the trace to that buffer's output and tie the Flute and Clarinet voice shapers to the second buffer. That may have some unintended consequences with the Piano voice, but whatever. Additionally, I'm going to look for a nice 5-position switch to hotwire the tone selection input to the Tone Generator, that will let me mix and match tone settings with tone shaping circuits. Eventually I may even get around to re-wiring the whole signal path as I described above.

Someday I may even upload sound clips, it's nice to dream.

Merging MIDI Channels for Guitar Controller

Here's a short project I did with a cheap MIDI guitar a while ago.

The Controller!



First off, can you believe this thing was made? A +102 button MIDI guitar hidden in a video game controller! There were made for Rock Band 3 in what must have been a reaction to all those annoying "you're not playing real guitar!" posts back when Guitar Hero/Rock Band was a marketable franchise. God, that seems like an eternity ago, right? Anyway, Madcatz produced these controllers for Wii, PS3, and XBox 360. While they can be used wirelessly with their respective systems, they also include MIDI out! Being a hunk of plastic almost a decade old, you can find these controllers relatively cheap (~20$) at used video game stores or goodwill, making it a no-brainer if you're even a little interested in a guitar-style MIDI controller.

It Works!

I first hooked this thing up to a Casio Priva piano to test it out, everything worked just like I expected, the strings are even velocity-sensitive. The buttons are tied to octave and program-change commands, there's better documentation of that here. There's even a mode where just pressing a fret transmits the associated note command (without needing to strum). 

Hooking the controller up to my Volca FM, however, I found that it would only play notes on one string (high E). The Volca is set up to only receive MIDI on one channel at a time, and mine was set to channel 1. It turns out, the guitar transmits notes from each of the strings on different MIDI channels, 1-6.  This is apparently typical for guitar controllers. I don't know the history here, but there's probably a potential for message confusion if there are too many note on/note off commands happening in a short period of time. Anyway, this meant that the controller couldn't effectively be used with the Volca which was pretty disappointing.

It Could Work Better!

Not one to give up on such a cool toy, I started thinking about a "man-in-the-middle" message handler which could look at note data coming from a controller and change its channel before passing it on to the receiving device. It could be pretty simple, MIDI is basically just UART with some simple isolation between devices. There are a million Arduino MIDI sketches out there to use as examples of receiving and transmitting MIDI. Even better, there are plenty of readymade MIDI shields for Arduino.

Okay, so hardware looks easy. How about software? Looking at the MIDI Protocol, channel specific messages like Note On and Note Off consist of a status byte followed by one or more data bytes. I'll tell you all a secret: I'm not very good at programming and I get myself mixed up on what are probably simple tasks, like managing data on a serial port. When I first looked at the protocol I thought I would have to create some functions to grab sequences of 3 bytes, make sure the first one I pulled was the status byte, then manipulating the data and sending it back out in the right order. Probably not too complicated for someone who knows what they're doing, but I don't have much experience with that.

Fortunately, on a closer look at the MIDI communication protocol, I noticed that all of the status bytes related to channel-specific messages fall between 0b1000nnnn and 0b1110nnnn, where "nnnn" is the associated channel, 0b0000-0b1111. Even better, all data bytes are limited to being between 0b00000000 and 0b01111111, which means that it's actually really easy to figure out what kind of MIDI message you're looking at based on a single byte! The status byte indicates which channel the message is addressed to, since the only thing I wanted the program to do was change the message channel, all I cared about were status bytes between 0b10000000 and 0b11101111 (0x80 and 0xEF).

My program is therefore very simple. It looks at each byte being transmitted by the controller. If it's outside the range 0x80 to 0xEF, then the command just gets sent along unchanged. If it's within that range, then the program does a bitwise AND with the received message and 0b11110000 (0xB0). This leaves the first 4 bits (which identify the type of status message) unchanged, while changing the last 4 bits (which identify channel) to 0 (MIDI channel 1). Easy! And something this simple will take practically no time to process so there's little risk of adding any latency to the MIDI messages.

It Works Better!

Using the super cheap arduino middleman, I can now get the Volca to play notes from all 6 strings! As far as I can tell, there isn't any note confusion happening as a result of throwing everything onto a single MIDI channel, maybe the Volca being limited to 3-note polyphony keeps things simple? 

It Could Be Easier!

As nice as this is, the MIDI Middleman needs its own power supply, not to mention it requires an extra MIDI-MIDI cable, and I only have the two of them. That controller is awfully big, I bet there's room on the inside for a microcontroller that could do the message manipulation before the data even reaches the MIDI port...

Friday, April 12, 2019

Hanging Gymnastics Rings for Cheap

I never really got weights, I think I just don't have the patience for them and everything about the mechanics of lifting just seems too...rigid for me, I guess? A few years ago I came across a video like this of a woman shooting an arrow with her feet while balancing on traffic cones, and the comments section led me to the Bodyweight Fitness subreddit. Here, I found tons of great resources for making an exercise plan that builds strength while focusing on mobility.

I got pretty far with just a pullup bar for equipment, but most of the really interesting skills use rings. I don't have a lot of options for hanging rings, eventually I settled on placing them over a girder in my basement. I have a somewhat low basement ceiling, so they could only be used at hip height or lower. This meant I could do dips but no ring pull-ups or muscle-ups.

While most the ceilings in my home were too low for hanging rings, my garage ceiling was fairly tall at around 9'. I was intrigued by ceiling-mounted ring hangers made by Rogue Fitness and some other companies, but balked slightly at the price; $65 plus shipping for a hunk of metal seemed a little much. There's a youtube tutorial out there from a guy who created a mount from bar of C channel steel that he drilled holes into. I couldn't find any C channel steel at the nearby hardware stores but found a 2' steel framing strut right as I was about to give up. This was perfect, it was only about $10, the 12 gauge steel could easily support my weight, it already had slots along the top for mounting, and recommended ring spacing is about 50cm so it was just long enough. I also picked up some clevis bolts and lag bolts at the hardware store, these were probably the most expensive parts in the whole project.

I drilled three holes through the side of the strut. The two end holes are about 50cm apart for the rings, the center hole is for a climbing rope should I decide to attach one in the future. The holes are just large enough for the clevis bolts to fit through.

Side view of drilled strut
Ceiling beams are spaced every 16", so this strut can only span 2 beams on its own. Since this needs to support my weight, I decided to cut and place a ~40" 2x4 to span 3 beams, then mount the strut to that 2x4 using another 3 lag bolts and washers. This way, if any single bolt fails, then the whole thing won't immediately crash down onto my head.
Finding the beams in the ceiling took an embarrassingly long amount of time. I spent more than an hour holding a stud finder against the ceiling in confusion, only to realize that I was looking in the wrong spot for the beam orientation I needed. I did, however, learn that stud finders still work reasonably well on popcorn ceilings, though if you have a tough time with it you can put a thin piece of cardboard between the ceiling and the stud finder.
Hanger mounted to the ceiling on 2x4
I gave each lag bolt in the 2x4 a counterbore so they wouldn't interfere with the strut, though I guess I could have just done the counterbore on the center bolt. Or I could have just put the center bolt through both the strut and the 2x4. Oh well, this works all the same.

The rings mount beautifully and more importantly, securely. All for under $30 and about the amount of labor that I would have put into the more expensive hanger.

Materials:

  • 1x 40" 2x4
  • 1x 2' framing strut
  • 6x 3/8" lag bolts
  • 6x 3/8" washers
  • 2x clevis bolts
  • 2x cotter pins

Tools

  • Stud finder
  • Drill press for drilling holes in steel strut
  • 3/8" bit
  • Hand drill
  • 15/64" bit for lag bolt pilot holes
  • Counterbore bit
  • 3/8" ratchet

Monday, April 8, 2019

Adding Sidechain to a Stompbox Compressor

Introduction

A compressor is an effect which reduces the volume of a signal. See the block diagram below, the effect can be thought of as a variable-gain amplifier and a level detector with the level detector setting the amplifier gain.


In most guitar compressor effect pedals, the input signal A and the control signal B are the same, or the amplifier output is fed back into the level detector. A high amplitude input signal is compressed while lower amplitude signals are mostly unchanged. This effect is often used to emulate power amp sag in a tube amplifier.

Sidechain compression is less common in stomp boxes, but everywhere in music production. In this configuration, an external signal, or sidechain, is fed into the level detector. The sidechain volume controls the volume of the output signal.

There aren't many guitar pedals which feature sidechaining; in my search I've only found the Empress Effects Compressor and the Deep Space Pulsar that explicitly offer it. Otherwise, the best options are rack effects or DAW plugins.

If you're wiling to put in some work, and have a compressor pedal you don't mind cracking open, you can play with sidechain effects in an inexpensive stompbox.

Goals

At the end of this project I wanted a compressor with the following:
  • Sidechain input
  • Sidechain level control
  • Ability to switch between sidechain and regular compression (unmodded function)

The Victim

Never having tried a compressor before, I got the TC Forcefield form their budget Smorgasbord of Tone line. TC was recently acquired by MUSIC Group, the same company that owns Behringer. All but one of the pedals in this series are reworked Behringer designs, which more often than not means they're reworked pedals from other well known brands. With a little bit of research, I traced back that the Forcefield was based on the Ibanez CP9 compressor, the schematic of which can be found on tonepad.com.

Looking at the CP9 compressor, you can see that it's an OTA compressor like the MXR Dyna Comp. electrosmash.com has a great analysis of this pedal which was used when designing my modification. If you're interested in this mod, or want a better explanation of how compressors work, please read that first.

The key piece in performing this mod is to separate the variable gain amplifier (referred to as OTA from here out) output from the level detector (referred to as envelope detector from here out). Once that connection is broken, you can plug your sidechain into the envelop detector to control the OTA.

The CP9/Forcefield has an excellent breakpoint, capacitor C7 is right between the OTA output and the envelop detector circuitry. Also, it's a through-hole part so very easy to remove.

Getting the sidechain input into the enclosure proved to be the most puzzling part of the mod. The 1/4" jacks are on the top of the enclosure with the DC input between them, so adding the sidechain input to the top wasn't an option without relocating the DC jack. The right and left sides of the enclosure are actually a separate piece from the enclosure face, which makes it difficult to wire anything to the left or right side. Also the enclosure is steel, so not easy to drill.

I noticed that both the input and output jacks of the effect were TRS jacks. Sadly, the output jack ring conductor is soldered directly to the ground plane and breaking this connection would be too difficult. The input jack ring conductor allows the battery to be switched out of the circuit when the input is unplugged, a pretty common arrangement. I decided that I probably wouldn't be using a battery in this effect, so cut the trace from the battery to the ring conductor. Now I could use the ring conductor of the input jack to get the sidechain signal into the pedal.

Ring conductor trace cut, jumper wire to boost/cut block

This adds some complexity when cabling; if I want to use the sidechain then the input jack has to be connected to a TRS splitter with the ring connection as the sidechain input and the tip as the effect input.

Sidechain Input Conditioning

I wasn't sure what level of signals I'd use for sidechaining so I decided to add a boost/cut block to the sidechain input. The EHX LPB-1 is a simple booster with fewer than 10 components, all of which I happened to have on hand. I was able to squeeze it onto a perfboard a little larger than a quarter, this sits sideways between a couple of the effect's potentiometer shafts. Some electrical tape prevents the LPB-1 board from shorting to the Forcefield PCBA. The C7 cap was moved onto this board so that breakout wires could be added between the OTA and envelope detector. The diagram below is a basic illustration of the mod. the only parts added to the original PCBA are the LPB-1 components, a switch, and some wire.

In order to switch between the normal compressor operation and the sidechain mode, a SPDT switch was added to the input of C7. Remember, the input to this cap is fed into the envelope detector. The switch pole is connected to the cap input, switch throw 1 is connected to the OTA output (normal operation) and switch throw 2 is connected to the LPB-1 output (sidechain mode).

Modded PCBA, cap C7 space is to top right of added potentiometer

I tested the pedal by running a constant synth tone into the pedal input while running bass kicks into the sidechain. Whenever a kick hits, the synth briefly drops out of the mix. The response is still sensitive to the sustain and attack controls the pedal came with, and the mode switch lets me return the pedal to its normal configuration. I'll call it a success.

Pedal reassembled


Future improvements:

  • The LPB-1 is a guitar booster and as a result it doesn't have a very sensitive bass response. The sidechain effect is probably used most effectively to duck bass hits, so it'd be a good idea to change the caps of the boost/cut board to allow more bass through.
  • Using a TRS splitter for the sidechain is a bit of a pain. Moving around the DC jack may be worth the convenience of having a dedicated 1/4" connector. A pigtail connector might work too, though that'd be pretty ugly and fragile.
  • Loss of battery function is a bummer, it'd be great to get that back either by finding a way to use the ring conductor on the output jack, or adding a 1/4" input somewhere.
  • The LPB-1 board is just kind of rattling around in the enclosure. This box isn't likely to leave my basement, but if it's going to last I'll need to work out some method to secure it to the PCBA or enclosure.
  • The sidechain level control is way too close to the pedal's original level control. I underestimated just how massive the stock knobs were when I was drilling the enclosure. Swapping the level pot and sidechain switch would have been a good idea, since they're the same size I could probably just go ahead and do that...

Conclusion

This mod wasn't all that difficult to perform once I had a plan, the most time consuming part was probably wiring up the LPB-1 board. A similar modification could probably be done using compressor pedals with different designs; like optical or FET compression. The basic strategy of separating the variable gain amplifier output from the level detector should still hold, though it may be more difficult than it was here.

About

I like to tinker in my spare time. Mostly, I'm interested in DIY music electronics like guitar gear and synthesizers. My education is in mechanical engineering and I work as an engineer in the medical device industry.

This blog is meant to be a repository for documenting some of my projects on the off chance that someone else needs a pointer while working on their own. Pretty much all of my projects are based off of write ups I found online written by smarter people, so I'd like to give back just a bit.