In robotics there is a need to calculate motor movements, angles, and speeds and then use physical timing to keep things in sync. These timings with any size of computer eats up valuable compute time that would be better spent on higher level functioning. This board solves this problem by using an SPI interface to transmit a custom set of commands similar to gcode.
The full duplex nature of the SPI interface further allows for effecient use of compute on the main or "master" machine. This fire/receive and forget aspect means that the main computer can immediately move on with assurity that the board will handle it from that point forward.
The pico and it's RP2040 chip were chosen because of the existing C/C++ sdk offered for the chip. The sdk allows us to have the speed offered by C++ bare metal binary while keeping many layers of abstraction between implimentation and the chip layer. The Raspberry Pi foundation also offers superb support for their hardware, sdk, and their own OS which is planned to be run on the actual controlling module.
In solution to the problem statement, the firmware receives new commands from the control module, while also transmitting important information regarding its current state. Then the pico manages the necessary peripherals in order to ensure that the transmitted commands are executed properly.
The theory of Operation is as follows:
- Pico is powered on and establishes the necessary structs and classes to maintain the correct state within the system. All pins are initialized at this time.
- Communication is initialized from the master device through the spi interface.
- Need to communicate is acknowledged by the Pico and a new script of commands is created to transmit the state of the pico to the command module.
- Bytes are exchanged in full duplex mode between each system.
- Pico moves altered servos and motors to their correct locations.
This project is structured into two main folders, structs and modules, along with a main.cpp file that initializes each class described in the module files. "structs" is for classes that act more like json objects storing new data and moving it around the application. currently there are only two of these but as methods change and get updated I'm sure more will be added.
The "main" file houses the initial startup for each module and also initializes the second core running the read/write layer. Once a new command set is read in the class maintaining the state of device is able to destribute that data to all the appropriate motors and devices.
Numberings from here forward are in reference to physical pins not gpio numbers.
- Serial Data line for I2C - goes to PCA9685 IC.
- Serial Clock line for I2C - goes to PCA9685 IC.
- GND
- 1A of L239D IC(1)
- 2A of L239D IC(1)
- 3A of L239D IC(1)
- 4A of L239D IC(1)
- GND
- 1A of L239D IC(2)
- 2A of L239D IC(2)
- 3A of L239D IC(2)
- 4A of L239D IC(2)
- GND
- Stepper Motor(1) EndStop 1
- Stepper Motor(1) EndStop 2
- Stepper Motor(2) EndStop 1
- Stepper Motor(2) EndStop 2
- GND
- This is connected to a generic output with uni directional current at 5V
- This is connected to a generic output with uni directional current at 5V
- SPI interface RX - MOSI
- SPI interface CSn - Chip Select line
- GND
- SPI interface SCK - Serial Clock Line
- SPI interface TX - MISO
- Generic GPIO input
- Generic GPIO input
- GND
- Generic GPIO input
- RUN - not planned for use.
- Analogue to Digital input 0
- Analogue to Digital input 1
- GND
- Analogue to Digital input 2
- Analogue to Digital input 3
- 3V out - rail connects to all logic power circuits found throughout architecture
- 3v3 enable pin - not planned for use.
- GND
- VSYS - power in
- VBUS - usb power out
There are a few components that had to be picked for this project. While not all of them are optimal or perfect for their roles, there were reasons behind every choice though, for better or for worse. Those reasons are outlined below.
The L293D is a versitile and sturdy IC that offers a wide range of functionality. As well as giving us control of one stepper motor, we can control two brushed dc motors bi-directionally as well. The temperature range is far above necessary parameters, but being able to deal with being in direct sunlight in a variety of climates and conditions is mandatory for the final project. The wide voltage range accepted by it is also favorable for future upgrades to more powerful stepper motors than the current NEMA 17's being used.
Along with being plenty durable for the task at hand, the PCA IC is simple in it's operation and provides a range of functionality and options. Offering 16 pwm channels we can operate as many servos as we could conceivably need. The currently used servos operate at 5V, but due to the channels on this chip being purely for the PWM duty cycle, we can run the power for the given servos at any desired level in the circuitry.