You are here

Dual VESC, Dual UART?

11 posts / 0 new
Last post
kneave
Offline
Last seen: 2 months 5 days ago
Joined: 2018-08-18 15:59
Posts: 6
Dual VESC, Dual UART?

Howdo,

I've two VESC 4.12 boards and will be connecting them via CAN and controlling them using a VESC Wand.  One thing I realised only after buying the latter is that it doesn't have a deadmans switch and that it'll be using the UART.  My previous plan was to make my own remote and that there'd be an Arduino connected to allow for other things like light control (brake lights for example) as well as data logging.

It occurred to me there is a UART on the second VESC, the guides say to disable this app however I was wondering if I could use it too for telemetry?  I'm not sure how to do the deadman switch, I was thinking a pressure sensor in the rear truck to detect a rider but I'm not sure how I'd interrupt the signal from the remote.

Does anyone have any suggestions please?  I'm a little worried about the whole "screwing with the throttle/brake and dying" thing so a bit hesitant just to try things out!

Could adding an Arduino on the CANBUS be an option too?  Maybe UART+PWM and send a brake signal?  I'm not sure if PWM would have priority or not though... 

 

TheFallen
Offline
Last seen: 1 hour 57 min ago
VESC FreeVESC Original
Joined: 2017-09-11 11:46
Posts: 222

Finish the Luggage!

I'd be tempted to add the Arduno to the CAN bus, maybe a Teensy with SD Card shield and CAN shield and just spy on the CAN bus for the data. You can set the VESCs to update pretty regularly on CAN.

I've not really used the timeout features in VESCs so I can't comment much.

Duane Degn
Offline
Last seen: 2 months 3 weeks ago
Joined: 2020-08-01 02:54
Posts: 14

You could place a microcontroller between the Wand's receiver (assuming it's external to the VESC) and the VESC board. You could normally pass along UART transmissions but when it's appropriate to do so, you could send your own control signals to the VESC.

I'm doing something similar with two dual VESC boards. I'm still in the process of figuring out the UART interface but I'm slowly figuring it out. I'm using an 8 core Parallax Propeller chip as the microcontroller. This allows me to have custom UARTS and other inputs and outputs. Here's a link to a Parallax forum thread on the topic.

http://forums.parallax.com/discussion/171979/vesc-uart-control-with-spin

I want to make my own remote at some point but I'll likely start out by using Wii Nunchuck. I'll have the Propeller receive the Nunchuck data and then have the Propeller chip decide when to override the Nunchuck signal.

Something similar could be done with an Arduino type microcontroller but you probably want to use a capable microcontroller like the Teensy suggested by TheFallen. You don't want to use an Uno and resort to using a soft serial.

Using the CAN bus is probably a good idea but that's an added layer of complexity over a normal UART. As long as you keep your wires short a normal 3.3V data signal should be OK. At least I'm hoping a 3.3V UART will be OK.

I believe it's possible to use both PPM and an UART at the same time. I plan to test this later today. If this is the case, you could send your throttle commands over PPM and use the UART to continuously request "GET_VALUES" which replies with a bunch of data. I doubt this approach would be practical if your using the Wand, but if you use a different remote with a microcontoller interface, this could be an option. I'm pretty sure the data returned with the GET_VALUES command is most of the data you'd want to log. I'm planning to log the data to an SD card in my project.

I realize I'm thinking of using PPM as an input because I'm having trouble figuring out how to command the VESC using the UART. The GET_VALUES command is working but my attempts to control RPM and current to the motors haven't been completely successful (it would be more accurate to say my attempts haven't been complete failures, just mostly failures).

I hope you keep us updated on whatever you try. It's really interesting to see how other people use their VESCs.

Duane Degn

kneave
Offline
Last seen: 2 months 5 days ago
Joined: 2018-08-18 15:59
Posts: 6

Ha!  Fear not, I've an ODrive for The Luggage as I'm designing a cargo robot that will have an alter ego...

kneave
Offline
Last seen: 2 months 5 days ago
Joined: 2018-08-18 15:59
Posts: 6

Thanks Duane, the "man in the middle" idea had occurred to me, I've been planning on using a similar idea to snoop on my eBike controller, I love the Teensy as well so very much on to a winner there I think.

Thanks both for your thoughts, I'll be sure to update on here for sure :)

tabor
Offline
Last seen: 4 years 3 months ago
Joined: 2020-08-20 03:37
Posts: 2

I am trying to do something similar to this.  Want to simply control a Flipsky Dual 4,20 rto control a cart with an Arduino.  I can get the status from Arduino BUT cannot get it to move the motors.  With nunchuck command I can get it to move but erratically.  Have spend weeks trying to get a simple motor to change speed with an Arduino via a UART.  No idea what I could be wrong.

 

tabor
Offline
Last seen: 4 years 3 months ago
Joined: 2020-08-20 03:37
Posts: 2

I'm having problems trying to do something similar.  Can't get an Arduino to simply change the speed of a motor using a Dual 4.20 Flipsky drive.

Duane Degn
Offline
Last seen: 2 months 3 weeks ago
Joined: 2020-08-01 02:54
Posts: 14

"With nunchuck command I can get it to move but erratically."

Which brand of Nunchuck did you use? I've had success with a Nyko/Kama Nunchuck. I've seen this brand mentioned several times in VESC documentation so the sortware might behave differently with other Nunchuck brands. I recall becoming very frustrated on other microcontroller projects when attempting to switch brands of Nunchucks. Some drivers (especially the one I wrote) seemed to work best with specific brands.

The Nuchuck uses the same pins as one of the UART's tx and rx pins. You need to be extra carefull when attempting to interface over UART and Nunchuck at the same time.

I have this VESC:

https://flipsky.net/collections/electronic-products/products/dual-fsesc6-6-plus-based-on-vesc6 The TX and RX lines on connectors 6 and 7 are electrical linked to each other (TX to TX and RX to RX). If a Nunchuck is connected to connector 6 then the TX and RX lines on connector 7 will interfere with the Nunchuck and visa versa.

I tried setting the RPM over UART without any luck. I think my VESC was in the wrong mode to accept this command. When I attempted to set the current to the motor, I had one motor spring to life and then turn back off. I don't know why only one motor turned on. I don't mind controlling each motor with a separate UART but I'm pretty sure there's a way to have commands passed from one VESC to another over the CAN Bus. It's possible the motor turned off since the UART went quiet after the SET_MOTOR_CURRENT command. If I were to write ESC software, I'd have the motors turn off if the UART went quiet. It's likely Vedder added a timeout function as a safety feature.

I'll keep experimenting and post updates as I learn more.

 

Duane Degn

Duane Degn
Offline
Last seen: 2 months 3 weeks ago
Joined: 2020-08-01 02:54
Posts: 14

My assumption of the VESC needing continuous UART data in order to not timeout appears correct. When I sent MOTOR_CURRENT commands at about 8 Hz, the VESC would respond to serial commands as hoped. I still don't know how to control both motors from a single UART so I'm going to try connecting to each of the two UARTs on the VESC.

Duane Degn

kneave
Offline
Last seen: 2 months 5 days ago
Joined: 2018-08-18 15:59
Posts: 6

There's definitely a way to control both from UART over CAN as that's how the Wand does it.

I've just discovered that the dongle for the VESC Wand actually provides BLE data too, I'm wondering if that may be the solution to my problem if I can connect to it from an Arduino on the same board.

 

Duane Degn
Offline
Last seen: 2 months 3 weeks ago
Joined: 2020-08-01 02:54
Posts: 14

My idea of using two separate UARTs to control the dual VESC appears to work OK. I can sent the MOTOR_CURRENT on each VESC and control the motors. The motors don't start turning until MOTOR_CURRENT is set to about 500. Controlling the current is useful but I'd really like to figure out how to control the RPM directly had have the VESC adjust the current to produce the desired speed. I'd be very surprised if the VESC can't do this sort of thing. It's likely my own lack of understand which is holding me back.

It does feel good to be able to at least control the motors with current.

When the two VESCs have the MOTOR_CURRENT set to 500, the combined current draw from the 47V battery is about 160 mA. Is the setting of 500 supposed to be 50mA? It's possible the current setting isn't accurate at low power levels. Hopefully once I have the motors under load and running at normal skateboard speeds, the MOTOR_CURRENT figure will make more sense to me.

Duane Degn