en:examples:sensor:force
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:examples:sensor:force [2012/05/28 17:36] – heikopikner | en:examples:sensor:force [2020/07/20 12:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Force sensor ====== | ====== Force sensor ====== | ||
| - | <note important> | + | //Necessary knowledge: [HW] [[en: |
| - | + | ||
| - | //Necessary knowledge: [HW] [[en: | + | |
| ===== Theory ===== | ===== Theory ===== | ||
| - | [{{ : | + | [{{ : |
| - | [{{ : | + | [{{ : |
| - | FSRs (force-sensing resistor) | + | FSR (force-sensing resistor) |
| - | FSR consist | + | FSR consists |
| Force-sensing resistors are commonly used to create pressure-sensing " | Force-sensing resistors are commonly used to create pressure-sensing " | ||
| Line 19: | 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. | + | 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 |
| - | The easiest way to measure a resistance of FSR is to connect one end 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 |
| + | 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: | ||
| - | ~~PB~~ | + | R< |
| + | |||
| + | Where: | ||
| + | R< | ||
| + | V< | ||
| + | U – The measured voltage. The ADC reading must be converted to 0 V - Vcc | ||
| + | R1 – resistor. 10 k | ||
| + | |||
| + | |||
| + | Then you can calculate the conductivity C< | ||
| + | |||
| + | C< | ||
| + | |||
| + | Use the FSR guide graphs on the datasheet to approximate the force. It depends on the measurable range. For example (0-1 Kg) low force range can be use formula: | ||
| + | |||
| + | F< | ||
| + | |||
| + | The example program of the force sensor shows the measured force (Newtons) and weight (kg) on the LCD. | ||
| + | |||
| + | < | ||
| <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 40: | 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 48: | Line 60: | ||
| } | } | ||
| - | // | + | // Main program |
| - | // The main program. | + | |
| - | // | + | |
| int main(void) | int main(void) | ||
| { | { | ||
| - | signed short value; // The analog reading. | + | signed short value; // The analog reading. |
| char text[16]; | char text[16]; | ||
| - | int voltage; | + | int voltage; // The analog reading converted to voltage. |
| - | unsigned long resistance; | + | unsigned long resistance; // The voltage converted to resistance. |
| unsigned long conductance; | unsigned long conductance; | ||
| - | long force; | + | long force; // The resistance converted to force. |
| - | long weight; | + | long weight; // The force converted to weight. |
| // Set the external sensors pins. | // Set the external sensors pins. | ||
| Line 88: | Line 97: | ||
| value = adc_get_average_value(0, | value = adc_get_average_value(0, | ||
| - | // Analog voltage reading ranges from about 0 to 1023 which maps to 0V to 5V (= 5000mV) | + | // Analog voltage reading ranges from about 0 to 1023 |
| + | // which maps to 0V to 5V (= 5000mV) | ||
| voltage = map(value, 0, 1023, 0, 5000); | voltage = map(value, 0, 1023, 0, 5000); | ||
| // 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 |
| - | resistance = 5000 - voltage; | + | // fsrVoltage is in millivolts so 5V = 5000mV |
| - | resistance *= 10000; | + | resistance = 5000 - voltage; |
| - | resistance /= voltage; | + | resistance *= 10000; // 10K resistor |
| + | resistance /= voltage; // FSR resistance in ohms. | ||
| - | conductance = 1000000; | + | conductance = 1000000; //We measure in micromhos. |
| - | conductance /= resistance; | + | conductance /= resistance; // |
| // Move the cursor to the right of the screen. | // Move the cursor to the right of the screen. | ||
| Line 121: | Line 132: | ||
| } | } | ||
| } | } | ||
| - | |||
| </ | </ | ||
en/examples/sensor/force.1338215812.txt.gz · Last modified: (external edit)
