Using M4 with BLDCs - Short How to

Info and discussion about the autonomous Micro FC, suitable for nanos, micros and mini multirotors

Using M4 with BLDCs - Short How to

Postby aBUGSworstnightmare » Mon Nov 03, 2014 7:43 am

Hi,

since I wanted to use the M4 with brushless DC motors (BLDC) too I've designed an adapter board for the M4.
SANY0011.JPG
M4 BLDC+uSD adapter board


EDIT: look here on how to use it with 4S (or more) flight batteries: viewtopic.php?f=40&t=3857&p=29367#p29367

EDIT: look here for info on the Bluetooth connector: viewtopic.php?f=40&t=3857&p=30026#p30026

There will also be some official ones from viacopter (Jussi) soon.
You can find details on the M4 expansion header in the Wiki: http://autoquad.org/wiki/wiki/m4-microc ... n-options/
When building your own expansion boards keep the max. supply voltage of 1S in mind! Here's how I did it on my expansion boards:
supply.png
M4 supply voltage schematic - used on 0r1 and 0r2 board only!
supply.png (37.46 KiB) Viewed 10661 times

The adapter board shown offers two possibilities of supplying the M4 (derived from a 5V source (_+5V signal in the schematic), i.e. BEC or ESC):
1.) via +VB terminal to M4 LiPo connector

2.) via J1-2 = VCOM
+VCOM is the switched supply voltage of the M4 board --> no need to push the M4 'ON'-switch when using this option.
ATTENTION: +VB = +VCOM may not exceed +4.5V! DO NOT CONNECT +VB WHEN JP1 IS CLOSED if you want to use this schematic in your own designs!!!!

ATTENTION:
MODIFIYING THE FIRMWARE AS SHOWN BELOW IS ONLY NEEDED IN CASE OF USING A M4 BETA BOARD (M4r4 or M4r5)! WHEN USING A M4V2 PRODUCTION BOARD (M4r6) YOU SHOULD USE THE FIRMWARE DOWNLOAD WIZARD TO GET THE LATEST FIRMWARE!
THE FIRMWARE DOWNLOAD WIZARD IS HERE: http://autoquad.org/software-downloads/ ... ad-wizard/
YOU NEED TO DOWNLOAD A VERSION WITH 'EXTERNAL ESC OPTION'!


Since you will need to compile a new firmware for this I want to give a short how-too here.
I prefer to use the latest firmware which is available here: https://code.google.com/p/autoquad/source/list

You can either use Crossworks for compiling the firmware (refer to our Wiki: http://autoquad.org/wiki/wiki/building- ... velopment/) or use MAKE (refer to viewtopic.php?f=31&t=3114 for details).

Since the M4 uses the onboard brushed DCs by default you need to make some changes to the source. I will outline them below. A modified set of the sources is attached to this post; refer to these when doing your changes.

1. Selecting the right autoquad board
Board selection is made in aq.h. If you want to use QUATOS make sure to uncomment the related line. The files attached are for using PID!
Changes in aq.h
Code: Select all
#define USE_MAVLINK
#define USE_PRES_ALT          // uncomment to use pressure altitude instead of GPS
#define USE_SIGNALING                   // uncomment to use external signaling events and ports
//#define USE_QUATOS

#ifndef BOARD_VERSION
    #define BOARD_VERSION   8
#endif
#ifndef BOARD_REVISION
    #define BOARD_REVISION   5
#endif


Note: I need to check with Jussi on the board revision you guys got; mine if a modified m4r4 board --> now an m4r5 (Version 8 Rev 5 in case of the sources)!!

2.) All hardware related stuff is in the board_xx.h files (I/O assignment etc). Since my M4 is m4r5 I need to make the changes to board_m4_r5.h.
My expansion board use PA6 for reading the LiPo voltage (voltage divider on the expansion board) thats why I need to disable the SPI1:
Code: Select all
// aBUGSworstnightmare
// disable SPI1 since PA6 is used for LiPo voltage divider
//#define SPI_SPI1_CLOCK          RCC_APB2Periph_SPI1
//#define SPI_SPI1_AF          GPIO_AF_SPI1
//#define SPI_SPI1_SCK_PORT       GPIOA
//#define SPI_SPI1_MISO_PORT       GPIOA
//#define SPI_SPI1_MOSI_PORT       GPIOA
//#define SPI_SPI1_SCK_PIN       GPIO_Pin_5
//#define SPI_SPI1_MISO_PIN       GPIO_Pin_6
//#define SPI_SPI1_MOSI_PIN       GPIO_Pin_7
//#define SPI_SPI1_SCK_SOURCE       GPIO_PinSource5
//#define SPI_SPI1_MISO_SOURCE       GPIO_PinSource6
//#define SPI_SPI1_MOSI_SOURCE       GPIO_PinSource7

//#define SPI_SPI1_DMA_RX          DMA2_Stream0
//#define SPI_SPI1_DMA_RX_CHANNEL       DMA_Channel_3
//#define SPI_SPI1_DMA_RX_FLAGS       (DMA_IT_TEIF0 | DMA_IT_DMEIF0 | DMA_IT_FEIF0 | DMA_IT_TCIF0 | DMA_IT_HTIF0)
//#define SPI_SPI1_DMA_RX_IRQ       DMA2_Stream0_IRQn
//#define SPI_SPI1_DMA_RX_HANDLER       DMA2_Stream0_IRQHandler

//#define SPI_SPI1_DMA_TX          DMA2_Stream5
//#define SPI_SPI1_DMA_TX_CHANNEL       DMA_Channel_3
//#define SPI_SPI1_DMA_TX_FLAGS       (DMA_IT_TEIF5 | DMA_IT_DMEIF5 | DMA_IT_FEIF5 | DMA_IT_TCIF5 | DMA_IT_HTIF5)
// end


I'm using a voltage divider build with a 10K/1K2 resistors. The related changes to get correct readings are:
Code: Select all
#define ANALOG_REF_VOLTAGE   2.85f
#define ANALOG_VIN_RTOP         10.0f
// change resistor setting to 1k2 --> LiPo voltage divider RTOP = 10k, RBOT = 1k2
// aBUGSworstnightmare
//#define ANALOG_VIN_RBOT         10.0f
#define ANALOG_VIN_RBOT         1.2f
// end
//#define ANALOG_EXT_VOLT_RTOP   140.0f
//#define ANALOG_EXT_VOLT_RBOT   10.0f
//#define ANALOG_EXT_AMP_RTOP   1.0f
//#define ANALOG_EXT_AMP_RBOT   1.2f


Last modification in this file is to disable the onboard brushed DC ESC:
Code: Select all
// aBUGSworstnightmare
// comment next line to disable on-board ESC and use BLDC's instead
// motors were on M5-M8 --> be sure your mixer is configured accordingly
// #define HAS_ONBOARD_ESC         84000000
// end


NOTE: Be sure to get your motor mixing table setup correctly! My expansion board has M5 in front left, M6 in front right, M7 in rear right and M8 in rear left position (QuadX mixing)!

3.) Making the LiPo voltage divider read correctly
To get correct readings from the LiPo voltage divider (on PA6 in case of this board) you need to make a modification in analog.h:
Code: Select all
// aBUGSworstnightmare
//#define ANALOG_VOLTS_VIN       0
//#define ANALOG_VOLTS_EXT_VOLT       1
//#define ANALOG_VOLTS_EXT_AMP       2
// use PA6 (ADC_Channel_6) = ANALOG_CHANNEL_SPARE6 for LiPo voltage divider input
// starting counts from 0 (ZERO) --> PA6=ADC12_IN6 = 5
#define ANALOG_VOLTS_VIN       5
#define ANALOG_VOLTS_EXT_VOLT       5
#define ANALOG_VOLTS_EXT_AMP       5
// end


With all those changes made you're pretty much there! Next thing is to get your Crossworks project settings right.
5.) Be sure to build the THUMB RELEASE
project.jpg
Always build THUMB RELEASE for field use!


6.) The firmware flashing tool expects a .bin -file
output.jpg
Select BIN as ADDITIONAL OUTPUT FORMAT under LINKER OPTIONS (be sure Project 'autoquad' is selected in Project Explorer window!)


7.) BUILD the project
Click on BUILD and let Crossworks do it's job.
Your Output window should give you this (for Crossworks V2.3.4 only!; FLASH size is different when using later versions of Crossworks).
done.jpg
Output window after successful build


Now flash your BLDC firmware to the M4 as described in the Wiki: http://autoquad.org/wiki/wiki/m4-microc ... ion-setup/

aqv7.0.r440.b1844.zip
r440 firmware revision for use with external BLDC. Contains QUATOS and PID version for BETA (M4r5) and V2 production (M4r6) boards.
NOT FLIGHT TESTED 'TIL DATE!
ATTENTION: ALWAYS USE EXTREME CARE WHEN DEALING WITH CUSTOM FIRMWARE VERSIONS!
(618.36 KiB) Downloaded 322 times


Here is a .zip-file with the changes. The archive file includes my .bin file too!
r432_modified files for BLDC use.zip
ATTENTION: ALWAYS USE EXTREME CARE WHEN DEALING WITH CUSTOM FIRMWARE VERSIONS!
(157.03 KiB) Downloaded 323 times


Joerg
Last edited by aBUGSworstnightmare on Fri Jan 16, 2015 1:52 pm, edited 15 times in total.
aBUGSworstnightmare
 
Posts: 1460
Joined: Fri Jun 22, 2012 5:24 pm

Re: Using M4 with BLDCs - How to

Postby aBUGSworstnightmare » Mon Nov 03, 2014 7:44 am

Here are some screenshots of my Settings. The ESC were HK blue series flashed with SimonK Firmware, onboard Deltang RX used.
1.PNG
Deltang RX settings

2.PNG
Quad X mixer settings - be sure to get the Motor numbers right!

3.PNG
Used HK blue series flashed to SimonK when doing the screenshot. Other ESCs may slightly vary!
aBUGSworstnightmare
 
Posts: 1460
Joined: Fri Jun 22, 2012 5:24 pm

aBUGSworstnightmare M4 BLDC expansion boards

Postby aBUGSworstnightmare » Sat Nov 22, 2014 6:43 pm

Hi,

just want to add the info on my M4 BLDC expansion boards. There are now 3 revisions out there:

0r1: Power supply as shown in the first post
0r1.png
M4 BLDC expansion board 0r1 - connections

0r2: same as 0r1 but with M2 setnuts for easy mounting of the M4 (as pictured in the first post)
0r2.png
M4 BLDC expansion board 0r2 - connections

Revision 0r1 and 0r2 need to have a 5V source (BEC or from ESC) connected for operation. LiPo connector is used for voltage sensing only.

That's why I also developed a new revision - 0r3 - which is directly supplied from the LiPo (2S-3S).
SANY0019.JPG
M4 BLDC expansion board 0r3

0r3.png
M4 BLDC expansion board 0r3 - connections


ATTENTION:
Some components on the expansion board will get warm during operation! Take take of your fingers!


I/O connections:
M5: J2-7 (I2C1-SCL, PB6; MCU Pin58)
M6: J2-6 (I2C1-SDA, PB7; MCU Pin59)
M7: J2-10 (PC6, UART6-TX; MCU Pin37)
M8: J1-10 (PC7, UART6-RX; MCU Pin 38)

Voltage divider input to M4: J2-5 (SPI1-MISO, PA6; MCU Pin22)
This is only available when JP1 is closed and code changes were in place!

The data sheet of the M4 MCU is here: http://www.st.com/web/en/catalog/mmc/FM ... 5/PF252144
Attachments
M4 BLDC Expansion - 0r3.pdf
M4 BLDC expansion board 0r3 - connections
(123.35 KiB) Downloaded 444 times
M4 BLDC Expansion - 0r2.pdf
M4 BLDC expansion board 0r2 - connections
(146.51 KiB) Downloaded 357 times
M4 BLDC Expansion - 0r1.pdf
M4 BLDC expansion board 0r1 - connections
(146.88 KiB) Downloaded 432 times
aBUGSworstnightmare
 
Posts: 1460
Joined: Fri Jun 22, 2012 5:24 pm

Re: Using M4 with BLDCs - Short How to

Postby boriss » Sat Nov 29, 2014 4:50 am

HI Jörg,

little confused. The boards i got from jussi are labeled as Rev4 online and on the license sticker, but the output in the console is HW ver 8 rev5, thus can i use your FW you posted here ?

Thanks

Boris
boriss
 
Posts: 204
Joined: Wed Aug 08, 2012 7:26 pm

Re: Using M4 with BLDCs - Short How to

Postby Max » Sat Nov 29, 2014 5:00 am

Here's the difference between M4 r4 and r5: http://autoquad.org/wiki/wiki/m4-microc ... rst-option

So if you have the wire mod, then you have an "r5".

-Max
Max
 
Posts: 2814
Joined: Mon Aug 13, 2012 9:45 pm
Location: Near Ithaca, NY, USA

Re: Using M4 with BLDCs - Short How to

Postby boriss » Sat Nov 29, 2014 5:07 am

Thanks okay get it the wired mod turns it into a rev 5 Didn't get that :)

Thanks

Boris
boriss
 
Posts: 204
Joined: Wed Aug 08, 2012 7:26 pm

Re: Using M4 with BLDCs - Short How to

Postby aBUGSworstnightmare » Sat Nov 29, 2014 7:55 am

Max wrote:Here's the difference between M4 r4 and r5: http://autoquad.org/wiki/wiki/m4-microc ... rst-option

So if you have the wire mod, then you have an "r5".

-Max


Hey guys,

I've applied the 'wire mod' to my board, that's why it's now a M4r5.
SANY0307.JPG
M4r5 'wire mod' on a 0r2 expansion board

Would be great if someone could post a picture of an 'official beta' board.

Joerg
aBUGSworstnightmare
 
Posts: 1460
Joined: Fri Jun 22, 2012 5:24 pm

Re: Using M4 with BLDCs - Short How to

Postby boriss » Sat Nov 29, 2014 9:41 am

Sorry for asking questions that might be obvious to you guys, but does this look like a successful flash attempt ?

C:\Users\Boris Schwarz\Desktop\AQ\aq\bin\dfu-util.exe -a 0 -d 0483:df11 -s 0x08000000:leave -R -D C:\Users\Boris Schwarz\Desktop\r432_modified files for BLDC use\autoquad.bin

dfu-util 0.7

Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2012 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Filter on vendor = 0x0483 product = 0xdf11
Opening DFU capable USB device... ID 0483:df11
Run-time device DFU version 011a
Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg"
Claiming USB DFU Interface...
Setting Alternate Setting #0 ...
Determining device status: state = dfuERROR, status = 10
dfuERROR, clearing status
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 011a
Device returned transfer size 2048
DfuSe interface name: "Internal Flash "
Downloading to address = 0x08000000, size = 226528
...............................................................................................................
File downloaded successfully
Transitioning to dfuMANIFEST state
Resetting USB to switch back to runtime mode
No valid DFU suffix signature
Warning: File has no DFU suffix
Error during download get_status
can't detach

-------------

Rev 432 is shown after the attempt, but didn't even check what i had on before. And in the parameters the Lic key was still present shouldn't that be gone after a FW update ?

Thanks

Boris
boriss
 
Posts: 204
Joined: Wed Aug 08, 2012 7:26 pm

Re: Using M4 with BLDCs - Short How to

Postby Max » Sat Nov 29, 2014 9:48 pm

Yea that seems fine. Sometimes I see that last "can't detach" error from dfu-util, sometimes not. It's trying to detach from the device (M4) and restart it, which I guess sometimes fails. The flashing part works consistently though, so just reboot manually and you're set.

When flashing with dfu-util, the params are preserved. Feature, not a bug! :) I know no one reads it, but the "Confirm Firmware Flashing" prompt in QGC will make the distinction and warn when params will be wiped. Among other things... ;)

usb-flash-warn.png
usb-flash-warn.png (23.39 KiB) Viewed 10440 times


-Max
Max
 
Posts: 2814
Joined: Mon Aug 13, 2012 9:45 pm
Location: Near Ithaca, NY, USA

Re: Using M4 with BLDCs - Short How to

Postby DUKE40 » Sun Dec 07, 2014 5:29 pm

Hi Jörg,

do you know if there is any possibility to use it on a Hexacopter? I am thinking about building a NanoHexa with an M4 on it, but need to know if this is possible at all without CAN for the ESCs, as ESC32 would be to big for the project.
Best regards,
Image
Spacewalk 550, MT2216-11, SimonK 20A ESC, AQ6 DIMU, 10x5" CF, SJ4000
CamCruiser, MN3510, ESC32, AQ6 DIMU, 12x4" CF, SimpleBGC, GoPro Hero 3 BE
DUKE40
 
Posts: 364
Joined: Tue Mar 26, 2013 9:49 pm

Next

Return to AutoQuad M4 Micro Controller

Who is online

Users browsing this forum: No registered users and 3 guests

cron