Foot switches for PSR S775

I have extended my “Midi Mate” (in previous post) to incorporate four footswitches to control the variation and drum fill selection on the PSR S775. I bought 4 foot switches from Amazon for a total of £10. These are momentary push to make switches that are designed to operate mains voltage for machinery.

I mounted four of these onto a strip of MDF by screwing screws directly into the plastic switch body from underneath. I then connected the outgoing cables to a 5 core cable with four of the switch poles commoned to one wire. (This is the voltage send and the other 4 wires are for the sense)

The five way cable is terminated using a 5 pin DIN plug (as used for MIDI) and this plugs into the Midi Mate unit as shown in the picture:

The four foot switches are connected internally to the electronics that scans the 3×4 keypad using a fourth scan output line. (In the AK47M project this is wired to four push button switches on the front panel.)

When a foot press is detected, the unit sends a series of MIDI messages to select a variation fill and select a new variation. As far as I can see, the MIDI interface does not operate in the same way as the manual push buttons on the keyboard. If the “auto fill” mode is on and you press a new variation button, the keyboard does a drum fill and then starts on the new variation after it completes.

The MIDI interface has ‘ on/off’ messages for drum fills and variations. So if you switch a drum fill on, it keeps repeating until you send a message to switch it off. So what I have done is to send a ‘variation off‘ and a ‘fill on‘ message when the foot switch is pressed down and a ‘fill off‘ and ‘variation on‘ when the foot switch is released. So a fill keeps going as long as the foot switch is held down. The switch springs back by itself when the foot is released and the new variation resumes.

This works fairly well and means that I can operate fills and variation changes whilst using both hands to play the keyboard.

The MIDI messages are  (in HEX):

F0 43 7E 00 ss dd F7

where
dd = Switch On/Off 00H(Off) 7FH(On)

ss = Section

08H MAIN A
09H MAIN B
0AH MAIN C
0BH MAIN D
10H FILL IN AA
11H FILL IN BB
12H FILL IN CC
13H FILL IN DD

 

Stand for Hannspree 13.3″ Tablet

I use a Hannspree 13.3″ Android tablet to store and display sheet music. It runs the excellent “MobileSheets” app that allows me to store PDF files of sheet music scans and store them in an indexed database. THe Hannspree tablet was about the largest screen I could find at the time. It’s not bad and nearly A4 size and so not too strenuous on the eyes.

I tried to find an adaptor to mount it on a photography tripod but they all seem too small for the tablet. I had to build one myself. Its not too hard. I found a scrap of plastic extrusion that had a channel to hold the bottom of the tablet and mounted this on a piece of wood. The top of tablet is held in place with a large padded washer and a wing nut. I used a spare table leg bracket to attach the wooden piece to the tripod. The tripod I have has a detachable bracket which has a bolt that screws into the table leg bracket.

Jobs a good’un ……

Front view of holder. The squares are pieces of felt padding.

 

 

Rear view of holder with attached tripod mount piece.

Tablet mounted on tripod running MobileSheets.

 

 

New Yamaha PSR S775 with MIDI mate

PSR S775

I have bought myself a Yamaha PSR S775 as an early christmas present. (But really for starting up a functions duo). This is the flagship “arranger” keyboard that has lots of realistic voices, auto accompaniment, USB interface, MIDI record/play and MP3 record/play.

I decided to buy this keyboard to replace the defunct BK7M (spit!!) and upgrade from an earlier Yamaha arranger keyboard that I bought in 1993. (and still works!!) The PSR 6000 was very good at the time and I used it successfully in a functions duo (keyboard/vocals, guitar/vocals). It unfortunately had a floppy disk drive to save and restore registrations and there was not enough memory to hold everything required for a gig. This meant that there was a frantic swapping of floppy disks during the gig.

PSR6000

Now, with a 25 year interval, you would have thought that the latest keyboard would be best in all respects, but it is not necessarily the case …..

Here are my Pros and Cons :-

  1. Obviously with better technology there is more memory, more and better voices and everything can be stored on a USB stick. [+]
  2. The S775 buttons are much smaller and spongier. There is too much use of LEDs behind the buttons so it looks like a christmas tree. The PSR6000 had nice thumb wheels to change parameters whereas the S775 has fiddly up/down buttons. The PSR775 parameter selection wheel has a really cheap feel to it. [-]
  3. The PSR6000 has nice rounded corners, looks more robust and is more appealing to look at. There is more space used for the controls. [-]
  4. The PSRS775 has two “live control” knobs to adjust effects on the fly. [+]
  5. The auto accompany function and styles has not really changed at all. The S775 can store a lot more styles.
  6. The keyboard size and touch is identical.
  7. The pitch change and modulation wheels on the S775 are not as good as the PSR6000. [-]
  8. I think that the layout and ergonomics are better on the PSR6000. [-]
  9. The music stand is the most cheap and nasty thing ever. Obviously just an after thought. [-]

Overall the technology has improved, but little consideration has been paid to ergonomics and style !!

Anyhow the keyboard sounds as cheesy as its predecessor and you soon get tired of the novelty of the styles. However, it is ideal for the function gig either as a one man band or a duo.

 

It didn’t take me long to hook up my Yamaha P120 electronic piano using a midi cable in order to provide a wider and touch weighted keyboard.

It didn’t take me long also to realise that a “MIDI mate” would allow me to have two keyboard setups with different sounds. So I have written some firmware for my “MIDI mate” that allows me to some nifty functions by simply pressing keys on the keypad.

 

Midi Mate with keypad

The MIDI mate is connected in between the Piano and the S775 using standard MIDI cables. No battery or power is required, as it is able to obtain a small amount of power from the MIDI interface. The next picture shows the insides. I have used my AK47M pcb. You can see it is sparsly populated with one microcontroller chip a capacitor and 5 resistors.

 

The next picture shows my keyboard setup with the “Midi Mate” in place. There is also a screenshot of the MIDI configuration required on the PSR S775 :-

The nifty functions are as follows :-

  1. Press the “#” key and the piano keyboard duplicates the PSR S775 keyboard.
  2. Press the “*” key and the entire piano keyboard is independent to the S775 keyboard.
  3. Press keys “1” to “9” and a right hand voice is selected independent to the S775 keyboard. e.g 1=piano 4=strings 5=jazz organ. The piano keyboard is split so that the left hand can control the auto accompany.
  4. Press key “0” followed by two digit number to select a voice as in (3). The voice is stored for key press “9”.  Press key “0” three times to double up last two voice selections.

Function “4” may change as I explore what works.

This works really well by having a basic pallette of solo instruments on the piano keyboard and being able to swap quickly without any fiddling about. It also means I have a decent keyboard to play and plenty of space for the auto accompany left hand.

 

I mentioned the music stand was tacky – well this is what I meant ……

The Real book causes it to wobble like a demented penguin.

 

 

AK47M project part 10 (Prototype ready)

I have completed the prototype AK47M and the first versions of firmware and controller software. I used an old cigar box as the enclosure. I have tested the unit using my Yamaha electronic piano and a keyboard amplifier. It works as expected and I am currently  writing a user manual which will explain the operation in greater detail.

The front panel is a piece of laminated paper glued onto some thin MDF. The front panel comprises of a 3×4 keypad, a 2 line LCD display and a row of 4 push buttons.

 

On the back is from left to right:

  1. The USB power cable.
  2. A pair of jack sockets for the stereo output for the auto accompany synth.
  3. A pair of jack sockets for the stereo output for the solo (right hand) synth.
  4. A 5 way DIN socket for the MIDI input

The following shows a series of screen shots of the AK47 LIVE software that either runs on a Windows PC or the internal Raspberry PI on-board computer.

The windows version simulates the keypad using the PC numeric keypad.

 

This is the initial screen with control for the solo lead voices and the left right hand split.

The buttons along the bottom deal with navigating the performance file and editing the current performance file.

The green boxes allow for easy selection of a voice for a part. The blue boxes are volume control sliders.

 

These two screens control the selected style parameter. The style file assigned to the current performance is shown in red text. The individual style parts may be independently controlled

This screen shows the BIAB file selection and the BIAB editor with a chord sequence for “Ain’t Misbehavin”

 

 

 

 

Lazarus / FreePascal problem on 64 bit machines.

I ported some open source MIDI handler code from Delphi to Lazarus. This was originally working on a 32 bit Windows machine but when I compiled and ran it on my Windows 64 bit machine I got a Segment Violation error when opening the input MIDI port.

I tracked the error down to the system unit called “mmSystem”. This defines interfaces to the windows multimedia DLL –  “winmm.dll”. The offending interface was a function called “midiInOpen”.

The function has a parameter for the address of a callback function. The current “mmSystem” unit defines this as 32 bit and not 64 bit as it should be if the code is compiled for a 64 bit machine. The unit needs to be upgraded to handle both cases.

In the mean time, I hacked my (open source) MIDI driver code to handle both cases:

I used the compiler conditional expressions to determine when I am compiling a 32bit or 64 bit system.

I have defined an alternative interface for midiInOpen call midiInOpenX which has a 64bit parameter (int64) for the callback address.

Seems to do the trick…

 

// X64 hack
{$IFDEF WIN64}
Function midiInOpenX(x1: LPHMIDIIN; x2: UINT; x3: int64; x4: DWORD; x5: DWORD): MMRESULT;stdcall; external 'winmm.dll' name 'midiInOpen';
{$ENDIF}

procedure TMidiInput.Open(const aDeviceIndex: integer);
var
lHandle: THandle;
lResult: MMResult;

begin
inherited;
if assigned( fDevices.Objects[ aDeviceIndex ] ) then Exit;

{$IFDEF WIN64}
lResult := midiInOpenX( @lHandle, aDeviceIndex, int64(@midiCallback), aDeviceIndex, CALLBACK_FUNCTION );
{$ENDIF}

{$IFDEF WIN32}
lResult := midiInOpen( @lHandle, aDeviceIndex, longword(@midiCallback), aDeviceIndex, CALLBACK_FUNCTION );
{$ENDIF}

if lResult <> MMSYSERR_NOERROR then
raise exception.Create( GetLastErrorText );
midiInStart(lHandle);

fDevices.Objects[ aDeviceIndex ] := TObject( lHandle );
end;

MIDI gotchas !!

When I was writing code to handle the MIDI port it behaved well with my Yamaha P120 electronic Piano but behaved badly with my Yamaha PSR 6000. When I played keys on the PSR 6000, some notes would not play and others would not end correctly and kept sustaining.

I was baffled by this and saw that bytes seemed to be dropping out when viewing a raw dump of the port on the Raspberry PI. I was convinced there was a hardware problem, or a bug in the PI operating system.

I could play single notes and they would work but if I played a chord or two notes together I would get a problem. I then analysed the dump again and it struck me that there was a pattern. When a key is pressed, you normally get three bytes, the control byte $90, the pitch byte and the velocity byte. When two notes are pressed on the PSR 6000, I expected to get six bytes, two groups of three, but I got the control byte $90 for key down, the pitch byte for the first note, the velocity byte for the first note, the pitch byte for the second note and the velocity byte for the second note. I got 5 bytes instead of 6.

Its simple, multiple key presses are grouped together using a single MIDI control byte ! I altered the receiver code to keep accepting two byte segments until a new control byte is received. This solved the problem and the code works with both keyboards.

There is a subtle difference between theYamaha P120 midi firmware and the PSR 6000 firmware in this respect.

Gotcha #2 was that Yamaha do not use the MIDI spec for note off. (i.e. a control byte of $80). They use an alternative by using a key on but with a zero velocity. Presumably this helps when grouping mutiple key on/off events together.

Anyhow my code can handle both situations and always outputs 3 byte midi commands irrespective of what is received to keep things simple.

Gotcha #3 was that was a continuous flow of MIDI sense bytes of $F8 and $FE from both keyboards. These are simply filtered out.

 

 

AK47M project part 9 (PCB completed & updates)

I have received a set of PCBs and have built the first AK47M prototype. Everything seems to be working and I am currently working on an enclosure for it.

This shows the PCB populated with components:-

 

The next photo shows the addition of the two synthesizer modules:-

 

The final photo shows the addition of the PICs, the Raspberry PI Zero W and the wiring to additional components. It is ready to be put in the enclosure:-

 

There are a few tweaks required for the PIC firmware. I have done a lot more changes to the LIVE software running on the PI.

The “Band in the Bag ™” first cut of software is ready. I can create a chord sheet using an interactive editor using either the QWERTY keyboard or the MIDI keyboard. It handles repeats and variation selections. When a BIAB score is created and attached to a performance, it will play when the zero key is pressed. There is a tap intro for one bar before the sequence is played. The sequence can play to completion or repeat multiple number of times. This will be great to busk along with my Sax.

The LIVE software is now packaged as two versions, one for the Windows PC that interfaces to any attached MIDI device and one for the Raspberry PI that interfaces to the AK47M.

The hardware is modular so that certain functions can be added or dropped depending on requirement.

i.e.

  1. Either one or both Synth modules can be dropped and an external MIDI device used instead.
  2. The LCD display can be dropped and a HDMI device or Android tablet can be used instead.
  3. The Solo Parts keyboard function can be dropped.
  4. The Fluid softsynth can be installed on the PI to do drums / bass arrangements only.
  5. The PCB can be connected to a keypad with a single PIC and used as the self-powered MIDI-Mate for connecting to a BK7M.

I am now using PIC 16F628A chips that are cheaper and have a more accurate internal oscillator. So I can also drop the resonators.

I am now working on the display of sheet music and lyric sheets. The intention is to synchronise the selection of a music/lyric sheet with the performance selection. I am on the look out for a portable HDMI monitor that I can hook up to the PI.

 

AK47M project part 8 (Connection to tablet)

I have investigated a simple way of connecting my Android tablet to the AK47M system in order to view and edit configurations.

The general method is to set up a WiFi hotspot on the Android tablet and connect to it from the PI Zero W. This WiFi network can be independent of the Internet and allows for a connection anywhere even on gigs.

Once a WiFi connection is established then a VNC client can be run on the tablet that shows the PI desktop and allows it to be controlled by screen touches or using a mouse attached to the tablet by USB.

When the connection is initially established it is necessary to obtain the IP address of the PI to configure the VNC client. Fortunately, there is an easy way by using a Hotspot manager app as it shows the addresses of attached devices.

I downloaded and installed two free apps from the Android Playstore …..

Hotspot manager allows you to configure a hotspot on the tablet with a WiFi password and switch it on or off as an when required. Running a hotspot does seem to drain the battery more than normal operation. It also lists any connected devices and their addresses.

 

VNC Client Free is a simple to use app to do the remote desktop connection to the PI Zero W. There is also a client produced by RealVNC that works well.

The IP addresses assigned by the tablet seem to be persistent, so once everything is configured it re-connects with no bother when the system is powered up.

My AK47M application running on the PI Zero W is called “AK47 LIVE” and is configured to run on boot up. This application integrates with the AK47M system and allows performances to be edited for the solo parts and the styles. It also runs the arranger that plays a style file and reacts to variation selections and chords played. There is also an additional tab for a “Band in the bag” which will allow the input of chord and variation sequences for a performance configuration, this is work in progress.

 

I have completed the AK47M PCB design and it is ready to be manufactured in China. (About £1.50 per PCB.)

 

AK47M project part 7 (Adding MIDI synthesiser and PCB generation)

I have investigated the possibility of running “FluidSynth” on a Raspberry PI in order to generate sounds from MIDI input. I have decided that a single PI is unable to handle 8 channels of MIDI generated from the Arranger software. It can only hack about two channels reliably with the sample rate halved from 41000 Hz and the latency is pretty bad at around 40 mS. Running several PIs in parallel is not really cost-effective either. This is unfortunate as the FluidSynth would be ideal for the application and could provide a lot of tailor made sounds. I will re-visit this when and if a more powerful cheap CPU card is mass produced.

I hooked up a PI zero running my Arranger software to my MIDI keyboard and this handles the MIDI generation successfully so I decided to look around for MIDI sound generation alternatives. I found a good alternative in the S2 synthesizer. This is produced by https://www.serdashop.com/waveblaster and it is a daughter board designed to plug into a PC sound blaster card. It is built around a Yamaha sound generation SAM2695 chip. I have successfully hooked this up to a PI Zero and generated sound from the Arranger software. The electrical connection to the device is very simple. One thing to watch out for is that the device reset line needs to be brought up to 5v on start up. They cost about £35 and I need two for my project, so I have bust my budget !!

 

 

I looked into the possibility of producing a printed circuit board (PCB) for my project as the separate components are on vero board and it looks a bit shoddy.

I was amazed at how cheap the production of PCBs is, especially if ordered from chinese shops and the large range of free CAD tools available for the PC. I tried out several of the free CAD packages and I decided that DipTrace https://diptrace.com/ was the easiest to use. It has a schematic editor for the circuit design. This can be transferred to a PCB design tool and there is a good auto routing tool available to optimise the PCB layout.

The design consists broadly of the following:-

  • Pi Zero W to run Arranger software and generate MIDI from style files and system configuration mesages. Also runs performance editor tools.
  • PIC to handle keypad, keyboard MIDI input and chord finder.
  • PIC to handle LCD display and accept configuration messages.
  • PIC to handle solo keyboard parts and accept configuration messages.
  • S2 synthesiser to generate 8 channels from Arranger software.
  • S2 synthesiser to generate solo keyboard sounds.

I have firmed up on the hardware so I am now going to concentrate on the software running on the PI. I am considering adding these features :-

  • A “Band in the Box” type of interface which was lacking from the BK7M. Here I am able to enter a chord sequence using standard notation for a style and let the software play the arrangement without having to play chords at the keyboard.
  • A display of a PDF file for a performance. This can contain a chord sheet, sheet music, words etc.
  • I can control the PI from an Android tablet using VNC virtual terminal software while it is connected to my WiFi network. It would be cool to be able to set up a local link from my tablet to the PI Zero
  • Some kind of “looping” software for live performance.

