Glitching Wasp keyboard fix

edp wasp inside

Bastard thing. It mostly works now, except when it doesn’t.

Ages ago, after moving house, I got my Wasp out to have a go at MIDI-fying it, and found that it would glitch when holding a note, as if it was flickering quickly between the held note and one much lower down.

Since then the Jasper clone was announced and released, I’ve got mine up and running in the last week, and that seems to work ok (although the VCA envelope sustain gets louder as a key is held down, which isn’t quite right). But the keyboard triggers absolutely perfectly, so it gives me a chance to compare it to my old Wasp.

Jasper (Wasp clone) all done bar the shouting

I noticed irregular pulses on the 4013 at IC44 on both Q and Qbar (labelled NOTE_READ and VCA_ENV_TRIG on the helpfully labelled Jasper schematic). I didn’t trust the Q-to-reset link, so I recreated that on a breadboard and linked to it, still the same. Checked the connections, my soldering might have been wonky – all OK. I replaced the CD4013 with a HCF, supposedly has Schmitt trigger inputs, so could be more forgiving of noisy inputs. Nope.

After much fretting all I had left was to strap a ceramic 0.1uF capaacitor across ground and +5V on IC44, and… it was much less glitchy. I added a couple more (fairly randomly) in the keyboard circuit, and then the glitches stopped.

And only then did I have a look at the 5V line on one of the non-decoupled ICs:

EDP Wasp - noise on the 5V rail

…which doesn’t look like it would much help. The Wasp uses a couple of NE555 timers at heart of the oscillators, and they have a tendency to smash the power rail. Only as far as I could tell the glitch wasn’t at its loudest next to the 555s, so I suspected something else.

Now I’ve put it all back together, I realise that 3.36µs works out to about 297KHz, which is in the same ballpark as the frequency of the master oscillator, which is supposed to run at 250KHz. Next time I open it up I’d be tempted to put a capacitor across 5V and ground on IC11 and see if that quietens it down.

Anyway with the glitch gone, I dared to start celebrating, and then found a different, intermittent problem – G and G# would play the notes B and C. Pressing the keyboard slightly harder seemed to bring the problem on, so it seem likely it was a dodgy solder joint, and I tracked it down to a dodgy connection between IC31 and IC30 – reflowing the joint on IC31 fixed it.

Very occasionally still F# will play a slightly inbetween lower note, but I’ve spent way too long staring at this as it is – I’m calling it done for now.

As a postscript, if you have a knackered or badly behaving Wasp, I had a look around for some help on fixing the keyboard and there was some interesting stuff in this post and comments on the Clacktronics post on the Wasp, but that’s about it. Now there’s a new generation of Wasps springing up in the form of the Jasper clone, the Muffwiggler DIY section might throw up some new help.

No Comments

midiwasp, kind of

Had a question from another Wasp owner about MIDI-ing up a Wasp so I chucked this thing together:

which seems like it works alright, but now I’m not so sure, due to my Wasp’s keyboard playing up fairly badly after being left alone for a few months. It seems like there’s a clocking problem somewhere in the keyboard note detection circuitry which causes it to semi-randomly flit between the note you pressed and a much lower one at a high speed… in some ways it’s quite an interesting effect, but not all the time.

To add to that, the timing from the x0xb0x via the Arduino seemed to get messed up as well, so I’m not convinced that this code is worth much but here goes anyway. Feel free to change it, smash it up, call it names.

/*

  __  __ ___ ___ _____      ___   ___ ___
 |  \/  |_ _|   \_ _\ \    / /_\ / __| _ \
 | |\/| || || |) | | \ \/\/ / _ \\__ \  _/
 |_|  |_|___|___/___| \_/\_/_/ \_\___/_|  
                                         

  - possibly cranky 5 pin DIN MIDI to Wasp LINK converter
  - uses PORTB (digital pins 8 to 13) for the note output
    and pin 7 for the gate trigger
  - tested on an Arduino Duemilanove,
  - should work on other 5V Arduinos - though the PORT
    number may change

  http://ua726.co.uk/2016/02/28/midiwasp-kind-of

  Libraries
  ===================
 
  You will need the...
 
  - FlexiTimer2 - http://playground.arduino.cc/Main/FlexiTimer2
  - MIDI library - http://arduinomidilib.fortyseveneffects.com/index.html

*/


// **************************************
// Set these up how you want them....

// MIDI base note is the lowest MIDI note that the Wasp will respond to
// 36 = C2
#define MIDI_BASE_NOTE 37

// MIDI input channel is the channel you want the Wasp to respond on
#define MIDI_INPUT_CHANNEL 1

//***************************************

#include <MIDI.h>
#include <FlexiTimer2.h>

#define TRIG_OUT 7
#define WASP_MAX_NOTE 35
#define NOTE_MEMORY_ARRAY_LENGTH 8
#define NO_NOTE -1

#define NP_LAST_NOTE 1
#define NP_HIGHEST_NOTE 2

const int8_t note_priority_mode = NP_LAST_NOTE;
volatile int8_t noteIsOnCount = 0;
volatile boolean triggerOutState = false;
int8_t noteMemory[NOTE_MEMORY_ARRAY_LENGTH] = {NO_NOTE, NO_NOTE, NO_NOTE, NO_NOTE, NO_NOTE, NO_NOTE, NO_NOTE, NO_NOTE};
const int8_t codeLookup [] = { 43, 42, 41, 40, 39, 38, 37, 36, 35, 34,
                      33, 32, 27, 26, 25, 24, 23, 22, 21, 20,
                      19, 18, 17, 16, 11, 10, 9,  8,  7,  6,
                      5, 4, 3, 2, 1, 0 };

MIDI_CREATE_DEFAULT_INSTANCE();

// -----------------------------------------------------------------------------

void handleNoteOn(byte channel, byte pitch, byte velocity)
{
  if(isMidiNoteInBounds(pitch)) {
    int8_t noteOn = pitch - MIDI_BASE_NOTE;
    noteMemory[noteIsOnCount] = noteOn;
    int8_t noteOnToPlay = getNoteToPlay();
    noteIsOnCount++;
    doNoteOn(noteOnToPlay);
  }
}

void handleNoteOff(byte channel, byte pitch, byte velocity)
{    
  if(isMidiNoteInBounds(pitch)) {
    int8_t noteOffToPlay = NO_NOTE;
    int8_t noteOff = pitch - MIDI_BASE_NOTE;
    removeNote(noteMemory, noteOff);
    noteIsOnCount--;
    noteOffToPlay = getNoteToPlay();
    if(noteIsOnCount > 0 && noteOffToPlay != NO_NOTE  ) {
        doNoteOn(noteOffToPlay);
    }
  }
}

int8_t getNoteToPlay()
{
  int8_t noteToPlay = NO_NOTE;
  if(note_priority_mode == NP_HIGHEST_NOTE)
  {
    noteToPlay = findHighestNote(noteMemory, NOTE_MEMORY_ARRAY_LENGTH);
  } else {
    noteToPlay = findLastNote(noteMemory, NOTE_MEMORY_ARRAY_LENGTH);
  }
 
  return noteToPlay;
}

boolean isMidiNoteInBounds(byte pitch)
{
  return pitch >= MIDI_BASE_NOTE && pitch <= MIDI_BASE_NOTE + WASP_MAX_NOTE;
}

int find(int8_t arr[], int8_t len, int8_t seek)
{
    for (int i = 0; i < len; ++i)
    {
        if (arr[i] == seek) return i;
    }
    return -1;
}
 
void removeElement(int8_t *array, int8_t index, int8_t array_length)
{
   int8_t i;
   for(i = index; i < array_length ; i++) {
     array[i] = array[i + 1];
   };
   array[array_length-1] = NO_NOTE;
}

void removeNote(int8_t *array, int8_t note)
{
  int8_t index = find(array, NOTE_MEMORY_ARRAY_LENGTH, note);
  if(index != -1) {
    removeElement(array,  index, NOTE_MEMORY_ARRAY_LENGTH);
  }
}

int8_t findHighestNote(int8_t *array, int8_t array_length)
{
  int8_t i = 0;
  int8_t highestNote = -1;
  while (i < array_length) {
    if(array[i] > highestNote ) {
      highestNote = array[i];
    }
    i++;
  }
  return highestNote;
}

int8_t findLastNote(int8_t *array, int8_t array_length)
{
  int8_t i = 0;
  int8_t lastNote = NO_NOTE;
  while (i < array_length) {
    if(array[i] != NO_NOTE ) {
      lastNote = array[i];
    }
    i++;
  }
  return lastNote;
}

// avoiding hanging notes with sequencers like the x0xb0x
void handleStop()
{
  doNoteOff();
  noteIsOnCount = 0;
}

