Double Transducer: Rotation to Force
Brandt Li & Audrey Reiley
Final images
Audrey's double transducer (worked on demo day)
Brandt's double transducer (failed on demo day)
Detail photos
Servo Motor attached to straw to exert force
Pins and wires soldered to bread board
LCD Displaying active updates
Wind Sensor inside fan to read wind
Final project movies
Brandt's double transducer (failed on demo day). The problem is between the wind sensor and the servo motor. It is assumed that there was an issue during soldering as it worked perfectly fine previously to the soldering.
Audrey's double transducer (worked on demo day)
Narrative description
On one end of the cardboard, there is a potentiometer that has a metal knob that can be turned. Once the knob is turned, the speed on the fan that it is attached to will increase with the rotation of the knob. As the wind from the fan increases, it is read by a small wind sensor that tells the servo motor it is attached to, to increase rotation according to wind speed to apply force.
Progress images
Initial wiring of Arduino, mosfet pin, potentiometer and fan
Troubleshooting LCD Display (was not displaying)
Troubleshooting LCD Display (incorrect format and placement)
In-progressing soldering
Discussion
During our first project, we created a double transducer that would use rotation from a potentiometer as an input and servo motor as our output. Other project components included an LCD, fan, wind sensor, and servo motor. One relatively easy aspect was the initial setup and connection of the individual components to the Arduino board and the breadboard. From doing the homework and taking advantage of reviewing IDE-provided sketches, we established our basic framework quickly. Creating the block diagram and schematics was a relatively simple process when we had our idea finalized. We first built one model together, and after the base components worked, we proceeded to make a more organized copy of our project, taking time to ensure that all the wiring was correct.
However, as we delved more into the project, synchronizing and mapping the interactions between each component presented us with multiple challenges. It seemed as though after debugging one aspect of our code, new problems would surface. An example of this would be the servo motor and the wind sensor. Both were mapped incorrectly, and it wouldn't function properly, for some reason, when the LCD was attached. After meeting with the TA, we could map each component correctly. One thing that we found particularly helpful was to debug each element one by one using the example sketches from the library. Using this method was even valuable during the demo day when our projects did not seem to work (one ended up not working due to a software or hardware issue). As we tested the software for the LCD and fan, we realized that both wirings were wrong, and we successfully fixed this issue before having to demonstrate it in class.
Because this project was highly technical, it allowed us to have experience in applying our base knowledge of Arduino to new inputs and outputs. We learned the technicalities of programming in alignment with the components we used and how they impacted one another. The challenges we continually faced allowed us to reflect on our processes and emphasize the value of testing and retesting and how fussy the relationship between software and hardware is!
Functional block diagram and electrical schematic
Code
/*
Double Transducer: Rotation-for-Force structure sketch
Demonstrates how to structure an Arduino sketch so that
the loop contains four basic elements:
1) read inputs (gather information from the world)
2) compute and make decisions based on those inputs
3) drive outputs (effect different actuators in the world)
4) report information back to the user
While not every interactive device necessarily needs all
four of these steps in the loop, many often do.
For the purpose of this demonstration sketch, this code
is written for a device that will read a potentiometer as an
input and drive a servo motor as an output. When the potentimoter is turned, the fan's speed is increased.
The wind created by the fan is read by a wind sensor so that as wind increases,
the servo motors will increase its rotatation to exert force.
Pin mapping:
Arduino pin | role | details
------------------------------
A0 input potentiometer
11 output mosfetpin
A1 input wind sensor
9 output servo motor
Released to the public domain by the authors, Febuary 2024
Audrey Reiley, areiley@andrew.cmu.edu
Brandt Li youranl@andrew.cmu.edu
*/
#include <Wire.h> //library to send and recieve information
#include <LiquidCrystal_I2C.h> //library for LCD display
#include <Servo.h> //Library for Servo Motor
// I2C address of the LCD. Most 16x2 LCDs use 0x27 or 0x3F
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int potentiometerPin = A0; // Analog input for potentiometer
const int mosfetPin = 11; // Digital output for MOSFET control
const int windSensorOutPin = A1; // Analog input for wind sensor
const int SERVOPIN = 9; // Define the servo motor pin
Servo myServo; // Servo motor control
void setup() {
Serial.begin(9600); // Start Serial communication at 9600 baud
myServo.attach(SERVOPIN); // Attach the servo to the defined pin (SERVOPIN)
// Initialize the LCD
lcd.init();
lcd.backlight(); // Turn on the backlight of the LCD
}
void loop() {
// Step 1: Sense
int potValue = analogRead(potentiometerPin); // Read the analog value from the potentiometer
int windOutValue = analogRead(windSensorOutPin); // Read the analog value from the wind sensor (received help from TA's Angie and Virshal Urlam)
// Step 2: Compute
int fanSpeed = map(potValue, 0, 1023, 0, 255); // Map the potentiometer value to the fan speed range (0-255)
int servoPosition = map(windOutValue, 270, 480, 0, 180); // Map wind sensor value to servo position
// Step 3: Drive outputs
analogWrite(mosfetPin, fanSpeed); // Set the MOSFET output to control the fan speed
myServo.write(servoPosition); // Set the servo position based on the wind sensor value (received help from TA's Angie and Virshal Urlam)
// Step 4: Report back data
Serial.println(windOutValue); // Print the wind sensor value to Serial monitor
// Update the LCD with the new values
lcd.clear(); // Clear the LCD screen
// Display potentiometer value and fan speed on LCD
lcd.setCursor(0, 0); // Set cursor to the top left
lcd.print("i=");
// Map and print the potentiometer value in the range 0-100
int potValuenew = map(potValue, 0, 1023, 0, 100);
Serial.println(potValuenew);
lcd.print(potValuenew);
lcd.setCursor(5, 0); // Move to the top center
lcd.print("m=");
// Map and print the fan speed in the range 0-100
int fanSpeednew = map(fanSpeed, 0, 255, 0, 100);
lcd.print(fanSpeednew);
// Display wind sensor output on LCD
lcd.setCursor(7, 1); // Move to the bottom left
//lcd.print("Wind=");
// Map and print the wind sensor value in the range 0-100
int windOutValuenew = map(windOutValue, 270, 600, 0, 100);
lcd.print(windOutValuenew);
// Display servo position on LCD
lcd.setCursor(12, 1); // Move to the bottom center
lcd.print("o=");
Serial.println(servoPosition);
// Map and print the servo position in the range 0-100
int servoPositionnew = map(servoPosition, 0, 255, 0, 100);
lcd.print(servoPositionnew);
delay(300); // Update every 300 milliseconds
}