xCPS
Public Member Functions | Protected Attributes | List of all members
xCPS Class Reference

#include <xCPS.h>

Collaboration diagram for xCPS:
Collaboration graph

Public Member Functions

 xCPS ()
 
void init ()
 
void xcps_sleep (int sleeptime)
 
void shutdown ()
 
void index_enable (int tablenumber)
 
void index_disable (int tablenumber)
 
void turn_moveUp ()
 
void turn_moveDown ()
 
void turn_enable ()
 
void turn_disable ()
 
void turn_grab ()
 
void turn_release ()
 
bool turn_isUp ()
 
bool turn_isDown ()
 
void pickplace_vacuum (bool state)
 
void pickplace_moveUp ()
 
void pickplace_moveDown ()
 
void pickplace_extend ()
 
void pickplace_retract ()
 
bool pickplace_isUp ()
 
bool pickplace_isExt ()
 
bool pickplace_isRetract ()
 
void band_enable (int bandnumber)
 
void band_disable (int bandnumber)
 
void stopper_enable (int stoppernumber)
 
void stopper_disable (int stoppernumber)
 
void switch_enable (int switchnumber)
 
void switch_disable (int switchnumber)
 
void separator_enable ()
 
void separator_disable ()
 
bool separator_isClosed ()
 
bool separator_isOpen ()
 
bool sensor_isUp (int sensornumber)
 
void arm_move (int armnumber, char axis, int position)
 
void arm_enable (int armnumber)
 
void arm_grab (int armnumber)
 
void arm_release (int armnumber)
 
bool arm_isReady (int armnumber)
 

Protected Attributes

Arm arm1
 
Arm arm2
 
IndexTable indextable1
 
IndexTable indextable2
 
CommSystem comm
 
Turner turner
 
PickPlace pplace
 
Band belt1
 
Band belt2
 
Band belt3
 
Band belt4
 
Band belt5
 
Band belt6
 
Stopper stopper14
 
Stopper stopper11
 
Stopper stopper18
 
Stopper stopper12
 
Stopper stopper16
 
Stopper stopperband5
 
Switch switchindex2band4
 
Switch switchband2band6
 
Switch switch100
 
Switch switch200
 
Switch switchband5
 
Separator separate
 
Sensor sensorband2nr4
 
Sensor sensorband2nr1
 
Sensor sensorband2nr2
 
Sensor sensorband2nr6
 
Sensor sensorband2index2
 
Sensor sensorband3pickplace
 
Sensor sensorband4nr9
 
Sensor sensorband6nr7
 
Sensor sensorband4nr10
 
Sensor sensorband2nr3
 
Sensor posband2switch
 
Sensor posindex2pickplace
 
Sensor sensorband5nr20
 
Sensor sensorband5nr10
 
Sensor sensorgriparm2
 
Sensor sensorband1nr21
 
Sensor sensorgriparm1
 
Sensor posindex1band5
 
Sensor posindex1sepa
 
I16 _Card0
 
I16 _Card1
 
I16 _Card2
 
I16 _Read0
 
int _out0
 
int _out1
 
int _out2
 
U32 _in0
 
U32 _in1
 
int arm1position
 
int arm2position
 

Detailed Description

Author
Max Houwing
Contact: m.hou.nosp@m.wing.nosp@m.@stud.nosp@m.ent..nosp@m.tue.n.nosp@m.l / maxho.nosp@m.uwin.nosp@m.g@gma.nosp@m.il.c.nosp@m.om
Date
November 23rd, 2015

This class is the most essential class when using the xCPS machine, since it connects all of the components together, while adding useful functionality. The main thing this class accomplishes is providing a relatively easy interface for all of the options of the machine. All of the sub-components of the xCPS machine are initialized here, giving access to everything the machine has to offer. Furthermore, all of the methods the components are 'referenced' here, such that can be called from within the xCPS class. The general structure of the naming of the methods is the name of the component (also shortend sometimes), followed by the same name the method has inside the component class itself. For example: Turner has a method moveUp(), this becomes "turn_moveUp()" in the xCPS class.

