STAR Firmware by JonnyC - Source Code and Explanation

Yes, I think you are correct. You can’t use the same pin for 2 outs, so you’re just stuck with only 3 on the 25/45/85. Even switching to a 20pin QFN package doesn’t fix it, most of the pins are NC (not connected). If you check the pinout in the datasheet it still gives only 3 different OC registers at once. http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf

To me it appears that the ATtiny24/44/84 provide four pins with different OC registers. Again, MLF/QFN is the only way to keep physical size under control. http://www.atmel.com/Images/doc8006.pdf

Another option to shove in even “larger” MCUs would be skipping QFN and moving directly to BGA. We don’t have to use all the pads for anything. I think we could almost completely ignore the inner 12 pins and focus on the outer 20. A 32-pin MCU in BGA is apparently 4x4mm, very small. Disclaimer - I’ve never worked with BGA! Since we’re reflowing anyway, I figure what’s the difference… :wink: Here are the megaAVR MCUs which have PicoPower, 1.8-5.5v, and 32 or less pins. Note that I think only the 168PA, 48PA, and ATmega88PA have BGA packages available. I think all of those provide a full 6 pins of hardware PWM.

As long as we’re talking about BGA :wink: here are the two PicoPower, 1.8-5.5v ATtiny parts which have small BGA packages available (3x3mm!):

BGA...man I would actually have to start being careful with my reflows!

I would imagine those tiny pins are a little harder to flash after soldering, too. Can they even be flashed once they’re stuck to a PCB?

You would have to have header pins or something, which would destroy any size advantage. You would have to pull it off and reflow to reflash without headers on the board.

That ATtiny24a looks like it would work… Pins 5-8

http://www.digikey.com/product-detail/en/ATTINY24A-SSUR/ATTINY24A-SSURCT-ND/2774343

$1.45ea… Not too bad but 14 pins you might as well run two 13a! The 20 pin QFN might be small enough to do what I need

You understand why running two 13a’s in order to control one light is an undesireable thing, right? I can’t tell if you’re joking or not! :~

I think he was simply referring to the size of the MCU...it was supposed to be a joke.

hehe well edited the 20 qfn might work… I still dunno the size until bust out my mm ruler though…

EDIT
What if I just set the buck to high (it has memory). Disconnect the eswitch wire from it’s mcu. Now I have voltage monitoring already setup in the bucks stock driver. Now use the bucks mcu vcc to power the tiny24a also (not sure if that’s too much of a load on that circuit, otherwise I’d zener to B). So I ’d run the LED on the buck to the emitters +.

On the LED - (4 sets of gnd on that 4 color XML) coming from the emitter, those would go to 4 fets pwm controlled by the 24a. When the voltage gets low the buck would simply flash and eventually go out on it’s own.

… and you wouldn’t want to do that, as I understand it. A BGA is a one-shot deal unless you “reball” it. It comes with balls of solder stuck to the bottom, once they’re used up the solder must be removed and replaced with new balls. It’s a pain and there’s gear available to make it easier, commonly used in refurbishing electronics like phones, computers, and game consoles.

If you just want to be able to reprogram the chip then the lack of exposed pins is not a big deal. If you want to make it a weekly practice to reprogram the chip, yes, I imagine it would be a pain. We normally break out some pins as inputs, outputs, etc. ISP flashing (what we do) only requires 4 pins in addition to VCC & GND. I’m glancing at the Atmega-88PA for reference and in that case MISO and MOSI are both on PWM pins, so no problem there - we’ll want to break those out anyway, right? SCK is on PB5, an outside row pin with no peripherals. Reset is on PC6, another outside row pin. PB5 can be used as a star or whatever, PC6 would have to have a dedicated, unused pad I think. So not that bad IMO. For development purposes you can either use a larger PCB with an actual ISP header if desired.

Another option for programming may be to use a properly setup bootloader (eg no delay at boot, it would look for a condition before going into bootloader mode). You’d need an extra PCB with some support components (caps, I think) and you’d need VCC, GND, and 2 data pins broken out. http://www.obdev.at/products/vusb/index.html Some frequency stuff would also have to get worked out for a V-USB based bootloader.

IMO the bootloader business is pretty ambitious - I’m not suggesting that anyone work on it! I’m only mentioning it so that everyone knows this stuff exists.

It’s pretty small, smaller than the ATtiny13A-SSU’s package (what we use now). Wiring it up is different though, so it would require new PCB designs.

I’d have assumed it was a joke, but this isn’t the first post where fellfromtree mentioned using multiple MCUs to get enough PWM. I didn’t feel like writing out why it’s undesirable if it’s a joke.

Gotcha. I was wondering if you had lost your sense of sarcasm.

Thanks, that’s a good summary.

