Jump to content

Firmware


jayjay23

Recommended Posts

@electric_vehicle_lover

How much of the VESC firmware code is actually dedicated to the FOC and motor detection? Is it mainly the pwm_foc files? I found an interesting controller option that can run a full linux install but retains the ADC and realtime functions of a MCU by offloading real time processes to a real time unit. Would it be an advantage if all the parts that aren't real time specific could just be written in high level code in a standard linux environment? There would be no need to constantly flash firmware either, just SSH in and replace the program that configures the realtime units. It would give you a full ARM a9 cpu for running bluetooth, music and anything else anyone can ever think of in the future.

  • Upvote 2
Link to comment
Share on other sites

@Lizardmech,

Yes, I think is pwm_foc files. I just want to focus on this firmware for motor control and nothing more. Although I use every day and I prefer Linux, I also think is much more complex than I can handle -- I will keep my focus on trying porting VESC/FOC for 30B4 board.

Link to comment
Share on other sites

19 hours ago, electric_vehicle_lover said:

Seems we are reading the same messages on VESC forum ;-)

Someone tried to use it on stm32f1 for quadcopters a while ago. Even on the ST motor control solution the F1 is very limited you have to calculate all the motors electric and magnetic specifications using something else and then code them directly into the firmware. I don't think anyone would use this MCU for new projects, only when you have existing firmware to reuse.

  • Upvote 1
Link to comment
Share on other sites

On 28.7.2016 at 1:08 PM, lizardmech said:

I don't think you can use stm32f1xxx because they lack the FPU that VESC firmware uses.

Does that mean that floating point calculations are completely impossible with it, or does it just do it "in software"? Is it too slow without a real FPU?

Old 286's and 386's (except the "DX" / so-called "387") didn't have FPUs either (if memory serves), but you could still do floating point calculation with them? Maybe it was something like fixed-point integer maths behind the scenes to "emulate" floating point calculations?

If I have the time and interest, I might take a look how Arduino handles this, you can use floats in code (and doubles, but they're just the same as float, ie. no more precision) but the ATMega328's don't have separate FPUs as far as I know.

Link to comment
Share on other sites

You can always perform these sort of things via software, dedicated silicon will often be 1000x faster. If it were cheap to make low volume chips you would see all kinds of application specific hardware. FPGA are the closest you can get but they're still slower than dedicated silicon. FPGA are actually very good for motor control, you can run multiple different motors off one FPGA and they have lower latency, higher reliability  and can manage 100khz+ switching speeds. Some MCUs can run multiple motors but they usually have to share the same specifications and all the MCU does is change the timing.

  • Upvote 2
Link to comment
Share on other sites

I think @lizardmech is correct, also because the VESC developers told that on their forum. Also, please see here the guy that optimized the STM32F103 code for FOC (but doesn't share it): http://scolton.blogspot.pt/2011/11/ah-software-optimization-my-old-friend.html

Open BLDC uses also STM32F103 (I think) but I guess doesn't FOC, nayway, I want to read the code to learn more: https://github.com/open-bldc/open-bldc/blob/master/source/firmware/src/

  • Upvote 1
Link to comment
Share on other sites

Of course I had to look it up (in ATMega-cases), the AVR libc ( http://download.savannah.gnu.org/releases/avr-libc/ ) contains the floating point library code ( avr-libc-2.0.0\libm\fplib ), although I didn't delve much deeper as it's pure assembler... :P

I'd expect that a floating point library (or several) exists also for STM32F1xx's, but it might be too slow for timing sensitive real-time stuff...

EDIT: Here's a thought: do external FPU-chips still exist? Maybe you could add a separate FPU and offload the calculations to that? :P  Don't know if moving data back and forth between the *PU's then becomes the next bottleneck...

Edited by esaj
  • Upvote 1
Link to comment
Share on other sites

I have seen people make FOC controllers with 8-bit MCUs, but there is a big difference between getting FOC running on one motor you know the exact specifications for and run at constant speed. Compared to running it with unknown motors, getting decent low speed rotor estimations, violently changing speed and braking is going to be very different to a basic FOC setup.

  • Upvote 2
Link to comment
Share on other sites

Hi all. Very interesting project. You guys are amazing to write this from scratch. As im not strong skills I tried to use instrcuctions to compile and flash the code. But didnt find makefile. Could you please share it as i coudnt write it by myself. It could be very belpfull!

Thanks!

  • Upvote 1
Link to comment
Share on other sites

@Sindijs The makefile I use and the OpenOCD scripts are here: https://github.com/casainho/casainho-generic_electric_unicycle

Just checkout that repo and put inside the firmware folder. You can inspect the Makefile and see the firmware sources are expected to be here: generic-electric-unicycle/firmware/src/

  • Upvote 1
Link to comment
Share on other sites

1 hour ago, Sindijs said:

Thank you ! 

Got  error:

GNU ld (2.26-4ubuntu1+8) 2.26
generic-electric-unicycle/firmware/src/IMU/imu.o: In function `IMU_read':
/home/user/generic-electric-unicycle/firmware/src/IMU/imu.c:113: undefined reference to `atan2'
Makefile:53: recipe for target 'main.elf' failed
make: *** [main.elf] Error 1
 

Any suggestions ? 

Link to comment
Share on other sites

2 minutes ago, lizardmech said:

Do you have the ARM compiler installed?

Mean this one? :  gcc-arm-embedded

Have this: gcc-arm-none-eabi is already the newest version (15:4.9.3+svn231177-1)

Edited by Sindijs
Link to comment
Share on other sites

41 minutes ago, electric_vehicle_lover said:

I already saw that error of atan2. Maybe I didn't comkit my chabges to make filé.

It is something with libmat that you need to include in the makefile

Could you please just copy content of your makefile here to see difference?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...