This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
en:examples:sensor:force [2012/06/06 18:21] – raivo.sell | en:examples:sensor:force [2020/07/20 09:00] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Force sensor ====== | ====== Force sensor ====== | ||
- | //Necessary knowledge: [HW] [[en: | + | //Necessary knowledge: [HW] [[en: |
===== Theory ===== | ===== Theory ===== | ||
- | [{{ : | + | [{{ : |
- | [{{ : | + | [{{ : |
FSR (force-sensing resistor) sensor allow you to detect physical pressure, squeezing and weight. FSR is basically a resistor that changes its resistive value (in ohms Ω) depending on how much it’s pressed. These sensors are fairly low cost and easy to use but they' | FSR (force-sensing resistor) sensor allow you to detect physical pressure, squeezing and weight. FSR is basically a resistor that changes its resistive value (in ohms Ω) depending on how much it’s pressed. These sensors are fairly low cost and easy to use but they' | ||
Line 17: | Line 17: | ||
===== Practice ===== | ===== Practice ===== | ||
- | [{{ : | + | [{{ : |
- | [{{ : | + | [{{ : |
Pololu FSR with 12.7 mm diameter circular active area are exhibits a decrease in resistance with an increase in the force applied to the active surface. Its force sensitivity is optimized for use in human touch control of electronic devices. The force vs. resistance characteristic provides an overview of FSR typical response behavior. | Pololu FSR with 12.7 mm diameter circular active area are exhibits a decrease in resistance with an increase in the force applied to the active surface. Its force sensitivity is optimized for use in human touch control of electronic devices. The force vs. resistance characteristic provides an overview of FSR typical response behavior. | ||
- | The easiest way to measure a resistance of FSR is to connect one terminal to power and the other to a pull-down resistor to ground. Then the point between the fixed pull-down resistor and the variable FSR resistor is connected to the analogue input of a Homelab controller | + | The easiest way to measure a resistance of FSR is to connect one terminal to power and the other to a pull-down resistor to ground. Then the point between the fixed pull-down resistor and the variable FSR resistor is connected to the analogue input of a Controller |
Measuring the Newton force by the FSR it is good idea to map analogue voltage reading ranges to 0 V to supply voltage. After that you can calculate the FSR resistance using following formula: | Measuring the Newton force by the FSR it is good idea to map analogue voltage reading ranges to 0 V to supply voltage. After that you can calculate the FSR resistance using following formula: | ||
- | R< | + | R< |
Where: | Where: | ||
Line 45: | Line 45: | ||
The example program of the force sensor shows the measured force (Newtons) and weight (kg) on the LCD. | The example program of the force sensor shows the measured force (Newtons) and weight (kg) on the LCD. | ||
- | ~~PB~~ | + | < |
<code c> | <code c> | ||
- | // | ||
- | // The demonstration program of the force sensor. | ||
- | // The LCD display shows the measured force (Newtons) and weight (kg). | ||
- | // | ||
#include < | #include < | ||
#include < | #include < | ||
Line 58: | Line 54: | ||
#include < | #include < | ||
- | // | ||
// Map a value from one range to another. | // Map a value from one range to another. | ||
- | // | ||
long map(long x, long in_min, long in_max, long out_min, long out_max) | long map(long x, long in_min, long in_max, long out_min, long out_max) | ||
{ | { | ||
Line 66: | Line 60: | ||
} | } | ||
- | // | + | // Main program |
- | // The main program. | + | |
- | // | + | |
int main(void) | int main(void) | ||
{ | { | ||
Line 78: | Line 70: | ||
long force; // The resistance converted to force. | long force; // The resistance converted to force. | ||
long weight; // The force converted to weight. | long weight; // The force converted to weight. | ||
- | |||
// Set the external sensors pins. | // Set the external sensors pins. | ||
Line 111: | Line 102: | ||
// The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V | // The voltage = Vcc * R / (R + FSR) where R = 10K and Vcc = 5V | ||
- | | + | // so FSR = ( (Vcc - V) * R) / V |
- | // fsrVoltage is in millivolts so 5V = 5000mV | + | // fsrVoltage is in millivolts so 5V = 5000mV |
resistance = 5000 - voltage; | resistance = 5000 - voltage; | ||
resistance *= 10000; // 10K resistor | resistance *= 10000; // 10K resistor | ||
Line 141: | Line 132: | ||
} | } | ||
} | } | ||
- | |||
</ | </ |