Saturday, July 6, 2013

Hobby King MultiWii 328P Flight Controller w / FTDI & DSM2

The latest toy in the Man-Cave is this little beauty.
Credit to:



This board has plenty of features at a very reasonable price (Cheap) BUT the is a good reason for it. Its like the boards were from a prototype production run. There are missing tracks and incorrect pin labels. Many ports are named incorrectly, some PINS CPU are wired incorrectly or not at all. To quote Google translated Tungsten: "Even the Broken Played Software is not fault-free - including the functions for measuring voltage and signal LEDs are not enabled". See Tungsten's pictures and mods further down

Introduction.

Before diving in with Tungsten's modifications (Below), I download Multiwii 2.1 GUI and installed it, unpack your Hobby King MultiWii 328P Flight Controller w / FTDI & DSM2 port and connect it up to your PC (I was doing this before to couier had cot back in his van) . 
The board actually comes with a USB to mini-USB cable thats of reasonable quality but no cables to hook it up the controller and the receiver
The USB chip is FTDI so you shouldn't need to download drivers for any of the later widows versions.(I didnt for Win7 64)
MultiWii software for X-copter is preloaded but I'm told a bit buggie but good enough to check the board I bought works and have a play. Fire up MultiWiiConf_2_1.exe, select your COM port (It will likely be a high number depending on the USB port on the PC you have used).  Click [Start]  and you should see a number of coloured lines running accross the white window, wiggle and swivel the board around all the axis. For each movement you should see changes in the coloured lines and corresponding movement of the Pitch, Roll and Compass indicators (plus the little stick figure quad copter will move). To check the barometer (The square tin witht the pin hole) blow gently across it and the line corispondiing with ALT should dive to the bottom of the screen (This is why you should attach a piece of foam over it when you „Go LIVE“)

Getting started

First you should load new MultiWii 2.1 software, since  the included software cant be trusted. Below is links to a few turn-key loads. (More to be added mine included)
  • Tungsten's Multi Wii 2.1  X-Copter with battery monitoring. (You need to complete his modifications for all the features to work)

Using the  Arduino software Stop your snickering Jacob

Not being a total noob I managed to download the software and set the com port (Hey I knew it from playing with the Multiwii Conf software). Then the wheels came off.  So I posted this in a few places:
Guys I've just taken delivery of one of these boards and plan to use in in Airplane mode (Later for a quad) I'm a complete noob so some of these questions muy be ready stupid. I been reading up everywhere and anywhere about multiwii etc (Steep learning curve)
www.flugwiese.de has some really helpful info and I plan to make the changes to the board he metioned.(Just need to grab some kynar wire)
This is where I came unstuck, looking at his config zip fle, do I change/generate (MultiWii Platform Config tool) my own config.h file.
Then using Arduino Sketch software add that and the balance of his files and complile?

Other dumb questions
is there any way to backup the config on the board before I take the plunge?
Under Tools->Board What selection is the Atmega328P (In 1.0.5 there are 7 choices metioning the 328)
Under Tools->Programmer what do you select for the direct connection via USB.

Nada ! It was like I was using invisible font. (In the radio and electronics forums the Mod will move your post to the kindergarten section or after a few flames some kindly sole will take pity on you)
Then after much Googling, I found this little peal of wisdom courtesy of Mr majek  (Dont you just love blogs)
 "choose Tools/Board/Arduino Pro or Pro Mini (5V, 16MHz) w/ Atmega328"
  Ah-ha! One step closer.
Another tip from majek's blog, dont open a .h file go the biggest ino file in the case of Tungsten's ZIP file that was MultiWii_2_1_HK_Board_V3.ino and hey presto I have a whole bunch of Tab's. As I plan to use the board in a foamie first, I went back to Google looking for Multiwii Airplane Config.h …...Multcopter, X-Copter, Quadcopter, Hexcopter Tricoper and even Bicopter.
  
Tungsten's modifications (after tweeking Google translate)
Solder a thin wire from pin 12 of the CPU to pin D9 (labeled BUZ on the board).
Then cut the track from D9 (BUZ) to D9 (Confused yet? BUZ is actualy D8 and we are making it so) Note the yellow line in the figure below.


Those who wish can also wire the pin A3, which is not necessary, however, because the V_BATPIN has been redefined according to the software provided above to A7. Then the additional 2.54 solder connectors to the pads A7, A6 and D8 (formerly D9) can also used

 

Modified table from majek's page

Atmega328 pin and description
Arduino pin
HK’s controller pin
After Tungsten's mod
1 (PD3/PCINT19/OC2B/INT1)
D3
AX4
 No change
2 (PD4/PCINT20/XCK/T0)
D4
ROL
No change
9 (PD5/PCINT21/OC0B/T1)
D5
PIT
No change
10 (PD6/PCINT22/OC0A/AIN0)
D6
YAW
No change
11 (PD7/PCINT23/AIN1)
D7
AX1
No change
12 (PB0/PCINT0/CLKO/ICP1)
D8
unconnected
D8, (BUZ/D9)
13 (PB1/PCINT1/OC1A)
D9
D9, BUZ/D9
D9 (Motor)
14 (PB2/PCINT2/SS/OC1B)
D10
D10
No change
15 (PB3/PCINT3/OC2A/MOSI)
D11, MOSI
D11, J5-4
No change
16 (PB4/PCINT4/MISO)
D12, MISO
PWR, UN4(***)/D12, J5-1
No change
17 (PB5/SCK/PCINT5)
D13, SCK
J5-4, led D4
No change
19 (ADC6)
A6
UN2(***)/PSE
No change
22 (ADC7)
A7
UN1(***)/BAT
No change
23 (PC0/ADC0/PCINT8)
A0
A0
A0
24 (PC1/ADC1/PCINT9)
A1
A1
A1
25 (PC2/ADC2/PCINT10)
A2
A2
A2
26 (PC3/ADC3/PCINT11)
A3
unconnected
N/C lable now A3
27 (PC4/ADC4/SDA/PCINT12)
A4
SDA (*)
No change
28 (PC5/ADC5/SCL/PCINT13)
A5
SCL (*)
No change
29 (PC6/RESET)
RESET
J5-5
No change
30 (PD0/RXD/PCINT16)
D0, RX
AX2, DSM-S(**), USB
No change
31 (PD1/TXD/PCINT17)
R1, TX
AX3, LCD
No change
32 (PD2/INT0/PCINT18)
D2
THR
No change

(*) – pins SDA and SCL are connected by 5V to 3.3V level converter
(**) – this pin is also connected to jumper J1 which connects DSM2 port
OR USB interface.
(***) – pins named UNx are pins without names (on old version of board, new one has labels near all pins). On right row there are pins: …AX3, AX4, UN1, UN2, BUZ, PWR, LCD, UN3. On bottom connector there are pins: … A2, UN4, D11,…
Header J5 haven’t header soldered.
Led D1 indicates that main 5V voltage is applied to the board.
Led D5 is connected after 3.3V voltage regulator.
Leds D2 and D3 are connected to FTDI chip and indicate USB uart activity.
And one
warning: this processor have only one serial port, DSM2 input uses it, so it’s not possible to connect receiver to this port and at the same time use usb interface for configuration! 
  •  I've read some stuff about using I2C for the GPS, Ladyada I think (Gunna have to try that !)

 Tungsten's X-copter Guide

To install the FC board in the copter, complete following:
Terminals
RX
D7
AUX1 (switch for stabilization)
 D12
AUX 2 (for switch position control) channels 5 and 6 of the receiver can be connected.
D6
YAW
D11
Connections to the receiver to control of the motors as per the MultiWii Copter X-diagram.
D3
D9
D10
D2
Power
D4
CROSS
D5

D6
HEIGHT = PAGE

(Here designated as common area fliers).
 
If you would like to monitor the voltage of the flight battery, so soldered to a voltage divider consisting of a 51K resistor and a 33K resistor to the central power distribution of the copters between plus and minus one. The center then goes as a single wire to the terminal A7 of the board. (See diagram above)
TIP: If you can not get 51K
resistor, then simply use a 47K and a 3K9 resistor in series.
         51K (47K and 3K9 in series) and 33K

To signal the under-voltage, a bright LED is then connected via a resistor (180-330 ohms), which begins to blink when the battery voltage drops below 10.7 volts on pin 8. The LED and resistor are soldered to a connector and plugged directly into the board.
Now the board is ready and a successful application should not stand in the way.
Another note in conclusion: The printed on the board in the upper right corner arrow points forward in the direction of flight of the copters. Please install the board correctly.

Notes from Majek   

To properly compile I had to get source from MultiWii_shared and rename directory to MultiWii.
Once opened sketch MultiWii.ino, there should be multiple tabs with included files. In this version there is enough to modify config.h: uncomment #define HK_MultiWii_328P and copter specific options (for me there were TRI, MINTHROTTLE and SERIAL_SUM_PPM for CPPM output from FrSky receiver).
I flashed it with this firmware without any problems using only usb cable and above configuration (this board already has flashed Arduino bootloader).
Update 2013.04.27
I ordered another one and it looks like a little different version. At least it has all labels near pins, so I updated table above. Additionaly it has soldered pin header on ISP (programming) pins.


Useful links to other sites on this board: 


4 comments:

  1. Great write up!
    So did you find a way to backup the already installed code in your board?

    Sakis

    ReplyDelete
  2. Hi Sakis
    There is a way but it was dependent on if the protection fuse was set. As it turns out I did not need to. After performing Tungsten's (and others) mods I did not need it. I have versions 2.1 and 2.2 of MultiWii conf that now use D7, D9 and D12.
    Rod

    ReplyDelete
  3. Hi Rod, thnx for the reply. I am waiting my GLB package with the FTDI programmer and then I will just cross my fingers.
    My quad:
    http://www.rcgroups.com/forums/showthread.php?t=1970923
    Another thread with info:
    http://www.rcgroups.com/forums/showthread.php?t=1757643
    I am having a blast FPV flying with that cheap- basic quad.
    I just love the versatility!

    Sakis

    ReplyDelete
  4. This is a very comprehensive Blog well done. However i am having problems my self. i am yet to find anyone to ask a few questions of, my hope is that you may have an idea of the best direction to take. Its my first scratch build X-Quad I have done pritty much what you have suggested here yet i am having problems with Yaw control. Pitch and roll seems to work (hard to tell in flight when all the copter want to do is spin, Anti clockwise i will add). If i hold the copter spin up the props and then tilt there is resistance so this tells me that the Gyro is working, If i rotate it the opposite prop to the rotation will spin up while the rest slow down. The PID settings are at 4, 0.0045, 15 for pitch and roll and 8, 0.000, 0 for Yaw. Im hoping to get some fresh ideas as i have run out and am looking at throwing it in the bin. The board is i believe to be the same as the second one you pictured.

    ReplyDelete