Arduino_VESC_Library
vesc.h
Go to the documentation of this file.
1 /*
2  * This file is part of the arduino vesc library (https://github.com/arduino_vesc)
3  *
4  * Copyright (c) 2019 Gianmarco Vitelli
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, version 3.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 #ifndef Vesc_h
19 #define Vesc_h
20 
21 #include <Arduino.h>
22 #include "vesc_types.h"
23 #include "vesc_packet.h"
24 
28 class Vesc {
29 
30  public:
31  Vesc(void);
32  void init(HardwareSerial* uartPort, HardwareSerial* debugPort);
33  void setDuty(float duty);
34  void setCurrent(float current);
35  void setBrakeCurrent(float current);
36  void setRPM(int32_t rpm);
37  void setPosition(float position);
38  void setHandbrake(float current);
42  float getFetTemperature();
43  float getMotorTemperature();
44  float getAvgMotorCurrent();
45  float getAvgInputCurrent();
46  float getResetAvgId();
47  float getResetAvgIq();
48  float getDutyCycleNow();
49  float getRPM();
50  float getInputVoltage();
51  float getAmpHours();
52  float getaAmpHoursCharged();
53  float getWattHours();
54  float getWattHoursCharged();
55  int32_t getTachometerValue();
56  int32_t getTachometerAbsValue();
57  uint8_t getFault();
58  float getPidPosNow();
59  uint8_t getControllerId();
60  float* getMosfetsTemperature();
61  float getResetAvgVd();
62  float getResetAvgVq();
63 
64  private:
65  HardwareSerial* uartPort = NULL;
66  HardwareSerial* debugPort = NULL;
67 
68  void sendPacket(unsigned char *data, unsigned int len);
69  bool receivePacket(unsigned char *data);
70  bool getRealtimeValuesSelective(unsigned char *data, unsigned int index);
71 };
72 
73 #endif
Vesc::setHandbrake
void setHandbrake(float current)
set handbreak 0 - MAX
Definition: vesc.cpp:114
Vesc::getPidPosNow
float getPidPosNow()
get pid pos now
Definition: vesc.cpp:477
Vesc::getRealtimeValues
vesc_values getRealtimeValues()
get real time values
Definition: vesc.cpp:160
Vesc::getMosfetsTemperature
float * getMosfetsTemperature()
get mosfets temperature
Definition: vesc.cpp:510
Vesc::getAmpHours
float getAmpHours()
get amp hours
Definition: vesc.cpp:359
Vesc::setRPM
void setRPM(int32_t rpm)
set rpm to set 0 - MAX
Definition: vesc.cpp:86
Vesc::getTachometerAbsValue
int32_t getTachometerAbsValue()
get tachometer abs value
Definition: vesc.cpp:444
Vesc::setBrakeCurrent
void setBrakeCurrent(float current)
set current 0 - MAX this value will passed directly to mcpwn / mcfoc / mcbldc and will be not truncat...
Definition: vesc.cpp:72
vesc_packet.h
Vesc::uartPort
HardwareSerial * uartPort
Definition: vesc.h:65
Vesc::init
void init(HardwareSerial *uartPort, HardwareSerial *debugPort)
init vesc interface
Definition: vesc.cpp:31
Vesc::getResetAvgVd
float getResetAvgVd()
get reset average vd
Definition: vesc.cpp:530
Vesc::getResetAvgIq
float getResetAvgIq()
get reset average iq
Definition: vesc.cpp:290
Vesc::receivePacket
bool receivePacket(unsigned char *data)
helper method to receive packet
Definition: vesc.cpp:593
Vesc::getaAmpHoursCharged
float getaAmpHoursCharged()
get amp hours charged
Definition: vesc.cpp:376
Vesc::setCurrent
void setCurrent(float current)
set current 0 - MAX this value will passed directly to mcpwn / mcfoc / mcbldc and will be not truncat...
Definition: vesc.cpp:57
Vesc::getInputVoltage
float getInputVoltage()
get input voltage
Definition: vesc.cpp:341
Vesc::getMotorConfiguration
mc_configuration getMotorConfiguration()
get motor configuration
Definition: vesc.cpp:603
Vesc::getFetTemperature
float getFetTemperature()
get MosFet temperature
Definition: vesc.cpp:205
Vesc::Vesc
Vesc(void)
Definition: vesc.cpp:21
Vesc::getRealtimeValuesSelective
bool getRealtimeValuesSelective(unsigned char *data, unsigned int index)
helper method to retrieve single values from vesc
Definition: vesc.cpp:564
Vesc::getFault
uint8_t getFault()
get fault
Definition: vesc.cpp:461
Vesc
vesc interface
Definition: vesc.h:28
Vesc::getAvgInputCurrent
float getAvgInputCurrent()
get average input current
Definition: vesc.cpp:256
Vesc::getAvgMotorCurrent
float getAvgMotorCurrent()
get average motor current
Definition: vesc.cpp:239
Vesc::debugPort
HardwareSerial * debugPort
Definition: vesc.h:66
Vesc::sendPacket
void sendPacket(unsigned char *data, unsigned int len)
helper method to send packet
Definition: vesc.cpp:581
vesc_types.h
Vesc::getControllerId
uint8_t getControllerId()
get controller id
Definition: vesc.cpp:494
vesc_version
Definition: vesc_types.h:19
Vesc::getWattHoursCharged
float getWattHoursCharged()
get watt hours charged
Definition: vesc.cpp:410
Vesc::getWattHours
float getWattHours()
get watt hours
Definition: vesc.cpp:393
Vesc::setPosition
void setPosition(float position)
set rpm 0 - MAX
Definition: vesc.cpp:100
Vesc::setDuty
void setDuty(float duty)
set duty cycle range 0.0% - 1.0%
Definition: vesc.cpp:42
Vesc::getDutyCycleNow
float getDutyCycleNow()
get duty cycle now
Definition: vesc.cpp:307
Vesc::getRPM
float getRPM()
get rpm
Definition: vesc.cpp:324
Vesc::getFirmwareVersion
vesc_version getFirmwareVersion()
get firmware version
Definition: vesc.cpp:128
Vesc::getResetAvgId
float getResetAvgId()
get reset average id
Definition: vesc.cpp:273
Vesc::getResetAvgVq
float getResetAvgVq()
get reset average vq
Definition: vesc.cpp:547
vesc_values
Definition: vesc_types.h:27
mc_configuration
Definition: vesc_types.h:53
Vesc::getMotorTemperature
float getMotorTemperature()
get motor temperature
Definition: vesc.cpp:222
Vesc::getTachometerValue
int32_t getTachometerValue()
get tachometer value
Definition: vesc.cpp:427