Têtière articulée
Projet réalisé par Camille, Fred, Patrick, et Philippe.
Projet abandonné
Présentation
Le projet a été initié suite à une demande de Vincent, kinésithérapeute au service MPR du CHU Grenoble Alpes, département Hôpital Couple Enfant.
Une jeune patiente, Audrey, utilisatrice d'un fauteuil roulant, subit un dysfonctionnement mécanique lorsqu'elle change la position de son dossier. La têtière qui maintient sa tête ayant une position fixe par rapport au dossier, perd le maintien de la tête lorsque le dossier passe en position verticale.
La maladie d'Audrey ne lui permettant pas de relever la tête, il faut donc trouver une solution mécanique pour palier le défaut du mécanisme existant.
Vincent, dont le cabinet de kinésithérapie est voisin de celui de Véronique, ergothérapeute qui connait bien la team Gre-Nable, nous a contacté pour tester notre capacité à inventer un système qui adapterait la position de la têtière à la position du dossier.
team Gre-Nable, membre de l'association e-Nable France et constituée de membres du LOG, a relevé le défi et conçoit une articulation motorisée 3 axes, qui sera pilotée directement par Audrey. La team reçoit également l'aide de membres éminents du LOG.
Ressources
Comme pour les projets de prothèses, la team n'utilise que des solutions open-source ou gratuites et des produits facilement accessibles. Tous nos projets sont open-source et les détails de conception sont disponibles sur demande.
Développement
CAO
ONSHAPE : application en-ligne de CAO paramétrable, collaborative, gratuite pour les makers, développée par les concepteurs de SolidWorks.
(nécessite de créer un compte)
BOM Electronique
- CPU : ESP32-S2 (carte WEMOS ESP32 mini) chez aliexpress : [1]
- Joystick 3 axes, sourcé chez aliexpress [2] ou équivalent
- 3 moteurs avec réducteurs, sourcé chez aliexpress [3] ou équivalents
- 2 drivers moteur à base de L298N [4] ou équivalents
Logiciel applicatif
- programme développé en Micropython (compatible Espressif).
Mécanique
- sous ensemble de type V-slot [openbuilds] (profilé, chariot, roulettes ....)
- en cours d'évolution suite à une trop grande souplesse
- pièces spécifiques obtenues en impression 3D, principalement en ABS ou PLA.
Intégration
Attribution des GPIO de l'ESP32 S3
les affectations GPIO sont susceptibles d'évoluer. La mise à jour sera faite après la livraison !!
- GPIO3 --> endswitch_HI moteur A (pullup au 3.3V via une résistance de 10 kohms)
- GPIO5 --> endswitch_LO moteur A (pullup au 3.3V via une résistance de 10 kohms)
- GPIO7 --> endswitch_HI moteur B (pullup au 3.3V via une résistance de 10 kohms)
- GPIO9 --> endswitch_LO moteur B (pullup au 3.3V via une résistance de 10 kohms)
- GPIO11 --> endswitch_HI moteur C (pullup au 3.3V via une résistance de 10 kohms)
- GPIO12 --> endswitch_LO moteur C (pullup au 3.3V via une résistance de 10 kohms)
- GPIO39 --> driver#1 IN4 > moteur A
- GPI037 --> driver#1 IN3 > moteur A
- GPIO35 --> driver#1 IN2 > moteur B
- GPI033 --> driver#1 IN1 > moteur B
- GPIO18 --> driver#2 IN4 > moteur C
- GPI017 --> driver#2 IN3 > moteur C
- GPIO13 --> I2C SDC (clock) pullup au 3.3V via une résistance de 2.2 kohms
- GPIO14 --> I2C SDA (data) pullup au 3.3V via une résistance de 2.2 kohms
Programmation et Code Source
Le programme (écrit par Fred) est exécuté en microPython, le développement est réalisé avec l'IDE "Thonny".
Une library servoNode pilote le joystick via i2c, la carte d'interfaçage du joystick a été conçue également par fred.
servoNode.py
<syntaxhighlight lang="python">
- -*- coding: utf-8 -*-
""" ServoNode class """
import micropython import machine
class ServoNode:
""" """ REG_INPUTS = micropython.const(0x00) # RO, uint8_t REG_ADC_0 = micropython.const(0x01) # RO, uint8_t REG_ADC_1 = micropython.const(0x02) # RO, uint8_t REG_ADC_2 = micropython.const(0x03) # RO, uint8_t REG_ADC_3 = micropython.const(0x04) # RO, uint8_t REG_CONFIG = micropython.const(0x05) # R/W, uint8_t
INVERT_INPUT_0 = micropython.const(0x01) # 0=normal, 1=inverted INVERT_INPUT_1 = micropython.const(0x02) # 0=normal, 1=inverted INVERT_INPUT_2 = micropython.const(0x04) # 0=normal, 1=inverted INVERT_INPUT_3 = micropython.const(0x08) # 0=normal, 1=inverted INVERT_ADC_0 = micropython.const(0x10) # 0=normal, 1=inverted INVERT_ADC_1 = micropython.const(0x20) # 0=normal, 1=inverted INVERT_ADC_2 = micropython.const(0x40) # 0=normal, 1=inverted INVERT_ADC_3 = micropython.const(0x80) # 0=normal, 1=inverted
ADC_0 = micropython.const(0) ADC_1 = micropython.const(1) ADC_2 = micropython.const(2) ADC_3 = micropython.const(3)
INPUT_0 = micropython.const(0) INPUT_1 = micropython.const(1) INPUT_2 = micropython.const(2) INPUT_3 = micropython.const(3)
def __init__(self, i2cBus, address=0x10):
"""
"""
self._i2cBus = i2cBus
self._address = address
self._inputs = 0
self._adc = 4 * [0]
self.refresh()
def _i2cRead(self, reg):
"""
"""
self._i2cBus.writeto(self._address, reg.to_bytes(1, 'big'))
value = self._i2cBus.readfrom(self._address, 1)
return int.from_bytes(value, 'big')
def _i2cWrite(reg, value):
"""
"""
self._i2cBus.writeto(self._address, reg.to_bytes(1, 'big'), stop=False)
self._i2cBus.writeto(self._address, value.to_bytes(1, 'big'))
def refresh(self):
"""
"""
self._inputs = self._i2cRead(self.REG_INPUTS)
self._adc[0] = self._i2cRead(self.REG_ADC_0)
self._adc[1] = self._i2cRead(self.REG_ADC_1)
self._adc[2] = self._i2cRead(self.REG_ADC_2)
self._adc[3] = self._i2cRead(self.REG_ADC_3)
def getInput(self, inputNum):
"""
"""
return (self._inputs & (1 << inputNum)) >> inputNum
def getAdc(self, adcNum):
"""
"""
return self._adc[adcNum]
def readConfig(self):
"""
"""
return self._i2cRead(self.REG_CONFIG)
def writeConfig(self, config):
"""
"""
self._i2cWrite(self.REG_CONFIG, config)
def main():
"""
"""
i2c = machine.I2C(0, scl=machine.Pin(13), sda=machine.Pin(14))
print("I2C devices:", i2c.scan())
joystick = ServoNode(i2c)
print()
print(" ADC INPUTS")
print(" 0 1 2 3 0 1 2 3")
while True:
joystick.refresh();
adc0 = joystick.getAdc(ServoNode.ADC_0)
adc1 = joystick.getAdc(ServoNode.ADC_1)
adc2 = joystick.getAdc(ServoNode.ADC_2)
adc3 = joystick.getAdc(ServoNode.ADC_3)
inp0 = joystick.getInput(ServoNode.INPUT_0)
inp1 = joystick.getInput(ServoNode.INPUT_1)
inp2 = joystick.getInput(ServoNode.INPUT_2)
inp3 = joystick.getInput(ServoNode.INPUT_3)
print(f"{adc0:03d} {adc1:03d} {adc2:03d} {adc3:03d} {inp0:1d} {inp1:1d} {inp2:1d} {inp3:1d}\r", end=)
if __name__ == "__main__":
main()
</syntaxhighlight>
L'appli consiste de 3 scripts:
- boot.py
- config.py
- main.py
boot.py
<syntaxhighlight lang="python">
- This file is executed on every boot (including wake-boot from deepsleep)
- import esp
- esp.osdebug(None)
- import webrepl
- webrepl.start()
import main </syntaxhighlight>
config.py
<syntaxhighlight lang="python">
- -*- coding: utf-8 -*-
""" Pilotage de têtière. """
import micropython
- Consts
IN1_PIN = {
'A': micropython.const(39), 'B': micropython.const(35), 'C': micropython.const(40)
} IN2_PIN = {
'A': micropython.const(37), 'B': micropython.const(33), 'C': micropython.const(36)
} PWM_PIN = {
'A': micropython.const(38), 'B': micropython.const(34), 'C': micropython.const(21)
} ENDSTOP_UP_PIN = {
'A': micropython.const(3), 'B': micropython.const(7), 'C': micropython.const(11)
} ENDSTOP_DOWN_PIN = {
'A': micropython.const(5), 'B': micropython.const(9), 'C': micropython.const(12)
} DEAD_ZONE = {
'A': micropython.const(16), # to avoid moves when joystick centered (motor A) 'B': micropython.const(16), # to avoid moves when joystick centered (motor B) 'C': micropython.const(16) # to avoid moves when joystick centered (motor C)
} DUTY_MAX = {
'A': micropython.const(65535), # can be used to adjust motor A max speed 'B': micropython.const(65535), # can be used to adjust motor B max speed 'C': micropython.const(65535) # can be used to adjust motor C max speed
}
PWM_FREQ = micropython.const(30000) # PWM frequency (in Hz) </syntaxhighlight>
main.py
<syntaxhighlight lang="python">
- -*- coding: utf-8 -*-
""" Pilotage de têtière. """
import machine
import servoNode
from config import *
- Create I²C bus
i2c = machine.I2C(0, scl=machine.Pin(13), sda=machine.Pin(14))
- Print connected I²C devices
print("I2C devices:", i2c.scan())
- Create joystick device
joystick = servoNode.ServoNode(i2c)
- Create DC motors I/O
motors = {} for axis in ('A', 'B', 'C'):
motors[axis] = {
'pwm': machine.PWM(machine.Pin(PWM_PIN[axis]), freq=PWM_FREQ, duty_u16=0),
'in1': machine.Pin(IN1_PIN[axis], mode=machine.Pin.OUT),
'in2': machine.Pin(IN2_PIN[axis], mode=machine.Pin.OUT),
'endstop_up': machine.Pin(ENDSTOP_UP_PIN[axis], mode=machine.Pin.IN, pull=machine.Pin.PULL_UP),
'endstop_down': machine.Pin(ENDSTOP_DOWN_PIN[axis], mode=machine.Pin.IN, pull=machine.Pin.PULL_UP)
}
- Main loop
while True:
# Refresh joystick values joystick.refresh();
# Get joystick values
adc = {
'A': joystick.getAdc(joystick.ADC_0),
'B': joystick.getAdc(joystick.ADC_1),
'C': joystick.getAdc(joystick.ADC_3)
}
- print(adc)
button = joystick.getInput(joystick.INPUT_0)
for axis in ('A', 'B', 'C'):
endstop_down = motors[axis]['endstop_down'].value()
endstop_up = motors[axis]['endstop_up'].value()
if adc[axis] <= 127-DEAD_ZONE[axis] and not endstop_down:
in1 = 0
in2 = 1
speed = 127 - adc[axis]
elif adc[axis] >= 128+DEAD_ZONE[axis] and not endstop_up:
in1 = 1
in2 = 0
speed = adc[axis] - 128
else:
in1 = 1 # 0 pour roue libre
in2 = 1 # 0 pour roue libre
speed = 127 # 0 pour roue libre
print(f"{axis}: in1={in1}, in2={in2}, speed={speed:03d} (endstop={endstop_down}/{endstop_up}) - ", end=)
motors[axis]['in1'].value(in1)
motors[axis]['in2'].value(in2)
motors[axis]['pwm'].duty_u16(int(speed/127*DUTY_MAX[axis]))
print('\r', end=)
</syntaxhighlight>