Fall 2016 Prosthetic Hand: Final Code

Electronics and Control Engineer – Younis Al-Kharusi

We have two pieces of code, one for the transmitter side one side and the other for the receiver side. The hand works on two operational modes using a switch. First is the normal mode where fingers move together to form a specific grasping motion such as picking fries. Second is Adjustment mode, where individual fingers can be moved.

On the transmitter side, “Adafruit_MPR121.h” and “Wire.h” librabries are used to control the touch panel. The transmitter sends commands  “X”,”b”,”d”,”f”,”w”,”c”,”o”,”Y”,”Z”. The letter “X” is sent when nothing is touched so that all motors stop. The letter “Y” is sent when the switch is on Adjustment mode. The letter “Z” is sent when the switch  is on Normal mode. The switch is connected to an external interrupt, so that letter “Y” and “Z” are only sent once when the switch is switched. In normal mode “b” is for burger grasp, “f” is for fries grasp, “d” is for drink grasp ,”w” is for wrist clockwise. “c” is for wrist counter clockwise and finally “o” is for open hand. In Adjustment mode “b”,”d”,”f”,”w”,”o” are used to move individual fingers and “c” is used to switch direction of flexion.

On the receiver side, we are using three libraries Adafruit_PWMServoDriver.h, Servo library and Wire library. Adafruit_PWMServoDriver.h is used to control PCA9685 PWM drivers that control the TB6612FNG motor drivers. The Servo library controls the wrist servowire library is for i2c communication. The code incorporates six different subroutines.

motordriver_setup() sets up PWM pins and the standby pin in all of the motor drivers.

DC(motor#,mode) controls all the DC motors. It has three operational modes, GRASP, RELASE and STOP and they are numbered 1,2,3 respectively. In this subroutines a pointer (motor) I used to switch between to different PCA9685 chips. This subroutine is only called in setup();

Read_force() is used to read force sensor data using analogRead. This subroutine is called at the beginning of the code to update sensor data.

Servo(deg) this subroutine is used to control the degree of the thumb servo.

Open_hand(); is used to retract flexed fingered when “open hand” command is sent form transmitter.

Adjust(); is used to move fingers individually instead of moving it collectively. Adjust() is called when the switch on the transmitter side is switched to adjustment operational mode

In the main loop we first read data form the sensors then check if any commands were received then implement the received commands.

Here are the links to the code –

Transmitter Code:

https://drive.google.com/open?id=0BzJlMPCB0tFPTVlOM2NiRmJ5STA

Receiver Code

https://drive.google.com/drive/folders/0BzJlMPCB0tFPbUlEekZpMGFKOTQ?usp=sharing