Flex Sensor with Arduino
A flex sensor or bend sensor is a low-charge and easy-to-use sensor particularly designed to measure the quantity of deflection or bending.
It became famous inside the 90s because of its use within the Nintendo Power Glove as a gaming interface. Since then humans were the usage of it as a goniometer to determine joint motion, a door sensor, a bumper switch for wall detection or a pressure sensor on robot grippers.
Flex Sensor Overview
A flex sensor is basically a variable resistor that varies in resistance upon bending. Since the resistance is right away proportional to the quantity of bending, it's far frequently referred to as a Flexible Potentiometer.
Flex sensors are typically available in sizes: one is two.2″ (five.588cm) prolonged and any other is four.5″ (11.43cm) long.
Construction
A flex sensor includes a phenolic resin substrate with conductive ink deposited. A segmented conductor is positioned on pinnacle to form a flexible potentiometer wherein resistance modifications upon deflection.
Directions to Use
Flex sensors are designed to flex in handiest one direction – away from ink (as proven within the parent). Bending the sensor in a few other course may also harm it.
Also take care not to bend the sensor close to the lowest, due to the fact the lowest of the sensor (wherein the pins are crimped on) may be very fragile and can wreck when bent over.
How Flex Sensor Works?
When the sensor is straight away, this resistance is prepared 25k.
When the sensor is bent, conductive layer is stretched, resulting in reduced pass phase (consider stretching a rubber band). This reduced bypass segment outcomes in an prolonged resistance. At ninety° attitude, this resistance is about 100KΩ.
When the sensor is straightened again, the resistance returns to its unique rate. By measuring the resistance, you can decide how an awful lot the sensor is bent.
Reading a Flex Sensor
The best manner to have a look at the flex sensor is to connect it with a hard and fast fee resistor (usually 47kΩ) to create a voltage divider. To try this you be part of one give up of the sensor to Power and the opportunity to a pull-down resistor. Then the point many of the constant value pull-down resistor and the flex sensor is connected to the ADC enter of an Arduino.
This manner you could create a variable voltage output, which can be look at via a Arduino’s ADC input.
Note that the output voltage you degree is the voltage drop across the pull-down resistor, now not for the duration of the flex sensor.
The output of the voltage divider configuration is described by means of the equation:
In the established configuration, the output voltage decreases with growing bend radius.
For example, with 5V supply and 47K pull-down resistor, at the same time as the sensor is flat (0°), the resistance is fairly low (around 25kΩ). This consequences in the following output voltage:
When flexed all of the manner (ninety°), the resistance rises to 100KΩ. This effects inside the following output voltage:
Wiring Flex Sensor to Arduino UNO
You need to attach a 47kΩ pull-down resistor in collection with the flex sensor to create a voltage divider circuit. Then the thing among the pull-down resistor and the FSR is hooked up to the A0 ADC enter of an Arduino.
Const int flexPin = A0; // Pin related to voltage divider output
// Change these constants in keeping with your assignment's layout
const go with the flow VCC = 5; // voltage at Ardunio 5V line
const glide R_DIV = 47000.0; // resistor used to create a voltage divider
const go with the flow flatResistance = 25000.0; // resistance when flat
const flow bendResistance = 100000.0; // resistance at ninety deg
void setup() {
Serial.Start(9600);
pinMode(flexPin, INPUT);
}
void loop() {
int ADCflex = analogRead(flexPin);
float Vflex = ADCflex * VCC / 1023.0;
float Rflex = R_DIV * (VCC / Vflex - 1.0);
Serial.Println("Resistance: " + String(Rflex) + " ohms");
// Use the calculated resistance to estimate the sensor's bend perspective:
drift angle = map(Rflex, flatResistance, bendResistance, 0, 90.0);
Serial.Println("Bend: " + String(perspective) + " degrees");
Serial.Println();
delay(500);
}
If the entirety is excellent, you want to peer a trade in resistance and predicted mind-set calculation, as you bend the flex sensor.
The comic strip starts offevolved with the statement of the Arduino pin to which FSR and 47K pulldown are related
Const int flexPin = A0;
it’s flat and bent at 90°. Make certain which you set the ones constants as it should be.
const go with the flow VCC = 5;
const glide R_DIV = 47000.0;
const go with the flow flatResistance = 25000.0;
const flow bendResistance = 100000.0;
In setup function of code we initialize the serial communique with the PC and set the flexPin as INPUT.
void setup() {
Serial.Start(9600);
pinMode(flexPin, INPUT);
}
In loop function, we first take the ADC studying.
int ADCflex = analogRead(flexPin);
When the Arduino converts this analog voltage into virtual, it absolutely converts it to a ten-bit wide kind of range 0 to 1023. So to calculate the actual output voltage, we use beneath device:
float Vflex = ADCflex * VCC / 1023.0;
Next, we calculate the resistance of the flex sensor the usage of the method derived from the voltage divider components and display it at the serial display.
float Rflex = R_DIV * (VCC / Vflex - 1.0);
Serial.Println("Resistance: " + String(Rflex) + " ohms");
Finally, we use the calculated resistance to estimate the sensor’s bend mind-set. To do this we use the IDE’s integrated map() characteristic.
The map() characteristic maps and converts the resistance of the sensor to the sensor’s bend attitude. So, on the same time as we call map(Rflex, flatResistance, bendResistance, 0, 90.0), fee of flatResistance may additionally get mapped to 0°, a price of bendResistance to ninety° and values in-among to values in-amongst.
drift angle = map(Rflex, flatResistance, bendResistance, 0, 90.0);
Serial.Println("Bend: " + String(perspective) + " degrees");
Serial.Println();
delay(500);
No comments:
Post a Comment