A Little Extra About Peripherals and Communication Channels
1. Peripherals
It has been suggested that all robots follow the pattern "sense, think, do, repeat". The idea is that the first thing the robot does is use whatever sensors are available to learn about its current environment. Then the robot tries understand the sensor data and decide what it needs to do - sometimes this is called making a plan. Next, the bot has to actually perform the planned actions. These might be moving a motor, turning on or off a light, sounding an alarm, activating a new sensor, etc. Then the process is repeated. The point is that sensors are as important as any other part of your robot.
When choosing a sensor it helps to keep in mind how it will be used. What problem is it supposed to help solve? Does it need to be attached to the XRP? How will it communicate with the XRP? Can it be powered by the XRP or will it need a separate power supply? Will the sensor require custom software to operate?
The XRP is intended to support the addition of lots of different types of sensors. The chassis includes an outer "rail" that sensors or other objects can use to attach to the XRP. This is usually via a clip or mount that attaches to the rail and the object being attached to the XRP. The XRP kit includes a mount/clip for attaching the servo to the XRP and a separate clip for attaching Ultrasonic range finder to the XRP. Yet another clip is provided for attaching the HuskyLens camera module to the XRP.
Physically attaching a sensor to the XRP's rail is an important step but you also have to connect the sensor electrically to the XRP so that the sensor can send information to the XRP's Raspberry Pi. There are LOTS of different types of sensors. And there are lots of different ways to communicate with sensors. The XRP provides a few commonly used ways to communicate with sensors:
- I2C (Inter-Integrated Circuit) is a commonly used for sensors and other peripherals. The XRP mother board QWIIC connections. QWIIC uses I2C but its physical connectors place the pins in a different order. The primary advantage of I2C is its simplicity. It only needs two wires and it can be used to connect to multiple devices as long as each device listens on a different address. Each I2C device may need additional pins for power and ground. Is biggest disadvange is that it is slow.
- SPI (Serial Peripheral Interface) is another commonly used communication interface. It can be much faster than I2C. It also supports communication with multiple devices. The protocol is more complex than I2C and needs 5 wires instead of only two. Although, as noted earlier each device may need two additional pins for power and ground.
- UART (Universal Asynchronous Receiver/Transmitter) is a very simple point to point type of connection. It only requires two wires. It is a widely available type of connection but it is most often used to connect CPUs such as two RPIs or a RPI and an Arduino. It is rarely used to connect with sensors.
- And of course it possible to create remote sensors that communicate via wifi or bluetooth.
The XRP's CPU is a Raspberry Pi Pico. The Pico has many General Purpuse I/O pins (GPIO). Some sensors or other devices may not be controlled by I2C, SPI or UART connections but communication is possible by writing the code (usualy microPython or C++) that directly controls each GPIO pin. The details of how to do this are beyond the scope of this document. Students interested in learning to control the RPI GPIO pins may be able to find the guidance they need from Sparkfun or Raspberry Pi Foundation documentation.
The XRP is powered by 4 AA batteries. The XRP can provide 3.3 or 5 volts - depending on how you connect to the XRP. If your new sensor draws too much power it may need an additional power supply, i.e., additional battery power. This is possible but it can make your project much more complicated and is not recommended.
Software for the XRP can be developed using Blockly and MicroPython. There is a pretty good chance new sensors will NOT have blocks that can be easily integrated with the version of Blockly used by the XRP. If this turns out to be the case, you will have to use MicroPython to integrate the sensor with the XRP.
Many simple sensors intended to be easily (hopefully) connected to the XRP can be found on the Sparkfun site.