CB2 micro
Extensions
Go back to the main site
About this page

This page includes all the hardware extensions that have been made for the CB2 micro, as long as I am aware of.

Have you made an extension for the CB2 micro that you think it will be useful or just fun for other people to have? Please email it to me to upload it on this page.



Quick index reference


Click on a word in the table below to navigate to the relevant extension. Then use "back" on your browser to return to this table.


1 The Dataflash module
1.1 Circuit diagram
1.2 PCB layout

2 The 64K memory expansion XRAM64

2.1 Circuit diagram
2.2 PCB layout
2.3 Control

3 Local Area Network
3.1 How to build the hardware
3.2 Networking examples
3.2.1 Connecting two CB2 micros together
3.2.2 Connecting three CB2 micros together
3.2.3 Connecting three CB2 micros and a modem together
3.2.4 Connecting three CB2 micros, a PC and a modem together
3.2.5 Connecting three CB2 micros, a PC, a modem and a serial printer together
3.3 Writing networked applications

4 External EEPROM expansion
4.1 Circuit diagram

5 LPT connector addition
5.1 Circuit diagram
6 Reflashing the CB2 micro
6.1 Programmer circuit diagram
6.2 Reflashing procedure

7 Battery PSU
7.1 Circuit diagram

8 Color composite video/S-video
8.1 Circuit diagram

9 PS/2 keyboard
9.1 Circuit diagram
9.2 Firmware

10 3D printed case
10.1 Info and files

11 USB connectivity
11.1 Circuit diagram
11.2 Drivers

12 RF modulator
12.1 Circuit diagram






1 The Dataflash module

The first additional module is an ATMEL DataFlash and it is plugged into the (normally free) ISP connector. Files can be stored on the module similar to a floppy disk or a USB stick (as an analogy to the PC). Either BASIC or binary programs can be stored, but also USER files (eg for data loggers). The module works with the AT45DB041B (512 kBytes) or the AT45DB081B (1MByte). The difference between the two blocks is only the number of available pages (2048/4096). The D-types should work as well but have not been tested.



1.1 Circuit diagram

Since the Dataflash needs 2.7-3.3 volts supply voltage, this is simply generated by a series connected green or yellow LED with approximately 1.8V forward voltage. A resistor with 3.3kOhm forms the base load for the LED, in parallel there is a blocking capacitor. This should not be too small, so that there are no problems because of the differential resistance of the LED when writing to the flash.





1.2 PCB layout

The printed circuit board can be made of 0.4mm epoxy to fit between the two rows of a ten-pin socket for the ISP interface. The contacts on the conductor side are soldered directly, the contacts located on the other side must be connected by means of short wires to the connections on the circuit board. As a result, the circuit board is up, but can be quite well stuck and remove again.



Above the dataflash in the SOIC-28 package and the SMD-LED, on the left of a ceramic 10uF capacitor and a 3.3Kohm resistor as base load for the LED.

The Dataflash module can also be built without an etched PCB, on a piece of proto-board like shown below. Most of the unused pins of the SOIC flash chip were cut and the closely spaced used ones were bent a bit to be soldered on nearby pads.





2 The 64K memory expansion XRAM64

The XRAM64 module provides 64 Kbytes of additional memory (XMEM). It is connected to the parallel port, which is therefore not usable for other applications. Binary programs can both directly access the external memory and use the corresponding driver routines. For BASIC programs, a driver with the necessary functionality must be loaded on program location 8.

2.1 Circuit diagram

The 64K memory extension basically consists of two SRAMs with 32 Kbytes and a CPLD and is plugged into the parallel port. However, the + 5V must be connected to pin 14 of the parallel interface, with the original version this must be retrofitted.



With the CPLD also the relatively slow XC9536-15-PC44 works, with the SRAM the access time should be under 50ns, otherwise possibly wait states must be built into the driver routines. The exact values ​​of the block capacitors are not critical.

2.2 PCB layout

The printed circuit board layout is again one-sided, but 7 wire bridges must be used. Of course, a two-sided layout would also be possible, but single-layer printed circuit boards can be produced with less effort. The CPLD can be programmed via the JTAG connector.





2.3 Control

For the implementation, only the parallel port was available, so the address lines must be buffered. This could also be realized by two registers. A special feature, however, is the fast incremental access, which effectively requires only 3 processor clocks for read and write accesses. Thus, for example, a video resolution of 320x240 is possible with 16 simultaneously displayable colors. In order to be able to control the module with its own routines within the framework of a driver or a binary program, the various cycles are described below.



During the read cycle, it must be noted that reading the port pins into the AVR is actually one bar earlier. A read cycle is thus inevitably at least one clock cycle longer, but in this time, for example, the address counter formed from registers can be incremented in ATMega.



In the XRAM64 drivers you will also find code sequences for reading and writing, which can also be used for own controls.





3 Local Area Network

The CB2 micro has an RS-232 port which can be used for point to point communication between two CB2 micros, or between a CB2 micro and a PC, or between a CB2 micro and another device, such as a serial modem. Communication between the two points is done with the help of a serial cable, either straight or null modem. However, if more than two parties need to communicate together, then a local area network (LAN) has to be created.


The picture above shows the CB2matrix program running on three CB2 micros, just after transferring it from one CB2 micro to the other two simultaneously.

3.1 How to build the hardware

Creating a LAN which can connect more than two CB2 micros together, or CB2 micros to more than one other devices, is not difficult. It is accomplished by the use of the RS-232 port. The only extra hardware required, is the building of a special serial cable, to connect all the devices in the network together. This serial cable has 3 separate wires, one for TxD, one for RxD and one for the GND. All the CB2 micros, PCs or other serial devices, are tapped to this serial cable. This serial cable then becomes the common bus where all these devices are tapped to. Their TxD wires are tapped to the TxD wire of the bus. Also, their RxD wires are tapped to the RxD wire of the bus. Finally, their GND wires are tapped to the GND wire of the bus.

To build this serial cable, you could use bare wires, but to achieve some short of shielding, you could use a stereo audio cable. This cable has the right and left audio wires wrapped around a common ground shield.  Take two serial female connectors and connect their TxD pins together, with the help of one of the two channels of the audio cable. Then connect their RxD pins together, with the help of the other channel of the audio cable.
Finally connect their grounds together, with the help of the shield of the audio cable. With the above procedure you build a point to point straight serial cable.

Now, to connect a third device to this cable, use another piece of audio cable and a third serial female connector. Connect the
TxD pins of one of the connectors of the previously made cable and this third connector together, with the help of one of the two channels of the audio cable. Then connect the RxD pins of the same connector of the previously made cable and this third connector together, with the help of the other channel of the audio cable. Finally connect the grounds of the same connector of the previously made cable and this third connector together, with the help of the shield of the audio cable. At the end of this procedure, you will have a serial cable with 3 serial female connectors, and their TxD pins connected in parallel, their RxD pins connected in parallel and their GNDs connected in parallel.



This cable will then It will look like this (picture above): From the first connector an audio cable will come out and connected to the second connector. From this second connector another audio cable will come out and connected to the third connector. The second connector will then have two audio cables in it, one that comes in from the first connector and one that comes out to the third connector. If you want to connect more than three devices to this LAN, you must repeat the above procedure, to add another serial connector to the cable.

Note that the RS-232 is for short distance links only, so although not yet tested, you might not expect good performance in distances larger than a room or so.
  Also, there may be an upper limit in the number of devices connected to the serial LAN, because of the loading these devices present on it.


3.2 Networking examples

After the special serial cable has been built and all the serial devices have been connected to the LAN, the jumpers J2, J3, J4, J5 have to be configured on every CB2 micro that is connected to the LAN. The settings of these jumpers, allow for different LAN configurations to be accomplished, without the need to rewire the serial cable. Here, a few networking examples which have been tried out successfully will be presented. There are many more that you can try out yourself. These examples are all refferenced to the picture below but I will include or exclude devices and jumpers as I go through the explanation of each of them.



3.2.1 Connecting two CB2 micros together

If you want to connect together just two CB2 micros, you don't need the LAN cable of course, but just an ordinary serial cable. However, I will describe the connection here, using the LAN cable.
Referring to the circuit diagram above, CB2 micro stations A and B are connected together using the LAN cable.

If J2 and J3 are closed on station A and J4 and J5 are closed on station B, this creates a null-modem connection between the two stations and data transfer can occur through the BASIC editors, the CBterm and the desktops of the stations, as described in the manual. 

If J2, J3, J4, J5 are all closed on any of the two stations, then the TxD and RxD lines of the LAN cable are shorted. This creates a data loopback for the station that sends the data, but data is also send to the RxD of the receiving station (which is shorted to the TxD). In this case, data can be transferred through the BASIC editors, but files cannot be exchanged through the
CBterm and the desktops of the stations, as Xmodem transfers are not possible in this mode. However, text typed on CBterm on one station, is received by all the other stations. So chatting between all stations is feasible.



3.2.2 Connecting three CB2 micros together

Referring to the circuit diagram above, CB2 micro stations A, B and C are connected together using the LAN cable.

If J2, J3 are closed on station A and J4, J5 are closed on station B and C, this creates a null-modem connection between station A and station B and another null modem connection between station A and station C. Station A can exchange data with station B and station C through CBterm. However, since in CBterm data transmission initialization occurs prior to the reception, the station that goes first into receive mode, is the only one that receives the data. This is also true for data transfers through the desktops. However when transferring data through the BASIC editors, transmission initialization must occur after reception, so in that case station A can send a BASIC program simultaneously to stations B and C, provided that these have been previously set for data reception through their BASIC editors.

It is interesting the fact that in this mode, station A can send BASIC programs through the editor, to both stations B and C. However station B can only send data to station A and not to station C. Similarly, station C can only send data to station A and not to station B. Stations B and C are prohibited to send data to each other, but not to station A. This might be proven useful in cases where you want station A to act as a server and stations B and C as clients. B and C can communicate with the server only, but not to each other. Station A, the server, can communicate to both stations B and C and both of them will receive the data the server sends.

If J2, J3, J4, J5 are all closed on any of the three stations, then the TxD and RxD lines of the LAN cable are shorted. This creates a data loopback for the station that sends the data, but data is also send to the RxD of the receiving stations (which is shorted to the TxD). In this case, data can be transferred through the BASIC editors, as described in the previous case, but files cannot be transferred through the
CBterm and the desktops of the stations, as Xmodem transfers are not possible in this mode. However, text typed on CBterm on one station, is received by all the other stations. So chatting between all stations is feasible.

By making combinations of the J2, J3, J4, J5 on each of the stations, or by adding more stations to the LAN, different configurations can occur (data access restrictions etc.). However, I am not going to experiment with every possible case in this description.



3.2.3 Connecting three CB2 micros and a modem together

Referring to the circuit diagram above, a dial-up modem and CB2 micro stations A, B and C are connected together using the LAN cable.

J2, J3 are closed on all stations and J4, J5 open on all stations. If the modem is switched on, data can be transferred through the BASIC editors, as described in the previous cases, but files cannot be transferred through the CBterm and the desktops of the stations, as Xmodem transfers are not possible in this mode. However, text typed on CBterm on one station, is received by all the other stations and the modem. So chatting between all stations is feasible. Also each station can control the modem with AT commands or transmit data through it to other modems in remote networks. Data received by the modem is sent to all LAN stations. In simple terms, the modem is shared among the CB2 micro stations A, B and C.
By making combinations of the J2, J3, J4, J5 on each of the stations, different configurations can occur (data access restrictions etc.). However, I am not going to experiment with every possible case in this description.

It is interesting that in this mode, if the modem is switched off, no communication can occur between the stations. Communication takes place through the modem only and back to the stations. Just for reference, the modem used in this experiment was the Diamond SupraExpress 56e PRO, which is shown in the middle left area in the picture below, during a dial-up operation.



3.2.4 Connecting three CB2 micros, a PC and a modem together

Referring to the circuit diagram above, a PC, a dial-up modem and CB2 micro stations A, B and C are connected together using the LAN cable.

J2, J3 are closed on all stations and J4, J5 open on all stations. The PC runs Hyperterminal or another terminal emulator and it's connection properties are set to 1200 baud and 8-N-1 with no flow control. If the modem is switched on, data can be transferred through the BASIC editors as well as the PC, as described in the previous cases, but files cannot be transferred through the CBterm, the desktops of the stations and the PC, as Xmodem transfers are not possible in this mode. However, text typed on CBterm on one station, is received by all the other stations, the PC and the modem. So chatting between all stations and the PC is feasible. Also each station and the PC can control the modem with AT commands or transmit data through it to other modems in remote networks. Data received by the modem is sent to all LAN stations and the PC. In simple terms, the modem is shared among the CB2 micro stations A, B and C and the PC.
By making combinations of the J2, J3, J4, J5 on each of the stations, different configurations can occur (data access restrictions etc.). However, I am not going to experiment with every possible case in this description.

