Sunday 28 June 2020

Mini PET Options

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

As I am starting to put together the kits for the second batch of Mini PET boards, I thought it would be useful to go through the options available.
All versions share the same main board. This provides the following:
  • W65C02S CPU running at 1MHz
  • 32K RAM
  • 20K BASIC / OS, 2x4K option ROMs
    • Original BASIC 1/2/4
    • Custom Mini PET BASIC 4
    • Built in ROM/RAM self test
  • Compatible with most Commodore PET software and peripherals, with the following exceptions:
    • The screen is 40 columns only, so any 80 column (mainly business) software will not look correct on any 40 column PET
    • There is no CRTC chip, so any software (mainly later demos) that needs a CRTC will not work
    • The CPU socket is not pin compatible with the original NMOS 6502, so nothing that plugged into the 6502 socket will work.
    • There are no internal power headers (but these were generally only used in conjunction with the CPU socket above). 
  • 2x W65C21N and 1x W65C22N providing the following IO ports
    • IEEE-488 bus for disk drives / printers
    • Userport with 8 bit parallel port
    • 8x10 keyboard matrix
    • 2x Commodore Datasette connectors (compatible with C2N and 1530)
    • Piezo sounder connected to CB2 (as required by Invaders and as fitted to later PETs)
  • 1K video RAM providing 40x25 character based display, via one of the following:
    • Composite video, monochrome PAL / NTSC
    • PET 9" monitor
    • PET 12" monitor
  • Single 9V DC supply from external supply or PET transformer, 170mA 
  • Self assembly kits. 
    • Modest soldering skills are required. 
    • All through hole parts.
    • All brand new and currently in production.

Kit A - Standalone 

This is the version of the Mini PET which is stand alone PET compatible computer with it's own keyboard. This would normally be used with a 9V DC power supply and would drive a composite video TV or monitor.
This goes well with an SD2PET future SD card disk drive.
The keyboard is connected underneath the board via a 20 way 0.1" header, and can be detached for easier storage. 
The combined unit stands on a number of nylon pillars, which are M3 threaded if you wish to attach to a baseplate.

Kit B - PET Replacement Board

This version would normally be used to replace the mainboard in a Commodore PET case. It should fit in most cases from the 2001 to the 8096-SK.
If mounted at the back of the case, the three edge connectors line up with the holes in the case where the orignal PET board had it's edge connectors.
The board is much smaller, so only picks up on one mounting post, at the top right. The rest of the board is supported on self adhesive pillars.
Power is taken from the PETs power transformer using a power interface board. This makes use of the large capacitor in the case in the same was as the PET mainboard did. The output is a single 9V DC supply for the Mini PET board.The blue wires are a second winding that used to feed the 12V supply. This is not used.
The PET 2001 also only required 9V in, so did not have the extra windings, and used a 5 way plug rather than  9 way, this should be aligned to the edge, where the brown, red and black wires line up. The connector is symetrical, so either brown wire can be towards the edge.
The 9V plugs into the Mini PET board, as do the PETs keyboard and monitor. The Mini PET can drive a variety of monitors, with appropriate DIP switch settings.
The black and white 9" tube on the original 2001s.
The green screen 9" on the 2001N/30xx/40xx series.
The green screen 12" on later 40xx and 80xx models.
The Mini PET can support both the graphics keyboard (top, found in most 2001/2001N/30xx/400xx PETs) and the business keyboard (found in 4032B and 80xx machines). Although most software was written for the graphics keyboard and some games may have hard coded keyboard scanning routines rather than using the OS ones, so there may be some issues with certain programs.
Another option for mounting is to move the board further into the case, so an SD2PET future can be installed inside the case. This is useful if you need the space behind the PET, or don't want the extenal device to be visible (or where it may get borrowed).
The datasette board can be used to still have an external datasette power at the rear or side (or the internal drive on a 2001)
You can also fit the board inside an 8032-SK case, and use the original cabling to feed the front and rear connectors.
Or disconnect the external IEEE-488 port and fit an SD2PET future inside.

Various options there, available to order now from The Future Was 8 bit. What are you going to do with your Mini PET?

2022 Update: The Mini PET has been replaced by the Mini PET 40/80. This has a built in much nicer keyboard and supports 40 and 80 column mode. Also available is the Mini PET 40/80D, a preassembled drop in replacement board with a built in SD2PET. Both are available now from The Future Was 8 bit.

Sunday 21 June 2020

IKA Logic SQ200 Logic Analyser Review

This is a new toy I have just got, I've only had it a few days, but I've been quite impressed so far. It is an SQ200 from IKA logic, a 200MHz 4 channel logic analyser / signal generator.

I've been using a DSLogic Pro for the last three or four years, until last month it stopped being detected properly. It is one of those things which has the firmware loaded onto it by the driver, so it connects as one type of device, get the firmware, disconnects and then reconnects as the proper device. That has stopped happening now, and I've not been able to get it to identify properly, so it's bricked, currently waiting to hear back from support to see if there is anything they can do.

In the interim, I have been using a cheaper generic clone of something or other from ebay. It works, but has a sample rate of 24Mhz, which means it's not accurate enough to things changing at 16Mhz. I am currently working on the firmware for the Mini PET video controller, and the timing has to be precise down to one instruction of it's 16Mhz clock, and that is down in the sample noise of that unit.

So, time to get something that's a lot faster. This is 200Mhz, so is rather to be able to cope with signals up to 50Mhz, which is more than enough for what I need at the moment. It's limited to four channels, which is not ideal for some of the other things I do where 16 or more would be useful. But for serial protocols like UART, I2C, SPI etc. and the current video signalling it's great.

The unit comes with a USB lead and some probes. It's a very small box, 50mm square, but I guess it doesn't need to be any larger.

I wasn't too impressed with the quality of the supplied probes, those sort of clips aren't very good with IC legs. The connector at the device end is just a 5 way 0.1" connector, which is great, so you can make up your own leads. Not sure how that will work out with the higher frequency signals, but I guess just keep the leads short.

I have made up a set using the EZ Hook clips I have been using, these were a bit expensive, but have been worth it.

Because it is a easy connector to use, I have also made up a custom lead for the current job so I don’t need to clip multiple probes on each time.

The software is custom, and it is not currently supported by the open source sigrok Pulseview programs I have been using. So far it seems very nice and is doing what I need.

At 200Mhz I can capture 20mS, which is enough for a frame of video, and I can zoom down to line and pixel detail.

The issue I am currently dealing with is based on timing of the HSync pulses. They should all be 24uS high followed by 40uS low, but somewhere there is one that is slightly out. The dot clock on the PET video is 8MHz, so each pixel is 125nS wide. 
One instruction cycle on the microcontoller is 62.5nS, so a couple of instructions out and you are one pixel to the right of where you should be. Most of the code is NOP instructions so there are only a couple of NOPs to move around to fix it.

Various tweaks to the timing have given me close to the correct result, but each of the video modes needs to be dialled in to the exact timing. Ah, there's one of the culprits that 40us pulse is 60nS longer that it should be. One NOP instruction removed and it's now 40.000uS.

That is enough to change the video output from...

A nice straight line, and with all the other timing tweaks, composite and drive to CRT monitors is now all working nicely with nice straight edges on the side.

The SQ200 has a lot of functionality I have yet to investigate fully. One thing that looks very handy is being able to set a conditional trigger, only trigger when that signal is low and that one goes high, then low before the other one goes high, and things like that.

It had protocol decoders built in, so you can decode I2C etc.

It can work as a signal generator, and can also work as mixed input and output, so it can actually send I2C commands and display the results.

So that's looking like a very handy tool to have, and helped me finish off the last few tweaks to the PET video firmware.

Sunday 7 June 2020

Minstrel 4th Quick Start Guide by George Beckett

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

Here is a guide to getting started with Forth on the Minstrel 4th, written by George Beckett.


The Minstrel 4th stands out from many other micros, in that it ships with FORTH as its built-in language, rather than the otherwise ubiquitous BASIC. FORTH has several big advantages that make it a good match to the Minstrel. First, it is fast, and, in particular, it is much faster than BASIC. FORTH programs are compiled and interact with the hardware on a lower level than they do in BASIC, meaning it is not uncommon for a FORTH version of a program to run ten times faster than the BASIC equivalent. Second, a FORTH program is lean, using much less memory than its BASIC equivalent. This means you can write fast and compact programs for the Minstrel 4th, without having to resort to machine code.

However, FORTH has several idiosyncrasies that can deter those who are unfamiliar with the language. First, FORTH is a stack-based programming language. A stack is a relatively primitive data structure intended to provide temporary storage for a program. The programmer adds numbers to a stack in the same way a writer adds pages to a pile of paper. Numbers in a stack have to be accessed in a certain order; you can only access the entry on top of the stack, which is the most recent value added.  To get to numbers lower down the stack (a number you added earlier on), you have to take off the values above it (after it) first.

While a stack is primitive, it is much faster to access than program variables. In FORTH, data is (usually) passed to and from routines via the stack rather than as parameters or variables, something that can be confusing to the uninitiated. FORTH has a common notation for describing the state of the stack: the value on the top of the stack is called TOS and the next lower value on the stack is called 2OS.

Because the stack is so important in FORTH, the language relies heavily on Reverse Polish notation, in which parameters precede the procedures that act upon them. For example, in BASIC, you can set the print location on the screen using something like  AT 12, 14 . The equivalent expression in FORTH is  12 14 AT . The parameters appear before the function (and there is no punctuation, other than spaces). 

If you can get past these idiosyncrasies, you will find that your Minstrel 4th gives you lots of scope to indulge your passion for micro-computing and to create useful and interesting programs.

The FORTH Language

At the heart of Forth is a dictionary of procedures, referred to as words, which encapsulates the functionality of the computer. You can see a list of built-in words, in the Minstrel 4th, by typing the command  VLIST . Looking at the list produced, there will probably be some words, such as  PLOT  and  BEEP , for which their purpose seems obvious, but also many words for which it is not. In fact, words such as  .  and  :  may look more like punctuation than words. However, rest assured that they are words and it is important to remember that when writing FORTH. 

The syntax of FORTH is very simple, with programs being built up from sequences of (FORTH) words and numbers, separated by spaces. There is no other punctuation in FORTH other than space.
If you have the Minstrel powered up, you can type the following simple expression:
 3 4 * 10 + 
When you press Enter, the expression is copied to the upper part of the screen alongside the response 
OK ’, indicating success, but you will notice that no obvious answer is produced. 
The field near the bottom of the screen, where you enter commands, is called the Input Buffer. When you press Enter, the Minstrel looks to see what instructions are in the Input Buffer and processes them item by item. The first item it will come across in this case is the  3 . It will check to see if  3  is a word in its dictionary. It is not, so it will then try to interpret  3  as a number. This will succeed, so it will add '3' to the top of the stack (it will also move the item to the upper part of the screen, to indicate it has been processed).

The Minstrel then checks if there is anything else in the Input Buffer. It finds  4  and again will interpret this as a number. It will add '4' to the stack and move it to the top of the screen. The stack now contains two values '3' and '4' in positions 2OS and TOS, respectively. 

The next item it finds is  * . The Minstrel will search its dictionary and find a word named  *  that takes the top two items off of the stack, multiplies them together, and puts the answer back on the stack. The  *  will be echoed to the upper screen and the stack will now contain one value 12.

Continuing on, it will add 10 to the stack and then execute the next word + which will add the top two number on the stack and replace them with the answer.

There are no more items in the Input Buffer, so the Minstrel prints ‘ OK ’ to indicate it has successfully processed all of the instructions it has been given. 



But where is the answer, you say? The answer is on the stack. If you want to see the answer, you need to ask the Minstrel to print the value on the top of the stack and to do this you type the word   .  (that is, a full stop). This is another standard Forth word: it removes the top number from the stack and prints it on the screen. 
The above example is not exactly earth shattering, but it does explain how Forth processes commands. Having cut your teeth with Forth, you might now try the apparently similar expression 
 200 200 * .  
