You are here

Bluetooth 4 remote

21 posts / 0 new
Last post
bob23
Offline
Last seen: 3 years 6 months ago
Joined: 2020-09-04 02:05
Posts: 12
Bluetooth 4 remote

Hello guys,

I'm wondering if a bluetooth 4 remote would  work if I have a nrf51822 chip connected to a VESC (hw 6 based). 

I found this thing that looks interesting:

I found it cheap, 9$ with free shipping, says it's Bluetooth 4, and already has USB connector, on/off switch and some buttons that I can use for different actions.

Would be great as I could skip the nrf24 chip stuff. Atm I was considering doing a nunchuck version. But this seems a bit more compact, and has more buttons. 

Also theoretically I could still use the app on bluetooth when the remote is connected?

I think these types of remotes are used for VR stuff. The ad mentions it's compatible with IOS/Android phones as well, and has some default mappings for the buttons.

vadicus
Offline
Last seen: 1 day 7 hours ago
VESC Free
Joined: 2018-08-17 07:26
Posts: 426

It boils down to the guts inside this plastic enclosure and whether it's easily reprogrammable. Ideally, it needs to be NRF51/52 family with SWD. 

By the way, no need to withhold the source. We know where to find it: https://www.aliexpress.com/item/33055385661.html?spm=a2g0o.productlist.0.0.4551369fow1Q3l&algo_pvid=8ff74506-6c59-439d-a252-58fd08ee4b01&algo_expid=8ff74506-6c59-439d-a252-58fd08ee4b01-22&btsid=0bb0623915991889105157836e38ef&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_

 

 

 

NextGen FOC High voltage 144v/34s, 30kw (https://vesc-project.com/node/1477)

bob23
Offline
Last seen: 3 years 6 months ago
Joined: 2020-09-04 02:05
Posts: 12

I found it on ebay but I wasn't sure about the advertising politics of this forum.

For 9 bucks I'm not sure they have any NRF52 chip. The cheapest module is about 8 bucks, and cheapest NRF51 module is about 4-5 bucks.

If I decide to try it out and maybe make a pcb with nrf51 for it, I think there needs to also be a controller on the pcb, because the NRF51 module has only TX/RX:

 

I don't see how it would take the analog joystick inputs, or buttons.

Is there any bluetooth remote project around for the VESC?

bob23
Offline
Last seen: 3 years 6 months ago
Joined: 2020-09-04 02:05
Posts: 12

I managed to find some photos of the inside:

https://files.melda.ru/Cycle-R1/

I see that this remote is always called R1 but has different names like Acgam, Magicsee or Luphie.

Seems easy to get into, but space is pretty tight. I don't know how easy would be to add a nrf module on a custom pcb. I like the form factor tho. 

I'm looking into making a remote but I don't like the whole display thing. I find it distracting, I need the remote to be as small as possible, and have customizable buttons to program features like turn on/off the light at night. And I use my phone app to check on battery or other stats, via bluetooth. 

edit: found some other info online about the remote, apparently it only outputs digital signals on/off for the joystick, no analog info from it. So either way a new pcb is needed. 

I noticed the nrf52 project on Benjamin's github, but that is for the receiver. Curious if there's any nrf51/52 code for the remote. pcb is easily done, software is more of a problem for me.

vadicus
Offline
Last seen: 1 day 7 hours ago
VESC Free
Joined: 2018-08-17 07:26
Posts: 426

I think posting a link to facilitate a discussion would be fine. But seems like this forum has been open about people advertising and selling stuff as long as it's relevant to the main theme of the forum. No crime there at all.  

If it's actually using BLE 4.0, there is a very good chance it is NRF.  $4-5 is the retail price. When these things are produced in volume, the production cost can go below a dollar per unit.  

I can't tell from you images what it runs. It would help to post the picture of the actual chip.  If it's any of the nrf, it would be easy to reprogram via SWD but now I think of it this may not be necessary at all. I would just document the protocol and add support for it on the VESC nrf side. It would make little sense in my view to rip out all the guts of this device just to use it's plastic shell. Well, for one off DYI project it would be fine I guess.

If, however, SWD port can be easily accessed without effectively destroying the plastic enclosure, or, even better programmed without opening via DFU, that would make most sense. Otherwise, using the existing comm protocol will do the trick. It would be easy to add to the existing code on the vesc side.

I've had some good luck programming an NRF based watch (https://vesc-project.com/node/1814) to control vesc from the touchscreen, run motor detection, and getting telemetry data. I think it would have a great application for things like hydrofoils because it's water proof but will likely work well for skate boards and such. Making relevant data large print on the screen make it work for ebikes pretty good as well.

And initially, I was using NRF chip on my 20kw controller (https://vesc-project.com/node/1477) but I switched to esp32 as the it's 1/3 of the NRF cost and is a power house of performance and features. 2 core 240Mhz, wifi, 16Mb of flash memory, etc. I can process video stream on it if I want.

 As for the joystick, I would check what's being actually sensors there. Analog would be cool but digital would work to some degree as well. Depending on what the application is. Just mving the cursor, etc. It would be fine.

    

 

 

 

 

 

 

NextGen FOC High voltage 144v/34s, 30kw (https://vesc-project.com/node/1477)

bob23
Offline
Last seen: 3 years 6 months ago
Joined: 2020-09-04 02:05
Posts: 12

I am pretty sure it's one of these one chip solution:

https://www.edn.com/teardown-bluetooth-controller-for-low-cost-vr/

I think I'll buy one of the first one I posted, seems to be having some more space for a custom board. That way I can test what kind of signal it outputs as well, and check if the forward/brake sensing is analog or 1/0.

I got used to the low format of the Koowheel D3M remote and now I wouldn't want to have a larger one, like the nunchuck. So either way I'd need to make a custom remote. Would be great if I could do it with a nrf51/52 chip as I can leave out the nrf24 one. Worst case I'll use a nrf24 on a sort of nunchuck clone in a case that I fancy. I also designed a dc/dc converter to drive a 1W led at night, and I tied it to a free pin on the mcu. I also found a unused button in the nunchuck code, I think the name for it is "PUSH". I just need to tell the VESC firmware to pull high/low the chosen pin. Could I use one of the free ADC pins on the COMM connector for this job? I didn't yet get to the firmware side of the VESC, just about finished the pcb and was looking into what RF solution I go with. I have room for both tho, nrf51 and nrf24. There's not much space so if I go for nrf52 I need to drop the nrf24. Hence why I was looking into the remote solutions.

vadicus
Offline
Last seen: 1 day 7 hours ago
VESC Free
Joined: 2018-08-17 07:26
Posts: 426

Can't be Beken chip if the other remote it BT 4.0 BLE. Beken is 3.0. 

 

 

NextGen FOC High voltage 144v/34s, 30kw (https://vesc-project.com/node/1477)

bob23
Offline
Last seen: 3 years 6 months ago
Joined: 2020-09-04 02:05
Posts: 12

Ah yes, I was saying that it might be something similar. I presume there's other BT 4.0 chips, apart from the nrf51?

Anyway, I'll check it out once it arrives. I'll post some photos of the pcb as well. 

edit: Forgot to mention. the Koowheel remote has a mcu (forgot which one, dual inline package) + nrf24. The downside is it only has one button. Could VESC learn its codes as well?

bob23
Offline
Last seen: 3 years 6 months ago
Joined: 2020-09-04 02:05
Posts: 12

I asked the guy who modded the remote, for some pictures of the pcb.

It's using a ST17H26 SoC:

I think this is the datasheet:

https://wp.geekfun.com/wp-content/blogs.dir/22/files/2019/07/LENZE-ST17H...

The joystick is tied to analog inputs.

I also measured and scaled (roughly) a nrf52840 module (E73-2G4M08S1C) outline. Seems it should fit great. I don't know how it is thickness wise but I think maybe shaving off some plastic should do the trick. nrf24 is similar, the nrf51822 is even smaller.

 

vadicus
Offline
Last seen: 1 day 7 hours ago
VESC Free
Joined: 2018-08-17 07:26
Posts: 426

Seems like there are programming pads there, so it can be reprogrammed. I can't see the SDK or some sample codes readily available for this chip but I haven't looked too deep. In any case, I think with this device and similar ones with obscure hardware, it would be just much less effort to document the protocol and add it to the VESC Bluetooth code. It would take a few lines of code versus cannibalizing the plastic enclosure, ripping and replacing the board. Not worth the trouble if the same can be achieved within the software. For a one off DYI project may be fine though.

 

 

NextGen FOC High voltage 144v/34s, 30kw (https://vesc-project.com/node/1477)

bob23
Offline
Last seen: 3 years 6 months ago
Joined: 2020-09-04 02:05
Posts: 12

That sounds interesting, I think I'll give it a go when I receive it. 

I presume nrf52840 can talk on Bluetooth 4.0 with this chip right?

vadicus
Offline
Last seen: 1 day 7 hours ago
VESC Free
Joined: 2018-08-17 07:26
Posts: 426

Yes, the GATT protocol would be the same provided that it's implemented to the standard on this chip. In your first link, there is a table with keycodes that seem to be the protocol for this remote.

So you would just need process those codes when they are received and map them to whatever action is desired from VESC. I am still not clear whether the joystick is analog or digital. The keycodes suggest the output is digital even though the joystick may be connected to analog inputs on the chip.

 

 

NextGen FOC High voltage 144v/34s, 30kw (https://vesc-project.com/node/1477)

bob23
Offline
Last seen: 3 years 6 months ago
Joined: 2020-09-04 02:05
Posts: 12

I found this table of functions: 

Is there info on what would I see on the RX pin of the receiver nrf51/52 chip when using the remote? Dunno if the VESC board will be done when I start tinkering with the remote. I presume there's a constant flow of info from the joystick, like its position? Is it something like 128 value dead center, 255 full speed and 0 is full stop? Is the sequencing of the variable resistor voltage done on 8 bit or more?

vadicus
Offline
Last seen: 1 day 7 hours ago
VESC Free
Joined: 2018-08-17 07:26
Posts: 426

That table is just the mapping of the functions for Android and iOS. Not a description of the protocol. I doubt it's sending a constant stream of data all the time, that would not be effecient. It's likely sending it when a button is pressed or a joystick is used. But you can't tell for sure with chinese programming. You would need to pair the device to a BT dongle connect to a terminal or to phone running a Bluetooth terminal to see what it is sending. Then document all the events at the byte level.  

 

 

NextGen FOC High voltage 144v/34s, 30kw (https://vesc-project.com/node/1477)

bob23
Offline
Last seen: 3 years 6 months ago
Joined: 2020-09-04 02:05
Posts: 12

I'll get back when I had a chance to play with it. Thank you for the info!

bob23
Offline
Last seen: 3 years 6 months ago
Joined: 2020-09-04 02:05
Posts: 12

One last thing to get out of the way. I see that the nrf51 example from VESC6-Plus schematic has the nrf51822 chip tied on RX/TX as opposed to the nrf24 chip which is tied into SPI.

I presume I can safely use this nrf52832 (the one without USB) variant that is UART only, as the receiver?

http://www.ebyte.com/en/product-view-news.aspx?id=756

The footprint is pretty small, similar to the nrf51822 modules I found on ebay. 

I think the only difference between nr52840 and nrf52832 is USB connectivity which isn't needed anyway. Benjamin Vedder's bootloader code for the receiver also has a nrf52832 reference in the code.

Also this nrf52832 module is cheaper than the nrf51822 one on ebay.

vadicus
Offline
Last seen: 1 day 7 hours ago
VESC Free
Joined: 2018-08-17 07:26
Posts: 426

nrf24 is older tech and still good for it's purpose. It has some advantages over BLE, I believe, mainly lower latency. But it's not Bluetooth 4/5. With that said, I'd go with NRF51/52 because BLE is the industry standard today which means it's compatible with so many devices including pretty much any phones, watches, etc. Benjamin's code would run pretty well even on NRF51 as it has pretty small fotprint, so if the lowwest cost is the priority, I'd go with 51. I've personnally used NRF52840 but I run my adapted Arduino style code that has other features. First I went with this chip because it had 1Mb of flash compare to 512kb in 52832 and, yes, having USB makes uploads simple. Either will work equally well though. It's mostly about the cost and future proofing where you would actually ever need extra memory and performance. 

 

 

NextGen FOC High voltage 144v/34s, 30kw (https://vesc-project.com/node/1477)

bob23
Offline
Last seen: 3 years 6 months ago
Joined: 2020-09-04 02:05
Posts: 12

I managed to fit all three footprints, just that I can either use nrf51+nrf24 combo for phone on bluetooth and remote on nrf24 either nrf52 which is over the nrf24 footprint. this way I'm sure to get something working either way.

vadicus
Offline
Last seen: 1 day 7 hours ago
VESC Free
Joined: 2018-08-17 07:26
Posts: 426

Looks like a good strategy for a prototype. Once you figure out which module works for you best you can remove the other footprints. I liked NRF52840 a lot as you can do so much with so little memory but ended up going to esp32. I thought 4Mb default SPI flash size would give me more than I will ever need but quickly hit the limit because BLE and Wifi libraries alone took about 1.5Mb before you even start adding any of your code. Then 1/2 of flash needs to be reserved for OTA partition and you end up with somee meager 300-500kb that gets eaten up quickly as you start adding more libraries. Thankfully, 16Mb versions are readily available and the price is about the same as for 4Mb. I now have full files system, I can use OTA and I can load complete VESC images onto ESP32. It works great and the price of the chip is 1/2 of the NRF52840.   

 

 

NextGen FOC High voltage 144v/34s, 30kw (https://vesc-project.com/node/1477)

bob23
Offline
Last seen: 3 years 6 months ago
Joined: 2020-09-04 02:05
Posts: 12

You ported the VESC system to esp32? As in, it runs from it and not from the stm32? 

Seems interesting to be able to update the firmware without having to take out the pcb to plug usb into it, but do you need to do it as regular as finding OTA useful? I never thought about the need to upgrade the firmware, I mean I presumed I might do it once a year or something if some useful feature gets out. 

I made the pcb on the original Koowheel D3M pcb size for a direct swap, and it's kinda small. About 94x77mm. I don't think I'd be able to fit two esp32's into it. Maybe the ESP-WROOM-32 modules. 

Do they still talk on CAN? The esp32 is a bad choice for a remote I think, they're pretty power hungry as far as I remember.

vadicus
Offline
Last seen: 1 day 7 hours ago
VESC Free
Joined: 2018-08-17 07:26
Posts: 426

Nope, I didn't port VESC code to esp32. It would be a huge undertaking porting it even to another STM32 chip. I am using esp32 as the communication module that talks to the STM32 via UART. Basically replacing NRF.

Exactly for the reason you specified, to be able to use OTA over WiFi. I can load the bin image to ESP32 and push it to VESC STM32 chip. For my purpose, OTA is very important because once thousands of controllers are deployed, there should be seamless way to fix bugs and add functionality seamlessly without requiring customers to use USB or even a phone app.

I would not call any chip good or bad choice per se, it depends on your goals. NRF is a great chip for the latest BLE functionality which is good but requires extra devices to make communication. ESP32 is two core has tons of performance and memory and wifi on top of it. Consumption is in fact high when it runs full speed but you can bring it down to as little as 2.5µA in hibernation mode. Lot's of flexibility to mange power consumption. 

 

 

 

 

NextGen FOC High voltage 144v/34s, 30kw (https://vesc-project.com/node/1477)