15. System Integration¶
This week I worked on my final project.
Weekly Objectives¶
- Design and document the system integration for your final project
Sketch and Overview of my Final Project¶
3D View of myfinal project¶
Flowchart¶
I designed a flowchart for my whole final project. I made using Lucid Chart.
Input: Touch Sensor built by myself.
Output: a 4” TFT Screen for displaying images.
Process: When I touched my touch sensor, the screen will light up and display matching images. For example, if I touch the sensor that is for Italy, it would only display images related to Italy.
Building my Own Sensor¶
Step Response¶
Since I am not allowed to use pre-built touch sensors, I had to figure out how to build my own. My frist option was Step Response. I first got the example code from Neil. Then I used ChatGPT to modify the code into C++ and based on mywiring. Then I got the step response sensor to work with objects but not my hands.
Then I continued to use ChatGPT to modified the code. I ask ChatGPT to increase the sensitivity of the sensor. Then I successfully make the sensor work with my hand.
The Working Code:
// Capacitive Step-Response Sensor for Seeed Studio XIAO RP2040
const int tx_pin = 28; // TX Plate (Digital Output)
const int rx_pin = 27; // RX Plate (Analog Input)
const int led_pin = 26; // LED Indicator
const int settle_time = 100; // Microseconds to wait after setting TX pin
const int samples = 100; // Number of samples for averaging
void setup() {
pinMode(tx_pin, OUTPUT);
pinMode(led_pin, OUTPUT);
Serial.begin(115200);
}
long average() {
long total = 0;
for (int i = 0; i < samples; i++) {
digitalWrite(tx_pin, HIGH);
delayMicroseconds(settle_time);
int up = analogRead(rx_pin);
digitalWrite(tx_pin, LOW);
delayMicroseconds(settle_time);
int down = analogRead(rx_pin);
total += (up - down);
}
return total;
}
void loop() {
long avg = average();
Serial.println(avg);
// Adjust the threshold value based on your setup
if (avg < 16000) {
digitalWrite(led_pin, HIGH);
} else {
digitalWrite(led_pin, LOW);
}
delay(100);
}
Then since I needed to make it work with the screen, I decided to add an OLED Screen for testing.
After making ChatGPT modify my code, I successfuly light up the screen through the step response sensor.
Code With the OLED Screen:
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
const int tx_pin = 28;
const int rx_pin = 27;
const int settle_time = 100;
const int samples = 100;
bool screen_on = false;
unsigned long screen_timer = 0;
const unsigned long display_duration = 5000; // 5 seconds
void setup() {
pinMode(tx_pin, OUTPUT);
Serial.begin(115200);
Wire.setSDA(6); // or your correct SDA pin
Wire.setSCL(7); // or your correct SCL pin
Wire.begin();
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 allocation failed"));
while (true);
}
display.clearDisplay();
display.display();
}
long average() {
long total = 0;
for (int i = 0; i < samples; i++) {
digitalWrite(tx_pin, HIGH);
delayMicroseconds(settle_time);
int up = analogRead(rx_pin);
digitalWrite(tx_pin, LOW);
delayMicroseconds(settle_time);
int down = analogRead(rx_pin);
total += (up - down);
}
return total;
}
void loop() {
long value = average();
Serial.println(value);
if (value < 16000 && !screen_on) {
screen_on = true;
screen_timer = millis();
// Show something on screen
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(10, 20);
display.println("Hello!");
display.display();
}
// Turn off screen after timeout
if (screen_on && millis() - screen_timer >= display_duration) {
screen_on = false;
display.clearDisplay();
display.display();
}
delay(100);
}
Failure Modes¶
Connection between Screen and Sensors: Since I am using different microcontrollers, the communcation between each other maybe ad and may not work
Gap between Acrylic and Sensor: The tape may be loosen my gravity so that the connection between the acrylic andthe sensors maybe bad which may cause the sensor stop working.
Packaging¶
For packaging, I will make the wooden frame hollow so that I can hide the PCBs with in the wooden frame. I will use gluee to stick the PCB onto the bottom surface of the frame and stick sensors onto different acrylics. I will use press-fit method to assemble the frame.
Reflection of the Week¶
For this week, I was workig on my final project. Specifically the 3D design part and the touc sensor. Since I am not allowed to use pre-built touch sensors, I had to figure out how to build my own. My frist option was Step Response. Then I figured out that although the step response is pretty sensitive, it needs two pads to make it work well. However, I need at least 8 sensors which the ports are not enough to use. So I may need to find a better sensor for my final project.
AI Usage¶
I used ChatGPT to help me generate the code and fixing my wiring. You can found the whole conversation here.