Prototyp V2
Dependencies: PM2_Libary
mapping.cpp
- Committer:
- lupomic
- Date:
- 2022-04-20
- Revision:
- 54:86a90ce4e412
- Parent:
- 49:c2ebc11520f9
File content as of revision 54:86a90ce4e412:
#include "math.h" double mapping(float adc_value_mV){ double distance = 0.0f; //distance in mm double infY =360 , supY = 2360; //Window for sensor values double voltage_mV = adc_value_mV; double p1 = -1.127 * pow(10, -14), p2 = 8.881 * pow(10, -11), p3 = -2.76 * pow(10, -7), p4 = 0.0004262, p5 = -0.3363, p6 = 120.1 ; //faktoren für polynomkurve -> von matlab exportiert if(voltage_mV > infY && voltage_mV < supY){ distance = p1 * pow(voltage_mV, 5) + p2 * pow(voltage_mV, 4) + p3 * pow(voltage_mV, 3) + p4 * pow(voltage_mV, 2) + p5 * voltage_mV + p6; } return (distance); }