Codding Prosthetic Arm

Written by: Fabian Suske

Approved by: Carolina Barrera

 

Intro:

In order to fulfill mission success, the selected components need to brought to live. Therefore the MCU Teensy needed to be programmed.

 

Objective:

The objective of the Code is to read the EMG sensor, the temperature sensor, the kill switch as well as moving the motor. Due the components chosen a variety of challenges needed to be addressed. The main challenge arises due to using a stepper motor in combination with the Allegro A4988 stepper motor driver. This combination needs constant signals from the MCU to the driver while moving. Therefore pulling of items like the kill switch or the temperature sensor are not possible. As a result Interrupt Service Routines (ISR) were used for almost everything.

 

Main components:

EMG

The first ISR was used to read the EMG signals. Prototyping has shown that pulling this value, the way it is required, is not sufficient enough. The arm then reacts funny and junky. It also has a poor response time. Most of this results in the fact, that the user starts using the arm in the middle of the pulling process. As a result the long burst might be interpreted as short ones. Or short ones not at all.

 

This problems were solved once the ISR was implemented. If the user starts using the arm, the Teensy registers an interrupt at the assorted pin. Then the burst duration algorithm “kicks” in and delivers an accurate result.

The code to detect if the user operates the arm or if noise triggered the interrupt is as short as possible in order to not interrupt the movement of the arm.

 

Temperature Sensor

The temperature sensor was another challenge. The way the sensor is designed to work as followed: After a few byte were written into registers on the sensor the sensors starts the temperature reading. Then the user has to wait at least 750ms (a little more is better) before the measurement can be read. If the user tries to read the measurement faster the senor either return one of his “default” values 0 or 85 or it simply returns the last measured value. If the value continuously is read to fast, the value displayed might be obsolete and wrong.

Waiting for 750ms on the other hand is not acceptable while the motor is running. An ISR that performs the reading in a smart way has been implemented:

The ISR will be handled by a timer object. Every time the timer has an overflow the ISR is triggered. Once the ISR is called it checks a flag to see if the sensor is currently reading a measurement or not. If the measurement is not in progress a measurement is started. Once the ISR is triggered the second time 800ms later the values are ready to be read.

In this way no time is wasted with a delay function.

Kill switch

The kill switch is handled in a similar fashion as the EMG sensor. In case the kill switch is triggered due to an external interrupt, the ISR then sends a low signal to the enable pin of the LDO which then shuts down the entire system.

 

Motor control

The last part that’s needs to be coded is the motor control. The previously mentioned EMG-ISR has provided us with the direction of movement (Up, Down or Stop). The constantly called motor routine then moves the arm in the desired way.

In order to not violate our range of motion a few functions needed to be implemented additionally. The 150 degrees of freedom needed to be translated into degrees the motor actually travels. Once the position of the motor was found a routine checked if the desired motion is valid. If the motion is not valid, the arm travels the maximum possible distance.

 

Temperature Protection

In order to shut down the system once an unsafe operating temperature of 55°C is reached yet another ISR has been implemented. This ISR is also based on a timer. Once this ISR detects that the temperature is unsafe, the system is shut down in the same fashion as with the kill switch

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *