TFC library Kacper
Dependents: 2018_NXP_car_Kacper
Fork of FRDM-TFC by
Diff: TFC.cpp
- Revision:
- 9:06ec88181b40
- Parent:
- 8:24430a0d7fd8
diff -r 24430a0d7fd8 -r 06ec88181b40 TFC.cpp --- a/TFC.cpp Thu Feb 11 14:58:08 2016 +0000 +++ b/TFC.cpp Mon Apr 30 18:32:16 2018 +0000 @@ -960,15 +960,11 @@ void TFC_SetMotorPWM(float MotorA , float MotorB) { - if(MotorA>1.0) - MotorA = 1.0; - else if(MotorA<-1.0) - MotorA = -1.0; + if(MotorA>1.0) MotorA = 1.0; + else if(MotorA<-1.0) MotorA = -1.0; - if(MotorB>1.0) - MotorB = 1.0; - else if(MotorB<-1.0) - MotorB = -1.0; + if(MotorB>1.0) MotorB = 1.0; + else if(MotorB<-1.0) MotorB = -1.0; TPM0->CONTROLS[2].CnV = (uint16_t) ((float)TPM0->MOD * (float)((MotorA + 1.0)/2.0)); TPM0->CONTROLS[3].CnV = TPM0->CONTROLS[2].CnV; @@ -986,6 +982,23 @@ return ((float)PotADC_Value[1]/-((float)ADC_MAX_CODE/2.0))+1.0; } +//Pot Reading is Scaled to return a value of 0 to 10.0 +//float TFC_ReadPotRange(uint8_t Channel) +//{ +// if(Channel == 0) +// return (((float)PotADC_Value[0]-1)/40.94); +// else +// return (((float)PotADC_Value[1]-1)/40.94); +//} + +float TFC_ReadPotRange(uint8_t Channel) +{ + if(Channel == 0) + return ((float)PotADC_Value[0]); + else + return ((float)PotADC_Value[1]); +} + float TFC_ReadBatteryVoltage() { return (((float)BatSenseADC_Value/(float)(ADC_MAX_CODE)) * 3.0);// * ((47000.0+10000.0)/10000.0);