Just for reference, the modem used in this experiment was the Diamond SupraExpress 56e PRO, which is shown in the middle left area in the picture below. Just below the modem, the PC I used is shown (Alix-1D).




3.2.5 Connecting three CB2 micros, a PC, a modem and a serial printer together

Referring to the circuit diagram above, a PC, a dial-up modem, a serial printer and CB2 micro stations A, B and C are connected together using the LAN cable.

J2, J3 are closed on all stations and J4, J5 open on all stations. The PC runs Hyperterminal or another terminal emulator and it's connection properties are set to 1200 baud and 8-N-1 with no flow control. If the modem is switched on, data can be transferred through the BASIC editors as well as the PC, as described in the previous cases, but files cannot be transferred through the CBterm, the desktops of the stations and the PC, as Xmodem transfers are not possible in this mode. However, text typed on CBterm on one station, is received by all the other stations, the PC, the printer and the modem. So chatting between all stations and the PC and at the same time printing the chat sessions, is feasible. Also each station and the PC can control the modem with AT commands or transmit data through it to other modems in remote networks. Data received by the modem is sent to all LAN stations, the printer and the PC. In simple terms, the modem and the printer is shared among the CB2 micro stations A, B and C and the PC.
Anything typed on the CB2 micros or the PC and any data received by the modem, is printed out on the printer. By making combinations of the J2, J3, J4, J5 on each of the stations, different configurations can occur (data access restrictions etc.). However, I am not going to experiment with every possible case in this description. Note that serial printers usually require null modem cables for connecting to PCs, so depended on the printer model, if you want your PC to print on the printer, you may or may not have to swap the TX/RX connections of the serial LAN connector that goes to the printer. By connecting a printer to the LAN, you can use this printer alone as an ascii terminal, along with a CB2 micro, just like the old printer-only-output teletypes!

If you do not have a serial printer, you can use an ordinary parallel printer, but make sure you see the printSRV program solution, where you can use a second CB2 micro as a serial to parallel converter and printer server.


Just for reference, the printer used in this experiment was the Epson LX300+ II, which is a dot matrix printer and it has USB, parallel and serial ports available. You have to configure this printer (and possibly yours) for 1200 baud 8-N-1 with no handshaking.
Configuring this particular printer is not very straight forward (you have to enter on its help mode with a combination of buttons and change the settings there), so please read the manual of the printer.  

3.3 Writing networking applications

By networking the CB2 micros through the serial LAN cable, you mess up with the physical layer. Primitive data routing and/or restriction is performed in different ways based on the J2, J3, J4, J5 settings on each micro, but this is only in the physical layer. In the application layer you have much more flexibility and you can write your applications to communicate in any way you want. Since there is no communication protocol standard like TCP/IP for example, you have to invent the communication way yourself for every application you write. This can be as simple as no "protocol" at all but just plain serial data transfer, or as advanced as packet based networking ways.

If you write a LAN application that is going to be used by more clients simultaneously, it would probably be helpful to have a mechanism to identify each client to the others or to the server. Since data is transmitted asynchronously, it might also be useful to have a mechanism to restrict data transfer by other clients, when one client is already transferring data to the LAN. If your application needs to exchange data to specific stations only, apart from configuring the jumpers in the physical layer, you can accomplish this on your application by assigning identifiers to the clients and making the application to respond only to specific identifier calls. The possibilities are endless and it is really up to you to decide how complex your application must be, based on the requirements.






4. External EEPROM expansion

External serial EEPROMs of type 24C64 ... 24C512 can be added to the CB2 micro, through the I2C bus.

4.1 Circuit diagram

Below, the circuit diagram for two EEPROMs connected to the CB2 micro is shown. Addresses 0 and 1 (first and second chip) are shown pre-wired. The used address can be selected in the configuration menu, whereby XPOKE and XPEEK only work with this selected address. So you cannot use both EEPROMs at the same time in your program, you use each one of them each time. When you have consumed the first memory chip and you need more memory, you select the next chip from the configuration menu and then use it.





