eBoard ๐Ÿ‰  โ‘ โ‘งโ‘จ
Written for SIA 2017/2018
ServoCds55 Struct Reference

#include <eBoard.h>

Public Member Functions

 ServoCds55 (int CS=53)
 
void begin ()
 
void WritePos (int ID, int Pos)
 
void write (int ID, int Pos)
 
void setVelocity (int velocity)
 
void setPoslimit (int posLimit)
 
void rotate (int ID, int velocity)
 
void SetServoLimit (int ID, int upperLimit)
 
void SetMotormode (int ID, int velocity)
 
void SetID (int ID, int newID)
 
void Reset (int ID)
 
byte sendWait (const byte what)
 

Public Attributes

int velocity_temp
 
int upperLimit_temp
 
int cs
 

Detailed Description

Definition at line 1486 of file eBoard.h.

Constructor & Destructor Documentation

◆ ServoCds55()

ServoCds55::ServoCds55 ( int  CS = 53)

Definition at line 1508 of file eBoard.h.

References upperLimit_temp, and velocity_temp.

1508  :cs(CS) {
1509  velocity_temp = 150;
1510  upperLimit_temp = 300;
1511  }
int velocity_temp
Definition: eBoard.h:1504
int upperLimit_temp
Definition: eBoard.h:1505
int cs
Definition: eBoard.h:1506

Member Function Documentation

◆ begin()

void ServoCds55::begin ( void  )

Definition at line 1512 of file eBoard.h.

References eagle_impl::SPIClass::begin(), cs, eagle_impl::SPIClass::setClockDivider(), SPI, and SPI_CLOCK_DIV8.

Referenced by setup().

1512  {
1513  pinMode(cs,OUTPUT);
1514  digitalWrite(cs,HIGH);
1515  SPI.begin ();
1517  }
static void begin(void)
Definition: eBoard.h:613
static void setClockDivider(uint8_t rate)
Definition: eBoard.h:627
#define SPI_CLOCK_DIV8
Definition: eBoard.h:567
SPIClass SPI
Definition: eBoard.h:632
int cs
Definition: eBoard.h:1506
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Reset()

void ServoCds55::Reset ( int  ID)

Definition at line 1579 of file eBoard.h.

References cs, and sendWait().

1579  {
1580  digitalWrite(cs, LOW);
1581  sendWait ('r'); sendWait (ID);
1582  sendWait ('\t'); sendWait ('\r'); sendWait ('\n');
1583  digitalWrite(cs, HIGH);
1584  delay(10);
1585  }
byte sendWait(const byte what)
Definition: eBoard.h:1518
int cs
Definition: eBoard.h:1506
+ Here is the call graph for this function:

◆ rotate()

void ServoCds55::rotate ( int  ID,
int  velocity 
)

Definition at line 1533 of file eBoard.h.

References SetMotormode(), and SetServoLimit().

1533  { // Motor Mode
1534  SetServoLimit(ID,0);
1535  delay(100);
1536  SetMotormode(ID,velocity);
1537  }
void SetServoLimit(int ID, int upperLimit)
Definition: eBoard.h:1551
void SetMotormode(int ID, int velocity)
Definition: eBoard.h:1561
+ Here is the call graph for this function:

◆ sendWait()

byte ServoCds55::sendWait ( const byte  what)

Definition at line 1518 of file eBoard.h.

References SPI, and eagle_impl::SPIClass::transfer().

Referenced by Reset(), SetID(), SetMotormode(), SetServoLimit(), and WritePos().

1518  {
1519  byte a = SPI.transfer (what);
1520  delayMicroseconds (20);
1521  return a;
1522  }
SPIClass SPI
Definition: eBoard.h:632
static byte transfer(byte _data)
Definition: eBoard.h:606
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetID()

void ServoCds55::SetID ( int  ID,
int  newID 
)

Definition at line 1571 of file eBoard.h.

References cs, and sendWait().

1571  {
1572  digitalWrite(cs, LOW);
1573  sendWait ('i'); sendWait (ID);
1574  sendWait (newID);
1575  sendWait ('\t'); sendWait ('\r'); sendWait ('\n');
1576  digitalWrite(cs, HIGH);
1577  delay(10);
1578  }
byte sendWait(const byte what)
Definition: eBoard.h:1518
int cs
Definition: eBoard.h:1506
+ Here is the call graph for this function:

◆ SetMotormode()

void ServoCds55::SetMotormode ( int  ID,
int  velocity 
)

Definition at line 1561 of file eBoard.h.

References cs, and sendWait().

Referenced by rotate().

1561  {
1562  int velocityB = (velocity>>8 & 0xff);
1563  int velocityS = (velocity & 0xff);
1564  digitalWrite(cs, LOW);
1565  sendWait ('m'); sendWait (ID);
1566  sendWait (velocityB); sendWait (velocityS);
1567  sendWait ('\t'); sendWait ('\r'); sendWait ('\n');
1568  digitalWrite(cs, HIGH);
1569  delay(10);
1570  }
byte sendWait(const byte what)
Definition: eBoard.h:1518
int cs
Definition: eBoard.h:1506
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setPoslimit()

void ServoCds55::setPoslimit ( int  posLimit)
inline

Definition at line 1526 of file eBoard.h.

References upperLimit_temp.

1526  { // set servo pos limit
1527  upperLimit_temp = posLimit;
1528  }
int upperLimit_temp
Definition: eBoard.h:1505

◆ SetServoLimit()

void ServoCds55::SetServoLimit ( int  ID,
int  upperLimit 
)

Definition at line 1551 of file eBoard.h.

References cs, sendWait(), and upperLimit_temp.

Referenced by rotate(), AX12Servo::setID(), and write().

1551  {
1552  int upperLimitB = (upperLimit_temp>>8 & 0xff);
1553  int upperLimitS = (upperLimit_temp & 0xff);
1554  digitalWrite(cs, LOW);
1555  sendWait ('s'); sendWait (ID);
1556  sendWait (upperLimitB); sendWait (upperLimitS);
1557  sendWait ('\t'); sendWait ('\r'); sendWait ('\n');
1558  digitalWrite(cs, HIGH);
1559  delay(10);
1560  }
byte sendWait(const byte what)
Definition: eBoard.h:1518
int upperLimit_temp
Definition: eBoard.h:1505
int cs
Definition: eBoard.h:1506
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setVelocity()

void ServoCds55::setVelocity ( int  velocity)
inline

Definition at line 1523 of file eBoard.h.

References velocity_temp.

Referenced by AX12Servo::setPosition().

1523  { //set servo velocity
1524  velocity_temp = velocity;
1525  }
int velocity_temp
Definition: eBoard.h:1504
+ Here is the caller graph for this function:

◆ write()

void ServoCds55::write ( int  ID,
int  Pos 
)

Definition at line 1529 of file eBoard.h.

References SetServoLimit(), upperLimit_temp, and WritePos().

Referenced by SoccerBoard::motor(), and AX12Servo::setPosition().

1529  { // Servo Mode
1531  WritePos(ID,Pos);// default velocity:150
1532  }
void SetServoLimit(int ID, int upperLimit)
Definition: eBoard.h:1551
void WritePos(int ID, int Pos)
Definition: eBoard.h:1538
int upperLimit_temp
Definition: eBoard.h:1505
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WritePos()

void ServoCds55::WritePos ( int  ID,
int  Pos 
)

Definition at line 1538 of file eBoard.h.

References cs, sendWait(), and velocity_temp.

Referenced by write().

1538  {
1539  int PosB = (Pos>>8 & 0xff);//low
1540  int PosS = (Pos & 0xff);//high
1541  int velocityB = (velocity_temp>>8 & 0xff);
1542  int velocityS = (velocity_temp & 0xff);
1543  digitalWrite(cs, LOW);
1544  sendWait ('p'); sendWait (ID);
1545  sendWait (PosB); sendWait (PosS);
1546  sendWait (velocityB); sendWait (velocityS);
1547  sendWait ('\t'); sendWait ('\r'); sendWait ('\n');
1548  digitalWrite(cs, HIGH);
1549  delay(10);
1550  }
int velocity_temp
Definition: eBoard.h:1504
byte sendWait(const byte what)
Definition: eBoard.h:1518
int cs
Definition: eBoard.h:1506
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ cs

int ServoCds55::cs

Definition at line 1506 of file eBoard.h.

Referenced by begin(), Reset(), SetID(), SetMotormode(), SetServoLimit(), and WritePos().

◆ upperLimit_temp

int ServoCds55::upperLimit_temp

Definition at line 1505 of file eBoard.h.

Referenced by ServoCds55(), AX12Servo::setID(), setPoslimit(), SetServoLimit(), and write().

◆ velocity_temp

int ServoCds55::velocity_temp

Definition at line 1504 of file eBoard.h.

Referenced by ServoCds55(), setVelocity(), and WritePos().


The documentation for this struct was generated from the following file: