FSR
Dependents: FSR_hello_world FINAL_PROJECT Pousse_seringue_Ulg 0__Pousse_seringue ... more
FSR.cpp
00001 #include "FSR.h" 00002 #include "mbed.h" 00003 00004 FSR::FSR(PinName pin, float resistance) : _ain(pin), _r(resistance) 00005 { 00006 } 00007 00008 float FSR::readRaw() 00009 { 00010 float read = _ain; 00011 return read; 00012 } 00013 00014 float FSR::readFSRResistance() 00015 { 00016 float read = _ain; 00017 return _r * 1 / read - _r; 00018 } 00019 00020 float FSR::readWeight() 00021 { 00022 float read = _ain; 00023 float rfsr = _r * 1 / read - _r; 00024 float slope = (4 - 2) / (log10(6.2) - log10(0.25)); 00025 float a = log10(rfsr); 00026 if (a < log10(6.2)) 00027 { 00028 return pow(10, ((log10(6.2) - a) * slope + 2)); 00029 } 00030 else 00031 { 00032 return 0; 00033 } 00034 }
Generated on Tue Jul 12 2022 11:35:09 by 1.7.2