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. KIT discounts can be arranged if you have your extensions listed 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.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





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.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 included in the CB2 micro KIT. 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 KIT comes with 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.