SOFTWARE

Raspberry Pi (RPi)

We were able to connect to the RPi with wifi, such that we could control it from our own laptops.

 

Overall block diagram

 

Reflectance Array Sensor + ADC

Model: QTR-8RA

The reflectance array sensor comprises 8 sensors, which would give 8 separate signals to the RPi.

Analog-Digital Converter (ADC)

However, as these sensors gave analog signals, while the RPi only can read digital signals, we needed an Analog-Digital Converter (ADC).

Wiring

In addition to VCC to supply power to the sensors as well as ground, each reflectance sensor was also connected to a GPIO pin on the RPi, with the ADC in between. The signals detected by each sensor each gave a value to be read by the RPi, which the code could interpret.

Code

Based on readings, a threshold (950) was decided such that black(>950) and white(<950) could be defined. As the reading depended on the angle of the sensor and the distance between the sensor and the floor, we fixed these variables with a mount.

The following are the various things the floor patterns can trigger.

 

Normal line tracking: Robot is able to follow a line and make turns.

Status: Normal

 

 

 

 

Pre-programmed turns:

(1) Robot chooses to execute a right-angled turn or continue going straight, based on its status. The robot status is based on the readings from the weight sensor and timer in RPi. If the weight or time threshold is exceeded, the robot will choose to unload. 

Status: Normal -> Unload sequence started

(2) When the robot reaches the junction, the status (‘Just unloaded’ or ‘Continuing Circuit’) would ensure it executes the necessary actions for it to continue to the main circuit.

Status: Waiting to merge -> Merging -> Normal

 

Loading or unloading:

When the center sensors detect white and the sensors at the two ends detect black, the loading sequence is triggered. Wheels stop turning and current is supplied to the linear actuators to lower the rack.

Status: Waiting to unload -> Waiting to load

With this status, the next time the same pattern is encounted, the unloading sequence is triggered, where the actions are the same except the current is supplied in the opposite directions to lift the actuators.

Status: Waiting to load -> Waiting to merge

 

Wheel Motor Driver + PCA9865

Motor Driver for Wheels – Model: MDD20A

For our wheels, we are using 2 brushed DC motors with a power rating of 250W, operating at a maximum of 24V and 13.4A. Hence, we chose a motor driver that had 2 channels such that both motors can be controlled with 1 driver.
The motor driver, MDD20A, is compatible for 6V to 30V, and up to 20 A. As our robot does not require high speeds, we concluded that 20A is sufficient.

PCA9865

Additionally, as the wheel motors operate at high voltage and current, we added a server driver PCA9865 between the RPi and Motor Driver, such that the RPi would not be directly affected if the Motor Driver were to malfunction.

Wiring

The motor driver has 2 sets of inputs and outputs.

The black one (as seen in the image above) is connected to the car battery (~12V), which supplies the power to each of the 2 motors. As the wires would be carrying high currents and high voltage, we used a thicker wire that can support up to 25A.

Meanwhile, the green one (as seen in the image above) is connected to the PCA9865, which is in turn connected to the RPi. This provides control of the direction and amount of potential difference applied, which in turn affects the speed and direction of rotation of the motor driver.

Code

The RPi takes the readings from the reflectance array sensors and generates the signals to control the wheels.

For normal line tracking, the left wheel turns faster than the right wheel to turn left when more right sensors detect black, and vice versa. Both wheels turn at the same speed to go straight when the middle 2 sensors detect black. This keeps the robot centred on the line as it moves forward.

For the pre-programmed turns, the robot moves slightly forward before executing the turn as the reflectance array sensors are located at the front of the robot. The right-angled turn is done by one wheel turning forward and the other turning backwards, in order for the robot to turn on the spot.

 

Linear Actuator Motor driver + PCA9865

The linear actuators we are using are rated for 30W, 12V, 2.5A. To control all 4 actuators simultaneously, we planned to connect them in parallel with each other. Hence, our driver would need to handle up to 10A (2.5A x4) and 12V.

