Open Source Arduino transmitter/receiver for (V)ESC

Lightweight / Folding / Portable EVs - seats optional
jacobbloy   100 W

100 W
Posts: 237
Joined: Feb 12 2013 4:45pm

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by jacobbloy » Jul 05 2015 7:43pm

At this point I can sell it as I don't have firmware, but I'm getting them made!

jacobbloy   100 W

100 W
Posts: 237
Joined: Feb 12 2013 4:45pm

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by jacobbloy » Jul 05 2015 8:06pm

I'm actualy looking to swap the receiver to the nrf51822 Bluetooth smart module.
The reason why and maybe a good reason for others to use it, is because it is compatible with Bluetooth smart and 2.4ghz gazel protocol (nrf24l) it is the chip I am writing my android and iOS app around, but the reason for this is i can use the same chip for my in hand transmitter and an iPhone/android app, there are already apps on the markets to send pwm signals like redbear, ADRFRUIT, and Nordic with a simple slider, so we can use a controler and an app when battery goes dead.

This chip also can be used as a beacon so you can be notified to connect or disconnect to you board when you get near. Or even get charge status data.

Sadly you can only use 1 protocol at a time!

verruckt   10 mW

10 mW
Posts: 22
Joined: Jun 11 2008 7:57pm
Location: San Diego

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by verruckt » Jul 06 2015 12:54pm

jacobbloy wrote:At this point I can sell it as I don't have firmware, but I'm getting them made!
Hi Jacob,

I would also buy a couple of sets from you if you do a run.

Thanks and keep up the good work!

:D

RomeoEG   10 W

10 W
Posts: 72
Joined: May 29 2014 9:39pm

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by RomeoEG » Jul 12 2015 10:55am

Wiiceiver - very dangerous due to random periodic dropped signal (so ultimately not feasible), but awesome coding and control of the board especially with the cruise control and variable acceleration speeds when it isn't dropping signal

2.4ghz R/C remote like the gt2b - awesome reliability, but the trigger is so sensitive and impractical to hold the 'perfect' speed long term.. it's sketchy enough to also not be a feasible solution long term.. not an enjoyable one anyway



Can someone with the skilllzz put the awesome wiiceiver coding with 2.4ghz R/C stability/reliability inside the same Nyko Kama controller (I love the controller, its the perfect size and perfect setup with the cruise control button)??

If someone can do that, I'll take 3-4 units right away :)

torqueboards   100 MW

100 MW
Posts: 2940
Joined: May 27 2013 10:02pm
Location: San Francisco, CA
Contact:

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by torqueboards » Jul 12 2015 1:24pm

I think jacobbloy is working on something. Would be nice if it was universal with other ESCs.

Gt2b is awesome 2400+ miles with no drops and holding throttle is easy for me compared to the Quantum Pistol Grip. Only drop was when the battery died out on me.

Wiiceiver works but takes time to fix the connection issue with the Nyko Kama Receiver + Nyko Kama Transmitter. I'll buy for an upgraded Nyko Kama Receiver/Transmitter in 2.4ghz also.
DIYElectricSkateboard.com Electric Skateboard Kits

User avatar
buzztiaan   1 W

1 W
Posts: 52
Joined: Mar 09 2015 4:57am
Location: Netherlands

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by buzztiaan » Jul 15 2015 5:53pm

Could an admin move the non-arduino posts to a seperate thread? :D
HK150 - 5055 SK3 280kv - 6S 5000mAh - 90mm bigfoots
https://nurdspace.nl/RobertLongboard

vedder   100 W

100 W
Posts: 249
Joined: Nov 05 2011 9:37pm

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by vedder » Jul 16 2015 9:21am

Just wanted to post some updates on my modified nunchuk with a custom PCB. I have been working on it the last couple of days, mostly on power saving.

