Shop OBEX P1 Docs P2 Docs Learn Events
Another Prop Controlled LED RC Airplane — Parallax Forums

Another Prop Controlled LED RC Airplane

xanaduxanadu Posts: 3,347
edited 2013-06-02 09:49 in Robotics
This is the third RC plane I've put LEDs on. I've learned from my last two airplanes that I only need a few LEDs to be able to fly but more LEDs is a real crowd pleaser. As inclined as I am to please people, none of these people carry spare LiPos and if they did probably have the wrong connector. So how can I minimize the number of LEDs to get more flight time, but also not let our audience down?

Add a microcontroller. I can make some lights blink, which not only makes up for lack of LEDs but also cuts down on power as well :)

[video=youtube_share;_SwmvyhGOBQ]


{{

Airplane Anti-Collision, Position, and Nav light testing

}}

CON

 _clkmode = xtal1 + pll16x  
 _xinfreq = 5_000_000

 BLED = 2                      'Pin of Blue Canopy LED
 STR = 1                   'Pin of thy Strobe Lights


VAR

 long beacons [100] 'stack space
 long strobess [100] 'stack space
 long BLEDi 


PUB main


 dira[BLED] := 1     'enable output on blue LED pin
 dira[STR] := 1     'enable output on strobes pin


 cognew(beacon, @beacons)      'start a cog to run the blue beacon
 cognew(strobes, @strobess)      'start a cog to run the strobes

    
PUB beacon

 dira[BLED] := 1    'enable output on blue LED pin 

 BLEDi := 10         'sets the initial brightness percentage at 10%
 
  repeat
  
    repeat until BLEDi == 20            'get brighter
      CTRA := %0_0110<<26 + BLED
      FRQA := $7FFF_FFFF/50 * BLEDi
      BLEDi := BLEDi + 1
      waitcnt(clkfreq / 20 + cnt)

    repeat until BLEDi == 5             'get dimmer 
      CTRA := %0_0110<<26 + BLED
      FRQA := $7FFF_FFFF/50 * BLEDi
      BLEDi := BLEDi - 1
      waitcnt(clkfreq / 20 + cnt)
   


PUB strobes

 dira[STR] := 1     'enable output on strobes pin 
 
repeat                                 'strobe blink pattern
  
  outa[STR] := 1
  waitcnt(clkfreq / 15 + cnt)
  
  outa[STR] := 0
  waitcnt(clkfreq / 15 + cnt)
  
  outa[STR] := 1
  waitcnt(clkfreq / 15 + cnt)
  
  outa[STR] := 0
  waitcnt(clkfreq / 15 + cnt)
  
  outa[STR] := 1
  waitcnt(clkfreq / 15 + cnt)

  outa[STR] := 0
  waitcnt(clkfreq / 15 + cnt)

  outa[STR] := 1
  waitcnt(clkfreq / 15 + cnt)
  
  outa[STR] := 0
  waitcnt(clkfreq * 2 + cnt)   
 

