View Single Post
Old 18th Mar 2019, 10:56 pm   #6
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,574
Default Re: Mk14 programming

I gave Karen's idea a go, but only in one direction (from the PC to the MK14) so far. I made up a little interface (diagram attached).

I don't have any sort of modern PC programming toolchain so I had to do a bit of OS time travelling, and dug out a Win '98 laptop on which I have Qbasic V4.5.

After a bit of experimentation - I had some difficulty remembering how to send a single byte to the com port - and twiddling with various values, I arrived at this:

Code:
CLS

'Define the RS232 '0' and '1' bit characters.

'For a zero, 0 11111111 1 = start bit (L) + 8 data H + Stop (H)
zero$ = CHR$(&HFF)

'For a one,  0 00001111 1 = start bit (L) + 4L data + 4H data + Stop (H)
one$ = CHR$(&HF0)

'Initialise COM port
OPEN "com1: 300, N, 8, 1, bin,cs0,ds0" FOR OUTPUT AS #1
'Adjust UART COM1 clock divider registers to get 320 Baud
'For 320 baud, UART DLM = 01H, UART DLL = 68H
'To write DLL and DLM set DLAB=1 (Base addr + 3, bit 7)
OUT &H3FB, &H83 'Dlab switch = 1, access second layer registers
OUT &H3F8, &H68 'Write DLL value H68 320bd
OUT &H3F9, &H1  'Write DLM value H01 320bd
OUT &H3FB, &H3  'Dlab switch = 0, return to primary layer registers

'With a load start address of OF12 this range of values should
'fill 0F12-0FF0 with the data 12H to F0H, so when looked through
'after loading, the data in each of those addresses should equal
'the low byte of the address.

FOR ValueToSend% = &H12 TO &HF0 ' Sequential values to send out

FOR BitNumber% = 0 TO 7 ' Bit pointer

BitMaskValue% = (2 ^ BitNumber%)

IF (BitMaskValue% AND ValueToSend%) = 0 THEN
         PRINT "0"; : PRINT #1, zero$;
ELSE
         PRINT "1"; : PRINT #1, one$;
END IF

NEXT BitNumber%

PRINT ' Move down one display line

NEXT ValueToSend%

CLOSE #1
I started off at 200 baud but found that the overall length of one 'MK14 bit' was rather longer than 32mS, enough to scramble the values being sent.

Twiddling around, I arrived at a baud rate of 320 as this resulted in an MK14 bit time of roughly 32ms according to my wheezy old scope, and I also modified the 'one' byte value from E0H to F0H so that one low start bit + 4 low bits + 4 high bits +one high stop bit gave the 'one' bit a roughly 16ms on, 16 ms off structure.

The penalty was that the 'zero' bit was then only one tenth of an MK14 bit time long instead of one-eighth which was what was really required.

In practice, however, it works.

I didn't go to the extent of loading in a binary file and sending its contents to the MK14 - anyone who wants to take it that far can easily do so, instead, I hit on the idea of just sending the consecutive values of a FOR-NEXT loop, from 0x12 to 0xF0, to addresses 0F12 to 0FF0. If the MK14 reads the characters correctly the locations 0F12 to 0FF0 end up containing data = the low byte of the address, so it's easy to see whether the code in any address in that range is what it should be.

To try this, do the following steps on the MK14:

Reset
0 F F 9 Term
0 F Mem
1 2 Mem
Abort
0 0 7 C
Go

(The MK14 displays go blank).

Run the Qbasic program and let it run to the end, until the interface LED stops flashing.

On The MK14, hit Reset and then look through the locations OF12 onwards, you should find the locations have all been programmed with values equal to the low byte of the address.

Interesting footnote: After all the trouble I went to to fiddle a non standard baudrate, I then tried it at 300baud. (Comment out the OUT lines in the code). It still worked!

So you could probably do this on a modern computer using Python or C or VBasic without having to worry about how to generate unusual baud rates.
Attached Thumbnails
Click image for larger version

Name:	MK14_Via_Serial.png
Views:	145
Size:	11.6 KB
ID:	180170  
SiriusHardware is online now