Besides just having references to methods of other classes, the xCPS class itself has three methods as well: xcps_sleep(), init() and shutdown(). The xcps_sleep() method basically just calls a usleep() command, but enums provide specific sleep times for different components. For example, it has been found (through experience) that component such as the Turner and Pick&Place need certain sleep periods in order to function as expected. This is offered by the enums, where the times have been chosen as the shortest delays that have been shown to work. Finally, the init() method is essential to the operation of the xCPS machine, since it initializes things such as communication and enables the arms. The shutdown() method does mostly the exact opposite, and ensures the machine is shutdown in a correct manner. The best way to use the xCPS class is shown in the example below:

xCPS xcps;

xcps.init();

From there, all of the functionality can be used by simply writing xcps, followed by a dot, e.g.: xcps.index_enable(index1).

Constructor & Destructor Documentation

xCPS::xCPS ( )

xCPS class: The main class of the entire xCPS system. This class MUST be instantiated when using the xCPS machine! All components of the system will be created accordingly. Furthermore, it is useful to call the init() function of the xCPS class to initialize the system before use.

Member Function Documentation

void xCPS::arm_enable ( int  armnumber)

Enables the arm, by moving it to its homing position. Please ensure that the arms are already somewhere near their home position to avoid errors! Note that this function is already called in the xCPS init(), so using it is not strictly necessary when using the xCPS class.

void xCPS::arm_grab ( int  armnumber)

Enables the gripper of the arm, allowing the arm to grab on to blocks. Note that the gripper will stay enabled (closed) until arm_release() is called.

bool xCPS::arm_isReady ( int  armnumber)

Returns the readiness of the arm for movement. This boolean can be used as an indicator for whether a (movement) action is still going on, but should mainly be used to check whether the arms have been enabled.

void xCPS::arm_move ( int  armnumber,
char  axis,
int  position 
)

Move the arm along the specified axis to the specified position. These positions are pre-defined integers, and will overwrite any previous positions instead of adding to them . The axes that can be used are 'x', 'y' and 'z'.

void xCPS::arm_release ( int  armnumber)

Disables the gripper of the arm, releasing any block that it might be holding on to.

void xCPS::band_disable ( int  bandnumber)

Disables the band, stopping it from running. Take care that the block most likely will not be stationary immediately. Allowing some time between disable() and the next operation (if it involves the block) might be helpful.

void xCPS::band_enable ( int  bandnumber)

Enables the band by writing its mask to the output. Note that the band will keep running until band_disable() is called!

void xCPS::index_disable ( int  tablenumber)

Disables the given Index Table. Apart from an (integer) 1 and 2, also the enums index1 (= 1) and index2 (= 2) can be used.

void xCPS::index_enable ( int  tablenumber)

Enables the given Index Table. Apart from an (integer) 1 and 2, also the enums index1 and index2 can be used.

void xCPS::init ( )

This function initializes all the commmunication between the components and the xCPS system. This function should always be called after instantiating the xCPS class, to prepare the system for operation. Furthermore, writes zeros to the outputs to ensure a 'clean' start of the machine. Finally, it enables the xCPS arms.

void xCPS::pickplace_extend ( )

Moves the Pick & Place (horizontally) outwards, placing it above the location of the index table. Also checks the sensor input to ensure that it has moved as desired. The 'Extend' bit is then written 0 again, to avoid interfering with possible retracting in the future.

bool xCPS::pickplace_isExt ( )

Checks if the Pick & Place is extended. If it turns out the class has just been initialized, this is done on the basis of sensor data. Otherwise, the boolean _HorExt is simply used. Returns true if the Pick & Place is indeed extended.

bool xCPS::pickplace_isRetract ( )

Checks if the Pick & Place is retracted. If it turns out the class has just been initialized, this is done on the basis of sensor data. Otherwise, the boolean _HorRetract is simply used. Returns true if the Pick & Place is indeed retracted.

bool xCPS::pickplace_isUp ( )

Checks if the Pick & Place is up. If it turns out the class has just been initialized, this is done on the basis of sensor data. Otherwise, the boolean _IsUp is simply used. Returns true if the Pick & Place is indeed up.

void xCPS::pickplace_moveDown ( )

Moves the Pick & Place (vertically) down. Furthermore, checks the sensor input to confirm that the Pick&Place has reached the 'down' position. Then, the 'MoveDown' bit is written 0 again, to avoid interfering with possible moving up in the future.

