OpenSource Remote for VESC ArduBoardControl

RollingGecko

100 W
Joined
Jul 14, 2015
Messages
110
Hi,

I want to present you my new remote for the VESC Controller. As I started to develope it,I had some requirements in mind:

- Arduino based
- Conection via nRF24
- Feedback of all measured values of the VESC
- Reliability
- Indication of remaining capacity of VESC and TX
- extensibility
- Different designs of the remote possible

And what I get?

Well lock at the pictures.

The enclosure is from a Nunchuk. (still! Later an own design maybe 3D printed)

The electronic are

- arduino nano
- 2S Lipo
- nRF24 Transmitter
- 4 WS2812 RGB lights
- Vibrator from a cellphone

I emptied the complete Nunchuck including all plastic parts from the inside (A Dremel helps a lot) Then was plenty of place inside. Look at the pictures for details.

On the remote site I will also use an Arduino Nano with a nRF24.

I communicate to the VESC over UART. I can control the nunchuk app as well as directly current and break. I read out all measured data and send them to the remote.

Here is the complete current feature list as I wrote also on github to the prerelease 0.2b:



Features:

UART connection to VESC with control of Nunchuk app and reading of relevant values (Voltage, rpm, etc)
Bidirectional conection to remote over nRF24

Remote Features

supports nRF24 bidirectional connection
reads 2 potentiometers and 2 buttons
state indication over 4 x WS 2812
measuring of the lipoVoltage and check for remaining capacity
Vibrator alert
all measured values from vesc are transfered to remote
Configurability over Config.h
rudimentary direct current control and break on vesc over UART possible

On arduino nano:

Binary sketch size: 11.098 bytes (used 36% of a 30.720 byte maximum)
Minimum Memory Usage: 690 bytes (34% of a 2048 byte maximum)

Open points

Many features to be added
Problem with nunchuck app on vesc: No acceleration or break in PID mode
reverse does not work
remote still a Mega2560 because of Serial ports for debug. Must be changed to a Nano.

To be able to use the nunchuk app on the vesc I made some small changes on the BLDC FW. I will send a pull request soon to vedder. Meanwhile you can get the forked firmware here:

https://github.com/RollingGecko/bldc

The complete code of my ArduboardControl is open source and available here:

http://rollinggecko.github.io/ArduBoardControler/

As you can see at open points I've still some smaller issues to be solved. I still don't know where the problem is. So reviewers welcome.

Because of the fact, that I've all measured data already on the TX, one next desired feature is an OLED display. Currently I can state only over 4 RGB LED's.

Current States:
LED 1: remaining TX capacity in different colors
LED 2: connection TX > RX
LED 3: remaining VESC capacity
LED: free

For the traveled distance I've already a 4^x display with the 4 RGB's in mind.

From next week on I'm in holidays. I hope I will find some time to give a better documentation to the project on github.
 

Attachments

  • 2015-10-26 22.55.06.jpg
    2015-10-26 22.55.06.jpg
    56.5 KB · Views: 13,904
  • 2015-10-26 00.18.28.jpg
    2015-10-26 00.18.28.jpg
    59.8 KB · Views: 13,904
  • 2015-10-24 23.24.30.jpg
    2015-10-24 23.24.30.jpg
    71 KB · Views: 13,904
Hi,

I´ve added a bit more of documentation:

http://rollinggecko.github.io/ArduBoardControler/

Iwill update this also in future if I can identify an interest in.

Just check it out. Maybe you have also some open questions that should be explaned more in detail...
 
Hi RollingGecko

I was trying to use your code but was missing the Config.h, so i tried to make a more simplified approach, but i'm still getting erros with the UART library

this is my code so far

Code:
#include <SPI.h>
#include <nRF24L01.h>
#include "RF24.h"
#include "VescUart.h"
#include "datatypes.h"

RF24 radio(9, 10);

const uint64_t pipe = 0xE8E8F0F0E1LL;

struct remotePackage {
  int valXJoy;
  int valYJoy;
  boolean valLowerButton;
  boolean valUpperButton;
} ;

remotePackage remPack;

struct bldcMeasure VescMeasuredValues;

bool recOK;

int now;
int lastTimeReceived;
int TIMEOUTMAX = 500;

