Skip to the content
2 layers81.8 × 72.1 mmSwarm B 20230626, the printed circuit board in 3D

Swarm B 20230626

paulodowd/Swarm-B28

IR Communication board for Pololu 3Pi+ robots that also accommodates an M5 Stack Core2

Size
81.8 × 72.1 mm
Copper layers
2
Thickness
1.6 mm
Parts
32
Nets
62
Pads
145
Tracks, vias
336, 18
Pours
1
Routed
Yes
KiCad
KiCad 7 (file 20221018)
Created
12 Jul 2023
Updated
22 May 2026

Overview

Swarm B 20230626 is an open-source printed circuit board by paulodowd, from the paulodowd/Swarm-B2 repository on GitHub, published under the GPL-3.0 licence. It is a 2-layer board of 81.8 × 72.1 mm with 32 parts on 62 nets, routed with 336 tracks and 18 vias.

It is built around the TSDP34138 and 74LS32SC. Its parts include 9 connectors, 8 diodes, 7 resistors and 5 ICs. It belongs with the AVR (ATmega, ATtiny) boards of this library.

Main components

2

README

README.md



Swarm-B2

Infra-red (IR) Communication board for Pololu 3Pi+ robots that also has a pin header to interface with an M5 Stack Core2. This is the second major design of such a board, hence the name (S)warm (B)oard 2 - SwarmB2. A third version is under-development with the intention to supercede this design (SwarmB3).

The board functions as an i2c device, so it should be relatively easy to integrate into other projects using 5v, ground, SCK and SDA connections. The board can communicate with other SwarmB2 boards up to about 2.5m max, or down to less than a centimetre. The firmware for the board has been written with the intention that all (or most) configuration parameters can be set at runtime, so reprogramming firmware shouldn't be necessary.

Features

  • 32 bytes per message.
  • SLIP-style encoding/escaping.
  • 9600 or 4800 baudrate (device dependent)
  • Receive or transmit, cannot do both concurrently.
  • Receiving is polled across 4 receivers.
  • Transmission power set by a potentiometer (0-2.5m)
  • Message framing with start delimiter and message length embedded.
  • A 16 bit CRC to detect transmission errors.
  • Error statistics at message level.
  • Performance statitics (timings, etc).
  • Bearing estimation.
  • 3x LDR and 2x Sharp IR Range Finder integration on PCB.
  • Reconfigurable communication strategies/priorities.
  • Header pins to attach to a Pololu 3Pi+ robot.
  • Header pins for an M5Stack Core2 device interfacing.

Getting Started

The best way to get started is to download and install the example M5Visualiser written for the M5Stack Core2. This example demonstrates how to make function calls through the SwarmB2_c class. The class has function calls for all functionality available on the Swarm-B2, returning data types specified in the file ircomm_i2c.h.

Working with the M5Stack Core2

To get started with the M5Stack Core2, it is best to follow the manufacturers documentation to configure the Arduino IDE. Make sure you follow the instructions for both:

The M5Visualiser example was written against the M5Unified library - installing or using a different M5Stack library is likely to cause compilation errors for the provided example.

Important Characteristics

Message Size

The Swarm-B2 can receive a message of maximum length 32 bytes to transmit. This limitation is currently defined by the Arduino i2c implementation. The Swarm-B2 can accept a message of upto 32bytes, and it will then encode the message using a further number of bytes. It is important to consider that when transmitting a long length message, the probability that the message will become corrupted (or similar) increases.

Polling

The Swarm-B2 board can only read one receiver at a time. The board is configured by default to switch which receiver is enabled as soon as one message is successfully received. The board is also configured by default to switch receiver if it detects no activity. Otherwise, the board is configured by default to listen for a period of time before switching receiver.

Transmitting

The Swarm-B2 must disable receiving to be able to transmit, otherwise it will immediately receive it's own transmission. Therefore, the board is configured to periodically transmit messages, and in the interval period poll the receivers to receive messages.

Transmitting Power

The power of the IR LEDs which transmit messages can be varied via the blue potentiometer on the back of the Swarm-B2 circuit board. The blue potentiometer has a small silver dot: rotating the white arrow indicator to point at this silver dot will produce maximum power, or maximum range of transmission. Swarm-B2 can transmit upto 3m distance. However, this is not very useful in a swarm/multi-robot context. If the transmit power is set high, it is likely that the environment will become saturated with IR emissions, effectively blocking transmissions between all other robots. The recommended position for the potentiometer is indicated in the below image with a pink dot. This position sets the communication distance to approximately 20cm, or two robot-body lengths.

