Robotics and real-time control :

Using the BBC computer


Contents :


The Acorn BBC computer was in its time one of the better 8-bit microcomputers. As compared with others available, it has a fairly ambitious operating system in ROM, which shows evidence of having been designed rather than scraped up from a gutter somewhere. Its provision for interfacing with other devices is particularly good ( which is why we originally bought some for the real-time control course ), with the user port, controlled by a VIA, very accessible from programming languages.

We still use them because they are no worse now than they were originally. They don't do snappy graphics blindingly fast, but we don't need that for much of real-time control. They do give excellent access to a VIA interface ( and others ), which we do need, and you won't find on many modern machines. Even the A5000s don't do it so well, though ours have IO boards which mimic the BBC user port and other bits.

These notes introduce the machine and give you enough information to switch it on, read discs, plug things in, and so on. For details, look at the BBC literature in the laboratory; there is quite a bit of it, though documentation is one of the BBC's weakest points. ( It is interesting that the BBC manuals all contain a little note : "This book is part of the BBC computer literacy project". ) The clearest document is certainly not one produced by Acorn; it is the New Advanced User Guide ( see below ).

Guide to the BBC literature.

Please take care of the literature. It has essentially no commercial value - it's far too old for that - and some of these are absolutely our last copies.

Welcome guide.

Generally introductory; mildly interesting to give you an idea of what's available, but unlikely to be of great technical assistance. It does give a few tables, etc., which are not so easy to find elsewhere - screen modes, *FX instructions, some pin diagrams for the sockets at the back of the computer, etc.

Reference manual, part 1.

Operating system software, lots of API stuff. Dreadful index.

Reference manual, part 2.

Languages and suchlike : Basic, assembler. Dreadful index.

New Advanced User Guide : A.C. Dickens, M.A. Holmes ( Adder, 1967 ).

Very good system-level material. Lots of detail, quite readable. Particularly good for the VIA and other interface stuff. Even the index is reasonable.

VIA data sheet.

A full technical description of the VIA.

6502 Assembler Language Programming : ??????????????????

This is a good book, giving many details of the 6502 processor, how to programme it, and its associated devices such as the VIA. ( This is my book, and might have been lost. Anyway, I can't find it. If you find it, please let me know. )

The parts, and switching on and off.

You should find the computer itself attached to a disc drive and monitor. The monitor and computer have mains plugs; the disc drive gets its power from the computer. Switch on the mains, then switch on the monitor ( a button at the top right corner of the front panel ) and the computer ( a switch at the left-hand side at the back ). Certain lights and sounds should appear, and pressing keys on the keyboard should cause obvious consequences on the screen. To switch off, take the discs out of the disc drive ( good practice anyway, but also the next people might find life easier if no discs are concealed in the drive ).

Using discs.

The 473 demos disc mentioned in the assignment is kept in what looks like a piece of thick cardboard, but is in fact a disc envelope carefully reinforced for protection. Please put it back there after use.

Using the single disc drive is straightforward. Push the disc in the slot, and when it clicks into position turn the handle down to lock it in. To take it out, turn the handle back up again, and the disc will be slightly ejected.

The dual disc drive is just a little less obvious. To put a disc into the drive, slide it in in the obvious way; it should slide smoothly without heavy pressure. When it reaches what feels like the end, push a little harder, and it should snap into position. Then press down the knob just above the disc slot to close the drive. It should now be ready for use. To take a disc out of the drive, press the black rectangle just below the slot. This should release the knob, and eject the disc slightly; you can now take it out and put it away.

Both slots in the dual drive ( should ) work. The top one is drive 0, used by default; the other is drive 1, and you can use it if you want.

Type *cat to see what's on the disc - with the dual drive, that gives you the contents of the disc in the default drive. To be more specific with the dual drive, type cat :n, where n is the drive number. The computer is set up to use DFS ( the Disc Filing System ), which works but is mediæval. It can also use ADFS ( the Advanced Disc Filing System ), which is better, and more economical on space. Read the manual if you want to try that.

Running programmes.

If there is a Basic programme in memory, type RUN, and it will.

To get a Basic programme from a disc file called name into memory, type LOAD "name". LOAD must be in capitals ( or you will see the helpful error message "Mistake" ); the case of name doesn't matter.

To load and run a Basic programme, type CHAIN "name".

To list a loaded programme, type LIST; to list part of it, type LIST n1,n2, where n1 and n2 are line numbers.

There are also other programmes built in in ROM ( type *roms to see the list ), and it is possible to load code files from disc, but I don't think we have any. Look in the manuals for details if you want them. I think that all the programmes mentioned in the experiment descriptions are Basic.

Plugs and sockets.

The BBC's provision for connecting things is excellent in principle, but in practice not one of its happier features. This is partly because it provides a lot of connections, which is good so far as it goes, but the large number of connections cannot be accommodated on the back of the case, so all the ribbon cable connections are underneath. The type A, part 1, experiments make use of the user port ( underneath ) and the serial port ( on the back ).

Notice that the serial port has two-fold rotational symmetry, so you can insert the plug in two different ways. With the provided BBC-Macintosh cable, the screw head on the plug should be on the right as seen from above when leaning over the computer from the front.

Programming.

The BBC's natural language is Basic, the interpreter for which lives in a ROM. It includes certain extensions over original Basic to make it possible to write not terribly badly structured programmes if you want to. It is also possible to use many operating system calls from Basic, which makes it unusually easy to control the various interfaces.

The interpreter runs quickly ( by the standards pertaining when it was produced ), but it isn't lightning. If you want faster response, the usual means is 6502 assembly language; BBC Basic contains an integrated assembler, so that with care you can mix Basic and assembly language in a fairly orderly way. Full details are in the BBC manuals.

In the unlikely event that you want a large fast programme, you could use ISO Pascal. This also comes on a ROM, but we only have one of them, and I'm not sure which machine it's on. If you want it, ask.

The VIA.

The VIA ( Versatile Interface Adapter ) is an interface chip. Its function is to manage the device connections so that memory-mapped input and output can easily be carried out with a 6502 processor, but it has been more widely used than that description implies. It isn't just a passive device, and will perform certain useful functions like buffering, counting, timing, and so on.

The BBC in fact contains two VIAs, of which you will probably only want to use a half. That's the half which controls the user port, and other oddments, and it's fully identified in the BBC manuals.

It contains 16 8-bit registers, some of which are for data and some for control. The usual mode of operation is first to set the control registers so that the VIA will perform the operation you want, then to initiate the operation itself.

It is usually connected to the processor's data and address buses, though there's no law that says you have to. Typically the four bits which address the internal registers are connected to the low-order bits of the address bus, and chip-select circuitry causes it to notice only signals in a particular range of 16 addresses. Reading and writing to the VIA registers is therefore performed by the same instructions used to retrieve a value from the "memory" byte at the "address", and to store a value at the address.

With these simple ( as compared to the microprocesor ) facilities, much of the routine work of input and output can be carried out by the VIA, leaving the processor free for other work.

Bear in mind that the VIA and 6502 processor are quite separate items; each must be controlled individually. For example, to use interrupts, you must ensure both that the 6502 will receive them and that the VIA will produce them.

Communications.

When using the BBC computers, you might find it helpful to know that MacTerminal 2.2 is installed on the disc of the Macintosh in the 773 laboratory. If you set it up ( use the Settings:Compatibility form ) for 4800 baud, 8 data bits, no parity ( and 1 stop bit, but I can't find anywhere to set that ) communications and then run the MACBBC programme on the BBC connected to it, you will find it turns the Macintosh into a terminal to the BBC. If it doesn't work, make sure that the RS423 plug on the BBC is the right way round.

You can use this link ( for example ) to get listings of programmes from the BBC - list them, then copy and paste into something like a BBEdit document ( also on the Macintosh's disc ) which you can take away on a floppy disc and print out. You might find if you try to increase the data rate above 4800 baud that some characters are incorrectly received. ( Check the file anyway - even at 4800 baud there can be errors. ) Be warned that you can't use the usual shortcut keys to copy from MacTerminal - you have to use the Menu Copy item.


Alan Creak,
January, 1998.


Go to the 773 course page;
Go to me;
Go to Computer Science.