void setup() {
  //Initial for Radio
  Serial.begin(115200);
  delay(1000);
  radio.begin();
  radio.enableAckPayload();
  radio.enableDynamicPayloads();
  radio.openReadingPipe(1, pipe);

  radio.startListening();

  // For initial start

  remPack.valXJoy     = 512;
  remPack.valYJoy     = 512;
  remPack.valLowerButton  = 0;
  remPack.valUpperButton  = 0;
}

void loop() {

  VESC();

  radio_recieve();

}

void VESC() {
  VescUartGetValue(VescMeasuredValues);
}

void radio_recieve() {
  while (radio.available())
  {
    radio.read(&remPack, sizeof(remPack));
    recOK = true;
  }
  now = millis();
  if (recOK == true)
  {
    lastTimeReceived = millis();
  }
  else if ((now - lastTimeReceived) > TIMEOUTMAX)
  {
    remPack.valXJoy = 128; //middle Position
    remPack.valYJoy = 128;
    remPack.valLowerButton = 0;
    remPack.valUpperButton = 0;
    recOK == false;
  }
  
  VescUartSetNunchukValues(remPack);
  
}

But even if i remove VescUartSetNunchukValues(remPack); i get the following erros

Code:
In file included from C:\Users\Pedro\Documents\DIY\Long Elétrico\Arduino\programa_long_v10_VESC\programa_long_v10_VESC.ino:4:0:

C:\Users\Pedro\Documents\Arduino\libraries\VescUartControl-master/VescUart.h:85:31: error: variable or field 'VescUartSetNunchukValues' declared void

 void VescUartSetNunchukValues(remotePackage& data);

                               ^

C:\Users\Pedro\Documents\Arduino\libraries\VescUartControl-master/VescUart.h:85:31: error: 'remotePackage' was not declared in this scope

C:\Users\Pedro\Documents\Arduino\libraries\VescUartControl-master/VescUart.h:85:46: error: 'data' was not declared in this scope

 void VescUartSetNunchukValues(remotePackage& data);

                                              ^

exit status 1
Erro compilando.

Any idea whats happening?
 
Hi,

So just checked it. The RemotePackage is defined in the config file. This is the definition:

Code:
//Define remote Package

struct remotePackage {
	
	int		valXJoy;
	int		valYJoy;
	boolean	valUpperButton;
	boolean	valLowerButton;
	
} ;

I tried to avoid multible definitions with the limitations the arduino complier gives to libraries. Never the less, I will restructure it somehow soon. I will include it to datatypes.h somehow included in an ifdef.

So far if you add this struct to datatypes.h it should work. But as I allready said, the Config.h is available. Try to checkout the complete repo https://github.com/RollingGecko/ArduBoardControler again.
 
Thanks for the reply

I downloaded the updated version, seen like the problem is that the Config.h its not being read, even if it apear as a tab in the ide

i will look into

Code:
ArduBoardControler_Rx:63: error: 'pipe' was not declared in this scope

ArduBoardControler_Rx:75: error: 'remPack' was not declared in this scope

C:\Users\Pedro\Documents\DIY\Long Elétrico\Arduino\ArduBoardControler-master\ArduBoardControler_Rx\ArduBoardControler_Rx.ino: In function 'void loop()':

ArduBoardControler_Rx:96: error: 'pipe' was not declared in this scope

ArduBoardControler_Rx:101: error: 'remPack' was not declared in this scope

ArduBoardControler_Rx:122: error: 'TIMEOUTMAX' was not declared in this scope

ArduBoardControler_Rx:124: error: 'remPack' was not declared in this scope

ArduBoardControler_Rx:131: error: 'remPack' was not declared in this scope

ArduBoardControler_Rx:131: error: 'VescUartSetNunchukValues' was not declared in this scope

exit status 1
'remotePackage' does not name a type
 
I didn't change anything, just downloaded your code and tried to compile the rx version

This is specific made for the mega? My ide is configured for the nano, so i only have one serial
 
But still, using only the library i'm getting errors

Code:
#include "VescUart.h"

void setup() {
}

void loop() {
}

I get the same error relating to the nunchuck values remote package

Code:
In file included from C:\Users\Pedro\Documents\Arduino\sketch_dec30a\sketch_dec30a.ino:1:0:

C:\Users\Pedro\Documents\Arduino\libraries\VescUartControl-master/VescUart.h:85:31: error: variable or field 'VescUartSetNunchukValues' declared void

 void VescUartSetNunchukValues(remotePackage& data);

                               ^

C:\Users\Pedro\Documents\Arduino\libraries\VescUartControl-master/VescUart.h:85:31: error: 'remotePackage' was not declared in this scope

C:\Users\Pedro\Documents\Arduino\libraries\VescUartControl-master/VescUart.h:85:46: error: 'data' was not declared in this scope

 void VescUartSetNunchukValues(remotePackage& data);

                                              ^

exit status 1
Erro compilando.
 
Hi,

Forked bldc firmware is no updated with latest changes from Vedder. Nunchuk control over UART was send as pullrequest to vedder. Keep you updated.

Will now have a look to the mentioned problem.
 
OK. Issue fixed.
Struct remotePackage was moved to datatypes.h.

Please check out VescUartControl and ArduBoardControl again and retry.

Example of VescUartControl is compilable. Please comment out
Code:
#include Config.h
from VescUart.h if not Config.h is available.
 
Gave it another try, success, had to change somethings in the library to eliminate all debug serial and change serial1 to serial

Have you talked to vedder about the capability to control the nunchuck app via UART? if not how do i modify the latest firmware to receive the instructions? for what i understand i have to add some lines in the code and compile, but no idea how to do that

Thanks, very happy with the results so far
 
Hi,

That is cool. I already ported RX to an Arduino nano (328p). If you select the nano the BUGSERIAL is deselected automatically by an #ifdef. Allready checked in on GitHub.

I already send a pull request to vedder. Hope he will merge soon. Refer to: https://github.com/vedderb/bldc/pull/12

Until he pulls it, you can use my forked version, which is already merged and up to date: https://github.com/RollingGecko/bldc.git



With the ported RX I no finalized also the RX site and everything is ready for a test run when the weather is better! Here some pics to the assembly:

View attachment 5
2016-01-14 22.19.22 - Kopie.jpg
2016-01-14 22.19.26 - Kopie.jpg
2016-01-14 22.21.52.jpg
2016-01-14 22.22.43 - Kopie.jpg
 
If someone needs a case for his VESC: http://www.thingiverse.com/thing:1273544

Here you can find a case for the VESC stand alone and with place for a Arduino nano. I used a 2200µF Capacitor.
 
i think i tried that in the beginning, but forgot later, better not mess with something that's working

A alternative that i'm working in the moment is if C is pressed, read the ERPM from UART and set the control mode to ERPM for as long C is pressed, this way we avoid the nunchuck app, the downside is that you have to set the max and min current in the Arduíno, but that's something i will never change

Cool case, i will check the price on shapeways

Thanks for all the help

EDIT:

To soon to celebrate, something similar as i described here http://vedder.se/forums/viewtopic.php?f=6&t=38

With everything connected normal and my filter, it works one of ten times i power everything on

With no filter it never works

But the strange thing is, if everything is on and not working and i plug the arduino USB on a external power supply, wait for the arduino to reset and unplug the USB it keeps working, any ideia on whats causing this? i will try to debug this somehow, without 2 serial ports makes it dificult

EDIT2:

Forget the debugging via USB :| , there's no point, when connected everything works

EDIT3:

Ok, added a blinking led in the sketch and confirmed that the program is running under all circumstances, so the problem must be in the communication with VESC, probably in the start of the communication

To solve i added a 5s delay right on the beginning of the setup to give VESC time to boot up before the Arduíno start trowing data on the serial input, i don't know if my logic is right but it solved the problem 8) , even without the filter
 
I'm also struggling.

I realized, that I didn't upload the bootloader. I was able somehow to upload the firmware with the bldc tool but the firmware version showed 1.13. Didn't care really about that...:( because the UART communication worked. Now I uploaded the bootloader and now the firmware is at 2.8. FOC and so one is available. But the UART-control does not work anymore.

So back to basics and troubleshooting. Will need a while! Just need to remember again how to send messages to bldc tool terminal for debugging. Some time passed...

Sorry folks.
 
The 2.8 that you are using is the vedder original or the modified version? i'm in 2.8 and UART is working, just to be sure try this delay in the start, maybe something changed and it's causing all the problems
 
So. Tried it with simple current control I have in the ArduBoardControl. That works. He does not enter in the Nunchuk-Handler in commands.c. Have to check why.

Update: Stupid bug:

Vedder updated the datatypes.h and added COMM_PACKET_ID's . So the ID for the nunchuk packet changed. :roll: Updated the datatypes.h in the VescUart lib and now it works. Will upload it tomorrow.

Found also a bug in the FW upload on the bldc-tool. Will check it tomorrow and report it to vedder.

Good night.
 
Back
Top