I’m definitely a software person, not so much a hardware person… I enjoy doing the firmware-of-the-week thing (though, for convenience, development happens on a dedicated dev board). I like how it’s pretty standard these days to use big enough pins to easily reflash production hardware. More / smaller pins would significantly raise the barrier to entry for this hobby.

That’s why I like the idea of the attiny25. Same convenient size and interface, but more space and features to play with. Can even be used on existing boards in place of the tiny13. Or, for something with more I/O, the attiny84a-ssu might be nice… like, for a RGBW+ driver.

On second thought, maybe discussions like the ones above should be discussed somewhere else? Maybe this thread should be a discussion about single emitter lights and what variations of UI's people have come up with using STAR as a starting point, along with what new features can be added to make it even more useful.

I know there are other threads about multiple emitter (RGB) lights using the PIC. Maybe one can be created if people want to attempt to use an AVR instead. I for one won't be delving into that area, too complex for my tastes.

If I lost what little capacity I have for parsing sarcasm we’d be in pretty sad shape. :wink:

I agree that the ATtiny25 is a logical next step for these drivers. I also think that arbitrarily switching to a no-leads package for these drivers is most likely to unjustifiably raise the barrier to entry. We have enough documentation / training and specialty hardware issues as it is. If someone brings a design to the table which can’t be done without a QFP or BGA package that’s a little different - but we can burn that bridge when we get there ;).

I also have no immediate plans to build an RGB driver. Keeping the thread primarily on the topic of STAR based firmwares seems smart.

I agree as well. I'm attempting to write a forked version of STAR_momentary for RMM where it can monitor temperature via a voltage source from a temp sensor along with the existing battery voltage monitoring, then adjust output up and down according to defined temp thresholds. This requires jumping back and forth between ADC inputs, and it's not working very well right now (broken more accurately). On our list is to port the program to the ATtiny25, so that might happen sooner rather than later because I could really use a second timer so temp ramp up/down timing doesn't have to be squished into the WDT ISR (which has very inaccurate timing).

Do you have any inking as to what the problem is? (I will understand if it’s one of those situations where you say “if I knew what was wrong I’d have fixed it by now”)

I’ve been desirous of exactly the setup you describe. Having both measurements would open doors.

If we were truly constrained to the ATtiny13A here is what I’d suggest: Apparently there exist products called “Low Voltage Detectors” which provide a binary output, see post #6 here. I think combining the appropriate one of those with an analog temp sensor could provide an easy binary “overtemp or not” input. I would not be surprised to learn that a product which combines those two things in the same package was already available.

That said, let’s not do that. It’s way more flexible to have an analog temp input.

Actually the input that RMM was able to provide in his setup is good (honestly I didn't even know how he did it, I'm totally ignorant of circuits). We are still using the internal 1.1v reference to compare against. All I'm doing is switching the ADC input on each WDT tick, and keeping separate variables for the results of battery voltage and temp voltage ADC checks. It actually works fine, but then we attempted to change the number of ticks between temp voltage checks from 500 to 2000 (10 seconds to 40 or so) and it breaks. If I disable the battery voltage check it works just fine, which means we aren't switching ADC inputs. My suspicion is that I am going about the ADC switching and checking all wrong, so I'll go back to the datasheet.

I'm going to do some more testing tonight, and if I'm still stumped I'll post up a specific question here, or just give up and start porting it for the 25.

You can see the latest code here: https://github.com/JCapSolutions/blf-firmware/tree/master/MTN_momentary_temp

The only changes I've made to this is to changed the adc_temp_ticks to a 16 bit variable, and extend the time out. The momentary feature is commented out in my build, as well as the turbo timer.

Like Jon said, it all works, even with a 16 bit variable, until the temp ticks gets too long during the second temperature ramp down. I am feeding the adc with a temperature sensor through another voltage divider so I can use the 1.1V internal reference voltage to compare the temperature sensor against.

Initially I was just using the primary ADC voltage monitoring as a temperature step down, which worked alright, but then I got power hungry and wanted both to work at the same time!

So I think I have it working now. I just went about switching and polling ADC inputs poorly. If anyone else wants to give it a shot it's here...

https://github.com/JCapSolutions/blf-firmware/tree/master/MTN_momentary_temp

Sorry to break the train of thought here…

How much work would it be to almost completely change the UI of the momentary firmware? I am a fast learner (and have already learned alot in this thread), but have very little experience in this kind of thing.

I’m hoping to achieve something like this:

4 modes: Low ≤1, Medium 20, High 60, Turbo 100
90 sec Turbo timer down to High
Low voltage step-down
No mode memory

UI:
From off:
short click (<750ms) = power on low
long press (>750ms) = power on high
press&hold 3sec = short pulse at medium then “locked out” (3 short clicks from “locked” goes to low)

From on:
short click = advance to next mode (cycling L-M-H-T-L-M-H-T, with ‘off’ not in the rotation)
Long press = off

Thanks in advance