Shop OBEX P1 Docs P2 Docs Learn Events
Has any one adapted or rewritten the code for Jens Altenberg's Flight Control C — Parallax Forums

Has any one adapted or rewritten the code for Jens Altenberg's Flight Control C

LoopyBytelooseLoopyByteloose Posts: 12,537
edited 2005-12-05 14:52 in General Discussion
I was wondering if anyone had converted his 'C' programing code to Sasm or SX/B?

I am particularly interested in what might have been done to create a complete ISR as he has so much to integrate.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

Comments

  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2005-12-04 05:36
    i to am very interested in it but have not taken the time to pull the c apart and rewrite it. i would love to work on this with you or anyone else. i have been working on a simallar project for the basic stamp 2p but am stopped due to much entrigue with the sx28. i now hove the pdb and am working on learning it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    It's Only A Stupid Question If You Have Not Googled It First!!
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2005-12-04 08:15
    I think the first question would be this: Do you intend to use Jen's PCB design as it exists or do you want to redesign his hardware?

    It is a bit awkward to write software if the hardware is first resolved.

    I really like the thermopiles as they seem to be a very stable system for recognizing horizon. Jens mentions adding more to both provide better calibration and control on all axis.

    You could use the Memsic too, but you would have to filter a lot of vibration from the data. A hybird of theropiles on the roll axis and the Memsic providing data on the other two [noparse][[/noparse]pitch and yaw] might be interesting.

    The biggest questions I currently have is how to easily intialize the thermopiles settings in the field [noparse][[/noparse]I guess it means 4 thermopiles] and the how to easily turn on the roll control on a landing approach.

    The roll control needs to be triggered by an altimeter or by a 4th channel R/C signal. I have the 4th channel so it would be cheaper, but require a different board. [noparse][[/noparse]Post script - I see in Jens' code that the roll control is activated if you leave the stick in neutral position for a period of time']

    There is some discussion of LED indicators. [noparse][[/noparse]Apparently the·LEDs are on the radio link reciever which is not implimented at this time.]·It would not hurt to have an LED or two·indicate intialization status. Another LED might verify a motor off condition. I suppose that it could be on the output side of the MOSfet and not waste an I/O pin, but then you would see the motor turning unless you have an off switch (for safety).

    Migrating the code to SX/B or SASM might make it a lot easier to impliment.
    I did so preliminary math and it seems that a 32 or 33Mhz oscillator would be more optimal for providing the various serial clocks that are required. The slower osillator will use a bit less power too. The oscillator selection relates to how much data you need to build a smooth PWM control - 4 bits, 8bits or 16bits. [noparse][[/noparse]I think Jens is using 8bits]

    People who program in C seem to ignore or misunderstand that the environment of the SX-28 really doesn't efficently support a lot of divide and multiply. Using data lookups tables and an appropriate oscillator frequency may eliminate alot of waste in the EEPROM and program's execution.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

    Post Edited (Kramer) : 12/4/2005 1:40:46 PM GMT
  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2005-12-04 15:22
    Kramer, My current system uses the Memsic but have been considering also hybridizing with theropiles. Also, i was planning on redesigning the board (i have a pcb proto milling CNC) Also ,Altitude is not a big issue. I have several devices frome Freescale that work great for altitude calulations. in my last project i only used an 8bit ADC, The resolution is in the 6 foot range. 12 or 16 bit ADC would make it much more reliable for landing aplications.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    It's Only A Stupid Question If You Have Not Googled It First!!
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2005-12-04 15:43
    I have an conventional electric airplane and 4 channel r/c.
    Jens airplane is a 'flying wing' type without rudder, so the mixing is necessary and central to the design.

    My biggest problem is just getting off the ground and I suspect having a flight control computer won't do much for that unless I may stablize roll during take off. But I must admit that I would need a different bit of code to resolve it.

    I suppose I could build or buy the latter type of aircraft, but I am still a novice flyer. That was a lot of the appeal of Jens' solution.

    Where does one buy thermopiles and altitude devices? How costly are they?
    How suitable is the Memsic for flight control of roll?

    I suspect I could integrate the Memsic and a BS24px into my existing airplane for a trial run.

    Most of my confusion about his code is in regards to the ISR. There are several different values being timed off of various counters. It would seem that this might be redundant. Maybe it will become more clear to me as I learn more about C.

    I downloaded the CCS manual PDF as a free reference. Seems ideal because that is what Parallax has adopted and it didn't cost a penny.

    In the meantime, I have a BOEbot that I can set up with my second R/C receiver and try mixing two r/c inputs in Basic. There are some examples in the Projects section.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2005-12-04 17:03
    kramer. i dont know where to get thermopiles yet. havent googled it. [noparse]:)[/noparse] but if you send me a pm i will send you a couple of pressure sensors in the mail. my system that i have been working on all works seperately but not all tested together. i have mounted the memsic on the wing of my aircraft and used it to make the planes wings stay level. i was very amazed that i was able to make that work. also, my altimeter works but the resolution could be greatly improved with a higher bit adc. i am flying electric planes. ailerons rudder and elevator. so not muchmixing is required. i have a board designed etched and populated for the bs2p stamp.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    It's Only A Stupid Question If You Have Not Googled It First!!
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2005-12-05 00:46
    Kramer,

    Bytecraft has a much better download titled First Steps with Embedded Systems. It gives a very good overview of the C language, as well as background on embedded systems.

    Here is the link: www.bytecraft.com/publishing.html


    If you are currently trying to learn C, here are some resources that have been useful for me:

    1. Ch - a C/C++ Interpreter --> www.softintegration.com
    This is a very cool application. It makes coding pretty easy, although you do have to be aware of the differences in implementation of the languages. For instance, it doesn't support fuction overloading in C++, since it is a single pass interpreter, whereas compilers that support overloading resolve the function scope over several compilation passes. But learning that helps understand the languages. It's available for free download, in 2 versions, on several platforms, and they have good tech support if you run into problems. You can also download the ChSciTE editor from the site, which is configured to support the Ch interpreter. It make running your code fairly simple.

    2. In Easy Steps books --> www.ineasysteps.com
    There are 2 books by Mike McGrath that I recommend: C Programming In Easy Steps and C++ Programming In Easy Steps. Both are very good introductions to the languages, have a good amount of reference material included, are inexpensive ( < $10 USD ), and are very hands on.

    3. Steve Summit's home page --> www.eskimo.com/~scs/
    I came across this site from a web search. Apparently he taught some college level courses on C, and he posts his handouts, with assignments and answer on his site. I've been working through them, and they are well done and straight-forward. He also maintians the USENET comp.lang.c FAQ, which is another good resource.

    Post Edited (Kevin Wood) : 12/5/2005 4:09:22 AM GMT
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2005-12-05 09:45
    I am happy to see the book list. It looks like more and more of Parallax projects will be forthcoming in C.

    I found the LED pin in the software code. I seemed to miss it on the schematic which is a bit small to read.
    Jens' text does not go into great detail about the software. It is up to the reader to figure it out.
    It certainly helps to have some experience with the SASM.

    I need to do several things to get rolling on converting to SASM from the C.
    These things are helpful to migrate any C program into SASM.

    1. make a list of all the pins as configured for transfer into assembler
    2. make a list of all the variable assignments in their individual RAM pages
    3. break out the variable assignment by their functional groups
    4. note which 'byte' variables can be reduced to 'flag bits'
    5. list all the obvious code segments by title and then try to describe their activity.
    6. list all the various clocks, ticks, and PWM modes that are to be supported
    7. list all the intializations that are to be suportted.

    And then
    1. Study the SX-Ubicom SPI master interface Virtual Peripherall
    2. Review the Basic Stamp discussion of synchronous serial
    3. Try to comprehend how the synchronous serial C code is working.


    After spending a year reading SX-28 assembly, C looks fairly easy. I had a bit of trouble with some things [noparse][[/noparse]like VOID and ASSIGNMENT], but it is becoming clear.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan

    Post Edited (Kramer) : 12/5/2005 2:47:49 PM GMT
  • Kevin WoodKevin Wood Posts: 1,266
    edited 2005-12-05 11:59
    I downloaded the .zip file from the design contest website, and it contains a file called main.lst. It opens in Notepad, and it looks like it is assembly code mapped to the applicable C code. It might help make more sense of the application for those interested.
  • Brian CarpenterBrian Carpenter Posts: 728
    edited 2005-12-05 12:35
    what is thatlink. cant find it on the site.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    It's Only A Stupid Question If You Have Not Googled It First!!
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2005-12-05 14:52
    Altitudeap,
    Go to the SX-Ubicom page and then click on last year's contest.
    There you will find Jens' entry as the 3rd prize winner.
    Click on that and you will find the resest.

    I had overlooked the possiblity that the code might exist in a HEX file or something close to assembly.

    For myself, this is as much a learning project as a building project. By actually getting into someone's hardware and software and fully envisioning it, I am learning a lot of technical skills.

    When it comes time to build a FCC, it will really be helpful as you don't have much leeway for failure in actual flight.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)

    ······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
Sign In or Register to comment.