Jump to content

Firmware


jayjay23

Recommended Posts

This is the every first time I have the motor running with MicroWorks 30B4 board and my firmware. The motor is from my old generic EUC.

The current firmware have all drivers working:
- timer2 for timmings
- ADCs readings for phace A and phase C currents
- ADC for battery voltage
- MPU6050 including the angle measument
- USART for the Bluetooth module
- buzzer
- LEDS
- hall sensors
- PWM mosfet drivers

The motor worked at the first try!! but I guess I still can adjust a better rotor angle and test on more speeds:

@Lz Lee 

 

  • Upvote 3
Link to comment
Share on other sites

@changfrancis,

So the board we are using is this from the list: https://github.com/EGG-electric-unicycle/documentation/wiki
I am using a cheap "slow" motor from my old cheap other generic EUC, but in the end I will want use the MicroWorks 30km/h motor.

If you want to develop actively, I recommend 3 x MicroWorks 30B4 board (because it may burn some components on the experiences), one motor (on this phase maybe one slow that ask few current/power), one lab power supply that can handle 60V and 5A (or more if possible) and one oscilloscope.

For the compiler I use the ubuntu repositories arm-none-eabi-gcc. The IDE is the Eclipse with the plugin for the debug: http://opensource.zylin.com/embeddedcdt.html
OpenOCD 0.9 from ubuntu repos. The firmware github have the OpenOCD scripts I am using and the project files for the Eclipse.

Please ask if you need more information.

  • Upvote 1
Link to comment
Share on other sites

@changfrancis,

You will also need some connectors, the connectors female and male for the battery; for the charger. Also buy the 2 pins and 5 pins connectors for the headers on the board, to let you connect hall sensors, etc. I also use some of the free pins to get GND a 3.3V from the board and input to ADC a potentiometer signal.
You can find this connectors on ebay.

Link to comment
Share on other sites

I got the same microworks 30b4 board from Taobao.com the eBay of China. It will take about 2 weeks before it arrival. As for now I will need to know how u connect up the circuit for programming. Can u show me the required connection ? Programmer to controller board. How the jumper points are connected ? And can we Program it over Bluetooth ? 

I do have the necessary lab equipment to power up and scope the signals. I will take about 4 weeks from now before I can contribute to the community. 

Btw, from what I understand u had successfully flash the stm32, reads adc/i2c from imu and spin up the motor. Now what is missing the pid/fuzzy logic controller for balancing ?

 

  • Upvote 1
Link to comment
Share on other sites

On header J10. I should document this to the wiki. 3 pins: GND, SWDIO; SWCLK (from left to right on the picture):

SWD.jpg

I never tried with Bluetooth. Please see the simplified schematic I wrote - you will see the bluetooth/usart pins are connected to the USART that communicates with the STM32F103 bootloader. So should be a matter to try the app to flash firmware and select the correct serial port on PC - I would try on Ubuntu but for now I am working on the motor firmware.

On firmware for gen2 (30B4 board) I have the motor working but only with hall sensors. Also I can read with success the ADC values from phase A and phase C current.
For my understanding, the motor need to run with hall sensors at start and at very low speeds. After than that, the algorithm should change to sensorless and avoid the hall sensors signals.
I see some reasons for motor sensorless and FOC:
- need of hall sensors because FOC and sensorless don't work for zero and slow speeds
- sensorless don't need hall sensors and in the case the signal fails, when riding at high speed, the motor can keep working perfectly, so the system is more robust. In the case of hall sensors fail, if the motor is running only at low speeds, not danger for the rider
- hall sensors just provide rotor angle value in steps of 60º (6 steps only for the 360º total) and sensorless with estimation rotor angle should get much more resolution, I guess at least 1º VS 60º - this should improve motor efficiency, torque and quietness.

So, there is missing code for motor FOC and sensorless. Sensorless may be the most difficult because there is heavy math to be done for a Sliding Mode Observer to get the rotor angle. On top of this, STM32F103 don't do float point operations...

Just when having the motor with FOC and sensorless when can them finish the firmware.

BUT, hall sesnors are ok for slow speeds which means a firmware can be done for a proof of concept of balancing the EUC :-)

  • Upvote 2
Link to comment
Share on other sites

@esaj and others,

About mosfets burn on 30B4 board: the IC driver for the mosfets forces that everytime one mosfet is ON. When the the board resets, always the mosfets that are ON are the 3 ones that connect the phases to ground (braking the motor), this is the default after reset. For instance, on Gen1 board, I controlled directly each 6 mosfets and at reset they were all disable meaning the motor would free wheel.

So, on 30B4, if for some reason the motor get to high speed but suddenly the power fails and the board quick resets and the power goes on again, the motor will try to quick stop!! and the generated current should be high and burning mosfets. I bet this was happnned to my 2 boards, were I was using the lab power supply with current limitation. The motor quick spin on the air, the current were high and the pwoer supply quick reset... and then mosfets burnned :-)

  • Upvote 1
Link to comment
Share on other sites

Hi,

I found a chinese link on how to flash a rockwheel using BT. http://tieba.baidu.com/p/4407878290?pid=85556695575&cid=0#85556695575

LOL... this is my first time "googling" in chinese website. I also found chinese taobao(ebay) seller selling the source code for the PCB and C code. Price at $18000USD. LOL...

Edited by changfrancis
wrong price value
  • Upvote 1
Link to comment
Share on other sites

Thanks for the findings!!

For what I could understand from the translation of Google( great technology!!) The process explained is how to buy a generic cheap Bluetooth serial module and configure it to work the same as the original: the device name, nauseated and the pin. No information on how to flash.

Anyway, the STM32 can be flashed with a serial port taking advantage of the base bootloader of STM32. On our case, the Bluetooth module is connected to the serial port so we just need to use the same tools from STM - nothing really special. I have all the tools for it but I never did it, I will try in the next days.

The tool for Linux: stm32flash - http://rdpzycho.blogspot.pt/2014/06/stm32-flash-loader-for-linux.html?m=1

 

Link to comment
Share on other sites

no worries about the flashing over wireless(BT). I am currently trying to catching up on BLDC controller algorithm. 

How it works and what are the practical problems that we will face. I am also trying to understand why there is a need to use 2 control algorithm for low and high speed.

BTW, what does FOC stand for ?

Last, i always thought there are regenerative braking on unicycle but after looking at the "googled" circuit diagram. I guess there is none, the bigger capacitors is just receiving more charge causing more LEDs(battery indicator) to light up as we ride down slope :(

btw, my skype id is changfrancis@hotmail.com

 

  • Upvote 2
Link to comment
Share on other sites

FOC filed oriented control. See "teaching old motors new tricks" videos of TI on YouTube.

I don't understand many about regen but it just happens with current circuit and control. Everytime you force the motor to rotate, it will generate voltage that will make current flow to the battery. For instance, at a constant speed, if a load force the motor to run faster, the voltage will increase on bus voltage and current will start flow from the motor to the battery. I think is simple like this. To limit the current, we can measure it and adjust the duty-dycle.

 

Link to comment
Share on other sites

1 minute ago, changfrancis said:

Hi electric_vehicle_lover,

I noticed the firmware link is gone ? Are you stopping the development ?

I found it, sorry

Do you have a github account? please tell me your nick and I will add. There is a lot of things to do, since the firmware, the app, documentation on the wiki, etc :-)

Link to comment
Share on other sites

1 minute ago, electric_vehicle_lover said:

Do you have a github account? please tell me your nick and I will add. There is a lot of things to do, since the firmware, the app, documentation on the wiki, etc :-)

My github account is under: changfrancis@hotmail.com

My board and programmer will arrival coming tuesday. 

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...