* I have changed to this receiver on the VESC:
http://www.ebay.com/itm/NRF24L01-PA-LNA ... 58c5634c64
I don't know if my other receiver was broken, but this one has much better range even though the transmitter in my modified nunchuk is the same. I can be 100M far away and control it, and when I use it normally there are no glitches at all. With the other receiver, I could only go 3 to 5 meters away and while using it and I got occasional glitches like the nyko kama. Now the glitches are completely gone. I will experiment a bit more with receivers to see it if the one I had at first was faulty since 3 to 5 meters is way less than it should be.

* I have added a checksum on top of the packets in case there are glitches while reading over SPI with the cable.

* I have reduced the MCU clock frequency and made it go to low power mode when it cannot hear the VESC any more. In low power mode, the current draw is 0.09mA, so it can be left with the batteries for more than a year. Before this I had to remove the batteries when not using it because they would die in a day or two. While running, the current consumption now is 15mA, which is 60 - 70 hours on normal AAA-batteries. Using it for an hour every day (which is more than I do), the batteries would last for two months or more. The original kama had the same current consumption in low power mode, but 25mA when running which is a lot more. I don't know if I really need rechargeable batteries now.

What do you think? Is the power consumption low enough to use AAA-batteries, or would you prefer rechargeable batteries?
Some of my projects: http://vedder.se
Support my open source ESC development with a small donation

torqueboards   100 MW

100 MW
Posts: 2940
Joined: May 27 2013 10:02pm
Location: San Francisco, CA
Contact:

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by torqueboards » Jul 16 2015 9:30am

AAA sounds fine for 60-70 hrs of use. :mrgreen:
DIYElectricSkateboard.com Electric Skateboard Kits

erwincoumans   100 W

100 W
Posts: 141
Joined: Apr 02 2015 11:25pm

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by erwincoumans » Jul 16 2015 10:38am

vedder wrote:* I have changed to this receiver on the VESC:
http://www.ebay.com/itm/NRF24L01-PA-LNA ... 58c5634c64
Yes, that is the extended range version that I am testing too (PA+LNA/SMA). I have not had glitches with the regular nRF24L01+, as long as the transceiver is not too close to the motor or controller. The PA+LNA antenna seems a bit bulky for a hand-held controller.

I also have a USB dongle version of the nRF24L01+PA+LNA that works on Linux and Mac, so you can communicate to your VESC nRF24L01+. I use libusb to communicate with the USB transceiver. So you could use it also to wireless upload a new firmware and perhaps custom user-plugins for VESC. If you are interested in that, I can put the source code for this in a github repo.
Here is a link to the 'crazy radio long range': http://www.seeedstudio.com/depot/Crazyr ... -2104.html
What do you think? Is the power consumption low enough to use AAA-batteries, or would you prefer rechargeable batteries?
AAA batteries are a bit more convenient than small lipos, but either way will do.

I still prefer the ease of programming using the Arduino IDE over programming the STM32Fx series, Arduino seems to have more tutorials and library coverage. So if you want to go for STM32Fx it would be helpful to provide some tutorial how to write 'plugins', and make it easy to upload those plugins over USB instead of firmware flasher.

buzztiaan wrote: Could an admin move the non-arduino posts to a seperate thread?
At this stage this thread is hijacked beyond repair, I'm afraid. If I have new developments with Arduino, I likely create a new thread. I could as well remove the word 'Arduino' from the title :D

vedder   100 W

100 W
Posts: 249
Joined: Nov 05 2011 9:37pm

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by vedder » Jul 16 2015 1:37pm

Another update: I tried to minimize the time the NRF is on, so the current consumption in run mode is now less than 8mA. This means that the nunchuk can be on for more than 120 hours on 2 AA batteries.
erwincoumans wrote:
vedder wrote:* I have changed to this receiver on the VESC:
http://www.ebay.com/itm/NRF24L01-PA-LNA ... 58c5634c64
Yes, that is the extended range version that I am testing too (PA+LNA/SMA). I have not had glitches with the regular nRF24L01+, as long as the transceiver is not too close to the motor or controller. The PA+LNA antenna seems a bit bulky for a hand-held controller.
I'm only using the PA+LNA version on the receiver, the transmitter in the nunchuk is still the small smd module. So even if the TX power is the same, the gain in the antenna and possibly in the rx part of the LNA help a lot.
erwincoumans wrote: I also have a USB dongle version of the nRF24L01+PA+LNA that works on Linux and Mac, so you can communicate to your VESC nRF24L01+. I use libusb to communicate with the USB transceiver. So you could use it also to wireless upload a new firmware and perhaps custom user-plugins for VESC. If you are interested in that, I can put the source code for this in a github repo.
Here is a link to the 'crazy radio long range': http://www.seeedstudio.com/depot/Crazyr ... -2104.html
It would be nice to have some code that uses libusb for that :-)
erwincoumans wrote: I still prefer the ease of programming using the Arduino IDE over programming the STM32Fx series, Arduino seems to have more tutorials and library coverage. So if you want to go for STM32Fx it would be helpful to provide some tutorial how to write 'plugins', and make it easy to upload those plugins over USB instead of firmware flasher.
It is most likely easier for beginners to get an LED blinking with Arduino, but the Arduino IDE is horrible. Eclipse with indexing, refactoring, auto-completion etc. is so much better. Also, I think the Arduino libraries are not made for making complex programs. When things grow, ChibiOS with threads and the libraries made for an rtos is so much better. Even with the nunchuk transmitter I think the code is easier to follow than it would be if it was written using arduino. Another reason I prefer chibios with STM is that I can use the same code base for the VESC and the nunchuk implementation, which makes development easier for me.

Regarding writing and uploading firmware to the stm32f100, I'm using the build in UART bootloader in the f100, which is very similar to how firmware is uploaded to the arduino. Even an arduino could be connected to my modified nunchuk to upload firmware if you really want to do that. Otherwise, a CP2012 or ftdi USB-toUART module such as this one works:
http://www.ebay.com/itm/Replace-FT232-6 ... 4addaef097

A short tutorial for Ubuntu goes something like this:

1. Install toolchain

Code: Select all

sudo apt-get remove binutils-arm-none-eabi gcc-arm-none-eabi
sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded
sudo apt-get update
sudo apt-get install gcc-arm-none-eabi=4.9.3.2015q2-1trusty1 git build-essential
2. Install stm32flash

Code: Select all

git clone https://github.com/ARMinARM/stm32flash.git stm32flash
cd stm32flash
make
sudo make install
3. Connect the USB-to-UART module to the nunchuk PCB:
DTR is connected to the reset pin
RTS is connected to the boot0 pin
RX and TX are connected as usual (RX to TX and TX to RX).

4. Get and upload the firmware:

Code: Select all

git clone https://github.com/vedderb/nunchuk_mod.git nunchuk_mod
cd nunchuk_mod
make upload
5. Done! If you'd like, open main.c and study/modify it. Then upload it again with

Code: Select all

make upload
Some of my projects: http://vedder.se
Support my open source ESC development with a small donation

erwincoumans   100 W

100 W
Posts: 141
Joined: Apr 02 2015 11:25pm

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by erwincoumans » Jul 19 2015 3:46pm

vedder wrote:
erwincoumans wrote: I also have a USB dongle version of the nRF24L01+PA+LNA that works on Linux and Mac, so you can communicate to your VESC nRF24L01+. I use libusb to communicate with the USB transceiver. So you could use it also to wireless upload a new firmware and perhaps custom user-plugins for VESC. If you are interested in that, I can put the source code for this in a github repo.
Here is a link to the 'crazy radio long range': http://www.seeedstudio.com/depot/Crazyr ... -2104.html
It would be nice to have some code that uses libusb for that :-)
OK, I uploaded the code here, I got it to work for Linux and Mac OSX: https://github.com/erwincoumans/usbCrazyRadio

The Linux or Mac PC will connect to a nRF24L01+ receiver on a specific pipe, and enables dynamic payloads and acknowledgements packages. For testing, it sends a few thousand packets and waits for the ack each time. It takes around 1ms for each package, roundtrip (2000 packages at 2sec).

How would a VESC app look like that has similar functionality to the following Arduino script?
https://github.com/erwincoumans/usbCraz ... th_ack.ino

In other words for a VESC with nRF24L01+
  • How to connect/solder the nRF24L01+ radio, pinout, and does it require modification to the original VESC 4.7?
  • How to select the pipe number, say const uint64_t pipe = 0xe7e7e7e7e7LL;
  • How to enable dynamic payload and acknowledgements?
  • How to implement bool radio.available(), radio.getDynamicPayloadSize, radio.read(..), radio.writeAckPayload(...)?
Once this would work on VESC, it would be much easier to start developing some remote controller (and doing the testing/development on Linux or Mac first).

Thanks for all the hard work!
Erwin

User avatar
Nordle   100 W

100 W
Posts: 182
Joined: Jul 20 2015 1:42pm
Location: The Alps

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by Nordle » Jul 20 2015 3:40pm

Sry but i don't get it :(
I bought 2 Arduino Nanos + 2 nRF24 + still have an old nunchuck from my wii times:)
But that was it, i have no idea how to wire them, and no idea how to upload the programs.
Would be awesome if someone could make a beginnerfriendly tutorial, how to set this up. Maybe some pics.
4:20 Noob Hubz! BLAZE it
..sry for dat poor english..

erwincoumans   100 W

100 W
Posts: 141
Joined: Apr 02 2015 11:25pm

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by erwincoumans » Jul 20 2015 5:32pm

The wires between Arduino Nano and nRF24L01+ was in the first posting:

Code: Select all

The nRF24L01+ transceiver is connected to both Tx/Rx Arduino Nano as follows:

VCC -> 3.3v
GND -> GND
CE -> D9
CSN -> D10
MOSI -> D11
MISO -> D12
SCK -> D13
IRQ -> not used/not connected
If you don't want to solder, you can get this shield for Arduino Nano + nRF24L01+ from Amazon for 10 dollar:
http://www.amazon.com/Arduino-Nano-I-O- ... B00BD6KEYC

This shield is probably too bulky, but might help your testing (in case your soldering skills are not great).

Please download the Arduino IDE and follow the instructions from the Arduino websites how to upload a sketch.

At some stage I might write a beginner friendly tutorial. Until then, please ask more specific questions, where you get stuck exactly.

razad7@gmail.com   1 W

1 W
Posts: 58
Joined: Sep 11 2013 10:01am

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by razad7@gmail.com » Aug 10 2015 1:37am

Hey,
Awesome work, so i ordered everything and got everything to work
couple of problems i ran into:
1. but the thing is too sensitive -
as i see it, it all starts with the stick it outputs 128 on neutral - then at about a third of the range 255 (which is the maximum it goes up to) and in the other direction reaches 0 also at a third of the range.
So how do i get it to use the entire range? how do i increase its range?
2. when going quickly from full throttle to full brake it seems to ignore my command
is there any way to treat this?

Thanks a lot,
A

jacobbloy   100 W

100 W
Posts: 237
Joined: Feb 12 2013 4:45pm

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by jacobbloy » Aug 10 2015 10:34am

guys i think that vedder was working unchanging the NRF24 chip input to not require any soldering and instead use the hall sensor input in stead of using the servo input and removing lowpass filters. I'm not completely sure but i think this has already been done.
VEDDER has some of my nunchuck pcbs in hand and is working on testing them and helping to him any problems. austin creator of the wiiceiver is going to be helping write code for the whichever to allow my PCB to communicate directly to the whichever with so it can be used with non VESC applications or for quicker VESC connectivity.

https://github.com/jacobbloy/BLDCAPP/tr ... lNPNzk2Z3c

i need the community help to connect a bluetooth module to the VESC and test that the current APK can connect search for bluetooth devices found in the settings tap of the APP and connect to the VESC bluetooth module.

the data that i need is:
You should pair devices and tell me the device type - it will be displayed something like "Service %TYPE%: %NAME%"
this is done all through the settings tab of the android APP.

Connecting bluetooth is easy and works with the same firmware as before without modifications. Just enable the UART app and connect a bluetooth-serial dongle (e.g. the rn-41 as found on the bluesmirf gold) to the rx and tx pins of the VESC. Something like this works to connect to it from ubuntu:
https://gist.github.com/xseignard/9367829
Then, in BLDC Tool, replace /dev/ttyACM0 with /dev/rfcomm0

erwincoumans   100 W

100 W
Posts: 141
Joined: Apr 02 2015 11:25pm

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by erwincoumans » Aug 14 2015 5:38pm

razad7@gmail.com wrote:Hey,
Awesome work, so i ordered everything and got everything to work
couple of problems i ran into:
1. but the thing is too sensitive -
as i see it, it all starts with the stick it outputs 128 on neutral - then at about a third of the range 255 (which is the maximum it goes up to) and in the other direction reaches 0 also at a third of the range.
So how do i get it to use the entire range? how do i increase its range?
2. when going quickly from full throttle to full brake it seems to ignore my command
is there any way to treat this?

Thanks a lot,
A
Are you using the Arduino script?

You could tweak the value on the receiver scipt, rangeServo (and if neutral is not centered, adjust neutralServo).
https://github.com/erwincoumans/Arduino ... ver.ino#L7


If that doesn't help, try to debug using serial printf. Another value to check is potValueA in the transmitter script:
https://github.com/erwincoumans/Arduino ... er.ino#L70

Good luck!
Erwin

User avatar
Nordle   100 W

100 W
Posts: 182
Joined: Jul 20 2015 1:42pm
Location: The Alps

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by Nordle » Aug 15 2015 12:18pm

I finally got my arduino (clones) and after some frustrating hours (ch340 chip+win7=rage) i got one of them to do his work. I was able to upload the ''blink'' sketch. The other one is broken i think, it will not be shown under ''serial port'' but the power led is on :I
Nano OK.JPG
Nano OK.JPG (199.75 KiB) Viewed 2641 times
Nano Broken.JPG
Nano Broken.JPG (167.15 KiB) Viewed 2641 times
or maybe it isn't broken and im just stupid, dunno..

With the intact one i wanted to build my transmitter, but wich sketch do i have to upload?
-beetle_transmit_kama_pot
-nrf24l01_transmitter
-''the nrf24 from the readme''
???only questionmarks in my head :shock:
4:20 Noob Hubz! BLAZE it
..sry for dat poor english..

razad7@gmail.com   1 W

1 W
Posts: 58
Joined: Sep 11 2013 10:01am

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by razad7@gmail.com » Aug 15 2015 3:20pm

http://kiguino.moos.io/2014/12/31/how-t ... emite.html
try this for the undetected arduino. worked for me

User avatar
Nordle   100 W

100 W
Posts: 182
Joined: Jul 20 2015 1:42pm
Location: The Alps

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by Nordle » Aug 16 2015 2:09am

I just saw that and almost everything google spits out. CH341 driver didn't work under win7 for me, shouldn't be necessary under linux (I also have no idea how to install specific driver under Linux). Minicom didn't help to. If i don't get this chip working, I'll maybe try the Wiiceiver method.
4:20 Noob Hubz! BLAZE it
..sry for dat poor english..

Pedrodemio   10 W

10 W
Posts: 82
Joined: Jun 30 2015 8:38pm
Location: Brazil

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by Pedrodemio » Aug 16 2015 1:51pm

