Model Aircraft Llights

zoo12

New Member
[video]www.youtube.com/watch?v=HCReWdnqc44[/video]I am trying to get this bit of code to work, the wing tip strobes no problem but the rotating beacon fade needs a pulse at the end which so far has
beaten me.

The fade works a treat (HAKU 03-09-2010) but needs a flash at the end .

New Code with problems solved using HAKU sugestions
'Model aircraft mars beacon
' Wing tip strobe pins 3 and 6
'Flash and rotate beacon for other hazards pin 5
'Haku 03-09-2010


#picaxe 08m2

Main:

do
for b0=0 to 100 'Count up
w1=b0*b0/10 'square pwm smooth
pwmout 2,249,w1
pause 10 ;pin 5
next b0
pause 300

for b0=100 to 0 step -1 'count down
w1=b0*b0/10
pwmout 2,249,w1
pause 10
next b0

pwmout 2,249,1000 ' full brightness
pause 300
pwmout 2,249,0 ' no brightness

Flash:

pulsout B.1,800 'Portwing 2 flashes pin 6 red
pause 200
pulsout B.1,800
pause 200

pulsout B.4,800 'Starbourd wing 2 flashes pin3 green
pause 200
pulsout B.4,800
pause 200

loop ;loop back to start

aircraft strobe.JPG
 
Last edited:

hippy

Ex-Staff (retired)
pulsout B.1,500 ;send a 500ms pulse out of pin B.2
pulsout B.1,800 'Portwing 2 flashes pin 6 red
pulsout B.4,800 'Starbourd wing 2 flashes pin3 green
It's very difficult to tell which pins you mean to control from the comments and also which pins flash correctly and which don't from the description of the problem.

I suspect it's the pin you have executed PWMOUT on ( pin 2, leg 5 ). That will be because you have used the pin for PWMOUT and that will override other things you try to do with that pin. You either need to turn PWMOUT off and then control the pin or, perhaps easier, simply set PWMOUT duty to full for a time then to zero to flash the LED.
 

sedeap

Senior Member
Do a search for mars beacon and get more useful info
Mars Beacon video

;)

Note:
The issue seems to be: Ramp up to 80% of bright, pulse of 100%, and ramp out, loop...
Right?
 
Last edited:

zoo12

New Member
I suspect it's the pin you have executed PWMOUT on ( pin 2, leg 5 )
Is correct.
Never thought to play with PWM command I will give it a try.
Many Thanks
 

zoo12

New Member
@SEDEAP
Thanks I have had a quick look but they all seemed to end with pic mpu and nobody wanted to give the source code.
So the friendly Picaxe trail which has never let me down so far lol but thanks for reply.
 

Haku

Senior Member
As hippy said, after the fade up/down, try adding:

pwmout 2,249,1000 ' full brightness
pause 300
pwmout 2,249,0 ' no brightness
 

zoo12

New Member
@HAKU
Thanks for reply just about to try to edit posting, now sorted with hippys help working a treat.
 

hippy

Ex-Staff (retired)
Thanks for reply just about to try to edit posting
The circuit makes things much clearer, thanks.

In code comments and documentation it can be difficult to get round the dual-use "pin" terminology for "software pins" and "hardware pins" so I generally recommend "pins" and "legs" but accept others aren't entirely happy naming "hardware pins" as "legs". As long as there's no ambiguity, or any ambiguity is fairly easily resolved ( as with your circuit diagram ), it shouldn't be a problem.
 

sedeap

Senior Member
Maybe you must start in 80% of the max bright of the led, so decay to 0 and up again to 80%, then, make a pulse of 100% bright, and start over again.
 

Goeytex

Senior Member
Since the intensity of an LED is not linear in respect to current, you wont see much change in intensity between 80% and 100%, assuming 100 percent is the max rating of the LED.

The effect will be much better ( and more realistic) if you ramp up to 20% - 40% duty cycle and then flash at 100%.
 
Last edited:

zoo12

New Member
Thanks all.
I did not know how PWM commands worked but I do now!! Just Posted Video of Lamps flashing and fading.

@ Goeytex I will play some more and try your suggestion. Thanks
 

Goeytex

Senior Member
Last week I had another user ask me to help with the code for a Mars Beacon Simulator. So I was
working on this over the weekend.

The idea is to make the simulated beacon look as realistic as possible.

As I noted before, LED intensity is not linear with respect to current/duty cycle, so a bit
of compensation is needed for a realistic looking simulation. Also, the in the real world the
"flash" as the beacon reflector passes by is not instantaneous but also has time ramp. I have
given it a softer flash for better realism. This can be adjusted.

The Picaxe Frequency was increased to 16mhz to allow for more adjustment via a delay variable.

This code does a pretty good job of it all. Adjustments can be made by changing the values of:

1. Max_duty
2. Delay
3. F_Ramp

For Picaxe 08m2 Change c.5 to 2

Code:
[COLOR="#008000"]'Mars Beacon simulation  - Picaxe 20X2 "[/COLOR]

Symbol LED = C.5
Symbol MAX_DUTY = W5 
SYMBOL DELAY = B2
Symbol F_RAMP = B3

setup:
Max_duty = 250        [COLOR="#008000"] ' 25% duty but about 60 percent intensity  (Affects Ramp time)[/COLOR]
Delay = 15            [COLOR="#008000"] ' ramp/decay delay[/COLOR]
f_ramp = 15           [COLOR="#008000"] ' Flash ramp/decay time[/COLOR]


init: 
setfreq m16
pwmout pwmdiv16, LED, 249, 0

MAIN: 

Ramp_Up:
Do
   w0 = w0 + 4 
   pwmduty LED, W0
   pause delay
loop while w0 < max_duty
 
Flash: 
  
  for w0 = max_duty to 1000 step f_ramp
  pwmduty LED, W0
  next w0
  
  for w0 = 1000 to max_duty step - f_ramp
  pwmduty LED, W0
  next w0
  
Ramp_Down:
do
  w0 = w0 - 4 
  pwmduty LED, W0
  pause delay
loop while w0 > 5

pause 250   [COLOR="#008000"] 'stay off a short while for effect[/COLOR]

GOTO MAIN
 
Last edited:

zoo12

New Member
Goeytex
Many thanks, Just tried it and very smooth, I am going play with your code today to under stand it better .
 
Top