Official library for the FRDM-TFC shield

Dependents:   TFC-TEST TFC-RACING-DEMO TFC-RACING-DEMO TFC-RACING-FSLMENTORMATTERS ... more

Embed: (wiki syntax)

« Back to documentation index

FRDM-TFC_API

FRDM-TFC_API

Resources used by the TFC Library
. More...

Functions

void TFC_Init ()
 Initialized the TFC API.
uint8_t TFC_GetDIP_Switch ()
 Gets the state of the 4-positiomn DIP switch on the FRDM-TFC.
uint8_t TFC_ReadPushButton (uint8_t Index)
 Reads the state of the pushbuttons (SW1, SW2) on the FRDM-TFC.
void TFC_SetBatteryLED (uint8_t Value)
 Controls the 4 battery level LEDs on the FRDM-TFC boards.
void TFC_SetServo (uint8_t ServoNumber, float Position)
 Sets the servo channels.
void TFC_InitServos (float ServoPulseWidthMin, float ServoPulseWidthMax, float ServoPeriod)
 Initializes TPM for the servoes.
void TFC_InitMotorPWM (float SwitchingFrequency)
 Initialized TPM0 to be used for generating PWM signals for the the dual drive motors.
void TFC_SetMotorPWM (float MotorA, float MotorB)
 Sets the PWM value for each motor.
float TFC_ReadPot (uint8_t Channel)
 Reads the potentiometers.
float TFC_ReadBatteryVoltage ()
 Gets the current battery voltage.
void TFC_SetBatteryLED_Level (uint8_t BattLevel)
 Sets the Battery level indiciate.

Variables

volatile uint32_t TFC_ServoTicker
 ServoTicker will increment once every servo cycle.
volatile uint16_t * TFC_LineScanImage0
 Pointer to two channels of line scan camera data.
volatile uint8_t TFC_LineScanImageReady
 This flag will increment when a new frame is ready.

Detailed Description

Resources used by the TFC Library
.

I/O:
-------------------------------------------------------------------------------------------------

PTB0 (Servo Channel 0 - TPM1)
PTB1 (Servo Channel 1 - TPM1)

PTB8 (Battery LED0)
PTB9 (Battery LED1)
PTB10 (Battery LED2)
PTB11 (Battery LED3)

PTD7 (Camera SI)
PTE0 (Camera CLK)
PTD5 (Camera A0 - ADC_SE6b)
PTD6 (Camera A1 - ADC_SE7b)

PTE2 DIP Switch 0
PTE3 DIP Switch 1
PTE4 DIP Switch 2
PTE5 DIP Switch 3

PTC13 Pushbutton SW1
PTC17 Pushbutton SW2

PTC3 H-Bridge A - 1 FTM0_CH3
PTC4 H-Bridge A - 2 FTM0_CH4
PTC1 H-Bridge B - 1 FTM0_CH1
PTC2 H-Bridge B - 2 FTM0_CH2

PTE21 H-Bridge Enable
PTE20 H-Bridge Fault

PTE23 H-Bridge A - IFB
PTE22 H-Bridge B - IFB

}


Function Documentation

uint8_t TFC_GetDIP_Switch (  )

Gets the state of the 4-positiomn DIP switch on the FRDM-TFC.

Returns:
The lower 4-bits of the return value map to the 4-bits of the DIP switch

Definition at line 444 of file TFC.cpp.

void TFC_Init (  )

Initialized the TFC API.

Call before using any other API calls.

Definition at line 366 of file TFC.cpp.

void TFC_InitMotorPWM ( float  SwitchingFrequency )

Initialized TPM0 to be used for generating PWM signals for the the dual drive motors.

This method is called in the TFC constructor with a default value of 4000.0Hz

Parameters:
SwitchingFrequencyPWM Switching Frequency in floating point format. Pick something between 1000 and 9000. Maybe you can modulate it and make a tune.

Definition at line 910 of file TFC.cpp.

void TFC_InitServos ( float  ServoPulseWidthMin,
float  ServoPulseWidthMax,
float  ServoPeriod 
)

Initializes TPM for the servoes.

It also sets the max and min ranges

Parameters:
ServoPulseWidthMinMinimum pulse width (in seconds) for the servo. The value of -1.0 in SetServo is mapped to this pulse width. I.E. .001
ServoPulseWidthMaxMaximum pulse width (in seconds) for the servo. The value of +1.0 in SetServo is mapped to this pulse width. I.E. .002
ServoPeriodPeriod of the servo pulses (in seconds). I.e. .020 for 20mSec

Definition at line 488 of file TFC.cpp.

float TFC_ReadBatteryVoltage (  )

Gets the current battery voltage.

Returns:
Battery voltage in floating point form.

Definition at line 989 of file TFC.cpp.

float TFC_ReadPot ( uint8_t  Channel )

Reads the potentiometers.

Parameters:
ChannelSelects which pot is read. I.e. 0 for POT0 or 1 for POT1
Returns:
Pot value from -1.0 to 1.0

Definition at line 981 of file TFC.cpp.

uint8_t TFC_ReadPushButton ( uint8_t  Index )

Reads the state of the pushbuttons (SW1, SW2) on the FRDM-TFC.

Parameters:
IndexSelects the pushbutton (0 for SW1 and 1 for SW2)
Returns:
A non-zero value if the button is pushed

Definition at line 453 of file TFC.cpp.

void TFC_SetBatteryLED ( uint8_t  Value )

Controls the 4 battery level LEDs on the FRDM-TFC boards.

Parameters:
ValueThe lower 4-bits of the parameter maps to the 4 LEDs.

Definition at line 421 of file TFC.cpp.

void TFC_SetBatteryLED_Level ( uint8_t  BattLevel )

Sets the Battery level indiciate.

Parameters:
BattLevelA number betwween 0 and 4. This will light the bar from left to right with the specifified number of segments.

Definition at line 995 of file TFC.cpp.

void TFC_SetMotorPWM ( float  MotorA,
float  MotorB 
)

Sets the PWM value for each motor.

Parameters:
MotorAThe PWM value for HBridgeA. The value is normalized to the floating point range of -1.0 to +1.0. -1.0 is 0% (Full Reverse on the H-Bridge) and 1.0 is 100% (Full Forward on the H-Bridge)
MotorBThe PWM value for HBridgeB. The value is normalized to the floating point range of -1.0 to +1.0. -1.0 is 0% (Full Reverse on the H-Bridge) and 1.0 is 100% (Full Forward on the H-Bridge)

Definition at line 961 of file TFC.cpp.

void TFC_SetServo ( uint8_t  ServoNumber,
float  Position 
)

Sets the servo channels.

Parameters:
ServoNumberWhich servo channel on the FRDM-TFC to use (0 or 1). 0 is the default channel for steering
PositionAngle setting for servo in a normalized (-1.0 to 1.0) form. The range of the servo can be changed with the InitServos function. This is called in the TFC constructor with some useful default values--> 20mSec period, 0.5mS min and 2.0mSec max. you may need to adjust these for your own particular setup.

Definition at line 567 of file TFC.cpp.


Variable Documentation

volatile uint16_t* TFC_LineScanImage0

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.

Definition at line 342 of file TFC.cpp.

volatile uint8_t TFC_LineScanImageReady

This flag will increment when a new frame is ready.

Check for a non zero value (and reset to zero!) when you want to read the camera(s)

Definition at line 344 of file TFC.cpp.

volatile uint32_t TFC_ServoTicker

ServoTicker will increment once every servo cycle.

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

Definition at line 351 of file TFC.cpp.