-
Notifications
You must be signed in to change notification settings - Fork 0
Training Game
This wiki page provides documentation for the "Training Game for Dewclaw" program. This program is designed to be used with a Dewclaw, utilizing the A5 and A4 pins for bioamp input. It combines signals from these pins to simulate the interaction of flexor and extensor muscles, creating a one Degree of Freedom (DoF) training game. The program generates a random goal position and challenges the user to hold that position for a certain time interval. Once this is achieved, the goal changes to a new position. If the user is too far from the goal, they will have to hold the position longer.
The program uses an Arduino board with the following components and features:
- Two analog input pins, A5 (FLX1) and A4 (EXT1), for reading muscle sensor data.
- Two digital input pins, SWT1 and SWT2, which can be used for additional functionality.
- A Servo motor (connected to pin 9) for controlling the Dewclaw.
- Serial communication for debugging and monitoring.
-
REFRESH_INTERVAL
: Set to 3003, defining the servo refresh interval. This is specifically for a Savox SV1232MG Servo. Other servos might have different refresh rates.
-
FLX1
andEXT1
are defined as the analog input pins for muscle sensors. -
SWT1
andSWT2
are defined as digital input pins. - Various scaling factors (
sc1
andsc2
), deadzones (deadzone1
anddeadzone2
), and a circular buffer (buffer1
,buffer2
, andbuffer3
) are initialized to process and store sensor data. - A Servo motor (
myServo
) is configured with its attachment and limits.
In the setup()
function:
- Pin modes are set for
FLX1
,EXT1
,SWT1
, andSWT2
. - The Servo motor is attached to pin 9 with specified pulse width limits.
- Serial communication is initialized at a baud rate of 9600 for debugging.
The loop()
function implements the training game logic:
- Read raw data from the muscle sensors (
raw1
andraw2
) and add them to circular buffers (buffer1
andbuffer2
). - Calculate component values based on sensor data and buffer averages.
- Apply scaling and constraints to determine the combined position (
combined
) of the Dewclaw. - Add the combined position to a circular buffer (
buffer3
) to smooth the motion. - Map the smoothed position (
pos
) to servo motor angles. - Generate random goal positions and track how closely the user matches the goal position.
- Control the servo motor to move the Dewclaw to the calculated position (
pos
). - Print the current position and goal position via serial communication.
- Connect the Dewclaw and muscle sensors to the appropriate pins on the Arduino board.
- Upload the program to the Arduino.
- Open the serial monitor to observe the training game in action.
- The Dewclaw will move, and the user's goal is to match the Dewclaw's position as closely as possible.
- You can adjust the scaling factors (
sc1
andsc2
) and deadzones (deadzone1
anddeadzone2
) to fit your preferences or the specific characteristics of your setup. - Modify the code to add further functionality or integrate with external devices.
Please do not sell the Dewclaw. The main aims of this project are to provide a cheap prosthetic and a gateway to research into human augmentation