Skip to content

TrumpetDude/Hand-Code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

Hand Code

High-Level Description of Code Function and Hardware Used

The script "processInput.py" takes input from a MyoWare Muscle Sensor through an Analog to Digital Converter (ADC) and sets servos or linear actuator according to the input recieved. The code runs on a Raspberry Pi (we are using a Pi 2 Model B)

Further Documentation of Product

A Google Drive folder with other files and documentation related to this project can be found here.

Nitty-Gritty Code Stuff

Overview of Program Flow

processInput.py runs in an infinite loop after importing the necessary libraries and initializing variables and objects for the devices. The 5 most recent imput values are stored in a list, and each time the loop iterates and a value is taken, it is added to the list and the least recent input value is removed. The list is ordered least to greatest and the median value is used to set the position of the servo or linear actuator. The value is converted to a value to that is scaled to be in the range of the hardware. The values used to scale the input are stored in a text file that is generated by calibration.py.

Libraries

from __future__ import division Let the interpreter know to look for more modules.

import Adafruit_ADS1x15 Library for the ADC

import Adafruit_PCA9685 Library for Servo Hat

A list of libraries that had to be installed on the pi before use can be found here.

Conversion from MyoWare input values to Servo and Linear Actuator output values

Input values from the Myoware sensor's EMG electrodes, after going through the ADC, vary from user to user. Usually, they are around 4000 relaxed and 24000 tensed. calibration.py detects the user's average relaxed and tensed muscle values, and through an algorithm demonstrated in this Desmos graph, finds the values that the input must be scaled and shifted by to match the hardware's output. These values are saved to a equationValues.txt and they are read by processInput.py. calibration.py also sets the mode ("linear actuator" or "servo" and sets the scale/offset and the min/max values accordingly.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages