Anti-Sway Capstone 1.0
Loading...
Searching...
No Matches
io.h File Reference

Sensor/Actuator (Input/Output) Interfacing Library Header. More...

#include <stdbool.h>
#include "TimerIRQ.h"
Include dependency graph for io.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Angles
 A 2D Angle. More...
 
struct  Positions
 A 2D Position. More...
 
struct  Velocities
 A 2D Velocity. More...
 

Macros

#define MOTOR_V_LIM_H   10.000
 Motor Voltage High Limit (V)
 
#define MOTOR_V_LIM_L   -10.000
 Motor Voltage Low Limit (V)
 
#define R   0.0062
 Pulley Radius (m)
 
#define K_a   0.41
 Current Constant (A/V)
 
#define K_m   0.11
 Motor Constant (Nm/A)
 
#define FORCE_TO_VOLTAGE(force)    (force) * R / (K_a * K_m)
 Force to Voltage Conversion.
 
#define VOLTAGE_TO_FORCE(voltage)    (voltage) * (K_a * K_m) / R
 Voltage to Force Conversion.
 

Typedefs

typedef float Angle
 Alias for an Angle.
 
typedef float Position
 Alias for a Position.
 
typedef float Velocity
 Alias for Velocity.
 
typedef float Voltage
 Alias for Voltage.
 

Functions

int IOSetup ()
 
int IOShutdown ()
 
void Reset ()
 
int GetReferenceVelocityCommand (Velocities *result)
 
int GetReferenceAngleCommand (Angles *result)
 
int GetAngle (Angles *result)
 
int GetTrolleyPosition (Positions *result)
 
int GetTrolleyVelocity (Velocities *result)
 
int GetUserPosition (Angles *angle, Positions *pos, Positions *result)
 
int GetUserVelocity (Angles *angle, Velocities *vel, Velocities *result)
 
int SetXVoltage (Voltage voltage)
 
int SetYVoltage (Voltage voltage)
 
bool PressedDelete ()
 
int KeyboardControlFork ()
 
int KeyboardControlJoin ()
 

Variables

MyRio_IrqTimer timer
 The Timer.
 

Detailed Description

Sensor/Actuator (Input/Output) Interfacing Library Header.

Author
Anti-Sway Team: Nguyen, Tri; Espinola, Malachi; Tevy, Vattanary; Hokenstad, Ethan; Neff, Callen)
Version
0.1
Date
2024-06-03

Macro Definition Documentation

◆ FORCE_TO_VOLTAGE

#define FORCE_TO_VOLTAGE ( force)     (force) * R / (K_a * K_m)

Force to Voltage Conversion.

Parameters
forceAn int/float/double expression, which represents the force to transmit (through the motor)
Postcondition
Becomes the conversion between force to the voltage to output

◆ VOLTAGE_TO_FORCE

#define VOLTAGE_TO_FORCE ( voltage)     (voltage) * (K_a * K_m) / R

Voltage to Force Conversion.

Parameters
voltageAn int/float/double expression, which represents the voltage to transmit (through the motor)
Postcondition
Converts voltage into a force

Function Documentation

◆ GetAngle()

int GetAngle ( Angles * result)

Obtains the angle of the harness

Parameters
resultA return parameter, which will become the angle along both directions
Returns
0 upon success, other integers if otherwise
result, which will define the angle of the harness along both lateral directions
Here is the call graph for this function:

◆ GetReferenceAngleCommand()

int GetReferenceAngleCommand ( Angles * result)

Obtains the user command (for tracking)

Parameters
resultA return parameter, which will become the desired angle requested by the user
Returns
0 upon success, negative otherwise
An Angles structure, which reflects the angle requested from the user

◆ GetReferenceVelocityCommand()

int GetReferenceVelocityCommand ( Velocities * result)

Obtains the user command (for anti-sway)

Parameters
resultA return parameter, which will become the change in position requested by the user
Returns
0 upon success, negative otherwise
A Velocities structure, which reflects the change in position requested from the user

Setup discrete velocity commands, -1, 0, and 1

◆ GetTrolleyPosition()

int GetTrolleyPosition ( Positions * result)

Obtains the Trolley Position

Parameters
resultA return parameter, which will become the position of the trolley
Returns
0 upon success, other integers if otherwise
A Positions structure, which defines the Position of the Motor in the lateral plane
Precondition
This is called precisely once every BTI
Here is the call graph for this function:

◆ GetTrolleyVelocity()

int GetTrolleyVelocity ( Velocities * result)

Obtains the Trolley Velocity

Parameters
resultA return parameter, which will become the velocity of the trolley
Returns
0 upon success, other integers if otherwise
A Velocities structure, which defines the velocity of the trolley in the lateral plane
Precondition
This is called precisely once every BTI
Here is the call graph for this function:

◆ GetUserPosition()

int GetUserPosition ( Angles * angle,
Positions * pos,
Positions * result )

Obtains the User Position

Parameters
angleThe rope angle
posThe trolley position
resultA return parameter, which will become the position of the user
Returns
0 upon success, other integers if otherwise
A Positions structure, which defines the Position of the User in the lateral plane

◆ GetUserVelocity()

int GetUserVelocity ( Angles * angle,
Velocities * vel,
Velocities * result )

Obtains the User Velocity

Parameters
angleThe rope angle
velThe trolley velocity
resultA return parameter, which will become the velocity of the user
Returns
0 upon success, other integers if otherwise
A Velocities structure, which defines the Velocity of the User in the lateral plane
Here is the call graph for this function:

◆ IOSetup()

int IOSetup ( )

Sets up the System-Sensor/Actuator Interface

Returns
0 upon success, negative otherwise

Setup Timer

Setup Encoders Channels

Setup Potentiometer Voltage Channels (are swapped)

Setup Motor Channels

Setup Keyboard Channels & Resources

Setup Reset flag

Calibration Message

Set Reference Positions

Setup the holding

Calibrate voltage intercepts for potentiometer

Here is the call graph for this function:

◆ IOShutdown()

int IOShutdown ( )

Shutsdown the System-Sensor/Actuator Interface

Returns
0 upon success, negative otherwise

Dissasociate with Encoders

Dissasociate with Potentiometers

Disassociate with Motor

Destroy Keyboard Lock

◆ KeyboardControlFork()

int KeyboardControlFork ( )

Enables Keyboard Control for Anti-Sway (concurrently)

Postcondition
If its already running, does nothing
Returns
0 upon success, negative if error

Begin Keyboard Thread

Here is the call graph for this function:

◆ KeyboardControlJoin()

int KeyboardControlJoin ( )

Stops Keyboard Control for Anti-Sway (concurrent process)

Returns
0 upon success, negative if error

Destroy Keymap Thread

◆ PressedDelete()

bool PressedDelete ( )

Detects if the DEL key is pressed on the keyboard

Returns
true iff DEL is pressed on the keyboard

◆ Reset()

void Reset ( )

Resets GetTrolleyPosition and GetTrolleyVelocity by setting the velocity to zero

Postcondition
The next time GetTrolleyVelocity is called, both velocities are zero

◆ SetXVoltage()

int SetXVoltage ( Voltage voltage)

Sets the voltage of the X motor

Returns
0 upon success, other integers if otherwise

◆ SetYVoltage()

int SetYVoltage ( Voltage voltage)

Sets the voltage of the Y motor

Returns
0 upon success, other integers if otherwise

Variable Documentation

◆ timer

MyRio_IrqTimer timer
extern

The Timer.

The Timer.