Need help with STAR firmware (or driver recommendation)

I need a very simple driver with two modes without PWM. I decided on Nanjg with 12 AMC, 2+10 configuration. Because I'm not a coder I do not know how to convert the code to work as I want. One channel, 2 amc - first mode, second channel, 12 AMC - second mode. Without memory.

I decided to STAR because it's probably the simplest code that has two channels.

I tried something like that, but only one 700mA channel works.

/*

* =========================================================================

* Settings to modify per driver

*/

#define VOLTAGE_MON // Comment out to disable

//#define TICKS_250MS // If enabled, ticks are every 250 ms. If disabled, ticks are every 500 ms

// Affects mode saving and turbo timeout/rampdown timing

#define LVP_MIN 7 // Lowest level the LVP will step down to

//#define MODE_MOON 3 // Can comment out to remove mode, but should be set through soldering stars

#define MODE_LOW 255 // Can comment out to remove mode

//#define MODE_MED 39 // Can comment out to remove mode

#define MODE_HIGH 255 // Can comment out to remove mode

#define MODE_TURBO 255 // Can comment out to remove mode

#define MODE_TURBO_LOW 140 // Level turbo ramps down to if turbo enabled

#define TURBO_TIMEOUT 240 // How many WTD ticks before before dropping down. If ticks set for 500 ms, then 240 x .5 = 120 seconds. Max value of 255 unless you change "ticks"

// variable to uint8_t

#define TURBO_RAMP_DOWN // By default we will start to gradually ramp down, once TURBO_TIMEOUT ticks are reached, 1 PWM_LVL each tick until reaching MODE_TURBO_LOW PWM_LVL

// If commented out, we will step down to MODE_TURBO_LOW once TURBO_TIMEOUT ticks are reached

#define FAST_PWM_START 8 // Above what output level should we switch from phase correct to fast-PWM?

#define DUAL_PWM_START 255 // Above what output level should we switch from the alternate PWM output to both PWM outputs? Comment out to disable alternate PWM output

#define WDT_TIMEOUT 2 // Number of WTD ticks before mode is saved

#define ADC_LOW 130 // When do we start ramping

#define ADC_CRIT 120 // When do we shut the light off

/*

* =========================================================================

*/

This is the one-mode version by ToyKeeper, but I also tried the JonnyC version.

You can also recommend a driver with two modes lo> hi, no memory, no pwm. For green osram 2mm.

Why don’t you want to use firmware designed for 2 channels?

It is designed for two channels, but it doesn’t work the way I need it.

Please share the source code. The only star firmware I know is for one PWM channel: ~toykeeper/flashlight-firmware/trunk : contents of ToyKeeper/STAR_noinit/STAR_noinit.c at revision 249

https://bazaar.launchpad.net/~toykeeper/flashlight-firmware/trunk/files/head:/JonnyC/STAR

From the STAR META file ,

You’re right, second PWM channel is an compile time option. I didn’t see it before.

It seems that this part must be uncommented

255 is max. 39 is MED, so probably if you set it to 30, second channel will be activated on MED and TURBO modes.

I need 700mA in first mode and 4.2A on second mode. So both must be 255.

Did you get it working?

It’s a bit of a change, but if you don’t want PWM then you needn’t be worrying about 255 anyhow. Remove the PWM/timer related code and set the output pins connected to the 7135’s as high (on) or low (off) as needed. Sorry, I know your not a coder but that’s a cleaner way to do it.

I’m on my phone at the moment or otherwise I’d try to be of more assistance. I can try cooking something up later.

I’m still trying. It still doesn’t work.
I used to try to play around with Arduino but this is quite different.
And it was a long time ago :confused:

Could you send a link to which driver you’re using? I’ll see if I can throw something together real quick.

My current list of questions…

  • Which driver? (for layout purposes)
  • Memory or no?
  • Turbo timer to drop from high to low? If so, after how much time?

Feel free to PM if you’d rather discuss there.

Nanjg with cutted trace to the side amc which is connected to the fifth pin of attiny.
No memory by default. Can be configurable via star-gnd.
No turbo timer.
LVP

Something like that?

I have had similar questions as you

This is the problem with this firmware, and I need an even simpler option - switching between two channels. That’s all.
Probably trivial for every coder. They are wizards imho.

CVP, whenever I start working with a new board, I usually try the most simple code as possible to make sure that the hardware is working as expected. Once you know the hardware is functional, then I move onto the “real” code. The program below should be about as basic as it gets for your board. It rotates through the low channel, the high channel, and then both (pausing 3 seconds after each change). Could you confirm this works on your board?

This program changes modes (channels) every three seconds. Only Lo (first channel) and Med (second channel), but according to your comments it should be Lo (first channel) > Med (second channel) > Hi (both channels).
After inserting these two lines into the comment:

PORTB = (1 << LED_HIGH_PIN); // High channel on
_delay_ms(3000); // wait 3 seconds

the program jumps between Lo (first channel) > Hi (both channels)

These two lines seems needles, because I only need first channel and both channels.

Ok, that was just a test to make sure each channel worked independently. It actually worked though, right?

Now that I know that control method is working with your board, I can try helping out with the STAR code. :+1:

Alright… I’ve compiled this, but haven’t tested it at all on an actual driver (so good luck!). Feel free to give it a shot and let me know how it goes.

Works great! Just one question. If I want to turn on the turbo timer, I have to connect star3 with gnd. Then the default is 2 minutes. How can I set it to 5 minutes?
I know I need to change #define TICKS_250MS to a larger value, but what is max? 250ms is a quarter of a second, and for 5 minutes 1.25 is needed. How to make it work? 1250?

In the original STAR code there is a note at #define TICKS_250MS:
Affects mode saving and turbo timeout / rampdown timing

There are two things influencing the turbo timer: the TURBO_TIMEOUT setting (240 ticks) and the Watch Dog Timer (“WDT”) prescaler. By default in the firmware, the WDT is set to interrupt every 500 ms (bits WDP2 and WDP0). If you want something longer, the easiest thing is to probably change these flags. If you added WDP1 (in addition to WDP2 and WDP0), the WDT would fire off every 2 seconds instead of 0.5 seconds. 5 minutes = 300 seconds. If WDT fires every 2 seconds, set your TURBO_TIMEOUT to 300 / 2 = 150.

In summary, to obtain a 5 minute turbo timeout:

  • Change TURBO_TIMEOUT to 150
  • In WDT_on(),
    replace WDTCR = (1<<WDTIE) | (1<<WDP2) | (1<<WDP0);

    with WDTCR = (1<<WDTIE) | (1<<WDP2) | (1<<WDP1) | (1<<WDP0);

PS - you don’t need to worry about what the original code says about WDT affecting the mode switching. I replaced ontime memory with our “noinit” trick