Setting a speed (RPM) using UART

General topics and discussions about the VESC and its development.
andreas_667
Posts: 2
Joined: 14 Jan 2018, 16:52

Setting a speed (RPM) using UART

Postby andreas_667 » 14 Jan 2018, 17:14

Hello,

i have a VESC connected to a Arduino with serial connection.
The Motor is a little BL-Outrunner with 14 poles and the VESC runs in BLDC Mode with app "UART".
I have the VESC in "factory-setup". I have changed only the Values for ERPM in the BLDC Gruop and i have made a Motor-setup.
The "Control with arrow keys" in VESC-Tool works fine so i think till here all is ok.

Now i want to control the VESC with my Arduino.
For communication i use the Library " VescUart" from Andreas Chaitidis.
First i have tested the sample program and it runs without problems.
I got some values from the VESC and they were printed out on my screen.


Now i want set a speed RPM.
In the library i have not found a command for setting up a speed.
Therefor i have added a function:

Code: Select all

void VescUartSetRPM(float RPM) {
   int32_t index = 0;
   uint8_t payload[5];

   payload[index++] = COMM_SET_RPM;
   buffer_append_int32(payload, (int32_t)(RPM), &index);
   PackSendPayload(payload, 5);
}


It uses the command " COMM_SET_RPM".

The Motor moves, but the speed doesn't match with the value.
Example: If i send 4000 it moves with estimated 500 rpm.

What could be wrong?

greetings, Andreas

ThierryGTLTS
Posts: 86
Joined: 09 Aug 2017, 11:10

Re: Setting a speed (RPM) using UART

Postby ThierryGTLTS » 14 Jan 2018, 17:44

14 poles = 7 PP "Pole Pair".

571rpm x 7 PP = 3997erpm.

So that's right !

andreas_667
Posts: 2
Joined: 14 Jan 2018, 16:52

Re: Setting a speed (RPM) using UART

Postby andreas_667 » 14 Jan 2018, 18:12

Okay, I did not know that. Many thanks.

I hope it's okay if i I have any further questions in this direction:

1.) as you told me, its the electronic-RPM i have send to the VESC. But I want that the VESC hold a mechanical-RPM.
(the actual revolutions of the outer metal drum)
I know, without hallsensors or incremental encoder it's not possible to get this value but soon i will have a sensored motor.
Do I have to use a different command for this?

2.) Will the VESC use the brake automaticaly, if the motor runs too fast? (e.g. when going downhill)

Or short: I want a fully PID controlled speed (RPM) with brake if the motor gets externally accelerated.

Jackl
Posts: 10
Joined: 12 Mar 2017, 22:23

Re: Setting a speed (RPM) using UART

Postby Jackl » 14 Jan 2018, 19:52

Hi!

1): You can totally get the mechanical RPM without hall sensors, as it is always directly proportional to the ERPM. ERPM can be estimated from BEMF Zero-crossings, and other methods.

Just multiply your desired mechanical RPM by the number of pole pairs of you motor (7 in your case) and you will get the ERPM to send to the VESC.

2): Assuming all other settings are correct (battery current limits, etc.) the VESC will also apply negative torque ("brake") in order to keep the set rpm.
This is, of course, limited by factors such as motor torque, max battery current, etc.

Remember that regenerative braking feeds back energy to your battery. Two things to consider:
- Set your max battery voltage to the max voltage of the battery
- Braking will not work if the battery is full (have not tested this yet, but I assume...)

Long story short: the integrated RPM Control is exactly what you need :)

Cheers!

anttok
Posts: 1
Joined: 28 Jun 2018, 21:36
Location: United States

Re: Setting a speed (RPM) using UART

Postby anttok » 28 Jun 2018, 21:44

Hi all,

I have a similar setup with a VESC connected to arduino over UART using this library
https://github.com/bastianraschke/ESP8266VESC.

The motor was configured using VESC tools wizard and works fine with very smooth rpm with arrow keys, as well as by hitting the play buttons next to current, duty, and position fields. However when i hit play next to RPM, I get same erratic, loud motor behavior and in the rpm real time readout the RPM oscillate +-500 around the entered set point.

I'm using a 75 kv hub motor from link below
http://www.diyeboard.com/dual-hub-motor ... p-617.html

UPDATE: I set max breaking voltage and and wattage to 0, this seems to solve the problem, though I'm guessing this eliminates any ability to use break! Not ideal...


Return to “General”

Who is online

Users browsing this forum: No registered users and 2 guests