STAR Firmware by JonnyC - Source Code and Explanation

Is there a way to make a driver running Star OT think/act like it’s turned ‘off’ when it is still getting about 2ma of power?

This is a part of my idea in this thread

How to change the is_pressed() function to positive logic in momentary firmware?
I disabled the pullup resistor and soldered a pulldown resistor to the star and ground

I need it because my headlighe has a switch in front and 3 wires going to the battery and driver

  • +led which is also +batt
  • led which is not gnd so cannot use it for the the switch
  • is the switch - I connected the other side it to +led

If I understand your question correctly, you can do this by simply changing the “return (buffer” part to “return !(buffer” to logically invert the value.

Thanks, I will try it at home.
I’he tried it with ~ but it didn’t work. :slight_smile:

So... how feasible would it be to switch the Vref such that the Int 1V would be used for the OTC measurements and Vdd is used for low battery? I'd like to be able to use this with two and/or three cells, and I figure 5V Vdd as Vref will make the ADC count a bit more accurate. But I now realize that a 1V Vref is much more ideal for the OTC measurement. EDIT: or I may just use 20 and 38 for the Med and Short values...

Anyone have any ideas?

you can increase accuracy by calibrating the specfic PCB+voltage divider+MCU combo. Also you can get 10 bits out of ADC, as compared to 8 which are normally fetched in voltage monitoring. Just don’t do right shift of ADCL, but read both ADCL and ADCH. It’s a matter of do you trust more your regulated vref or internal vref, what’s more stable. For even more accuracy I’d check how voltage divider changes with temperature, ideally both resisotrs should increase R in the same percentage thus negating any temperature drift.

what is OTC?

edit: by calibrating I mean this: Get a calibrated multimeter, and for a number of ADC values throughout the range, note the value that DMM is showing. Then make a “adjustVoltageADC(ADCH,ADCL)” function that would actually have hardcoded values of mapping between ADC and calibrated DMM, and for each ADCH, ADCL pair it would interpolate what the actual voltage is. That’s how I plan to do it anyway.

That should be no problem if you have the space. OTC measurement is only done once (during start-up sequence), once that’s done you should be able to switch Vref before starting up the ADC routine for voltage monitoring. But, just to try cover all bases, I am assuming that changing Vref does not have any affect on the output voltage when cap pin is set high to charge the capacitor.

If you can live with checking for a short press only you could switch to the brown out detection method explained here: alexvh's firmware. Update: Hidden strobe, Ramping and optional mode memory added.. As mentioned, this method can’t detect different off time lengths, but for simple short press checking this method is reliable, easier to code and saves you space.

Off time capacitor.

I have a circuit I have been playing around with with a similar situation where the switch is coming from the positive supply (about 4V). With a pull-down resistor, removing the call out to enable the pull-up on the pin, and ToyKeepers mod above, I have the levels changing without an issue.

works also for me also.thanks.

Just got my USBASP in yesterday. I had been building some hex files while I waited for it to arrive.
I just finished up my Convoy C8 with off-time, no memory, MN-L-M-T. No stars on the 105D complicated it a bit, but once I got the levels I wanted (using on-time STAR) I flashed my off-time and then soldered the 1uF directly onto the attiny pins between 2 and 4. PWM level 4 is the lowest the LED would turn on (2800mA 105D w/ XM-L2).
My SRK clone is next on the list.

Thanks!

Ooh, I hadn’t thought about soldering one there… that’s a clever solution. :slight_smile:

For the SRK, be sure to take a look at ToyKeeper/Ferrero_Rocher/* in my code repo. Everything in there should run on a SRK (with attiny13a) and it’s all enhanced compared to STAR_momentary.

Thanks - will take a look. Need to get it disassembled first.
I thought about adhering the cap on top of the attiny and just run some small wire down to the pins - thought this would make it easier to reflash (out of the way of the clip), but figured I’d do that next time I need to flash it. Looking forward to trying it out tonight.

If you use anything with a battery check mode or low-voltage protection, you might want to check the calibration first. You can get raw voltage ADC values with the battcheck firmware; just connect a battery or power source at the voltage where you want to set a threshold, and it’ll blink out the number to plug into other firmwares.

Hi everyone,
after several try to resolve a strange problem with output i have to come back to get a good answer! I installed the firmware STAR mom , with e switch on pin number 2. I reprogram almost 30 drivers , may be 20 working good but some work strangly. If i put on turbo mode , even if a reprogram the timer to 120 sec or more or less… it will turn to lower mode after 5 sec. I changed a bunch of values, remove turbo mode, reprogram and get the same result.

I resolded every 7135 to check if it was a bad ground but i got the same result.

Is there a line of code that i could remove that could influence this situation???

Any idea what could go wrong with those driver? a bad 7135???

tks for your help

Stepping down in 5s sounds like a low voltage protection. Have you checked what voltage that driver thinks it's getting? See TK's calibration tip above.

^ Yeah, get a DMM voltage reading at the MCU pin connected to your voltage divider used for LVP. If low, check out the 2 resisters in your voltage divider.

Ill Check tonight with the TK battcheck program … I think your Right on that one.

Easy think to do is to remove battery voltage monitoring and see how it work.

That will point out what is the exact problem.

Tks for your answer!

Tks for all your answer. I check the voltage with the program of TK and i got 181 for result. Resistor have been check and value look ok. i Play with the code and i changed value and removed some

#ifdef VOLTAGE_MON
if (adc_ticks > 0) {
—adc_ticks;
}
if (adc_ticks 0) {
// See if conversion is done
if (ADCSRA & (1 << ADIF)) {
// See if voltage is lower than what we were looking for
if (ADCH < ((mode_idx 1) ? ADC_CRIT : ADC_LOW)) {
++lowbatt_cnt;
} else {
lowbatt_cnt = 0;
}
}

// See if it’s been low for a while
if (lowbatt_cnt >= 4) {*CHANGE VALUE TO 10 , SHOULD I PUT IT TO 3750 (1MIN)???*

prev_mode(); REMOVED THAT LINE AND EVERYTHING WORK FINE!!!

lowbatt_cnt = 0;
// If we reach 0 here, main loop will go into sleep mode
// Restart the counter to when we step down again
adc_ticks = ADC_DELAY;
}

// Make sure conversion is running for next time through
ADCSRA |= (1 << ADSC);
}
#endif
}
press_duration = 0;

Any idea how to change the value of battery monitoring (ADCH) in the code??? Dont want to compromise the battery monitoring and automatic previous mode…

TKs for your help!

To make LVP work correctly, you kinda need to measure the voltage with both a full battery and a nearly-empty battery, to find out how much it drops. Just one value won’t help much. :slight_smile:

Which of these will be a best replacement for off time cap, 0.1uf, 0.22uf, or 2.2uf? I am planning to buy the otc and c1 10uf x7r from one ebay seller but he doesnt have 1uf x7r in stock, only those caps i mentioned are in stock.
Also what would be the effect if i use y5v capacitor on c1?