Other Configurations

It is possible to change the Swarm-B2 configuration via i2c transactions. For example, it is possible to setup a Swarm-B2 to only transmit continously. Or, it is possible to setup the Swarm-B2 to only receive on 1 receiver continuously.

FAQ

Using the Swarm-B2 board in other Projects

This IR communication board can be used as a general purpose communication board. The firmware on this github page is written as an i2c slave device with address 0x11. It should be possible to use the IR Communication board in it's current design and format with any other device that can operate the I2C protocol. To do so, you simply need to connect the 5v, GND, SCL and SDA pins appropriately to your operating device. These physical pins are labelled on the underside of the circuit board as +RED (5v), -BLK (GND), SDA and SCL, or as 5V, GND, SCL, SDA on the topside of the circuit board.

Fabrication, Gerber files

Navigate to folder pcb to find the last known gerber files sent for manufacturing, Gerbers.zip.

Schematic

The schematic of the communication board is available in picture format in the images folder and within the pcb folder as KiCad files.

Interesting Information

IR communication is implemented using the standard Serial (hardware UART) functionality common to Arduino (e.g. Serial.print()), and so the IR circuit is electronically connected to the Arduino TX and RX pins. The detection (receiving) circuit uses a Demodulator chip that is tuned for a carrier frequency of 38.4Khz or 57.6Khz (more details below). Therefore, the Arduino Nano generates a 38Khz or 58Khz signal via an internal timer interrupt to provide the transmitting carrier, output on digital pin 4.

The carrier signal is combined electronically with the TX pin state through an OR gate (74xx32). The logic (OR) of this operation is defined by the gates sinking the current through the tranmitting IR LEDs. Therefore, the LEDs are not driven by the 74xx32 (or the Arduino Nano, to be clear), and are considered active low. A nice unintended side effect of this is that when TX is inactive (LOW, not transmitting), the 74xx32 output is HIGH despite the continued 38Khz signal generation - which means the IR LEDs are off and not saturating the environment.

In this circuit design, a single gate is used to sink current. It might be important to note that the datasheet for the logic gates specifies a max current sink of 50ma through ground - and here we are potentially sinking upto 200ma from the 4 IR LEDs. So far, I've not seen any significant changes to performance and this may be because I am not sinking current continuously, instead intermitently at 38Khz. All 4 OR gates within the 74xx32 are ganged, but the internal ground connection may still be a limitation. In either case, I haven't yet seen any problems or difference in performance. It might be unwise to active the IR LEDs continuously (i.e. not modulated).

Important Considerations

  • IR Demodulator: I tried a few IR demodulator chips and they are not all created equally. In particular, those designed to receive bursts of transmission appear poorly suited. When using ones for burst transmission, I observed that I had to wave the transmitter or receiver around to get a successful transmission (perhaps some inner circuitry reaches a saturation?). Instead it is better to use those designed for continuous transmission. The Vishay TSDP34138 (datasheet) seems to fit this and works well / reliably. The datasheet specifies upto 4800 baud for a 38.4Khz carrier frequency. If you want to reproduce this board, I recommend you use the same device, or be ready for some trials of different devices.
  • Self-Receiving: I did have an issue of a single board receiving it's own IR transmissions, and not being able to receive transmission from neighbours. I believe this is because the UART implementation (on the Atmega328 at least) operates send (TX) and receive (RX) independently. When using IR light, this means it will detect it's own transmission. After attempting a lot of different solutions, it was as simple as disabling the RX functionality of the UART by a register operation. I'm glad this was available! You can review the details of this on page 171 of the Atmega328 datasheet (here).
  • Programming the Arduino Nano: It is important to note that the programming of the Arduino Nano will most often fail if the IR Demodulator is electronically connected. Therefore, the circuit design has a jumper (labelled, "RX Break") intended for a connecting removable sleeve, to allow the connection to be broken for programming. Importantly, no IR messages can be received if this jumper is not closed with the sleeve.
  • Buffer Sizes: The main limitation on the size of a string that can be sent over IR is actually the number of bytes that can be transferred on the I2C bus. I think this is dependent on the Arduino Wire library and could be modifed. Or, strings to transmit could be broken into parts to transfer over I2C. A second consideration is that the Arduino UART device has a buffer of 64 bytes. For simplicity, the software current has buffers of 32 bytes.