void doNoteOn(uint8_t noteNumber)
{
  byte myNoteNumber = noteNumber;
  uint8_t note = codeLookup[noteNumber];
  PORTB = note;
  triggerOutState = HIGH;
  digitalWrite(TRIG_OUT, triggerOutState);
}

void doNoteOff()
{
  triggerOutState = LOW;
  digitalWrite(TRIG_OUT, LOW);
}

// 48hz - period of 20.833333333 ms
// need to use 10ms (as one-half of period)
void gateFlipTimerSetup()
{
  FlexiTimer2::set(10, 1.0/1000, gateFlip);
  FlexiTimer2::start();
}

void gateFlip()
{
  if(noteIsOnCount > 0) {
    triggerOutState = !triggerOutState;
    digitalWrite(TRIG_OUT, triggerOutState);
  }
}

void setup()
{
    // set PORT B to output mode
    DDRB = B11111111;
    PORTB = B00000000;
 
    // set up trigger out
    pinMode(TRIG_OUT, OUTPUT);
 
    gateFlipTimerSetup();
 
    MIDI.setHandleNoteOn(handleNoteOn);
    MIDI.setHandleNoteOff(handleNoteOff);
    MIDI.setHandleStop(handleStop);
    MIDI.begin(MIDI_INPUT_CHANNEL);
}

void loop()
{
    MIDI.read();  
}

I used a CNY13-4 as the optocoupler to connect MIDI to the Arduino this post just because that’s what I had to hand – for my final version I’d heed Olivier’s warning and use a 6N137. This is the relevant part from the MI Shruthi schematic:

Example MIDI to Arduino from MI Shruthi
The Wasp works off 5 volts so I’d recommend a 5v Arduino. It might work with a 3.3v Teensy 3.x, but you’d probably need a bunch of level shifting from 3.3v to 5v to get it work reliably. Also, out of laziness I’m using a PORTB command to write out to more than one pin at the same time, so you’d need to change this if you decided to use something other than an a Atmega 168/328-type Arduino.

For the connection from the Arduino to the Wasp you’ll need a 8 pin DIN plug. The connector that you’ll need to make, looking from the back from left to right, goes like this:

1 – trigger
2 – a (least significant bit)
3 – b
4 – c
5 – d
6 – e
7 – f (most significant bit)

…and don’t forget the ground at the bottom, that needs to connect to ground on your Arduino. The trigger pin will connect to pin 7 on the Arduino, with pins 2 – 7 being connected to Arduino digital inputs 8 – 13 respectively.

Looking at the Spider schematic, the note outputs should all be connected through 10K resistors, with the trigger connected through 47K. In my quick test I’ve gone direct, mostly because the keyboard is playing up and affecting the input.

The code started out being the most simple thing that would work, before I realised that I wanted to to do highest note priority, as with the original keyboard. Then I wanted it to do last note priority, so it got more complicated.

You will need to stop MIDI input when uploading the program to the Arduino because it uses the TX and RX pins as part of that process.

You could make it fancier, or try variations on the theme. It’d be good to do a USB MIDI > Wasp version for example – that should be easier with an Arduino Uno or Teensy. Or if you’ve modded your Wasp (or Jasper…) for filter CV input you could add a simple DAC to control the VCF from velocity or other MIDI controller.

I guess you could do a CV/gate > Wasp version as well if you were really keen to sequence it from your MC-4 or whatever. It’s just a matter of sampling the CV voltage when interrupted by a gate, and then quantising that to a note number.

It remembers the notes you’ve held down (up to a maximum of 8) so you could step through them on a clock (MIDI or analogue clock input) to make a simple arpeggiator.

Also also… if that Disklavier in the corner of the room just seems a bit unsatisfying, why not alter the code to make it into a MIDI output and control that grand piano from the Wasp’s capacitive touch keyboard? Endless fun, and so on.

9 Comments

Fixing the Wasp

After a month or so of working hard on some other stuff I went mad and bought an advertised-as-working EDP Wasp off eBay for, er, well, some money. A bit more than I’d like, but nowhere near as much as some people are asking. It arrived in a reasonable sort of state – there’s a hairline crack through one corner and one of the screw holes is also cracked a bit, and a couple of the pot shafts aren’t 100% perpendicular to the board, but well apart from all that.

