Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of FSR by
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 return pow(10, ((log10(6.2) - a) * slope + 2)); 00027 00028 //if (a < log10(6.2)) 00029 // { 00030 // return pow(10, ((log10(6.2) - a) * slope + 2)); 00031 // } 00032 // else 00033 // { 00034 // return 0; 00035 // } 00036 }
Generated on Wed Aug 24 2022 06:50:00 by
1.7.2