Comments

  • xanaduxanadu Posts: 3,347
    edited 2013-05-29 01:02
    [video=youtube_share;tQC2jn43i5o]

    Nothing like a good field test.
  • xanaduxanadu Posts: 3,347
    edited 2013-05-29 01:02
    Here is the final board I'll be using. Prop Project Board. Almost teared up cutting it in half but you gotta do what you gotta do. The Project Board is great because it allows me to power the whole thing from a JST connector at 3S lipo voltages. On the Prop Protoboard I was powering the 3.3v regulator off the airplane's BEC via empty rx header which I never liked.

    I made it only three channel using NPNs to allow Vin to pass through the headers. Even though I cut the board in half I still have access to pins 0 through 21, which for this project I doubt I'll use. I added a fuse to the other side of the JST, and the three channel flashing LEDs are independent of the always on LEDs as well.

    IMG_1861a.jpg


    IMG_1862.jpg


    For the price of the Project Board and the work involved it blows away purchasing some of the controllers I've seen. There's a ton of room to expand as well, but I don't need to on this airplane at all.
    980 x 735 - 486K
    1024 x 768 - 82K
  • xanaduxanadu Posts: 3,347
    edited 2013-05-29 01:04
    The changes I'm making to the code are adding a third channel, and formatting the patterns of the three channels.

    For the blue LED in the center I'm going to have that blink different patterns based on how long the system has been on which should make a good battery timer.

    The strobes blink a couple different patterns as well.
    {{
    
    3 Channel LED Controller for LEDs
    
    }}
    
    CON
    
     _clkmode = xtal1 + pll16x  
     _xinfreq = 5_000_000
    
     BLED = 0                                   'Pin of blue canopy LED
     LSTR = 5                                   'Pin of left LED wing strobe
     RSTR = 4                                   'Pin of right LED wing strobe  
    
    VAR
    
     long beacons [100]                         'stack space
     long strobess [100]                        'stack space
     long time
    
    PUB main
    
     cognew(beacon, @beacons)                   'start a cog - blue beacon of time keeping 
     cognew(strobes, @strobess)                 'start a cog - strobes of awesomeness
    
        
    PUB beacon
    
     dira[BLED] := 1                            'enable output on blue LED pin
    
     waitcnt(clkfreq * 60 + cnt)                'offset the timer by one minute
     
       time := 0                                'reset timer
     
         repeat until time == 180               'blink blue LED slow pattern 
     
           outa[BLED] := 1
           waitcnt(clkfreq * 3 + cnt)
           outa[BLED] := 0
           waitcnt(clkfreq * 1 + cnt)
           time := time + 4
    
    
         repeat until time == 360               'blink blue LED medium pattern 
     
           outa[BLED] := 1
           waitcnt(clkfreq * 2 + cnt)
           outa[BLED] := 0
           waitcnt(clkfreq * 1 + cnt)
           time := time + 3
       
         repeat until time == 540               'blink blue LED fast pattern 
         
           outa[BLED] := 1
           waitcnt(clkfreq * 1 + cnt)
           outa[BLED] := 0
           waitcnt(clkfreq * 1 + cnt)
           time := time + 2
    
       outa[BLED] := 0                          'blue LED off at 9 minutes + timer offset 
              
    
    PUB strobes
    
     dira[LSTR] := 1                            'enable output on strobes pin
     dira[RSTR] := 1                            'enable output on strobes pin
     
     
    repeat                                      'regular strobe blink pattern
      
      outa[LSTR] := 1
      outa[RSTR] := 1
      waitcnt(clkfreq / 15 + cnt)
      
      outa[LSTR] := 0
      outa[RSTR] := 0
      waitcnt(clkfreq / 15 + cnt)
      
      outa[LSTR] := 1
      outa[RSTR] := 1
      waitcnt(clkfreq / 15 + cnt)
      
      outa[LSTR] := 0
      outa[RSTR] := 0
      waitcnt(clkfreq / 15 + cnt)
      
      outa[LSTR] := 1
      outa[RSTR] := 1
      waitcnt(clkfreq / 15 + cnt)
    
      outa[LSTR] := 0
      outa[RSTR] := 0
      waitcnt(clkfreq / 15 + cnt)
    
      outa[LSTR] := 1
      outa[RSTR] := 1
      waitcnt(clkfreq / 15 + cnt)
      
      outa[LSTR] := 0
      outa[RSTR] := 0
      waitcnt(clkfreq * 1 + cnt)
    
    
    
      outa[LSTR] := 1                           'alternate strobe blink pattern 
      outa[RSTR] := 0
      waitcnt(clkfreq / 2 + cnt)
      
      outa[LSTR] := 0
      outa[RSTR] := 1
      waitcnt(clkfreq / 2 + cnt)
      
      outa[LSTR] := 1
      outa[RSTR] := 0
      waitcnt(clkfreq / 2 + cnt)
      
      outa[LSTR] := 0
      outa[RSTR] := 1
      waitcnt(clkfreq / 2 + cnt)
      
      outa[LSTR] := 1
      outa[RSTR] := 0
      waitcnt(clkfreq / 2 + cnt)
    
      outa[LSTR] := 0
      outa[RSTR] := 1
      waitcnt(clkfreq / 2 + cnt)
    
      outa[LSTR] := 1
      outa[RSTR] := 0
      waitcnt(clkfreq / 2 + cnt)
      
      outa[LSTR] := 0
      outa[RSTR] := 1
      waitcnt(clkfreq / 2 + cnt)
      outa[RSTR] := 0
      waitcnt(clkfreq* 1 + cnt)
    
      
      outa[LSTR] := 1                           'both on for one second
      outa[RSTR] := 1
      waitcnt(clkfreq * 1 + cnt)
      outa[LSTR] := 0                           'both off for one second
      outa[RSTR] := 0
      waitcnt(clkfreq * 1 + cnt)
      
    
    
  • xanaduxanadu Posts: 3,347
    edited 2013-06-02 09:49
    Saturday night's flight was great, the usual crowd loved the lights. Someone asked me if I put LEDs on model airplanes for a living lol, how cool would that be? Anyway this project is now complete :)
Sign In or Register to comment.