OpenSource Remote for VESC ArduBoardControl

Lightweight / Folding / Portable EVs - seats optional
Post Reply
RollingGecko
100 W
100 W
Posts: 110
Joined: Jul 14, 2015 2:20 am

OpenSource Remote for VESC ArduBoardControl

Post by RollingGecko » Oct 28, 2015 2:59 pm

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.47 KiB) Viewed 7885 times
2015-10-26 00.18.28.jpg
2015-10-26 00.18.28.jpg (59.79 KiB) Viewed 7885 times
2015-10-24 21.26.14.jpg
2015-10-24 21.26.14.jpg (53.97 KiB) Viewed 7885 times
2015-10-24 23.24.30.jpg
2015-10-24 23.24.30.jpg (70.96 KiB) Viewed 7885 times
2015-10-26 22.41.06.jpg
2015-10-26 22.41.06.jpg (86.73 KiB) Viewed 7885 times
Last edited by RollingGecko on Oct 29, 2015 5:59 am, edited 1 time in total.
Github: https://github.com/RollingGecko
ArduBoardControl: The Nunchuk Arduino implementation for the VESC: https://github.com/RollingGecko/ArduBoardControler
Berlin Custom Boards: All around DIY longboards: https://www.facebook.com/berlincustomboards/

torqueboards
1.21 GW
1.21 GW
Posts: 3907
Joined: May 27, 2013 10:02 pm
Location: San Francisco, CA
Contact:

Re: OpenSource Remote for VESC ArduBoardControl

Post by torqueboards » Oct 28, 2015 3:07 pm

Well done. Nice to see more implementations :) The regular wired Nunchucks are fairly easy to come by.
DIYElectricSkateboard.com Electric Skateboard Kits

User avatar
benj
100 W
100 W
Posts: 299
Joined: Jun 06, 2013 3:32 am

Re: OpenSource Remote for VESC ArduBoardControl

Post by benj » Oct 29, 2015 6:08 am

Awesome work, well done. And thanks for sharing :D

RollingGecko
100 W
100 W
Posts: 110
Joined: Jul 14, 2015 2:20 am

Re: OpenSource Remote for VESC ArduBoardControl

Post by RollingGecko » Nov 09, 2015 11:15 am

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...
Github: https://github.com/RollingGecko
ArduBoardControl: The Nunchuk Arduino implementation for the VESC: https://github.com/RollingGecko/ArduBoardControler
Berlin Custom Boards: All around DIY longboards: https://www.facebook.com/berlincustomboards/

Pedrodemio
10 W
10 W
Posts: 81
Joined: Jun 30, 2015 8:38 pm
Location: Brazil

Re: OpenSource Remote for VESC ArduBoardControl

Post by Pedrodemio » Dec 30, 2015 8:50 am

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: Select all

#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: Select all


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?

RollingGecko
100 W
100 W
Posts: 110
Joined: Jul 14, 2015 2:20 am

Re: OpenSource Remote for VESC ArduBoardControl

Post by RollingGecko » Dec 30, 2015 1:16 pm

Hi,
The Config.h is in the git repo available once for TX and once for RX. I just checked it.

Will try to have a look to your code a bit later.

Regards

Andreas
Github: https://github.com/RollingGecko
ArduBoardControl: The Nunchuk Arduino implementation for the VESC: https://github.com/RollingGecko/ArduBoardControler
Berlin Custom Boards: All around DIY longboards: https://www.facebook.com/berlincustomboards/

RollingGecko
100 W
100 W
Posts: 110
Joined: Jul 14, 2015 2:20 am

Re: OpenSource Remote for VESC ArduBoardControl

Post by RollingGecko » Dec 30, 2015 1:36 pm

Hi,

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

Code: Select all

//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.
Github: https://github.com/RollingGecko
ArduBoardControl: The Nunchuk Arduino implementation for the VESC: https://github.com/RollingGecko/ArduBoardControler
Berlin Custom Boards: All around DIY longboards: https://www.facebook.com/berlincustomboards/

Pedrodemio
10 W
10 W
Posts: 81
Joined: Jun 30, 2015 8:38 pm
Location: Brazil

Re: OpenSource Remote for VESC ArduBoardControl

Post by Pedrodemio » Dec 30, 2015 3:36 pm

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: Select all

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

RollingGecko
100 W
100 W
Posts: 110
Joined: Jul 14, 2015 2:20 am

Re: OpenSource Remote for VESC ArduBoardControl

Post by RollingGecko » Dec 30, 2015 4:23 pm

Did you take the correct config.h? Rx and tx have both a Config.h. But they are different.
Github: https://github.com/RollingGecko
ArduBoardControl: The Nunchuk Arduino implementation for the VESC: https://github.com/RollingGecko/ArduBoardControler
Berlin Custom Boards: All around DIY longboards: https://www.facebook.com/berlincustomboards/

Pedrodemio
10 W
10 W
Posts: 81
Joined: Jun 30, 2015 8:38 pm
Location: Brazil

Re: OpenSource Remote for VESC ArduBoardControl

Post by Pedrodemio » Dec 30, 2015 4:49 pm

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

RollingGecko
100 W
100 W
Posts: 110
Joined: Jul 14, 2015 2:20 am

Re: OpenSource Remote for VESC ArduBoardControl

Post by RollingGecko » Dec 30, 2015 5:24 pm

Yes. Currently it is still onöy for mega because of debugging. Will transfer it to nano next days.
Github: https://github.com/RollingGecko
ArduBoardControl: The Nunchuk Arduino implementation for the VESC: https://github.com/RollingGecko/ArduBoardControler
Berlin Custom Boards: All around DIY longboards: https://www.facebook.com/berlincustomboards/

