-
Notifications
You must be signed in to change notification settings - Fork 0
Direct Control
Hawkmask edited this page Sep 19, 2023
·
1 revision
This wiki page provides documentation for the "Dewclaw Direct Control Code" program. The program is designed to control the Dewclaw using a single muscle sensor per DoF connected to analog input pins A5 (FLX1) and A4 (EXT1). It calculates the position of the Dewclaw based on the muscle sensor readings and adjusts it to achieve a specified goal position.
The program utilizes an Arduino board and 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
: A constant set to 3003, defining the program's refresh interval. This is hardware dependent
-
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 circular buffers (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 control 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. - Control the servo motor to move the Dewclaw to the calculated position (
pos
). - Print the current position via serial communication for monitoring.
- 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 Dewclaw's position and control.
- You can adjust the scaling factors (
sc1
andsc2
) and deadzones (deadzone1
anddeadzone2
) to suit your preferences or adapt to the specific characteristics of your setup. - Extend the code to include additional functionality or integration 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