I am trying to integrate the vesc with arduino and I am running a simple code to print the voltage and other data into the serial monitor. Below is the code for reference. When I chekc the output, it doesnt seem to be parsing the data correctly. I see the output as @⸮ @⸮ @⸮ @⸮ I am using the code from this github page: VESC-UART-Arduino/VESC_UART_Nano.ino at master · R0b0shack/VESC-UART-Arduino (github.com)
` /* Arduino UART communication with VESC. This software reads VESC telemetr data and displays it on an OLED display. This code is under development for an improved ppm remote control.
It is written by Sascha Ederer (roboshack.wordpress.com), based on the code of jenkie (pedelecforum.de), Andreas Chaitidis ([email protected]) and Benjamin Vedder (www.vedder.se). Copyright (C) 2016
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include “config.h” //#include “printf.h” #include “datatypes.h” #include “vesc_uart.h” #include <SPI.h>
//Library for the OLED Display #include <Wire.h> #include <Adafruit_GFX.h> #include <Adafruit_SSD1306.h>
mc_values VescMeasuredValues;
float current = 0.0; //measured battery current float motor_current = 0.0; //measured motor current float voltage = 0.0; //measured battery voltage float c_speed = 0.0; //measured rpm * Pi * wheel diameter [km] * 60 [minutes] float c_dist = 0.00; //measured odometry tachometer [turns] * Pi * wheel diameter [km] double power = 0.0; //calculated power
#define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET);
//Setup--------------------------------------------------------------------------------------------------------------------- void setup() {
SERIALIO.begin(115200);
/* // initialize with the I2C addr 0x3C
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
// set text color
display.setTextColor(WHITE);
// set text size
display.setTextSize(1);
// set text cursor position
display.setCursor(1,0);
// show text
display.println("System startup");
display.display();
delay(1000);
display.clearDisplay();*/
}
void loop() { if (vesc_get_values(VescMeasuredValues)) {
// calculation of several values to be displayed later on
voltage = VescMeasuredValues.v_in;
current = VescMeasuredValues.current_in;
motor_current = VescMeasuredValues.current_motor;
power = current*voltage;
c_speed = (VescMeasuredValues.rpm/38)*3.14159265359*0.000083*60;
c_dist = (VescMeasuredValues.tachometer/38)*3.14159265359*0.000083;
Serial.println(voltage); //Serial.println(current); /Serial.println(motor_current);Serial.println(power); Serial.println(c_speed); Serial.println(c_dist);/
}
else
{
Serial.println(" ");
} }` Does anyone know what can be causing this issue?