SolidGeek / VescUart

An Arduino library for interfacing with the VESC over UART
GNU General Public License v3.0
179 stars 91 forks source link

Doesn't connect to STM32 Blue Pill over Serial1 (PA9 & PA10) #4

Closed neilbalch closed 5 years ago

neilbalch commented 5 years ago

I've been trying to get the sample code to read status parameters to work with my FSESC 4.12 over the STM32 Blue Pill's USART1 port (PA9 and PA10). No such luck, as I keep getting Failed to get data! messages. Do you have any idea what could be causing this?

SolidGeek commented 5 years ago

I would appreciate some more information, otherwise, it is very hard for me to diagnostic.

neilbalch commented 5 years ago

Sure! I'm using the Arduino core:

[env:genericSTM32F103C8]
platform = ststm32
framework = arduino
board = genericSTM32F103C8
upload_protocol = dfu
monitor_speed = 250000

Yes, I have updated to the latest firmware version with the updater tool. What is the development branch?

The sample code is yours, the getVescValues example.

SolidGeek commented 5 years ago

You should use the development branch indstead of the master, if you use the newest VESC firmware.

https://github.com/SolidGeek/VescUart/tree/development

Have you tried one of the other Serial ports?

neilbalch commented 5 years ago
  1. How would I do that with PlatformIO? I can only grab libraries straight from the master branch.
  2. Yes, I've tried all three of the USART ports on my Blue Pill board.
jimmil44 commented 5 years ago

Small world, I too am trying to get vesc data on an STM32 and mine worked just fine. Are you using Serial1.begin( insert baud rate here ); on PA9 and PA10? Then its the exact same as the test sketches. Working on the current development branch. I have attached the zip file containing the development branch. Hope it works! VescUart-development.zip

neilbalch commented 5 years ago

You described the hardware setup perfectly. I'm still not clear how I should be using the development branch in PlatformIO. As far as I know, it only supports using the master branch.

neilbalch commented 5 years ago

By the way, I still can't connect to the VESC, even when using the development branch.

#include <Arduino.h>
#include <HardwareSerial.h>
#include <VescUart.h>

#define VESC_USART Serial1

VescUart UART;

void setup() {
  Serial.begin(9600);
  VESC_USART.begin(19200);
  // while (!Serial) {;}
  UART.setSerialPort(&VESC_USART);
}

void loop() {
  if (UART.getVescValues() ) {
    Serial.println(UART.data.rpm);
    Serial.println(UART.data.inpVoltage);
    Serial.println(UART.data.ampHours);
    Serial.println(UART.data.tachometerAbs);
  } else {
    Serial.println((String)millis() + " Failed to get data!");
  }

  delay(50);
}
neilbalch commented 5 years ago

Deeeeeeerp. The example has the baud rate set at 19200 bps while the VESC communicates at 115200 bps by default. I forgot to check. Now it works properly with my code communicating with the VESC at 115200 bps.