—which does not produce the answer you probably expected. If you are familiar with machine code, you may spot immediately what has happened. If not, I will explain. Numbers on the Minstrel 4th are, by default held as 16-bit, signed integers, which can hold values between -32,768 and +32,767. If you happen to overflow this range (200 × 200 = 40,000, which is too big to fit in a 16-bit, signed integer), the answer will simply overflow and lose its most significant bit, leading to the wrong answer. 
However, the Minstrel will not tell you this has happened: It will happily compute and report the wrong answer. This is a potential downside of a language like FORTH. If you tried the same calculation in BASIC, it would have succeeded, though would have spent some time turning your inputs into its generic internal representation, consuming around five times as much memory and taking quite a bit longer to produce the answer. The trade-off for fast FORTH arithmetic is that it relies on the programmer being aware of and checking for its limitations. By the way, FORTH on the Minstrel can deal with bigger numbers (and floating-point numbers, too) though this requires the use of different words, which are best kept until you know some more FORTH.

Writing Programs

A key advantage of FORTH is the ability to define your own words, to supplement the standard dictionary. FORTH programs are effectively words written by an end-user to encapsulate some function—anything from a platform arcade game through to a spreadsheet.

The easiest way to define a new word is by combining existing words. In this way, a program can be represented by a top-level word built up from other user-defined and internal words. This form of programming encourages a top-down approach and a large program could be made up of a number of layers of lower-level words.

To define a new word from other, existing words, you need to be aware of two FORTH words,  :  and  ;  which switch FORTH between compile mode and interpret mode. Consider the following FORTH code 
 : DOUBLE 2 * ;  

We have seen * earlier, but the other words are new to us. This is a very simple word definition, which creates a new word, named DOUBLE. The  :  command tells the Minstrel you want to define a new word and the word immediately after is the name of that new word. Following on from that is the body of the new word, which is interpreted whenever you enter DOUBLE, terminated by the  ;  command, which returns FORTH to interpret mode. Note that because  :  and  ;  are words, they need to be surrounded by spaces.

As you have probably guessed,  DOUBLE  multiplies something by two. However, as only one value (‘2’) is added to the stack, within the word, this means that the other value needs to be on the stack already.

When you type the command above, the Minstrel will compile the new word into a fast, internal representation, ready to be used in the same way as other FORTH words.

You can see that your new word is part of the dictionary, using  VLIST . You should find that  DOUBLE  is the first word printed: it is at the top of the dictionary.

To test  DOUBLE  , you could enter something like:
 10 DOUBLE .  

For words that you define, you can display the definition using the word  LIST . Notice that the Minstrel will make an attempt to format the listing in an easy-to-read way. Notice, also, that  LIST  does not work for internal words: they are defined in a different way.
For this simple word, it is reasonably easy to work out what is going on, even if you come back to the word some weeks later. However, for more complicated words, it is useful to be able to add comments. To do this in FORTH, you use two words  (  and  ) , which indicate the beginning and end of a comment. You use them much as you would use when writing English (to add some extra explanation about what you have just written).

To update our word definition, for  DOUBLE  we type  EDIT DOUBLE . This will open the existing definition of  DOUBLE  in the input buffer and allow us to edit it, to something like:

 : DOUBLE ( N -- 2*n ) 
    2 * 

For longer word definitions,  EDIT  will divide the definition into sections of around 12 lines. Once you have finished editing the current section, press Enter to move on to the next one. Pressing Enter in the last section will end the editing session. Sadly, you cannot go back to the previous section in an editing session, so, if you need to backtrack, you will have to skip through the remaining sessions and  EDIT  the word again.

You might naturally assume that the definition of  DOUBLE  has been updated, in the dictionary. However, this is not quite what happens. When the Minstrel exits the editing session, it creates a new copy of the word at the top of the dictionary, though also keeps the previous version. You can see this by typing  VLIST , which will confirm you have two copies of the word  DOUBLE  .
Having edited a word, it is important to remember immediately to replace the old version, using a word named  REDEFINE —in this case, you would type  REDEFINE DOUBLE  . This will replace the old definition of  DOUBLE  by the word on the top of the stack (and also recompile any words that might depend on  DOUBLE  ).

