Introduction          Mechanical Design          Electrical Design          Software          Results and Reflections          Meet the Team          Parts

 

Software

 

The micoprocessor control of our system was achieved using an Interactive C program downloaded into our hanyboard. Our Interactive C program is very simple, but it effectively achieved the desired motor control. The psuedocode for our system is seen below.

***********************************

INITIALIZE servo1
INITIALIZE servo2
HOME servo1
HOME servo2

Do While STOP not pushed

       If player1=flexed & player1_switch=on
              MOVE servo1 FORWARD
              MOVE servo1 BACK
       End If

       If player2=flexed & player2_switch=on
               MOVE servo2 FORWARD
               MOVE servo2 BACK
       End If

End While

DEINITIALIZE servo1
DEINITIALIZE servo2

***********************************

To run two servos simultaneously using the handyboard *.icb files were downloaded from the Handyboard web site.

The signal from each emg circuit came into the Handyboard as a digital TTL signal. When the Handyboard saw the emg signal go from 0 to 1 (flexion), and the digital input corresponding to the SPST switch also read 1 (to ensure the circuit was activated), the Handyboard actuated the corresponding servo. The servo then moved along a specified path. The Handyboard monitored each players' respective circuits to ensure independent control.

Initially we had configured individual processes for each user (i.e. the If statement for each player was run as a respective process). These processes were run simultaneously and polling was used to ensure that user inputs were recognized.
Unfortunately this did not work. We found that the motors would move in synchrony when processes and polling were used. In effect the motors were not independently controlled; a single user input would result in actuation of both motors. We tried increasing the sleep times between servo commands however this did not solve the problem. The problem was finally resolved by using a while loop as outlined in our psuedocode.

The complete code for the Handyboard program is shown below.

 


void flexion() {

/*Runs program until stop button is pushed*/
while(!stop_button()){


/*Initializes Servos after the startbutton has been pushed*/
if (start_button()){
servo_a7_init(1);
sleep(0.2);
servo_a7_pulse=3640;

servo_a5_init(1);
sleep(0.2);
servo_a5_pulse=2840;

}

/*Checks if a signal above 5V threshold has been revieved from the EMG sensor &*/
/*Checks if the switch to activate the users sensor is on*/
if (digital(13) == 0 && digital(12)==1){
servo_a7_pulse=2540;
sleep(0.2);
servo_a7_pulse=3640;
}

/*Checks if a signal above 5V threshold has been revieved from the EMG sensor &*/
/*Checks if the switch to activate the users sensor is on*/
if (digital(14) == 0 && digital(15)==0){
servo_a5_pulse=3540;
sleep(0.2);
servo_a5_pulse=2840;
}

}

/*shuts servos off*/
servo_a7_init(0);
servo_a5_init(0);
}