Difference between revisions of "Hardware setup"

From Bare Metal micro:bit
Jump to navigation Jump to search
(Created page with "Here's what you will need: * {{microbit}} and micro USB cable. * {{microbit}} edge connector breakout. * 24MHz 8 bit logic analyser pod, with mini USB cable and female-to-fema...")
 
 
(4 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
* {{microbit}} edge connector breakout.
 
* {{microbit}} edge connector breakout.
 
* 24MHz 8 bit logic analyser pod, with mini USB cable and female-to-female jumper wires.
 
* 24MHz 8 bit logic analyser pod, with mini USB cable and female-to-female jumper wires.
* For building programs: ''either'' a Raspberry Pi with keyboard and display ''or'' a laptop or desktop running a recent version of Linux.
+
* For building programs: ''either'' a Raspberry Pi with keyboard and display ''or'' a laptop or desktop running a recent version of Linux.  Models 3B and 4B of the Raspberry Pi work well, as should the Raspberry Pi 400.  Earlier models may have difficulty with the USB speed needed to use the logic analyser.
* For use with a Raspberry Pi, an SD card at least 8GB in size.  [[Appendix B]] gives an overview of the process of setting up the necessary software on the SD card.
+
* For use with a Raspberry Pi, an SD card at least 8GB in size.  [[Software setup|Another page]] gives an overview of the process of setting up the necessary software on the SD card.
 
* If using a Raspberry Pi, get a good power supply, because it will be powering the Pi itself, the {{microbit}}, and the logic analyser pod.
 
* If using a Raspberry Pi, get a good power supply, because it will be powering the Pi itself, the {{microbit}}, and the logic analyser pod.
 
* For experiments with the serial port, follow one of the following three options:
 
* For experiments with the serial port, follow one of the following three options:
Line 19: Line 19:
 
==Modifying the {{microbit}}==
 
==Modifying the {{microbit}}==
  
The {{microbit}} contains two microcontroller chips: the Nordic nRF51822 main processor which we will program, and a separate Freescale processor that looks after communication with the host PC or Raspberry Pi over USB.  The Nordic processor has a serial port or UART that is connected to the Freescale processor, which acts as a USB-to-serial adapter, but the two pins used for this are not brought out to the edge connector of the {{microbit}}, and that makes it difficult to monitor the communication between them.  One solution to this problem is to use alternative pins for experiments with the UART and connect them directly to the Raspberry Pi, and instructions for this are given in the appropriate chapter.  Alternatively, it is fairly simple to modify the {{microbit}} to make the two UART pins accessible by soldering wires to two test points on the board.  This will not affect the function of the {{microbit}} for other purposes.  Instructions follow.
+
The V1 {{microbit}} contains two microcontroller chips: the Nordic nRF51822 main processor which we will program, and a separate Freescale processor that looks after communication with the host PC or Raspberry Pi over USB.  The Nordic processor has a serial port or UART that is connected to the Freescale processor, which acts as a USB-to-serial adapter, but the two pins used for this are not brought out to the edge connector of the {{microbit}}, and that makes it difficult to monitor the communication between them.  One solution to this problem is to use alternative pins for experiments with the UART and connect them directly to the Raspberry Pi, and instructions for this are given in the appropriate chapter.  Alternatively, it is fairly simple to modify the {{microbit}} to make the two UART pins accessible by soldering wires to two test points on the board.  This will not affect the function of the {{microbit}} for other purposes.  Instructions follow.
 
# Obtain a two-pin header socket and glue it to the processor board on the right-hand side with a drop of superglue.
 
# Obtain a two-pin header socket and glue it to the processor board on the right-hand side with a drop of superglue.
 
# Solder two fine wires to test points TP15 and TP17 on the board, as shown in the diagram.
 
# Solder two fine wires to test points TP15 and TP17 on the board, as shown in the diagram.
Line 27: Line 27:
  
 
[[Image:ubit-testpoints.png|frame|none|Test points on the {{microbit}} board]]
 
[[Image:ubit-testpoints.png|frame|none|Test points on the {{microbit}} board]]
 +
 +
{{V2box|On the V2 board, the test points are covered with solder mask to reduce the risk of short circuits, so it's probably best to use one of the other methods of monitoring serial commnications.}}
  
 
Connections to other pins of the {{microbit}} can be made using an edge connector breakout, which provides access to 17 of the edge connector pads on the board, together with power and ground.  For experiments involving the {{I2C}} bus, it's convenient to solder header pins in the remaining two pairs of holes, pins 19 and 20, on the breakout board.  These are connected to the two lines, SCL and SDA of the bus.
 
Connections to other pins of the {{microbit}} can be made using an edge connector breakout, which provides access to 17 of the edge connector pads on the board, together with power and ground.  For experiments involving the {{I2C}} bus, it's convenient to solder header pins in the remaining two pairs of holes, pins 19 and 20, on the breakout board.  These are connected to the two lines, SCL and SDA of the bus.
Line 32: Line 34:
 
==Connecting the logic analyser==
 
==Connecting the logic analyser==
 
Inexpensive logic analyser pods usually come with a strip of ten female-to-female jumper wires that are long enough to connect conveniently to the {{microbit}} breakout board.  The 8 data channels of the analyser are often numbered from 1 to 8 on a sticker, but the software numbers them from 0 to 7 and colours them according to the standard resistor colour code (see below).  It's therefore wise to attach the wires to the logic analyser following the same code, with black for what the sticker calls channel 1, brown for channel 2, etc., so that the colours agree with the software but not the sticker.  I use white for the Ground connection, and leave the Clock pin (if it exists) unconnected and the grey wire unused.<ref>On some samples of these logic analysers, the clock pin is not connected to anything, on others it is grounded, and on still others it carries a 12MHz square wave.  In any case, we have no use for the pin, so it is best left unconnected.</ref>  It's quite a good idea to use a drop of superglue to cement the connectors into a solid block so they stay in the correct arrangement but can still be disconnected from the pod if the need arises.
 
Inexpensive logic analyser pods usually come with a strip of ten female-to-female jumper wires that are long enough to connect conveniently to the {{microbit}} breakout board.  The 8 data channels of the analyser are often numbered from 1 to 8 on a sticker, but the software numbers them from 0 to 7 and colours them according to the standard resistor colour code (see below).  It's therefore wise to attach the wires to the logic analyser following the same code, with black for what the sticker calls channel 1, brown for channel 2, etc., so that the colours agree with the software but not the sticker.  I use white for the Ground connection, and leave the Clock pin (if it exists) unconnected and the grey wire unused.<ref>On some samples of these logic analysers, the clock pin is not connected to anything, on others it is grounded, and on still others it carries a 12MHz square wave.  In any case, we have no use for the pin, so it is best left unconnected.</ref>  It's quite a good idea to use a drop of superglue to cement the connectors into a solid block so they stay in the correct arrangement but can still be disconnected from the pod if the need arises.
 
At the {{microbit}} end, there are not quite enough channels to monitor every signal that might be of interest, but for many or our experiments it works well to connect six of the pads that are also connected to LEDs, plus the TX and RX pins of the serial interface -- those made accessible earlier by modifying the {{microbit}}.
 
 
{| class = "wikitable"
 
!Label!!Colour!!{{microbit}} pad
 
|-
 
|1||Black||3
 
|-
 
|2||Brown||4
 
|-
 
|3||Red||5
 
|-
 
|4||Orange||6
 
|-
 
|5||Yellow||7
 
|-
 
|6||Green||9
 
|-
 
|7||Blue||TX
 
|-
 
|8||Violet||RX
 
|-
 
|GND||White||0V
 
|}
 
 
{{Todo|This won't work for servo and neopixel experiments using pads 0, 1 and 2.}}
 
 
For the TX and RX pins, it's convenient to join the female-to-female jumper from the logic analyser with a short male-to-male jumper and plug that into the glued-on header.  It doesn't much matter if connections between the logic analyser and the TX and RX pins are swapped, because when we use the logic analyser to monitor serial communications, it quickly becomes apparent from the recorded traces which pin is which.
 
 
If you cannot modify the {{microbit}} to expose the TX and RX signals, then the appropriate chapter will direct you to connect a either a Raspberry Pi or a separate USB-to-serial adapter to pads 0 and 1, and to connect the blue and violet wires from the logic analyser to those pads also.
 
  
 
==Restoring the factory firmware==
 
==Restoring the factory firmware==

Latest revision as of 08:01, 24 May 2021

Here's what you will need:

  • micro:bit and micro USB cable.
  • micro:bit edge connector breakout.
  • 24MHz 8 bit logic analyser pod, with mini USB cable and female-to-female jumper wires.
  • For building programs: either a Raspberry Pi with keyboard and display or a laptop or desktop running a recent version of Linux. Models 3B and 4B of the Raspberry Pi work well, as should the Raspberry Pi 400. Earlier models may have difficulty with the USB speed needed to use the logic analyser.
  • For use with a Raspberry Pi, an SD card at least 8GB in size. Another page gives an overview of the process of setting up the necessary software on the SD card.
  • If using a Raspberry Pi, get a good power supply, because it will be powering the Pi itself, the micro:bit, and the logic analyser pod.
  • For experiments with the serial port, follow one of the following three options:
    • Modify the micro:bit as described below to give access to the serial port pins; or
    • Connect an unmodified micro:bit to the UART pins on the Raspberry Pi using a handful of additional jumper wires, and follow an alternative set of instructions; or
    • Use a USB-to-serial adapter with 3.3V signals together with a PC or Raspberry Pi to follow the alternative instructions.

The software we use for building programs will work on any version of the Pi, but a Raspberry Pi 2 model B or later is more convenient because it has more USB ports. The screenshots in the book were made on the Raspberry Pi, but the instructions work almost without change on any Linux machine; it doesn't matter whether the machine has an ARM or an Intel processor, because we will be using cross-compiling software that produces machine code for the embedded processor in the micro:bit whatever the host processor may be.

Some of the experiments in the book use various micro:bit accessories. It's perfectly possible to get value out of the book while avoiding these experiments, but the accessories make the programming more fun.

  • Experiment 00 optionally uses the scroll:bit, a matrix of white LEDs that can be controlled over the I2C bus.
  • Experiments 00 and 00 use the :move mini buggy, a two-wheeled vehicle powered by continuous motion servos. Experiment 00 makes a remote control for the buggy, using either a second micro:bit on its own, or the :game zip 64 with more buttons.
  • Experiment 00 needs some kind of neopixel (or zip) display, such as the small one incorporated in the servo board of the :move buggy, or the 8x8 matrix provided as part of the :game zip 64, or an Adafruit RGB neopixel strip, or just a short piece of flexible LED strip stuck on card with some wires soldered to the input end.

Modifying the micro:bit

The V1 micro:bit contains two microcontroller chips: the Nordic nRF51822 main processor which we will program, and a separate Freescale processor that looks after communication with the host PC or Raspberry Pi over USB. The Nordic processor has a serial port or UART that is connected to the Freescale processor, which acts as a USB-to-serial adapter, but the two pins used for this are not brought out to the edge connector of the micro:bit, and that makes it difficult to monitor the communication between them. One solution to this problem is to use alternative pins for experiments with the UART and connect them directly to the Raspberry Pi, and instructions for this are given in the appropriate chapter. Alternatively, it is fairly simple to modify the micro:bit to make the two UART pins accessible by soldering wires to two test points on the board. This will not affect the function of the micro:bit for other purposes. Instructions follow.

  1. Obtain a two-pin header socket and glue it to the processor board on the right-hand side with a drop of superglue.
  2. Solder two fine wires to test points TP15 and TP17 on the board, as shown in the diagram.
  3. Solder the other ends of the wires to the two header pins.
Modified micro:bit
Test points on the micro:bit board

micro:bit version 2

On the V2 board, the test points are covered with solder mask to reduce the risk of short circuits, so it's probably best to use one of the other methods of monitoring serial commnications.

Connections to other pins of the micro:bit can be made using an edge connector breakout, which provides access to 17 of the edge connector pads on the board, together with power and ground. For experiments involving the I2C bus, it's convenient to solder header pins in the remaining two pairs of holes, pins 19 and 20, on the breakout board. These are connected to the two lines, SCL and SDA of the bus.

Connecting the logic analyser

Inexpensive logic analyser pods usually come with a strip of ten female-to-female jumper wires that are long enough to connect conveniently to the micro:bit breakout board. The 8 data channels of the analyser are often numbered from 1 to 8 on a sticker, but the software numbers them from 0 to 7 and colours them according to the standard resistor colour code (see below). It's therefore wise to attach the wires to the logic analyser following the same code, with black for what the sticker calls channel 1, brown for channel 2, etc., so that the colours agree with the software but not the sticker. I use white for the Ground connection, and leave the Clock pin (if it exists) unconnected and the grey wire unused.[1] It's quite a good idea to use a drop of superglue to cement the connectors into a solid block so they stay in the correct arrangement but can still be disconnected from the pod if the need arises.

Restoring the factory firmware

The micro:bit comes with pre-installed firmware that demonstrate the features of the board, which is overwritten as soon as we upload our own programs. To restore the micro:bit to its pristine state, it you can upload a copy of the original .hex file that is accessible from the following page.

The file can be copied to the micro:bit just like any other .hex file.



  1. On some samples of these logic analysers, the clock pin is not connected to anything, on others it is grounded, and on still others it carries a 12MHz square wave. In any case, we have no use for the pin, so it is best left unconnected.