Compiling KK2.1 Steveis Firmware from Source Files

Discussion in 'Custom Programming' started by alm865, Apr 29, 2015.

  1. alm865

    alm865 Active Member

    For anyone else interested in compiling the Steveis Pro firmware, in particular KK2V1_1V18S1Pro, so that they can customise things:
    1. Install VS2010 and install VS2010 SP1
    2. Download and install Atmel Studio 6.2 (it may ask to update VS2010 again, just do it)
    3. Start a new Assembler project, make up a name
    4. Select ATmega644p as the processor
    5. Under Solution Explorer tab: Remove the .asm file from the project that was automatically generated (don't delete it because you will need to see where to add the steveis files later on..)
    6. Copy all the Steveis source files to your project directory in the same directory as the automatically generated, blank .asm file
    7. Under Solution Explorer tab: right click on your project and select add -> existing item (shortcut shift+ctrl+a) and select the KK2V1_1V18S1Pro.asm file
    8. Under Solution Explorer tab: right click on the KK2V1_1V18S1Pro.asm file and select 'set as entry file'
    9. Select release mode instead of debug
    10. Under build select build solution (F7)
    11. Under the output window you should see "Build succeeded.
      ========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped =========="
    12. Done!!!
    A detailed instruction word doc and a solution that has already been set up is attached.
     

    Attached Files:

    Last edited: Apr 29, 2015
    glowingturnip likes this.
  2. alm865

    alm865 Active Member

  3. alm865

    alm865 Active Member

    This is a rather minor mod, but it shows it is possible to add functionality to the Steveis Firmware.

    Using the menu on the KK2.1 gets a bit cumbersome if you want to go back to the top from the bottom of the menu, so I've added a 'loop back to top/bottom' function that allows to user to return to the top/bottom if they press up/down at the bottom/top of the menu respectively.

    I'll probably see how much work adding menu items is, if it isn't much I'll add a reset selection in the main menu (or maybe just clear receiver errors). It's a bit of a pain for me to remove my battery connector, and I'm not aware of an easy way of resetting the KK2.1 in the software.

    Anyways, if I think of some useful mods (or if anyone else can think of some) then I'll have a go at adding them.
     

    Attached Files:

  4. alm865

    alm865 Active Member

    Okay, so adding a menu is trivial, seems it's coded quite well and it's easy enough to follow minus the whole assembler scene...

    So in the attached project (and .hex file) I have added a reset item to the main menu and you can loop directly from top and bottom of the menu.
     

    Attached Files:

  5. glowingturnip

    glowingturnip Well-Known Member

    will follow your progress with interest mate - I'm a bit of a hobbyist programmer on and off, and wouldn't mind mucking about with the firmware too at some point, though at the moment, can't think of anything I'd want to change.

    It's a shame there are only 5 input channels on the board, otherwise it'd be quite fun to use another channel and the extra servo outputs to play around with accessories on the quad
     
  6. alm865

    alm865 Active Member

    I'm not sure how many physical inputs the Atmel chip has, it could be maxed out already.

    Alternatively it might be possible to do away with the 5th input and use it for serial comms with another Atmega chip like the 2560? Although programming serial comms in Assembly from scratch sounds like a bit of a nightmare...

    I'm thinking of adding a "controlled crash" if the receiver inputs are lost instead of just killing all the power like the stock firmware does. That way if you go out of range it'll just attempt to land. It's early days at the moment though, don't know how much time I'll have over the next few weeks. Next rainy weekend when I have nothing to do I'll have a go at adding it.
     
  7. glowingturnip

    glowingturnip Well-Known Member

    controlled crash would be quite cool - you could use the z-accelerometer readings to maintain a gentle downward motion, but boost the motors enough to stop it accelerating downwards. You can also make it kill the motors and auto-disarm as soon as it has no more z acceleration (ie it landed). So long as it's still right way up and level, of course.
     
  8. alm865

    alm865 Active Member

    I was thinking along similar lines. It probably wouldn't work in manual mode but stabilised mode would work okay.
     
  9. alm865

    alm865 Active Member

    Ah damn, just realised I left some old test code in the arm.asm file. Best to get the latest Steveis source files and replace the arm.asm file.
     
  10. glowingturnip

    glowingturnip Well-Known Member

    haha, would that be the onboard virus that makes it attack the Pentagon ?
     
  11. alm865

    alm865 Active Member

    lol, no, not that virus...

    I added some code to detect if the Rx has been lost and it automatically disarms the flight controller. Not overly useful mid flight...
     
  12. GJH105775

    GJH105775 Avid Linux User, and U.S. Air Force 1C6 Moderator

    An easier way is to just unplug motor one(from the KK) and plug it back in. :p Thanks for making this post, it is worth the download just for the loop back in the menu. When I get some time I hope to add a few things. The failsafe is a MUST if you have a Tx/Rx without it already embedded, and can't currently afford a better one.
     
  13. alm865

    alm865 Active Member

    All my cables into my flight controller are now tied down with zip ties so it's a mission to disconnect anything on my Quad.

    Just recompiled the menu mod into a hex file, it is attached. My first attempt at a 'controlled crash' is attached too, I do not recommend anyone use it except for testing purposes (without props!!) as I have no idea if it will even work.

    The basic idea is that if the Rx has been lost, it'll read in the AccZ value and store it in RxThrottle and set the rest to zero. So in theory when you loose the Receiver (while in stabilized mode), it'll level and descend, the faster it descends the higher the throttle, so it should slow it's decent and hopefully land, then disarm.

    That's how I've coded it but in reality it may not work as I expect. Off to test it later on this weekend!!!
     

    Attached Files:

  14. GJH105775

    GJH105775 Avid Linux User, and U.S. Air Force 1C6 Moderator

    Maybe test the controlled crash one with a tiedown or rope.
     
  15. alm865

    alm865 Active Member

    Yeah I'm first going to test it without props (i.e. arm, turn off Transmitter, pick up quad, slowly lower it to the ground and see if the props spin, raise it hopefully the props stop, put it on the ground hopefully the quad disarms)

    Then once I'm happy things are working then I'll tie the thing down with a rope and a stake in the ground and do a live test (never use bricks or weights, I've heard of quads lifting 10kg+ of weight unexpectedly then you have a flying 10kg death machine).

    Obviously I'll need to control the decent rate to stop vortex ring too, that's well down the track though, it's gotta work first....
     
  16. GJH105775

    GJH105775 Avid Linux User, and U.S. Air Force 1C6 Moderator

    Haha, flying death machines are scary xD. Yeah, a building or face brick could be lifted unexpectedly, but get your self a nice concrete block. Also you will want the pilot to be able to regain control if the signal is re obtained.




    [​IMG]
     
  17. alm865

    alm865 Active Member

    So, here is my attempt at a controlled decent when the Receiver is lost.

    It's not perfect, it has bugs and I haven't tested it with props on but it looks like it's working. You've been warned...

    Don't wave your Quad around when it is turning on, for some reason it Arms if it detects it's falling, but only while booting... Any other time it won't arm. I have no idea why and I've tried to stop it but it doesn't seem to like what I've coded.

    Anyways, I'm gonna test this weekend. I'll tether my quad so it doesn't fly away ;-)
     

    Attached Files:

  18. alm865

    alm865 Active Member

    Well, my tests with the props off look really good, raise the quad and it doesn't do anything, lower it and the props start to spin, drop it and the props go crazy trying to stop it from falling.

    With the props on however it's disastrous, it wants to fly away. All my code is attached if anyone else wants to fiddle. I have a feeling I just need to play with the offset and multiplier, no time this week so it may have to be next now :-/

    By the way, the accelerometer output is incredibly noisy! They have added a low pass filter on the Accelerometer Z axis but it still has moments of reading the wrong thing, I'm surprised they managed to get the Flight controller to work as well as they did, the amount of thought that went into the code is incredible!
     

Share This Page