23rd Mar 2023, 4:47 pm | #181 |
Dekatron
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,558
|
Re: Idiot building a MK14 thread
Start small - you'll be aware that the classic beginner's program in almost any language is one which displays 'Hello World!'.
Starting off by using Realtime's code to fill / clear the vdu screen, can you imagine a way to add some more code to print 'HELLO WORLD!' onto that blank screen? The easiest way, if not the most efficient way, is to load each of the required characters in turn into 'A' and then write them from 'A' into specific memory locations within the screen area. Code:
Load character code for 'H' into A reg Store character from 'A' into the destination screen memory location Load character code for 'E' into A reg Store character from 'A' into the next destination screen memory location Load character code for 'L' into A reg Store character from 'A' into the next destination screen memory location Code:
Print "H"; Print "E"; Print "L"; You might also point out that in BASIC you would actually just do this Code:
Print "HELLO WORLD!" When writing a program which, like this one, performs a single task only once, once your program has run its course you have to intentionally stop the microprocessor from ploughing onwards through the program memory and trying to execute whatever happens to be in it. One way to do this is to end your program with a jump instruction which jumps back to itself, so that the SC/MP stays in a controlled loop. |
23rd Mar 2023, 6:43 pm | #182 | |
Heptode
Join Date: Oct 2011
Location: Culcheth, Cheshire, UK.
Posts: 654
|
Re: Idiot building a MK14 thread
Quote:
How about this for reading a thermistor, or LDR, or any other analogue device ... Set a digital output to sort-of PWM, then connect to a smoothing RC. The 'smoothed' signal is now a voltage dependant on the PWM duty. Connect this signal to one input of an analogue comparator, and connect the other input to an analogue source. This source could be a simple voltage divider, with the LDR or thermistor as the active leg. Connect the output of the comparator to a digital input. Now by varying the PWM you can determine the analogue level from the source. Just record the value of the PWM when you see the comparator change. This is some very simple hardware, but needs a little more software. It's still a lot simpler to write than any serial device. Colin, if you need any ideas to prompt your imagination, how about ... A moisture monitor for potted plants, which sounds a beeper when dry. A temperature monitor that starts a fan when it's too hot. A LDR to measure daylight. Take readings every 15min. After 24h find the middle of 'darkness', call this midnight. Now you can build a porch light that comes on at, say 5h before midnight, then turns off at midnight. This will never need setting when clocks or seasons change, as it recalibrates itself every 24h. Cheers, Buzby |
|
23rd Mar 2023, 7:51 pm | #183 |
Dekatron
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,558
|
Re: Idiot building a MK14 thread
In the meantime, here is the simplest... simplest to understand, that is, method of displaying 'Hello World' on the first line of the VDU screen. It starts off by using Realtime's fill screen code from earlier to clear the screen, then outputs a simple text greeting to the screen. Load at 0B00 and run from 0B00 (the program does not Auto-Run). The VDU is assumed to be set up to use 0200-03FF as screen memory.
In Real Life, we wouldn't do it this way with all the individual LDI / ST statements inline as shown here. More likely, we would put the characters making up the message into a table and use a program loop with a single LD and ST instruction inside it to read each character from the table and write it to the screen memory, but that code wouldn't be quite so easy to understand in the first instance. I have attached the .asm, .lst file and Intel hex files in a .zip Code:
; "Hello World" for MK14 VDU done the inefficient, but easier to understand way... ; ***************************************************************************** ; Fill the screen with the character value held at B07 ; Load into 0xB00 ; Execute at 0xB00 ; ***************************************************************************** DISP_GR .EQ 0x0200 ; Start of VDU screen memory PROG .EQ 0x0B00 ; Start of program memory .OR PROG .CR scmp ; Use the scmp cross assembler .TF hiworld.hex,int ; Name, and type of output file .LI TON ; Also produce a 'List' file ; Fill the screen with a specified character FILL: LDI DISP_GR/256 XPAH P1 LDI DISP_GR\256 XPAL P1 ; P1 now contains start address of video display FILL1: LDI 0x20 ; Character to fill screen with (0x20 = 'Space') ST @1(P1) ; Clear location XPAH P1 XRI DISP_GR/256+2 ; XOR to determine if page clear completed JZ HELLO ; If zero then then finished clear screen, -> HELLO XRI DISP_GR/256+2 ; Restore P1_H XPAH P1 JMP FILL1 ; Having cleared the screen, now print "Hello World!" the 'longhand' way ; First, set pointer register P1 back to the start of the screen memory HELLO: LDI DISP_GR/256 XPAH P1 LDI DISP_GR\256 XPAL P1 ; P1 contains start address of screen memory again LDI 0x08 ; MK14SCII Code for 'H' ST @1(P1) ; 'Store at the address in P1, increase P1 by 1' LDI 0x05 ; MK14SCII Code for 'E' ST @1(P1) LDI 0x0C ; MK14SCII Code for 'L' ST @1(P1) LDI 0x0C ; MK14SCII Code for 'L' ST @1(P1) LDI 0x0F ; MK14SCII Code for 'O' ST @1(P1) LDI 0x20 ; MK14SCII Code for 'Space' ST @1(P1) LDI 0x17 ; MK14SCII Code for 'W' ST @1(P1) LDI 0x0F ; MK14SCII Code for 'O' ST @1(P1) LDI 0x12 ; MK14SCII Code for 'R' ST @1(P1) LDI 0x0C ; MK14SCII Code for 'L' ST @1(P1) LDI 0x04 ; MK14SCII Code for 'D' ST @1(P1) LDI 0x21 ; MK14SCII Code for '!' ST @1(P1) RET P3 ;Finished, now return to the monitor |
23rd Mar 2023, 8:04 pm | #184 | |
Dekatron
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,558
|
Re: Idiot building a MK14 thread
Quote:
|
|
23rd Mar 2023, 8:36 pm | #185 | ||
Heptode
Join Date: Oct 2011
Location: Culcheth, Cheshire, UK.
Posts: 654
|
Re: Idiot building a MK14 thread
Quote:
Yes, it would need bit-banging, but I don't think it would be too difficult. However, another idea has come to mind. Use a DAC from 8-bits of the 8184 to generate the comparator signal, instead of PWM. Now the code just needs to count up from zero until the comparator flips. There's always more than one way to skin a cat !. Cheers, Buzby |
||
23rd Mar 2023, 8:59 pm | #186 | |
Dekatron
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,558
|
Re: Idiot building a MK14 thread
Quote:
However, I think Colin may need a bit more detail with respect to both the hardware and the software to generate the ramp waveform for the comparator. As far as I know this is the first time he has tried to programme anything at this low level and I'm not sure we can ask him to think up circuits out of thin air based on one paragraph descriptions. I suppose this also poses the question - why not just use a parallel Analogue to Digital converter IC to read the voltage at the junction of the resistor / thermistor divider? No comparator needed then. Could also be used with a Light Dependent Resistor or a potentiometer for other experiments. The original (but software-complex) idea of using a one-wire DS1820 does have one merit, the output from the device is in straight numeric degrees Centigrade, whereas with any electronically simple scheme you automatically need look up tables or some mathematical way of converting the voltage from the thermistor / divider into a meaningful temperature reading. |
|
23rd Mar 2023, 11:34 pm | #187 |
Octode
Join Date: May 2012
Location: Perth, Scotland
Posts: 1,806
|
Re: Idiot building a MK14 thread
To set a level, I can program in BASIC (and REXX) til the cows come home. I've written assembler on a mainframe 30 odd years ago so that's so rusty it's seized.
If you all imagine my knowledge is where yours was when you were 14 or so, then that's probably for the best. But I do want to learn. Colin. |
24th Mar 2023, 12:29 am | #188 |
Octode
Join Date: Mar 2020
Location: Kitchener, Ontario, Canada
Posts: 1,294
|
Re: Idiot building a MK14 thread
One way to measure a thermistor or light dependent resistor is to make a simple two transistor multivibrator with the sense resistor controlling the length of the mark or space of the output, then using a sense input of the 8060 to measure the duration. 555 timer could be used in a similar way.
Last edited by Mark1960; 24th Mar 2023 at 12:30 am. Reason: Spelling |
24th Mar 2023, 12:40 am | #189 |
Heptode
Join Date: Oct 2011
Location: Culcheth, Cheshire, UK.
Posts: 654
|
Re: Idiot building a MK14 thread
[QUOTE=Mark1960;1546424... simple two transistor multivibrator with the sense resistor controlling the length of the mark or space of the output, then using a sense input of the 8060 to measure the duration. ...[/QUOTE]
That's another cat skinned !. This has prompted a memory. Somewhere, fairly recently, I've seen a photo-sensor which is a light-to-frequency converter. I don't know what range of frequencies it had. I just wish I could remember the part number !. |
24th Mar 2023, 1:11 am | #190 | |
Heptode
Join Date: Oct 2011
Location: Culcheth, Cheshire, UK.
Posts: 654
|
Re: Idiot building a MK14 thread
Quote:
You use these same basic ideas in assembler, but write in a different language, and usually take a few more steps. You also need to be familiar with the registers in the 8060. These don't have a direct equivalent in BASIC, but they are fundamental to programming in assembler, and they are different for each family of microcontroller. Luckily, the 8060 is a fairly simple device to understand, as it's only got about 46 instructions and 7 registers. It also helps to draw a flowchart before starting writing, it helps a lot in organising your code. Programming in assember is slower then in a high-level language, but you learn fast ! A good page is here : https://www.heinpragt.com/english/so...processor.html |
|
24th Mar 2023, 1:57 am | #191 |
Dekatron
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,558
|
Re: Idiot building a MK14 thread
For any kind of serious intent to do this kind of thing I think Colin is going to need:
-An SC/MP assembler program which runs, not on the MK14 but on something else. Writing programs in hex is undeniably hardcore, not to mention that it was the way we all had to do it originally but it soon gets tiring and if you want to add to or mod an already existing bit of code then you have to move it all around by hand and perhaps alter some of the jump / displacement offsets as well, all by hand. A few of us here use the SBASM3 cross assembler written by San Bergmans and available (free) from his website (the whole of which is very interesting, but here is the specific link to the assembler). https://www.sbprojects.net/sbasm/ -Some kind of loader hardware / interface. Even with an assembler to hand to convert assembly language into pure hex for you, any sense that you might be having fun soon evaporates when all of your painstakingly typed-in code vanishes the moment you switch the machine off, or if your code crashes. You can't really prevent that from happening on the base MK14 which has no non-volatile RAM, but if you can load all of your code back in in a matter of seconds that makes a huge difference. There are almost more individual MK14 loader projects nowadays than I can remember, so take your pick. -A tutorial for SC/MP programming, over and above what is offered in the original manual. In terms of telling you how to program the SC/MP, the original manual for the MK14 is generally held to be not very good, the basic methodology is to give you a book full of programs / subroutines which you have to try to understand the workings of yourself. There was an aftermarket book called 'Understanding Microprocessors with the MK14' which might be regarded as the manual the MK14 should have had, it explains each of the SC/MP instructions in greater detail than the original manual did and it goes into some detail about how to write to the display, which the original manual didn't even try to explain. Original copies of this softback book go for ridiculous sums now but you can probably find an electronic copy of it if you look hard enough or ask around. Other SC/MP books were discussed in recent threads. |
24th Mar 2023, 11:53 am | #192 | |
Octode
Join Date: May 2012
Location: Perth, Scotland
Posts: 1,806
|
Re: Idiot building a MK14 thread
Thank you - I will go and look for that book and software.
It does remind me that when I got my PET in early 1980 having won it, they didn't send the datasette for weeks so every night when I wanted to use my shiny new computer, I had to re-type the code for whatever it was I wanted to do. Off to Stonehaven for the weekend in the motorhome, so I won't get anything done for a few days. Colin. Quote:
|
|
24th Mar 2023, 2:16 pm | #193 | |
Pentode
Join Date: Nov 2022
Location: Chesham, Buckinghamshire, UK.
Posts: 135
|
Re: Idiot building a MK14 thread
Quote:
|
|
24th Mar 2023, 2:24 pm | #194 |
Dekatron
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,558
|
Re: Idiot building a MK14 thread
That's certainly the class of device I was thinking of but, crucially, how much do those cost now? I was looking at the ZN425E (for D-A output) and they go for about £6 upwards now.
It might actually make more sense to use a mid range PIC programmed to 'be' an analogue to parallel data out IC - all of that family have ADC functions on some of the port pins. But that would most likely be considered cheating. |
24th Mar 2023, 2:37 pm | #195 | |
Pentode
Join Date: Nov 2022
Location: Chesham, Buckinghamshire, UK.
Posts: 135
|
Re: Idiot building a MK14 thread
Quote:
|
|
24th Mar 2023, 6:36 pm | #196 |
Hexode
Join Date: Jan 2021
Location: Ashford, Kent, UK
Posts: 318
|
Re: Idiot building a MK14 thread
|
24th Mar 2023, 6:42 pm | #197 |
Hexode
Join Date: Jan 2021
Location: Ashford, Kent, UK
Posts: 318
|
Re: Idiot building a MK14 thread
Does anyone know of a link to a scanned copy? I've been looking out for an original but not seen one and never found a link (but of course it might have been stored under a different title somewhere on the web).
|
24th Mar 2023, 7:00 pm | #198 |
Octode
Join Date: Mar 2011
Location: North Yorkshire, UK.
Posts: 1,115
|
Re: Idiot building a MK14 thread
See PM Ian
Last edited by Phil__G; 24th Mar 2023 at 7:13 pm. |
24th Mar 2023, 7:35 pm | #199 |
Octode
Join Date: May 2012
Location: Perth, Scotland
Posts: 1,806
|
Re: Idiot building a MK14 thread
|
24th Mar 2023, 9:30 pm | #200 | |
Dekatron
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 11,558
|
Re: Idiot building a MK14 thread
Quote:
Try dropping a PM to Phil? |
|