Pedrodemio
10 W
10 W
Posts: 81
Joined: Jun 30, 2015 8:38 pm
Location: Brazil

Re: OpenSource Remote for VESC ArduBoardControl

Post by Pedrodemio » Dec 30, 2015 6:43 pm

But still, using only the library i'm getting errors

Code: Select all

#include "VescUart.h"

void setup() {
}

void loop() {
}
I get the same error relating to the nunchuck values remote package

Code: Select all

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.

RollingGecko
100 W
100 W
Posts: 110
Joined: Jul 14, 2015 2:20 am

Re: OpenSource Remote for VESC ArduBoardControl

Post by RollingGecko » Dec 30, 2015 6:48 pm

I will check it back from holidays.
Github: https://github.com/RollingGecko
ArduBoardControl: The Nunchuk Arduino implementation for the VESC: https://github.com/RollingGecko/ArduBoardControler
Berlin Custom Boards: All around DIY longboards: https://www.facebook.com/berlincustomboards/

Pedrodemio
10 W
10 W
Posts: 81
Joined: Jun 30, 2015 8:38 pm
Location: Brazil

Re: OpenSource Remote for VESC ArduBoardControl

Post by Pedrodemio » Dec 30, 2015 7:26 pm

Thanks :D

NyOliver
10 W
10 W
Posts: 76
Joined: Nov 12, 2015 10:05 am

Re: OpenSource Remote for VESC ArduBoardControl

Post by NyOliver » Dec 31, 2015 4:29 pm

Super project.

RollingGecko
100 W
100 W
Posts: 110
Joined: Jul 14, 2015 2:20 am

Re: OpenSource Remote for VESC ArduBoardControl

Post by RollingGecko » Jan 01, 2016 4:23 pm

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.
Github: https://github.com/RollingGecko
ArduBoardControl: The Nunchuk Arduino implementation for the VESC: https://github.com/RollingGecko/ArduBoardControler
Berlin Custom Boards: All around DIY longboards: https://www.facebook.com/berlincustomboards/

RollingGecko
100 W
100 W
Posts: 110
Joined: Jul 14, 2015 2:20 am

Re: OpenSource Remote for VESC ArduBoardControl

Post by RollingGecko » Jan 01, 2016 4:58 pm

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: Select all

#include Config.h
from VescUart.h if not Config.h is available.
Github: https://github.com/RollingGecko
ArduBoardControl: The Nunchuk Arduino implementation for the VESC: https://github.com/RollingGecko/ArduBoardControler
Berlin Custom Boards: All around DIY longboards: https://www.facebook.com/berlincustomboards/

Pedrodemio
10 W
10 W
Posts: 81
Joined: Jun 30, 2015 8:38 pm
Location: Brazil

Re: OpenSource Remote for VESC ArduBoardControl

Post by Pedrodemio » Jan 06, 2016 10:53 am

I will try it

Thanks

Pedrodemio
10 W
10 W
Posts: 81
Joined: Jun 30, 2015 8:38 pm
Location: Brazil

Re: OpenSource Remote for VESC ArduBoardControl

Post by Pedrodemio » Jan 15, 2016 4:47 pm

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

RollingGecko
100 W
100 W
Posts: 110
Joined: Jul 14, 2015 2:20 am

Re: OpenSource Remote for VESC ArduBoardControl

Post by RollingGecko » Jan 16, 2016 5:49 pm

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:
2016-01-14 22.18.51 - Kopie.jpg
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
2016-01-16 23.42.56.jpg
Github: https://github.com/RollingGecko
ArduBoardControl: The Nunchuk Arduino implementation for the VESC: https://github.com/RollingGecko/ArduBoardControler
Berlin Custom Boards: All around DIY longboards: https://www.facebook.com/berlincustomboards/

RollingGecko
100 W
100 W
Posts: 110
Joined: Jul 14, 2015 2:20 am

Re: OpenSource Remote for VESC ArduBoardControl

Post by RollingGecko » Jan 16, 2016 6:59 pm

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.
Github: https://github.com/RollingGecko
ArduBoardControl: The Nunchuk Arduino implementation for the VESC: https://github.com/RollingGecko/ArduBoardControler
Berlin Custom Boards: All around DIY longboards: https://www.facebook.com/berlincustomboards/

Pedrodemio
10 W
10 W
Posts: 81
Joined: Jun 30, 2015 8:38 pm
Location: Brazil

Re: OpenSource Remote for VESC ArduBoardControl

Post by Pedrodemio » Jan 16, 2016 7:22 pm

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

RollingGecko
100 W
100 W
Posts: 110
Joined: Jul 14, 2015 2:20 am

Re: OpenSource Remote for VESC ArduBoardControl

Post by RollingGecko » Jan 17, 2016 1:38 pm

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.
Github: https://github.com/RollingGecko
ArduBoardControl: The Nunchuk Arduino implementation for the VESC: https://github.com/RollingGecko/ArduBoardControler
Berlin Custom Boards: All around DIY longboards: https://www.facebook.com/berlincustomboards/

Pedrodemio
10 W
10 W
Posts: 81
Joined: Jun 30, 2015 8:38 pm
Location: Brazil

Re: OpenSource Remote for VESC ArduBoardControl

Post by Pedrodemio » Jan 17, 2016 1:51 pm

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

RollingGecko
100 W
100 W
Posts: 110
Joined: Jul 14, 2015 2:20 am

Re: OpenSource Remote for VESC ArduBoardControl

Post by RollingGecko » Jan 17, 2016 6:32 pm

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.
Github: https://github.com/RollingGecko
ArduBoardControl: The Nunchuk Arduino implementation for the VESC: https://github.com/RollingGecko/ArduBoardControler
Berlin Custom Boards: All around DIY longboards: https://www.facebook.com/berlincustomboards/

Post Reply