The process for  EDIT -ing and  REDEFINE -ing words is a potential source of problems for someone new to the Minstrel 4th. If you forget to  REDEFINE  your word, you will end up having two copies and, worse still, if you go on to define more words, you will not be able to  REDEFINE  the earlier word, since  REDEFINE  expects the new definition to be at the top of the dictionary. In this case, the only solution is to use a word  FORGET  to remove all of the subsequent words and then use  REDEFINE  as you should have done originally.  Say, you had forgotten to   REDEFINE DOUBLE , above, and fuelled with enthusiasm, had gone on to write further words  TRIPLE  and  QUADRUPLE . Then the top of your dictionary would look like:

To correct the issue, you would need to type the following:

In this case, the error is not too costly. However, in longer programs, it could become a very expensive mistake to fix. Because of this, it is wise to save your work frequently, as we will explain below.

Saving Your Work

When you turn the Minstrel 4th off, any new words you have defined will be wiped from memory. However, having spent time creating some new words, it is useful to be able to keep them for future use. To do this, in typical 1980s style, you need a cassette recorder (or a modern-day substitute, such as a PC with a mic jack). 
You need to connect your cassette recorder to the Ear and Mic sockets on the Minstrel 4th, using a 3.5mm headphone lead. The Mic socket is the output from the Minstrel and connects to the microphone socket on the cassette recorder to save data from the Minstrel. The Ear socket is the input to the Minstrel, and connects to the earphone socket on the cassette recorder to play back a saved program into the Minstrel’s memory.

To save  your words, you use the word  SAVE  followed by the name you want to give your new extended dictionary—for example,  SAVE MYWORDS . Before pressing Enter, you should press ‘Record’ on the cassette recorder, as the Minstrel 4th will immediately begin transmitting the data. It takes around 5 seconds per kilobyte to save your work.

Before powering off, it is worthwhile to check that you have saved your work successfully and, to do this, you use  VERIFY . Rewind your tape to just before the save session and enter  VERIFY MYWORDS . You can then play back the saved audio, so that the Minstrel 4th can check if it agrees with what is in memory.

Having successfully saved your work, you can load it back into memory, in a future session, using   LOAD MYWORDS .

It is worth noting that the Minstrel 4th is hard of hearing. You will need to play back your save audio at a high volume (though, thankfully, you will not hear it, as it goes straight into the computer’s Ear socket). In my experience, you should set a tape recorder to play-back at around three quarters of maximum volume (or, on a PC, full volume is likely to be needed). Trial and error is required to get a reliable process for saving and loading to cassette, so it is worthwhile to get to grips with this early on. (see a previous blog post for further advice on loading programs on the Minstrel 4th)

Next steps

This is the end of your quick tour of the Minstrel 4th. However, there are lots of other resources available to help you take your next steps. 

The Minstrel 4th uses a variant of FORTH, called AceForth, developed for an early 1980s micro called the Jupiter Ace. The Minstrel 4th shares the same memory map as the Ace and can run the same monitor and FORTH system as the Ace did. Software written for the Ace (and books about the Ace) should work on (and be relevant to) the Minstrel 4th. In particular, the original Ace user guide, called “Jupiter Ace FORTH Programming” by Steven Vickers, is an excellent book for learning to program the Minstrel 4th. It was recently re-printed to celebrate the Ace’s 35th birthday, so is relatively easy to find on retro-computing auction sites. Further, along with lots of software and other materials, you can find a PDF copy of the user guide on the Jupiter Ace archive website –

Hopefully, you will go on to have a great deal of fun programming your Minstrel 4th, and to become a convert to the FORTH way. However, even if you do not, you will still be able to enjoy the wide range of software that others have written for the (Jupiter Ace and) Minstrel 4th. 
An excellent example of which is Tut-Tut, ported by George himself from Dave Stevenson's original.

Thanks to George Beckett (@markgbeckett) for writing today's blog post.

2022 Update: George has also remade 3D Monster Maze for the Minstrel 4th / Ace.