RasPi rettet ODO nach Reifenwechsel

Nach 3000 km waren die dünnen Reifenflanken der Schwalbe Tryker auf den Vorderrädern an verschiedenen Stellen angeritzt und aufgerissen. Der rechte Reifen gab nach und der Schlauch platzte. Nun bin ich von 40 mm breiten Trykern auf 28 mm schmale Duranos umgestiegen: Schwupps, zeigte der Radcomputer eine höhere Geschwindigkeit an. Ich war aber nicht schneller angekommen: Der Reifenumfang in den Radcomputer-Einstellungen musste ja noch geändert werden. Dabei ist es dann passiert: Auf die falsche Taste gedrückt und der Gesamtkilometerstand war weg. Beim meinem Cateye Enduro Modell lässt sich dieser nicht manuell einstellen! Aargh!

Ist eigentlich egal. Wenn es aber doch ein schnelles Workaround gäbe? Gibt es: Mit Klebefilm Drähte an die Kontakte des Radcomputers kleben. Den positiven Pol des Tachos mit dem Emitter eines PNP Transistors verbinden. Der negative Tacho-Kontakt wird an den Kollektor angeschlossen. Der Kollektor wird ebenso mit der Masse des RasPi verbunden. Die Basis wird über einen Widerstand an einen GPIO Pin des RasPi angeschlossen (hier Pin 8 bzw. GPIO 14). Schließlich als Superuser das unten gelistete Python Skript starten.

Die »Höchstgeschwindigkeit« zeigt der Radcomputer mit 199,9 km/h an.  Die Kilometer werden mit den obigen Settings aber mit 501 km pro Stunde hochgezählt. Ein paar Stunden oder Tage dauert das Workaround also schon…

#!/usr/bin/env python3

'''
cateye_set_odo.py

To set the total distance of your Cateye Enduro:
Connect the positive contact of the cyclocomputer
and the emitter of an PNP Transistor (e.g BC557B).
The mass contact of the cyclocomputer is connected
with the collector. Also, wire the collector to the
a mass contact of the RasPi. One of the GPIO Pins
(here Pin 8, GPIO 14 respectively) goes to the base
of the transistor. Finally use identical settings
for the the wheel circumference in the cateye and
this script. Select the kilometers to go, lauch
the script as superuser and wait. The cyclocomputer
will display a speed of 199.9 km/h. In fact, it
will increase the total distance at a rate of 501 km/h.
'''

import RPi.GPIO as GPIO
import time
c = 1.46 # circumference in m
odo = 3509 # km to cycle
r = int(odo * 1000 / c ) # rounds
GPIO.setmode(GPIO.BOARD)
GPIO.setup(8, GPIO.OUT)
try:
   for i in range(r):
      GPIO.output(8, GPIO.LOW)
      time.sleep(0.005)
      GPIO.output(8, GPIO.HIGH)
      time.sleep(0.005)
      if (i % 1000 == 0):
         print('km: ' + str( i * c / 1000 ))
except (KeyboardInterrupt, SystemExit):
   GPIO.cleanup()

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert