UK Vintage Radio Repair and Restoration Powered By Google Custom Search Vintage Radio and TV Service Data

Go Back   UK Vintage Radio Repair and Restoration Discussion Forum > Specific Vintage Equipment > Vintage Computers

Notices

Vintage Computers Any vintage computer systems, calculators, video games etc., but with an emphasis on 1980s and earlier equipment.

Reply
 
Thread Tools
Old 22nd Aug 2022, 6:14 pm   #1
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 9,508
Default MK14 and MIDI

A while ago I mused over the idea of having my MK14 play one or more of my small collection of synths and tone modules.

Originally I meant to combine the original MUSIC BOX and SERIAL OUT programs from the manual to have the MK14 output MIDI note information at the MIDI serial baud rate of 31250. Phil_G and I had a brief discussion about it where we concluded that it would be quite difficult to software-time such a high serial baud rate with a 4MHz SC/MP.

I therefore built a hardware MIDI OUT interface, a virtual copy of the 6402 UART based user-port interface for the BBC Model B as shown on page 15 of R.A. Penfold's MIDI PROJECTS.

https://worldofspectrum.net/pub/sinc...DIProjects.pdf

Mine has a couple of extra tweaks - the UART's Transmit Buffer Empty pin is brought out to the controlling micro so that it can poll the UART to see if it is ready to accept the next MIDI byte. The original project was expected to be controlled by a BASIC program and the UART would have been able to get rid of each byte before being handed the next one. When the controlling device is running machine code it is highly likely to serve up data bytes faster than the UART can get rid of them, hence the need to be able to poll the UART.

I have also added a 4050 oscillator / divider chip with variable speed and that is so serve as a 'metronome' which outputs one cycle per 32nd of a whole note which can be polled by the controlling micro. This will relieve the SC/MP from having to software-time the interval between notes, making it easier to handle polyphony where each interval may see the start or end of no notes, one, two or three or more notes.

I've tested the interface initially using an Arduino as the controller and it works, but I was just about to start writing MK14 code for it when I saw this exchange in another SC/MP related thread...

Quote:
Originally Posted by Phil__G
Its almost like the SIO instruction with SIN & SOUT was designed for SPI

Originally posted by Silvester
Perfect for MIDI 31250 baud, which it can send faultlessly at full rate. Also 9600 Baud Rx/Tx fileserving is possible (albeit with 2 stop bits)
Silvester, if you have some working software-timed MIDI out code for SC/MP based on (say) a 4.00MHz clock, I would be interested to see it.
Attached Thumbnails
Click image for larger version

Name:	Midi_Out_Interface.jpg
Views:	70
Size:	65.2 KB
ID:	263420  
SiriusHardware is online now   Reply With Quote
Old 22nd Aug 2022, 10:05 pm   #2
Silvester
Triode
 
Join Date: Feb 2014
Location: Redditch, Worcestershire
Posts: 20
Default Re: MK14 and MIDI

Here is the routine I use. Simply load pointer 3 with start address then LDI data, XPPC 3 as required.
Attached Files
File Type: txt midi_asm.txt (752 Bytes, 29 views)
__________________
David
Silvester is offline   Reply With Quote
Old 22nd Aug 2022, 10:08 pm   #3
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 9,508
Default Re: MK14 and MIDI

Thanks David, I'll take a look at that.
SiriusHardware is online now   Reply With Quote
Old 26th Aug 2022, 1:40 pm   #4
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 9,508
Default Re: MK14 and MIDI

I did make a first attempt to try this by putting it inside a loop which continually called it with the same value to send. Although it did repeatedly send out some sort of serial pattern it didn't look the way I expected it to, probably an error on my part somewhere. Just to let you know I hadn't forgotten.

Couple of queries I did have though - can you explain to me how the last line, JMP $0, is ever reached? I'm probably being a bit slow but as far as I know the preceding instruction XPPC 3 functions like RET in any other assembly language by replacing the contents of the program counter. Also, can you confirm whether the '40' following the ADI instruction is hex, or decimal?

Code:
$0      xae              ;    7 ; data byte
        ldi     00       ;   10 ; start bit b0
        xae              ;    7 ; to send
        sio              ;    5 ; sout start bit
        xae              ;    7 ; data to send
        ccl              ;    5 ;
        ldi     00       ;   10 ; rotating mask
$1      rr               ;    5 ;
        sio              ;    5 ; data bits b0 to b7
        adi     40       ;   11 ; accumulate bits
        jp      $1       ; 9/11 ; until done
        xae              ;    7 ; FF to E reg
        sio              ;    5 ; sout stop bit
        xppc    3        ;    7 ;
        jmp     $0       ;   11 ;
SiriusHardware is online now   Reply With Quote
Old 26th Aug 2022, 2:20 pm   #5
Timbucus
Octode
 
Join Date: Mar 2019
Location: Barry, Vale of Glamorgan, Wales, UK.
Posts: 1,260
Default Re: MK14 and MIDI

The JMP after an XPPC is a neat trick so that you can just do multiple XPPC 3's one after another without having to reload the subroutine address into P3 as it is an exchange the address after the 'RET' XPPC is left in P3 so when you call again it executes the JMP and goes back to the start.
Timbucus is offline   Reply With Quote
Old 26th Aug 2022, 2:22 pm   #6
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 9,508
Default Re: MK14 and MIDI

I did not know that! One to remember.
SiriusHardware is online now   Reply With Quote
Old 26th Aug 2022, 3:52 pm   #7
Silvester
Triode
 
Join Date: Feb 2014
Location: Redditch, Worcestershire
Posts: 20
Default Re: MK14 and MIDI

The 40 is hex, it effectively just sets bit 6 in AC register, which gets rotated right, eventually setting bit 7 to end loop after 8 data bits sent out from E register.

I could have used ORI 40 - but then ORI is only 10 timing cycles - ADI 40 is perfect being 11 since the data bits need to be exactly 32uS long.

But using ADI means I need to make sure the carry link is clear, which means using CCL - which again is perfect since I needed to pad out start bit by 5 cycles to 32uS before first data bit.

Another nice twist was I ended up with FF for stop bit exactly 32uS after last data bit sent.
__________________
David

Last edited by Silvester; 26th Aug 2022 at 3:55 pm. Reason: 'stop' bit, last sentence
Silvester is offline   Reply With Quote
Old 26th Aug 2022, 4:03 pm   #8
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 9,508
Default Re: MK14 and MIDI

Thanks, I imagined it was 40 Hex, the aim being to set a single bit, but I am used to assemblers which require hex numbers to be prefixed by '0x... or suffixed with '..h' otherwise the default is decimal.

I'll give it another test drive in the near future.

I wonder what you are running this code on and for what specific purpose, since you took the trouble to write it? (I am aware that the MK14 is not the only SC/MP based computer ever to have existed).
SiriusHardware is online now   Reply With Quote
Old 26th Aug 2022, 4:56 pm   #9
Silvester
Triode
 
Join Date: Feb 2014
Location: Redditch, Worcestershire
Posts: 20
Default Re: MK14 and MIDI

I built an Elektor SC/MPuter clone https://www.vintage-radio.net/forum/...7&postcount=16

I then wrote a sequencer for a Maplin 5600S monophonic synth to control it through its simple digital input/output interface. I added the ability to drive MIDI from synth keyboard.

If you want I can assemble a simple MIDI test program (send repeating arpeggio). I just need to know what start address would be required. I don't know how you upload to MK14 but I can give you binary and hex dump of code (shouldn't be too big). The output from SOUT (INS8060 pin 23) ideally just needs to be buffered, though I guess just a 220ohm resistor should be OK.
__________________
David
Silvester is offline   Reply With Quote
Old 26th Aug 2022, 5:39 pm   #10
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 9,508
Default Re: MK14 and MIDI

