![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
ti bisogna il phaserunner
Dependencies: mbed PID mbed-rtos
Diff: Peripherien/Phaserunner.h
- Revision:
- 11:39bd79605827
- Parent:
- 9:56aed8c6779f
--- a/Peripherien/Phaserunner.h Wed May 29 18:57:39 2019 +0000 +++ b/Peripherien/Phaserunner.h Tue Jun 04 19:03:39 2019 +0000 @@ -23,14 +23,20 @@ //Modbus-Protokoll static const uint8_t SCHREIBANTWORT = 0x10; static const uint8_t LESEANTWORT = 0x03; - + + //Pedale oder Motor + const uint8_t PHASERUNNERTYPE; //Sonstiges static const uint16_t WRITE_PERIOD = 3; //Minimaler Zeitintervall zwischen zwei Messages an den Phaserunner [ms] static const float TICKER_PERIOD = 0.02f; //Zeitintervall für das Schreiben auf den Phaserunner [s] - + + AnalogOut* analogOut; //Wenn der Phaserunner Pedale kontrolliert, hat er einen analogOut + //Thread thread; //Wird für die Funktion writeToPhaserunner() gebraucht - Ticker ticker; + + Ticker ticker; //Wird gebraucht um nicht zu häufig zu schreiben + uint8_t timer; //Zeit, die vergehen muss, bis wieder geschrieben werden kann [ms] //Verbindung zum Phaserunner RawSerial& connection; @@ -75,7 +81,7 @@ * @param value: Wert der in das Register geschriebern werden soll. * @return Anzahl gesendeter Bytes */ - //int sendBuffer(unsigned short adress, unsigned short value); + int sendBuffer(unsigned short adress, unsigned short value); /** * @brief Sendet den writeBuffer @@ -89,7 +95,7 @@ * @param adress: Adresse des Registers aus dem gelesen werden soll. * @return: Anzahl gelesener Bytes */ - //int readBuffer(uint16_t adress); + int readBuffer(uint16_t adress); /** * @brief: Schreibt ein Drehmoment auf den Phaserunner. @@ -98,6 +104,12 @@ void writeTorque(uint8_t torque); /** + * @brief Schreibt einen Analogwert mit dem das Drehmoment kontrolliert wird. + * @param torque + */ + void analogTorque(uint8_t torque); + + /** * @brief: Schreibt den Rekuperationswert auf den Phaserunner. * @param: recuperation Rekupertation in Prozent */ @@ -111,9 +123,9 @@ static uint16_t getCRC(uint8_t* msgByte, uint8_t length); /** - * @brief: Sendet kontinuierlich einen Lesebefehl auf den Phaserunner. + * @brief: Sendet Befehle dem Phaserunner sobald es möglich ist. */ - void writeToPhaserunner(); + //void writeToPhaserunner(); /** * @brief: Sendet einen Schreibbefehl für die Drehgewschwindigkeit, die Stromstärke und die Spannung @@ -126,12 +138,21 @@ */ uint16_t readFaults(); + /** + * Reduziert den timer (Wird mit dem Ticker aufgerufen). + */ + void reduce_timer(); + public: static const uint8_t MAX_TORQUE_GAIN = 2; //Maximaler Sprung für Drehmoment static const uint8_t MIN_RECUPERATION = 10; //Schwellwert für die Aktivierung des Daumengriffbetätigers static const uint8_t MIN_HANDGRIFF = 5; //Schwellwert für die Aktivierung des Handgriffbetätigers - int sendBuffer(unsigned short adress, unsigned short value); - int readBuffer(uint16_t adress); + + static const uint8_t PEDALS = 0; //Phaserunner Type Pedal + static const uint8_t MOTORS = 1; //Phaserunner Type Motor + + //int sendBuffer(unsigned short adress, unsigned short value); + //int readBuffer(uint16_t adress); /** * @brief Initialisiert ein Phaserunner-Objekt * @param connection: Serielle Schnittstelle zum Phaserunner @@ -139,6 +160,13 @@ Phaserunner(RawSerial& connection); /** + * Konstruktor für Pedale + * @param connection + * @param analogOut + */ + Phaserunner(RawSerial& connection, AnalogOut* analogOut); + + /** * @brief: Schreibt ein Drehmoment ins Phaserunnerobjekt, das dann geschrieben wird. * @param: torque Drehmoment in Prozent */ @@ -164,7 +192,7 @@ * @return spannung */ float getVoltage(); - + /** * @return Ebrike Source */ @@ -175,7 +203,7 @@ uint8_t bufPointer; uint8_t read; DigitalOut led; - + uint16_t getRecup(); };