5. LPT connector addition

For cost reasons and because it is quite an old connector, the Sub-D 25 connector is not standard in the CB2 micro. However, LPT printing capabilities are supported by the CB2 micro. To add the connector yourself, follow the next schematic.

5.1 Circuit diagram

Below, the circuit diagram for the addition of the printer connector to the CB2 micro is shown. Current limiting resistors are included. In fact, it is advised to use current limiting resistors, even if you use the bare I/O pins of the MCU for measurements or devices control.






6. Reflashing the CB2 micro

The CB2 micro has a pre-programmed chip, so you do not need to do any firmware burning yourself. However, in cases where a new version of AVR chipbasic is released, you would want to upgrade the firmware on the MCU to the latest version. In that case, you have to build a simple programmer yourself and follow the instrucrions in this section, to update the firmware.

6.1 Programmer circuit diagram

Below, the circuit diagram of the programmer is shown. The programmer has to be connected to the ISP/SPI port of the CB2 micro as shown. Power must be applied to the CB2 micro prior to reflashing it. A serial cable must be used to connect the programmer to the RS-232 port of your PC, The PC RS-232 port will be used along with appropriate software, to reflash your CB2 micro. Note, in the schematic, the Sub-D 9 connector shown, is not the one mounted onboard the CB2 micro, but a different connector you have to solder to the programmer circuit yourself. Also note, some USB to serial port adapters, or RS-232 ports of some laptops may not work with this programmer. Try to use a real RS-232 port on a desktop PC if possible.


6.2 Reflashing procedure

The software used for reflashing the CB2 micro, is PonyProg. It works only on older Windows versions. After installing the program to your PC, the first thing you will need to do is configure PonyProg to work with the programmer. Connect the programmer circuit you have built to the ISP/SPI of the CB2 micro and to the PC and go to "Setup" menu in the program and select "Interface Setup". The following window will be shown and the highlighted areas show you exactly which options should be set.



Next, select "Setup" and "Calibration", to calibrate the software. After calibration is complete, select "AVR micro" and set your MCU type to ATmega644.



At this point PonyProg configuration is complete and you may open the AVR chipbasic system hex file with which the CB2 micro will be flashed. Go to "File" menu, select "Open Program (FLASH) File ...", and point to the AVR chipbasic system hex file to open it up. Once loaded, you should see hex numbers apear in the program display.

Next select "Command" and then "Security and configuration bits". Make the relevant settings are as shown in the window below and click "OK".



Then, in the main program window select "Command" and then "Write all", to reflash the CB2 micro. Ignore any warnings or verification errors that might appear during flashing. After flashing is complete, remove the programmer from the ISP/SPI connector and test to see if your CB2 micro boots up ok with the new firmware.





7 Battery PSU

This extension allows the CB2 micro to be powered by four AA or AAA batteries, either 1.5v alkaline or 1.2v Ni-MH or Ni-Cd rechargables. The PSU has been designed so that the next criteria are met:
In a test with AA rechargables, they lasted for 24 hours of continuous operation before they needed recharging. In a test with AAA rechargables, they lasted for 10 hours of continuous operation before they needed recharging.


7.1 Circuit diagram


The circuit diagram of the battery PSU is shown below. Instead of a trimmer resistor you can use two fixed resistors. About 560k from vcc to wiper and about 220k from wiper to gnd is a good approximation for switching on the battery-low indicator.







8 Color composite video/S-video

The CB2 micro has a grayscale composite video output (B/W out pad onto the PCB) for those that need to drive old TVs with composite video. If however a color composite video or S-video is required, a suitable converter can be built with the AD724 chip.


8.1 Circuit diagram


The circuit diagram of the color composite video/S-video adapter is shown below. You can choose between PAL or NTSC by the jumper on pin 1. A different crystal frequency has to be used for PAL and NTSC on pin 3. The jumper on pin 12 selects between the lower frequency or higher frequency pair of crystal frequencies. I recommend you to use the lower frequency pair. If you only need conposite video, leave pins 9 and 11 unconnected and remove the relevant capacitors, resistors and S-video connector. Note, to use this circuit, you have to manually ground pin 25 of the ATMEGA644P, so that its pin 19 outputs an Hsync signal instead of the default Csync.