AK47m Project Part 6 (Adding a LCD display to the system)

I have added a LCD two line display to my project. I obtained a two line by 16 characters wide that costs about £6. LCD displays generally have a standard interface based on the Hitachi model. It is easily hooked up to a 16F628 PIC. There are 4 data lines, 2 control lines and 5v power lines. Only 4 of the 8 data lines are used and the LCD is programmed using 4 bit nibbles of data. The LCD display that I obtained has the pin out arranged as two lines of solder connections. The usual ones have a single line. The solder pad with a square surround is pin 1 and the pins are numbered from left to right so the odd numbered pins are on the left and the even numbered pins are on the right.

Note that the LCD is powered from the 5v supply but the control and data lines are driven to +3.5v from the PIC. The 5v supply is taken from the USB connection to the power supply. The 3.5v supply for the PIC is derived from the Raspberry PI.

The excellent MikroElectronika pascal compiler has a library to drive the LCD and a simple means to configure the PIC IO pins used to connect to the display. The LCD display connections to the PIC are as follows:-

Pin1 - Ground

Pin2 - +5v

Pin3 - contrast (grounded)

Pin4 - RS (PIC A1)

Pin5 - RW (grounded)

Pin6 - En (PIC A0)

Pin7-10 - High Data (grounded)

Pin11-14 - Low Data (PIC B4-B7)

Pin15 -Backlight LED (+5v)

Pin16 -Backlight LED (grounded)

 

The PASCAL program requires a declaration of the pin out as follows:

var LCD_RS : sbit at RA1_bit;
var LCD_EN : sbit at RA0_bit;
var LCD_D4 : sbit at RB4_bit;
var LCD_D5 : sbit at RB5_bit;
var LCD_D6 : sbit at RB6_bit;
var LCD_D7 : sbit at RB7_bit;

var LCD_RS_Direction : sbit at TRISA1_bit;
var LCD_EN_Direction : sbit at TRISA0_bit;
var LCD_D4_Direction : sbit at TRISB4_bit;
var LCD_D5_Direction : sbit at TRISB5_bit;
var LCD_D6_Direction : sbit at TRISB6_bit;
var LCD_D7_Direction : sbit at TRISB7_bit;

The display is initialised using the following code, note that the compiler automatically links in the LCD driver library.

 Lcd_Init(); // Initialize LCD
 Lcd_Cmd(_LCD_CLEAR); // Clear display
 Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off

The display is updated as the following example:

 txt := 'PHSC (c)2018';
 LCD_Out(1,1,txt); // Write text in first row from character pos 1
 txt := 'AK47M Vs 1.0';
 LCD_Out(2,1,txt); // Write text in second row from character pos 1

When I first ran my program, nothing happened ! Eventually I realised that the contrast was not connected on Pin3. This is normally driven by a voltage divider to adjust the voltage. I simply grounded the pin and it worked fine.

These photos show the individual components:-

This is the LCD display with wires soldered on that connect to the PIC.

 

This is the display PIC. The wires to the right go to the LCD display. The wires to the left take power to the configuration PI card and receive MIDI data.

 

This is the connector to a PI B+ card to obtain power and send MIDI data to the PI. There are four connections : +5v, +3.5v, Ground, UART Receive.

 

Here are the three components connected up.

 

The PIC uses its internal UART to monitor the MIDI messages. I have defined a set of MIDI messages for internal use. These are kept short as there is no flow control. This means I can use a one wire connection to operate the LCD display.

Internal MIDI messages have the general format:

$F1 <length of data> <function> <data>

except for key press messages that have the format

$F1 $00 <key press>

Here is a summary of the messages :-

Key press - $F1 $00 <key press>
Display 1 - $F1 <length> $01 <text up to 16 chars>

Display 2 - $F1 <length> $02 <text up to 16 chars>

Select Style File - $F1 <length> $03 <style file name with extension>

Style Params - $F1 $18 $04 [Voice PC]x8 [Voice Vol]x8 [Voice Enable]x8

Style Aux - $F1 $04 $05 <tempoH> <tempoL> <transpose> <variation select>

Part Params - $F1 $10 $06 [Part PC]x4 [Part Vol]x4 [Part Flags]x4 <Split point> <Split Enable> <spare> <spare>

Chord Finder - $F1 $02 $07 <chord pitch> <chord type>

 

« Older Entries Recent Entries »