Notes on Using a M5Stack Core2

  • The docs for the M5Stack Core2 are at this link.
  • Follow the guides at this link to setup the Arduino IDE.

Links and resources I have found useful

  • Example code and discussion for different CRC algorithms: link
  • Interesting Arduino forum post debugging CRC: link
  • Microchip Application Note with CRC: link
  • Discussion on CRC and data length: link
  • Some information on UART Baudrates: link
  • Discussion on start/stop bit and errors with UART: link
  • Disucssion on catching frame data overrun in UART: link
  • Table of ASCII values: link

Parts

32
QtyValueFootprintReferences
8IR_LEDLED_THT:LED_D3.0mm_Horizontal_O1.27mm_Z2.0mmD1, D2, D3, D4, D5, D6, D7, D8
4TSDP34138OptoDevice:Vishay_MOLD-3PinU2, U3, U4, U5
310K_LDRResistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR4, R5, R7
3LDROptoDevice:R_LDR_5.0x4.1mm_P3mm_VerticalR2, R3, R6
115R_IRLEDResistor_THT:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR1
11K_Pot_IRLEDPotentiometer_THT:Potentiometer_Bourns_3386P_VerticalVR1
13PI_SWTCHConnector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ6
15v_3PiConnector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ1
174LS32Package_DIP:DIP-14_W7.62mm_SocketU1
1Arduino_Nano_v3.xModule:Arduino_NanoA1
1BttnButton_Switch_THT:SW_PUSH_6mmPWR1
1Conn_02x15_Top_BottomConnector_PinHeader_2.54mm:PinHeader_2x15_P2.54mm_VerticalJ4
1GND_3PiConnector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ2
1I2C_3PiConnector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ5
1I2C_ExpConnector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalJ7
1ProxAConnector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalJ8
1ProxBConnector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalJ9
1RX_BreakConnector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ3

Similar boards

  • 2 layers81.8 × 72.1 mmSwarmB3 pcb, the printed circuit board in 3D

    SwarmB3 pcb

    paulodowd/SwarmB3

    Working on Swarm Board version 3... so I decided the tinkering hadn't finished yet :)

    54 parts1GPL-3.0
  • 2 layers231.1 × 106.7 mmSnark barker, the printed circuit board in 3D

    Snark barker

    schlae/snark-barker

    A 100% compatible replica of the famed SB 1.0 sound card

    199 parts687
  • 2 layers237.5 × 102.9 mmInstruction, the printed circuit board in 3D

    Instruction

    jes/scamp-cpu

    A homebrew 16-bit CPU with a homebrew Unix-like-ish operating system.

    112 parts301Unlicense
  • 2 layers125 × 98 mm3-in-1, the printed circuit board in 3D

    3-in-1

    mudmin/AnotherMaker

    This is where I will store code snippets for AnotherMaker Videos

    44 parts258
  • 2 layers177.8 × 127 mmScopetrex, the printed circuit board in 3D

    Scopetrex

    schlae/scopetrex

    SCOPETREX vector gaming on your oscilloscope!

    201 parts248
  • 2 layers138 × 96.9 mmISA Card, the printed circuit board in 3D

    ISA Card

    AkBKukU/CM153-Repro

    A reproduction of the Philips CM-153 LMSI controller

    161 parts145
  • 2 layers370.8 × 298.5 mm8 Bit Computer, the printed circuit board in 3D

    8 Bit Computer

    The-Invent0r/8-bit-Computer-PCB

    These are the KiCAD files for my 8-Bit Computer.

    323 parts142

Questions

How big is the Swarm B 20230626 PCB?

It measures 81.8 × 72.1 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Swarm B 20230626 use?

32 parts, built around the TSDP34138 and 74LS32SC. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Swarm B 20230626 KiCad files?

From the paulodowd/Swarm-B2 repository on GitHub, at the commit this page was made from: the board is pcb/Swarm-B_20230626.kicad_pcb and its schematic pcb/Swarm-B_20230626.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Swarm B 20230626 design in my own project?

Its repository publishes it under the GPL-3.0 licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).