9 PS/2 keyboard

This extension is a homemade PS/2 keyboard for use with the CB2 micro. The extension has been submitted by Wolfgang Schmidt. Note that the keyboard is not a full 102 keys keyboard but a 51 keys. However, almost all the functions used in the CB2 micro are available.


9.1 Circuit diagram


The circuit diagram of the PS/2 keyboard is shown below. Each key in the matrix, shorts the row and the column under it when it is pressed, in the keys matrix.



A proposed layout for the keyboard is shown below. However you can try your own layout if you want.




9.2 Firmware

The source code (BasCom) of the keyboard is available here. A HEX file is also available here. The code table is available here. When you burn the firmware into the chip make sure you set the right fuses.








10 3D printed case

This extension is a 3D printed case for the CB2 micro. The extension has been submitted by Evilged.


10.1 Info and files

The case is composed of two parts, the top and the bottom, that clip together and sandwitch the PCB inside them. No screws are used in this design.



Holes are provided at the top side, to access the different jumpers and ports. Near the AF out and the B/W out PCB pads, there are suitable holes that can host screw-type RCA connectors if you wish to mount them in place.
The project was created in Fusion 365 and you can download the files in the link below, to print the enclosure on your 3D printer.

CB2 micro case





11 USB connectivity

This extension adds USB PC connectivity to the CB2 micro. Using this extension, you no longer need to have a PC with an RS-232 port to transfer programs to and from the CB2 micro.


11.1 Circuit diagram


The circuit diagram of the USB to UART adaptor is shown below. It can't be simpler than that, a single chip (available in through-hole package) and a USB connector. Because the adaptor is connected to the UART of the CB2 micro, the "Serial In/Out" setting in the CB2 micro configuration page must be set to "standard". Since the data pins of the USB connector that powers the CB2 micro, are left non-connected, you can possibly re-wire these pins directly to the data pins of the MCP2221A and use the onboard connector of the CB2 micro.



11.2 Drivers

Windows 10 recognize the device as a virtual COM port so no PC drivers are usually needed. However, drivers and utilities for different systems, are provided for the MCP2221A below in case you need them:

MCP2200/MCP2221 Windows Driver and Installer    
MCP2200/MCP2221 Linux Driver Information   
MCP2221 Utility (v1.0.2)    
MCP2221 DLL   
MCP2221 I2C/SMBus Terminal (v2.0.1)   
MCP2200/MCP2221 Mac Driver Information
MCP2221 Terminal Android App (v2.0)   
MCP2221 Command Line Interface (v1.0.2)   
MCP2221 DLL (v2.1.1)   
MCP2221 Java Native Interface (v1.0)   
MCP2221 DLL (v2.2.1)

You can find also these and possibly other drivers in the website of Microchip.





12 RF modulator

This extension allows the CB2 micro to be connected to very old TVs or handheld TVs that do not have any inputs, other than the antenna connector/whip. It also makes the CB2 micro, even more compatible for countries that do not have the SCART as standard connector. It is designed only for grayscale video, although one could inject an audio FM subcarrier to it, which would make the circuit more comlicated though. If you want audio as well, you can take the audio output of the CB2 micro and drive additional amplified speakers with it.

The RF modulator takes the grayscale output video signal
from the "B/W out" PCB pad and uses this signal to amplitude-modulate the RF carrier signal (and it's harmonics). For extreme simplicity, no additional RF oscillator is used, but the RF signal is taken from the CB2 micro crystal clock. The 20MHz RF signal at pin 12 of the MCU, is triangular and it is rich in harmonics, which reach well into the VHF region. Just scan with your analogue TV the low and medium VHF bands and eventually you will tune to a harmonic. Low VHF band harmonics (eg. around 60MHz) are stronger and generally work better.


12.1 Circuit diagram


The circuit diagram of the RF modulator is shown below. RF input is injected into the modulator with a small capacitor (for isolation) and then it reaches the RF output connector. The baseband video is injected to the diode and depended on it's strength it shunts the diode closer to the ground, efffectively shunting also the RF closer to the ground, thus amplitude modulating it. Since the RF signal has many harmonics, these harmonics are also amplitude-modulated. The variable trimmer is set for best video quality on your TV receiver, on the desired harmonic.