Nordel wrote:I just saw that and almost everything google spits out. CH341 driver didn't work under win7 for me, shouldn't be necessary under linux (I also have no idea how to install specific driver under Linux). Minicom didn't help to. If i don't get this chip working, I'll maybe try the Wiiceiver method.
Nordel,

If i'm not mistaken one of my nanos use the CH341, i had to do a lot of digging but found a driver on the manufacturer website that worked on win7, i'ts been a long time and i don't remenber where exactly, just to let you know that it can work

User avatar
Nordle   100 W

100 W
Posts: 182
Joined: Jul 20 2015 1:42pm
Location: The Alps

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by Nordle » Aug 17 2015 2:34am

I had that driver installed, didn't work for me.
Now I'm using Linux and everything worked, but only with one of both.
No matter.. my real problem is i don't know exactly what to upload :?:
4:20 Noob Hubz! BLAZE it
..sry for dat poor english..

erwincoumans   100 W

100 W
Posts: 141
Joined: Apr 02 2015 11:25pm

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by erwincoumans » Aug 17 2015 10:04am

Nordel wrote:I had that driver installed, didn't work for me.
Now I'm using Linux and everything worked, but only with one of both.
No matter.. my real problem is i don't know exactly what to upload :?:
The github repository has Arduino Nano + nRF24L01+ scripts for the receiver Arduino, and the transmitter Arduino. You don't have a Beetle Bluetooth, so can can ignore those scripts, right?

For the transmitter Arduino Nano + nRF24L01+ upload this script: https://github.com/erwincoumans/Arduino ... ransmitter
For the receiver Arduino Nano + nRF24L01+ upload this script: https://github.com/erwincoumans/Arduino ... 1_receiver
Transmitter has a potentiometer pin on Analog 3
Receiver has the servo PWM pin on D3

The nRF24L01+ transceiver is connected to both transmitter (Tx) and Receiver (Rx) Arduino Nano as follows:

VCC -> 3.3v
GND -> GND
CE -> D9
CSN -> D10
MOSI -> D11
MISO -> D12
SCK -> D13
IRQ -> not used/not connected
What part was confusing you?

Good luck!

User avatar
Nordle   100 W

100 W
Posts: 182
Joined: Jul 20 2015 1:42pm
Location: The Alps

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by Nordle » Aug 17 2015 11:11am

erwincoumans wrote: What part was confusing you?
The Readme file
Thanx for your help;)
4:20 Noob Hubz! BLAZE it
..sry for dat poor english..

erwincoumans   100 W

100 W
Posts: 141
Joined: Apr 02 2015 11:25pm

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by erwincoumans » Aug 17 2015 12:39pm

Nordel wrote:
erwincoumans wrote: What part was confusing you?
The Readme file
Thanx for your help;)
The readme file is not confusing to me. Can you please tell how to modify the readme file less confusing?

Thanks!
Erwin

User avatar
Nordle   100 W

100 W
Posts: 182
Joined: Jul 20 2015 1:42pm
Location: The Alps

Re: Open Source Arduino transmitter/receiver for (V)ESC

Post by Nordle » Aug 17 2015 1:52pm

Simple scripts for Arduino Nano with nRF24L01+ as transmitter and receiver for servo control.

The nRF24L01+ transceiver requires installing the RF24 library https://github.com/maniacbug/RF24 Hit the 'download' button, rename to RF24.zip and use Sketch/Import Library/Add Library and point to the RF24.zip file in the Arduino IDE

Also scripts for Bluno Beetle, Arduino Uno compatible transceiver with BLE Bluetooth

See also the discussion at http://endless-sphere.com/forums/viewto ... 35&t=70021


:?: I thought I would first have to upload something from link in the Readme. :?:

This method works better than https://endless-sphere.com/forums/viewt ... 35&t=57316?^^
4:20 Noob Hubz! BLAZE it
..sry for dat poor english..

Post Reply