User talk:Daveb: Difference between revisions

From London Hackspace Wiki

m (→‎firmware design: new section)
Line 136: Line 136:


== firmware design ==
== firmware design ==
===pseudo code===
<nowiki>


isr(int0)
isr(int0)
{
{
freq++ ;
freq++ ;
}
}
 
isr(counter_2_overflow)
isr(counter_2_overflow)
{
{
// copy current freq to main line, reset freq.
// copy current freq to main line, reset freq.
}
}
 
isr(adc_complete)
isr(adc_complete)
{
{  
copy adc value to mainline;
copy adc value to mainline;
}
}
 
isr(counter1_...)
isr(counter1_...)
{
{
// implement the lighting policy
// implement the lighting policy  
?flip the current MOSFETs bit..
?flip the current MOSFETs bit..
?change the current MOSFET
?change the current MOSFET
?change the counter target
?change the counter target
}  
}  
 


void
main()
main()
{
setup() ; // set the ports, direction etc.
for(;;)
  {
  {
  if (newFreq)
  setup() ; // set the ports, direction etc.
for(;;)
   {
   {
  if (newFreq)
  {
     {
     {
     DISABLE_ISR ;
     DISABLE_ISR ;
     copy new freq ;
     copy new freq ;
     }
     }
  if new freq != old freq
  if new freq != old freq
      adjust policy;
    adjust policy;
  }
  }
if (newLumons)
  if (newLumons)
  {
  {
     {
     {
     DISABLE_ISR;
     DISABLE_ISR;
     copy new lumons;
     copy new lumons;
     }
     }
  if new lumons != old lumons
  if new lumons != old lumons
      adjust policy ;
    adjust policy ;
  }
   }
   }
  }
  }
</nowiki>


===policy ideas===
# if it is dark provide light ASAP.
# if it be comes light, wait for a bit to confim it stays light, and thn start flashing the lights to provide visiblity
# as the speed increases, spend more time with tight focussed lights illuminated
# as the speed decreases, spend more time with flood lights illuminated.
# match the power available to the power cunsumed by the LED strings


policy ideas.
===policy mechanism===
1) if it is dark provide light ASAP.
Four intervals of variable length, applied to selected string of LEDs: off, string-a on, off, string-b on.
2) if it be comes light, wait for a bit to confim it stays light, and thn start flashing the lights to provide visiblity
3) as the speed increases, spend more time with tight focussed lights illuminated
4) as the speed decreases, spend more time with flood lights illuminated.
5) match the power available to the power cunsumed by the LED strings


policy mechanism
The intervals are defined as an array of counter[4]. The LED strings by the MOSFET number in an array of mosfet[4];
four intervals of variable length, for variable strings
off, string-a on, off, string-b on


defined as char counter[4], value[4];
This will allow:
* the fading from spots to floods gradually:).


will allow the fading from spots to floods gradually:).
* day lashing patterns to be set using any two strings of LEDs.


will allow the spots to be flashed at 10% duty cycle at a low speed during the day, intermingled with a 20% flash from the lower power medium floods...
===policy config===
* night vs day lumonosity value.
* samples of day light required for flashing to start.
* freq exponential smoothing factor (power of 2)
* night freq bounds[4] between {floods | mix | medium | mix | spots}
* day freq bounds[N] between flash patterns
* day flash patterns[N]


policy config.
===user config===
night vs day lumonosity value.
policy values in miles per hour?
samples of day light required for flashing to start.
or are they automated from load/power info?
freq exponential smoothing factor (power of 2)
night freq bounds[4] between {floods | mix | medium | mix | spots}
day freq bounds[4]
153

edits