That sounds interesting - your code would have to be able to run in a 256-byte block or else be spread across different areas.

A fully populated MK14 has three spaced out areas of memory.

256 bytes of undedicated memory at 0B00-0BFF

256 bytes of mostly undedicated memory at 0F00-0FFF, however the monitor uses 0F00-0F11 and writing to the very highest address 0FFF can do odd things like affecting the flags.

128 bytes of undedicated memory at 0880-08FF.

Given the above, if you need more than 256 bytes then it might be best to put the midi-out subroutine at 0880-> and the main program code which calls it at 0B00->

Intel Hex is actually the best file format for me because I use this project to load code into the MK14.

https://www.vintage-radio.net/forum/...d.php?t=151851

There is a link to a video showing it working in post #17 of that thread.

You can split the code across the various blocks of memory by placing ORGs at strategic points in your source code and the uploader will send it to the right places.

It's kind of you to offer to do this, but I should say there is no rush because I am about to go away for the long weekend - hopefully should have a chance to play when I get back.
SiriusHardware is online now   Reply With Quote
Old 30th Aug 2022, 9:35 pm   #11
Silvester
Triode
 
Join Date: Feb 2014
Location: Redditch, Worcestershire
Posts: 20
Default Re: MK14 and MIDI

Here a little player, I haven't got RAM in same place as Mk14 so I hope it works reassembled to required addresses.
Attached Files
File Type: zip MIDIout.zip (3.9 KB, 12 views)
__________________
David
Silvester is offline   Reply With Quote
Old 30th Aug 2022, 9:48 pm   #12
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 9,508
Default Re: MK14 and MIDI

Thanks David - I've just looked through that material and it looks fun to play with, the 'player' being very much along the lines of the original 'Music Box' program from the MK14 manual.

It's a little bit late for me to do justice to tonight as I have to get up at 6.20am most weekday mornings, but I will play with it tomorrow (Wednesday) night if I can get a couple of hours to myself.

Point taken about the moderate risk of driving the MIDI output directly from SOUT, I probably won't do that but will instead use a buffered open collector output.
SiriusHardware is online now   Reply With Quote
Old 31st Aug 2022, 5:53 pm   #13
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 9,508
Default Re: MK14 and MIDI

Just had a brief window to muck about, loaded up ARP.HEX and I could see it sending four different groups of serial characters out of SOUT over and over again. The shortest length of any pulse, i.e, one bit time, is 32uS on this MK14 issue VI replica running at 4.00MHz.

I had a busy day at work so I didn't get the hoped for 10-15 minutes to knock up a little output buffer circuit. Somewhere around here, I should have a MIDI interface cable intended for use with a 15-way sub-D PC 'Game' port, which I think will only need +5V power, GND and UART-level MIDI data going to it. I will have a hunt around for that.
SiriusHardware is online now   Reply With Quote
Old 31st Aug 2022, 9:26 pm   #14
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 9,508
Default Re: MK14 and MIDI

Hours later... I didn't find the cable I was actually looking for but I found a home brewed exact equivalent which I had originally made to plug directly into the IDC 'game' port connector on an old PC motherboard. The interface has an optocoupler for MIDI input and an open collector transistor driven MIDI output preceded by an inverting buffer. The input side is not needed, for the moment at least.

I've rigged it up to a spare MK14 edge connector so it will be ready to plug and go, but it has taken so long to get that far I have run out of time. Will have another go at it tomorrow.
SiriusHardware is online now   Reply With Quote
Old 2nd Sep 2022, 8:57 am   #15
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 9,508
Default Re: MK14 and MIDI

Unfortunately I didn't get time to do this last night and real life is going to get in the way for the next week or so (I will be away from base, so won't be able to make further progress until I get back).
SiriusHardware is online now   Reply With Quote
Old 2nd Sep 2022, 12:26 pm   #16
Timbucus
Octode
 
Join Date: Mar 2019
Location: Barry, Vale of Glamorgan, Wales, UK.
Posts: 1,260
Default Re: MK14 and MIDI

No panic I am enjoying watching the journey - the real advantage of this forum is that things happen at a more realistic pace for real life.
Timbucus is offline   Reply With Quote
Old 28th Sep 2022, 7:20 pm   #17
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 9,508
Default Re: MK14 and MIDI

Little update on this - I tried again this time with the TTL to MIDI level converter which I made a long time ago to plug into the GAME port on a PC - had almost no luck except when I did some combination of connecting and disconnecting things while the SHEBA code was running and suddenly there it was playing a long string of notes, quite fast, over and over again. I only got it to do that once but the fact that it worked at all, and kept on and on working once it did work, shows that the MIDI baud timing etc is spot on.

I think the problems I'm having stem from the fact that the reset condition of the SOUT port is low / logic 0 which also happens to be the 'active' state of a UART output, so as soon as the MK14 is powered the MIDI output is putting out what looks like a never ending start bit.

If I connect everything up, power up the MK14 and then power on my Yamaha SY22, the synth hangs at the startup message until I unplug the MIDI IN lead. If I then start the code running and reconnect the MIDI in to the synth the synth still doesn't (usually) play, but I have a feeling that is because it is difficult to connect the MIDI connection at the exact moment when nothing MIDI is going on.

I may have to try to arrange the MIDI OUT on SOUT to be inverse logic so that the SOUT idle state and MIDI idle state are the same, and then re-invert the MIDI data on the way to the MIDI output.
SiriusHardware is online now   Reply With Quote
Old 29th Sep 2022, 10:10 am   #18
Silvester
Triode
 
Join Date: Feb 2014
Location: Redditch, Worcestershire
Posts: 20
Default Re: MK14 and MIDI

Yes it is unfortunate that F/F feeeding SOUT is also reset to zero along with all registers on NRST. A bit of an oversight for a serial link IMHO. I forgot I altered my version of ELBUG (Elektor OS) to output a high condition immediately on reset so I didn't get this problem.

Rather than having to invert everything, perhaps a simple circuit using one of the Flag outputs to gate SOUT. Then have a simple prelude in MIDI routine to first set SOUT high and then release Flag gating SOUT output (using a 74126 ?).
Attached Thumbnails
Click image for larger version

Name:	sout.jpg
Views:	15
Size:	32.9 KB
ID:	265432  
__________________
David
Silvester is offline   Reply With Quote
Old 29th Sep 2022, 10:30 am   #19
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 9,508
Default Re: MK14 and MIDI

Inverting everything (start bit, data, stop bit) would actually make the output interface hardware simpler as a single transistor and three resistors would provide both the re-inversion of all the bits and the preferred open-collector drive.

I haven't looked into how difficult it would be - obviously the contents of A could be inverted on entry to the subroutine but inversion of the start and stop bits without spoiling your immaculate timing might be more tricky.
SiriusHardware is online now   Reply With Quote
Old 29th Sep 2022, 11:27 am   #20
Silvester
Triode
 
Join Date: Feb 2014
Location: Redditch, Worcestershire
Posts: 20
Default Re: MK14 and MIDI

I don't think it is possible to do MIDI with inverted start and stop bit (TBH it was a bit of a eureka moment when I realised MIDI could be done at all). Every possible solution I can think of so far upsets timing (or the carry link state).

BTW the 74126 solution would just require the chip and nothing else, it would buffer SOUT.
__________________
David
Silvester is offline   Reply With Quote
Reply

Thread Tools



All times are GMT. The time now is 7:23 pm.


All information and advice on this forum is subject to the WARNING AND DISCLAIMER located at https://www.vintage-radio.net/rules.html.
Failure to heed this warning may result in death or serious injury to yourself and/or others.


Powered by vBulletin®
Copyright ©2000 - 2023, vBulletin Solutions, Inc.
Copyright ©2002 - 2023, Paul Stenning.