void xCPS::pickplace_moveUp ( )

Moves the Pick & Place (vertically) up. Furthermore, checks the sensor input to confirm that the Pick&Place has reached the 'up' position. Then, the 'MoveUp' bit is written 0 again, to avoid interfering with possible moving down in the future.

void xCPS::pickplace_retract ( )

Moves the Pick & Place (horizontally) inwards, placing it above the location of the belt (Belt 3). Also checks the sensor input to ensure that it has moved as desired. The 'Retract' bit is then written 0 again, to avoid interfering with possible extending in the future.

void xCPS::pickplace_vacuum ( bool  state)

Turns the vacuum of the Pick & Place, which is used to 'grab' blocks, on or off, depending on the input boolean 'state'. Note that when (for example) calling vacuum(true), the vacuum will stay on until vacuum(false) is called.

bool xCPS::sensor_isUp ( int  sensornumber)

Function that returns true if the sensor is up (high / 1), and returns false if it is down (low / 0). Note: Some optical sensors are permanently high, unless an object 'breaks the beam'! Carefully check the documentation and/or the machine to ensure correct usage.

void xCPS::separator_disable ( )

Disables the separator.

void xCPS::separator_enable ( )

Enables the separator. Note that it will stay enabled until disable() is called.

bool xCPS::separator_isClosed ( )

Function to check if separator is closed. Returns true if indeed closed.

bool xCPS::separator_isOpen ( )

Function to check if separator is open. Returns true if indeed open.

void xCPS::shutdown ( )

Shuts down the xCPS machine in a correct way. Not required, but advised!

void xCPS::stopper_disable ( int  stoppernumber)

Disables the stopper, i.e. retract it such that it no longer prevents an approaching block from passing.

void xCPS::stopper_enable ( int  stoppernumber)

Enables the stopper. Note: with 'enable' is meant: the stopper extends, enabling it to stop an approaching block. The stopper will stay in its extended state until stopper_disable() is called! TODO: CREATE ENUMS THAT MAKE SENSE FOR THE STOPPER - INSTEAD OF NUMBERS 14, 11 ETC.

void xCPS::switch_disable ( int  switchnumber)

Disables the switch.

void xCPS::switch_enable ( int  switchnumber)

Enables the switch. Note that the switch will say enabled (extended) as long as disable() is not called!

void xCPS::turn_disable ( )

Turns the turner back (180 degrees) from the 'turned' state to its original position. Note that there is no sensor data available to check if the turner has been flipped. Therefore, a usleep command of about 150 ms is used to prevent moving the turner before flipping has completed.

void xCPS::turn_enable ( )

Turns the turner 180 degrees. Since the turner can only rotate back from this position, turn_disable should be called to turn it back. Note that there is no sensor data available to check if the turner has been flipped. Therefore, a usleep command of about 150 ms is advised to prevent moving the turner before flipping has completed.

void xCPS::turn_grab ( )

Enables the gripper of the turner. Additionally, sensor data is checked afterwards to ensure that the gripper has properly closed. The gripper will stay closed until turn_release() is called.

bool xCPS::turn_isDown ( )

Returns the 'answer' to the question: is the Turner down? (If yes, it will return true, otherwise it will return false)

bool xCPS::turn_isUp ( )

Returns the 'answer' to the question: is the Turner up? (If yes, it will return true, otherwise it will return false)

void xCPS::turn_moveDown ( )

Moves turner down. Afterwards, checks the sensor input to check when the turner has reached the 'down' position. Then, the 'move down' bit will be set back to 0 to avoid interference with possible future moving up.

void xCPS::turn_moveUp ( )

Moves turner up. Afterwards, checks the sensor input to check when the turner has reached the 'up' position. Then, the 'move up' bit will be set back to 0 to avoid interference with possible future moving down.

void xCPS::turn_release ( )

Releases the gripper of the turner. Additionally, sensor data is checked afterwards to ensure that the gripper has properly opened.

void xCPS::xcps_sleep ( int  sleeptime)

Performs a sleep (in ms) of the xCPS machine. Enums can be for the found 'safe' times.


The documentation for this class was generated from the following files: