TFC library Kacper
Dependents: 2018_NXP_car_Kacper
Fork of FRDM-TFC by
Revision 9:06ec88181b40, committed 2018-04-30
- Comitter:
- evenix
- Date:
- Mon Apr 30 18:32:16 2018 +0000
- Parent:
- 8:24430a0d7fd8
- Commit message:
- Added a potentiometer reading function with different range of values.
Changed in this revision
TFC.cpp | Show annotated file Show diff for this revision Revisions of this file |
TFC.h | Show annotated file Show diff for this revision Revisions of this file |
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);
diff -r 24430a0d7fd8 -r 06ec88181b40 TFC.h --- a/TFC.h Thu Feb 11 14:58:08 2016 +0000 +++ b/TFC.h Mon Apr 30 18:32:16 2018 +0000 @@ -149,7 +149,7 @@ * It can be used to synchronize events to the start of a servo cycle. ServoTicker is a volatile uint32_t and is updated in the TPM1 overlflow interrupt. This means you will see ServoTicker increment on the rising edge of the servo PWM signal * */ - extern volatile uint32_t TFC_ServoTicker; +extern volatile uint32_t TFC_ServoTicker; /** Gets the state of the 4-positiomn DIP switch on the FRDM-TFC @@ -211,6 +211,9 @@ */ float TFC_ReadPot(uint8_t Channel); +/// Reads potentiometers with range from 0 to 100 +float TFC_ReadPotRange(uint8_t Channel); + /** Gets the current battery voltage * * @returns Battery voltage in floating point form. @@ -227,8 +230,8 @@ void TFC_SetBatteryLED_Level(uint8_t BattLevel); -/** Pointer to two channels of line scan camera data. Each channel is 128 points of uint8_t's. Note that the underlying implementation is ping-pong buffer These pointers will point to the -*inactive buffer. +/** Pointer to two channels of line scan camera data. Each channel is 128 points of uint8_t's. Note that the underlying implementation is ping-pong buffer These pointers will point to the +*inactive buffer. * */