Linear Actuator Motor Driver – Model: MD10C

The linear actuator motor driver we are using, MD10C, is a DC motor driver that can handle between 5V-30V and up to 10A.

PCA9865

Again, to protect our RPi from the high voltage and current, we also added a PCA9865 between the RPi and linear actuator motor driver. As our PCA9865 had sufficient output pins, we used the same PCA9865 for both the linear actuator and wheel motor drivers.

Wiring

Similar to the wheel motor driver, the linear actuator motor driver also has 2 sets of input and outputs. In green, is the input and output that is connected to the car battery (~12V) and linear actuators. As we are controlling 4 linear actuators simultaneously, we wired them in parallel with each other such that each receives 12V. As the current through this will be high (max 10A, 2.5A per actuator), we also used a thicker wire here (rated for 25A).

Code

The line pattern detected on the ground by the reflectance sensors would be transmitted to the RPi, which then sends instructions to the linear actuator motor driver. The linear actuators move at a fixed speed and automatically stop after reaching their fullest extent. Hence, it is the change in current direction that causes the reversal in direction, for the linear actuators to be raised and lowered.

 

Load Cell + HX711

As these load cells give analog output, we also used HX711 to amplify the signal and convert it to a digital output for the RPi to read.

Wiring

Diagram of actual wiring of the load cells. Image adapted from: https://circuitjournal.com/50kg-load-cells-with-HX711

The 4 load cells were wired together such that one output value would be sent to the RPi.

Code

We needed to calibrate the weight sensors by using a block of a known mass and checking the change in the output reading, then adding a multiplicative factor to the code such that we get the actual mass readings.

We decided on a threshold of 820g (2 empty trays), such that the robot will turn into the docking station at the junction if it is exceeded.

 

Ultrasonic Distance Sensor

We used 4 ultrasonic sensor (HC-SR04) to detect distance from the front, back, left and right of our robot. This sensor works by sending out a signal and measuring time between the signal being sent and being received, then multiplying by a factor to get the distance of the object.

Wiring

Diagram of actual wiring, using a breadboard. F, B, L R refer to the Front, Back, Left and Right sensor, and the adjacent numbers refer the the GPIO pin number on the RPi.

VCC and GND refer to the power supply and ground respectively. These were connected to the corresponding pins on the RPi, where 1 GPIO and 1 ground pin could be shared among all 4 sensors, connected in parallel.

Meanwhile, Trig and Echo refer the trigger signal and the return signal respectively. These pins could not be shared as readings for the front, back, left and right directions must be processed separately.

Additionally, we also had to add resistors of 330 Ohms between the Echo and RPi as the HC-SR04 operates at 5V, while the GPIO pins on the RPi only tolerate up to 3.3V. The Echo is also connected to ground with a 470 Ohm resistor in between, such that if no signal is detected, the reading will be 0.

Code

We set the threshold distance at 40cm, such that any obstacles or humans that approach the robot will trigger a stop to prevent collision. This threshold can be customised based on the width of passageways in actual food courts.

 

Car Battery and Switches

As our robot is quite larger, the motors and actuators that it needs would require higher power, voltage and current. Hence, we have some safety measures in place.

 

Car battery

As our robot needs to transport quite a bit of weight, our motors and linear actuator must have sufficiently high power rating. These hence require a higher voltage supply than average smaller electronics, hence our use of the car battery.

Fuse box

This allows us to incorporate fuses into our 2 high-voltage and high-current circuits, quickly isolating the car battery if any error were to occur. Moreover, we can easily replace the fuses through this fuse box. 1 15A and 10A fuse were used for the wheels and the linear actuators respectively.

Emergency Stop

The emergency stop provides a quick way to isolate the power source from the rest of the circuit.

Switch

We used a double pull single throw switch which allowed us to close 2 separate circuits simultaneously. By doing so, we are decreasing the current flow in each wire, which would be safer.