Welcome to the EyeBot  Version 7 - RPi1
A Controller For Various Hardware IO
Functions
servos_and_motors.c File Reference

Defines functions to control servos and motors. More...

#include "servos_and_motors.h"
#include "hdt.h"
#include "stdio.h"

Functions

int SERVOInit ()
 Initialises the IO board and sets up tables for servos. More...
 
int MOTORInit ()
 Initialises the IO board and sets up tables for motors. More...
 
int SERVORange (int servo, int low, int high)
 Sets the range for the servos. More...
 
int SERVOSet (int servo, int angle)
 Set the given servos to the same given angle depending on table value. More...
 
int SERVOSetRaw (int servo, int angle)
 Set the given servos to the same given angle in raw mode. More...
 
int MOTORDriveRaw (int motor, int speed)
 Set the given motor to a given speed. More...
 
int MOTORDrive (int motor, int speed)
 Set the given motors to the same given speed dependant on hdt table. More...
 
int MOTORPID (int motor, int p, int i, int d)
 Set the given motors with PID control. More...
 
int MOTORPIDoff (int motor)
 Shuts off PID control. More...
 
int MOTORSpeed (int motor, int ticks)
 Sets the controlled motor speed in ticks/sec. More...
 
int ENCODERRead (int quad)
 Reads the value from the encoder. More...
 
int ENCODERReset (int quad)
 Resets the encoder, in reality just stores the current value of the encoder and subtracts it from future values. More...
 

Detailed Description

Defines functions to control servos and motors.

Author
Marcus Pham

Function Documentation

int ENCODERRead ( int  quad)

Reads the value from the encoder.

Parameters
quadthe encoder to read from
Returns
the encoder value on success, 1 on failure
int ENCODERReset ( int  quad)

Resets the encoder, in reality just stores the current value of the encoder and subtracts it from future values.

Parameters
quadthe encoder to reset
Returns
0 on success, 1 on failure
int MOTORDrive ( int  motor,
int  speed 
)

Set the given motors to the same given speed dependant on hdt table.

Parameters
motorthe motor to set
speed: motor speed in percent

Valid values for speed :

  • -100 to 100 (full backward to full forward)
  • 0 for full stop
    Returns
    0 on success, 1 on failure
int MOTORDriveRaw ( int  motor,
int  speed 
)

Set the given motor to a given speed.

Parameters
motorthe motor to set
speed: motor speed

Valid values for speed :

  • -100 to 100 (full backward to full forward)
  • 0 for full stop
    Returns
    0 on success, 1 on failure
int MOTORInit ( )

Initialises the IO board and sets up tables for motors.

Returns
0 on success, 1 otherwise
int MOTORPID ( int  motor,
int  p,
int  i,
int  d 
)

Set the given motors with PID control.

Parameters
motorthe motor to set
pthe p setting
ithe i setting
dthe d setting
Returns
0 on success, 1 on failure
int MOTORPIDoff ( int  motor)

Shuts off PID control.

Parameters
motorthe motor to set
Returns
0 on success, 1 on failure
int MOTORSpeed ( int  motor,
int  ticks 
)

Sets the controlled motor speed in ticks/sec.

Parameters
motorthe motor to set
ticksthe number of ticks per sec
Returns
0 on success, 1 on failure
int SERVOInit ( )

Initialises the IO board and sets up tables for servos.

Returns
0 on success, 1 otherwise
int SERVORange ( int  servo,
int  low,
int  high 
)

Sets the range for the servos.

Parameters
servothe servo to set
lowthe lower limit
highthe upper limit
Returns
0 on success, 1 otherwise
int SERVOSet ( int  servo,
int  angle 
)

Set the given servos to the same given angle depending on table value.

Parameters
servothe servo number
anglethe angle to set it to
Returns
0 on success, 1 on failure
int SERVOSetRaw ( int  servo,
int  angle 
)

Set the given servos to the same given angle in raw mode.

Parameters
servothe servo to set
intangle : valid values = 0-255
Returns
0 on success, 1 otherwise