The way it’s built with the shit plastic front and single board construction reminds me of a shoddier Pro-One, although it doesn’t sound like the American synth. On the plus side I love the retro-futuristic Microgramma (or Eurostile?), and Electronic Dream Plant is the best company name ever, really. Here’s a picture of the inside as I got it:

Wasp PCB - front

and round the back:

Wasp PCB back

And it sounds great. Even just droning a single note with the filter being opened and closed slowly is really satisfying, but there were a few things that weren’t quite right. The bottom key didn’t work (as mentioned in the auction), the VCA envelope was stuck on repeat, and some of the keys played the same note as the one before.

The key not playing was just down to a break in the track underneath one of the 4016s attached to the keyboard, which had been kind-of-not-really fixed by a previous owner.

dodgy fixed not fixed 4016

Suspicious looking 4016

The always-on-repeat VCA was just the wire from the switch on the rotary pot coming loose.

The keyboard problem was trickier to nail down. The service manual offers up suggestions of how to check the state of the keyboard encoding at a couple of places. I found that the binary code produced by the 40174 flip flop which holds the state of the keyboard was fine apart from the least significant bit, which was generally only getting up to 1.38v, apart from two notes where it hit 4.8v.

I then spent about two weeks (I’m not kidding) of evenings trying to work out what was going on. By the end of this I’d replaced most of the >30 year old ICs in the keyboard section. The Wasp has a double sided PCB but the traces aren’t connected through the board, so you need to solder on both sides, which is a horror. It’s really easy to lift tracks. The best way I found to remove the chips was to clip the legs close to the IC body, and then use a soldering iron and solder sucker to take out the remaining legs. If I clipped too close to the board there was a danger of lifting the pad and track.

Legs clipped and IC chopped out

After removing the chip I repaired any tracks that need fixing and put in sockets, gingerly soldering any pins on top first. It helped to leave a bit of solder on the pads for this.

Installing a socket

Installing a socket

Then I tested the connections to make sure I hadn’t created any solder bridges and to check there was continuity between the socket and the track. After replacing one chip I found I’d lost an entire octave, which after some head scratching I worked it this because of a pin not connected properly. On continuity testing it seemed fine, but that was because I was pushing down on the socket and temporarily making the connection…

The 78L05 was only getting up to 4.8v, so I replaced that as well, more out of hope than anything. I started to wonder if the same note on two keys thing was some sort of timing issue, so out came the oscilloscope, and everything seemed fine.

The breakthrough was lifting the leg of pin 2 on the IC30 and seeing that it did get up to 5v on every other key when it wasn’t connected to anything else. At the other end is (at IC27) was a 4019 which had been replaced by a previous owner, and looking at the tracks on the back of the PCB, I could see they were pretty close together at that point, and there was a short. Fffffffffff.

Here’s an exciting picture of the tracks half-way through desoldering, after I’d cleaned up the solder bridge – you can see how close the tracks are to each other:

IC27 tracks really close together

I’d already chopped the legs of the 4019 so I replaced it, cleaned the solder off, and… it worked.

Two weeks of head scratching, and the problem was down to a previous owners’ fix. Lesson learned, really. I’d suspected that chip because of the slightly dodgy top soldering, but all the continuity checks had worked out ok. I knew shotgun replacement of the keyboard ICs was probably not going to help, but I couldn’t see what else to do. Either way, at least those ICs are now fresh and socketed, they should last a good few years.

One minor wrinkle was that I found for the keyboard clock at IC35, that only certain 4069s had enough oomph to trigger the 4013 at IC44 – only an original RCA one, in this case.

Other than the circuit board being a pain, being a single board the Wasp is easy to work on, and it helps that all the ICs are common-or-garden CMOS. Laurie Biddulph of Elby Designs redrew the schematic for the Wasp, and as far as the keyboard section goes, it seems to be correct. There’s also the original service manual and schematic available from Derek Revell’s site.

There’s been lots written about the Wasp on Analogue Heaven over the years (sample subject line: “how do you plug a wasp into a spider?”). One thing I spotted that was possibly useful was Jürgen Haible noting that the LM386 power amp runs directly from the 9v DC input – which is probably the reason mine hums loudly when run from one adaptor, but hisses from another.

I made a video of me fiddling badly with the fixed-up Wasp just to show roughly what it sounds like, reminiscent to me of “On the wires of our nerves”-era Add N To (X). The glide is nice, with the pitch of the two oscillators rising and falling at slightly different rates.

I tried to edit some of the dull bits out, honest.

13 Comments