Suggestions for OpenSource Electric Unicycle firmware

Support for creating custom user applications on the VESC.
yes_we_can_gogreen
Posts: 40
Joined: 13 Apr 2016, 10:27
Location: uk

Re: Suggestions for OpenSource Electric Unicycle firmware

Postby yes_we_can_gogreen » 06 Aug 2016, 09:55

OK now I understand. I have a cheap 50mhz scope from Rigol.

Why don't you consider to use use the inverter that is already tested from the Chinese boards and add just the bits to have VESC firmware? - I would jump in the project.

But also I don't see you sharing your sources, I would not jump to a closed source project.

lizardmech
Posts: 171
Joined: 19 Jan 2016, 10:54
Location: Australia

Re: Suggestions for OpenSource Electric Unicycle firmware

Postby lizardmech » 06 Aug 2016, 12:17

I didn't put it on github or anything yet, it's too messy for release, many of the parts are redundant because I was using one board design to test different hardware. kicad files are here https://drive.google.com/open?id=0B9A_C ... DZCeC1ZU2M

I'm having trouble with VESC and MCUs now actually, it doesn't flash onto the newer discovery boards I have, openOCD won't flash it, stlink seems to work but BLDC tool doesn't like whatever changed because it can't write firmware. I have to test if it's a faulty MCU but stlink appears to have no issues and the example STM programs run on it. I think they changed something in a recent STM32f407 stepping.

yes_we_can_gogreen
Posts: 40
Joined: 13 Apr 2016, 10:27
Location: uk

Re: Suggestions for OpenSource Electric Unicycle firmware

Postby yes_we_can_gogreen » 06 Aug 2016, 12:53

If you make a 30B4 board using the same STM as VESC, and put the board files on Github, I can help to try port the firmware. I have a oscilloscope, lab power supply, hot air station - I can solder LQFP with some difficultie but I can.

The idea would be to have a mix of Chinese gen 2 boards + VESC. This way we could try to get the best of both worlds and who knows, make a reference design for EUCs.
It is a pity that VESC 5 boards can't handle the usual EUC battery packs 16S.
I think is important to be near the producers that are on the market of EUCs, I really thing current designs are more than enough since they can handle motors to run up to or more than 40km/h. I am looking for other features like RGB LEDs, light motors and batteries and features that depends only on firmware and Bluetooth and app.

Another route can be just use STM32F303 cortex m4 with 256kb flash memory that is pin compatible with current boards. This one should run VESC as it have also FPU but runs half the speed and have hall the memory. But it is pin compatible, no board change is needed!!!

lizardmech
Posts: 171
Joined: 19 Jan 2016, 10:54
Location: Australia

Re: Suggestions for OpenSource Electric Unicycle firmware

Postby lizardmech » 06 Aug 2016, 15:25

The chinese boards are really badly designed, the problem is they just upgraded some 10+ year old ebike controller designed for 250w motors, it's why all the expensive chinese models have constant issues with accidents and blown boards. The best one is the firewheel controller made by hopemotion, they make more expensive servo controllers and modified that for their EUC controller. The mosfet driver they use is still poor with no isolation.

Would it be possible to take portions of the VESC pwm_foc code and turn it into an open library that can run on anything with enough FP power? If the rotor estimator was separated from the other functions you could just use it as an open drop in replacement on many MCUs? I'm no good at programming but looking at the commercial solutions it looks like the all the complex math and estimator functions are contained in one isolated section that is closed source or locked away in the rom. While the VESC one has all kinds of functions in the mcpwm_foc.c file in addition to the critical estimator and clark transformation math.

I can probably incorporate my design into the VESC 5 hardware, I spent most of the time coming up with a solution to replace the drv8302 with something able to handle high voltages, provide isolation without using more space so it would fit without making significant changes. But Benjamin is missing, the last time he posted he said he was going to upload the new version in a day or two and that was a month ago. So I don't know what happened or if he is unable to work on it anymore for some reason.

yes_we_can_gogreen
Posts: 40
Joined: 13 Apr 2016, 10:27
Location: uk

Re: Suggestions for OpenSource Electric Unicycle firmware

Postby yes_we_can_gogreen » 06 Aug 2016, 16:14

OK. I will keep following your developments. I will also keep with my current plans around 30B4 boards.

pf26
Posts: 309
Joined: 28 Mar 2016, 14:37
Location: FR Valence

Re: Suggestions for OpenSource Electric Unicycle firmware

Postby pf26 » 06 Aug 2016, 19:10

Motor control MCUs use several peripherals (timers, ADC converter..) that are very specific to each manufacturer. And you really have to optimize there use, because the timings and synchronization is critical especially with PWM generation and ADC sampling.
There is a general trend going to more standardization and some code can be share and reused. But we are still far from using the same motor control code on different manufacturer MCUs. I think it is a better idea to start from the VESC hardware (last one) and code, and just replace the DRV and FETs. I think that non isolated drivers and 2 shunt current sensors are sufficient to get good FOC behavior, provided the layout is good and current remains below 50Amps (maybe a bit more for limitted times) up to 75/100V. Probably there are some power stage schematics and layout on endless sphere that can be used and coupled to the VESC.
I won't do it right now, because I have enough boards for my projects, but possibly I do it in a few month if it doesn't show up somewhere before.

lizardmech
Posts: 171
Joined: 19 Jan 2016, 10:54
Location: Australia

Re: Suggestions for OpenSource Electric Unicycle firmware

Postby lizardmech » 07 Aug 2016, 05:10

This is how my power stage is configured at the moment.
Each phase has an ADUM7223 isolated 4a driver. It's supposed to have low latency due to inductive isolation rather than an optocoupler, do I need to add some code because of the latency or is 60ns negligible.
Image

But I have software issues stopping me from testing.
1. How do I fix openOCD, vesc firmware and BLDCtool being unable to read or write to MCU flash memory on the newest stm32f407 steppings?
2. Where is the code that handles current sensing? I have 3 highside current sensors I need to configure it to use those.

rew
Posts: 943
Joined: 25 Mar 2016, 12:29
Location: Delft, Netherlands.

Re: Suggestions for OpenSource Electric Unicycle firmware

Postby rew » 07 Aug 2016, 06:44

0) IIRC VESC uses about 300-400 ns of dead time. That 60ns might get lost somewhere in there. If that 60ns is a delay for both directions, then it doesn't eat away at the dead time either. The only thing is that the VESC tries to put the current sampling points strategically, so the optimum point would move a bit. But you have the high side current sensors, so that doesn't matter....
1) I don't know why your openocd fails.
2) I don't think you need to change much (nothing). I haven't had time to test this yet.
The VESC from the CPU point-of-view, just gets a signal centered around a "zero current" point that ranges from 0 (max negative current) to about 3.3V for max positive current. This remains the same... The code is in the ADC callback in mcpwm_foc.c .

If a CPU isn't reachable for debugging, it is usually that you start by probing the power and ground signals (on the chip's pins!). (The STM e.g. won't run if you do not connect VBAT... Check ALL of them even if you think they are not necessary.....).
Last edited by rew on 07 Aug 2016, 08:38, edited 1 time in total.

lizardmech
Posts: 171
Joined: 19 Jan 2016, 10:54
Location: Australia

Re: Suggestions for OpenSource Electric Unicycle firmware

Postby lizardmech » 07 Aug 2016, 07:45

The MCU is fine, I can flash it in windows and make it run ST demo programs, verify binary isn't corrupt etc. Only on the STM stlink program though. You can flash VESC firmware via stlink and connect but it wont work as the firmware cannot read default config data from flash memory. BLDC tool has the same issue, it can no longer erase memory and write new firmware and it cannot write configurations to flash.

Maybe they added mcu hardware changes to prevent st link clones working or tried to make it harder to extract code but unintentionally broke compatibility with open source software. It's on a new STM discovery board, possibly the newer cpu stepping hasn't made it into normal supply chains yet. If it is an MCU revision issue it's possible people trying to assemble VESCs in the future will run into a similar issue as MCU suppliers get through existing stock.

rew
Posts: 943
Joined: 25 Mar 2016, 12:29
Location: Delft, Netherlands.

Re: Suggestions for OpenSource Electric Unicycle firmware

Postby rew » 07 Aug 2016, 08:37

Well... if you really think it is the CPU stepping, then please do look up where you can find the stepping and put the stepping of your CPU in your posting....


Return to “Custom Applications”

Who is online

Users browsing this forum: No registered users and 1 guest