STAR Firmware by JonnyC - Source Code and Explanation

Thanks fellfromtree. I went ahead and tried it before I saw your post and sure enough, leaving out REFS0 keeps it set to zero. (so vref is based on Vcc)

FYI for in the future, if you download the ATtiny13A datasheet you can just search for ADMUX and it will list the register, what the bits mean, and what their default values are.

Ah that’s cool… Yeah let us know how the monitoring of vcc goes wight. That sounds like fun for 1s, maybe eliminate 2 more resistors on the board

I don't think it is directly measuring voltage, but instead using the VCC as the reference voltage instead of the internal 1.1v. You could use it as the reference voltage with zener mod drivers or with an external voltage regulator (both with 2S+) since the voltage input will remain constant, but with 1S cells it would be pretty much useless. You would still need a voltage divider because the voltage you would be measuring against would still be higher than the reference. You can use it, however, for other measurements (like a temperature sensor) without needing an additional divider.

Ah gotcha… So your comparing it between the divider and vcc. Learn something new everyday thanks.

*Edit Wait wouldn’t it be the other way around. Cause the zener going to keep the voltage the same? The voltage will drain as the battery drains in 1s. Am I missing something… Oh nm I see what your saying 1.1v internal is always going to be 1.1. Still need the divider to get the voltage from B+… It’s too early for this sh :slight_smile:

Oh yeah sent my inlaw over your site yesterday. He saw my private video of the yezl blowing things up on dd and caught the lumen disease. He’s a pic guy though, so he’s talking about 3 phase pwm and all that other stuff. Can’t wait to see his lights really

Digging up an older concept here and hoping for some help.

I was hoping the above change in code would allow me to skip having the turbo timeout step down as an independent mode. My sense is I am one step away.

Here’s what I’m after: Low (1 value), Medium (2 value), Turbo (3 value) to step down (4th value).

As the FW is written, in order for me to have this I actually have 4 click through modes of Low, Medium, Step Down, and Turbo. I’m looking to have the turbo step down mode ONLY accessed following turbo time out. So in the end I’ll have 3 click through modes, but in operation 4 output modes.

I tried the above recommendation and then attempted to comment out “#define mode_high_w_turbo” but I was left with an error in line 259 “mode_high_w_turbo” undeclared (first use in this function)“. I assume the code is trying to reference the line I commented out but I don’t see it, and definitely don’t understand it.

With no working knowledge of C (other than reading through this whole thread), I was hoping I could get some help.

Thanks in advance.

Not sure which version of firmware you are looking at. Have you identified where in the code you are when the turbo times out? If so you should be able to set desired PWM_LVL and not store the mode.

Should be something like (simplified): “if ticks = turbotimeout and mode = turbo then {”

There you should be able to do a “PWM_LVL = XXX” (desired value).

Mike C is right, the concept works fine. You don’t need to comment out #define mode_high_w_turbo”, maybe that’s your mistake? Comment out other modes until you have only 3 user accessible modes (low, high-w-turbo, and turbo). Set those to your desired levels. This will give you 3 modes, then do the modification to “PWM_LVL =” discussed above:

// #define MODE_MOON            8   // Can comment out to remove mode, but should be set through soldering stars
#define MODE_LOW            14  // Can comment out to remove mode
//#define MODE_MED          39  // Can comment out to remove mode
#define MODE_HIGH_W_TURBO   39  // MODE_HIGH value when turbo is enabled
#define MODE_HIGH           120 // Can comment out to remove mode
#define MODE_TURBO          255 // Can comment out to remove mode

RMM is correct. I was working on measuring the entire throw of a potentiometer. Pots are setup as voltage dividers, so I need a V+ to hook up to one leg of the pot, Vcc is an easy source for that. The middle leg goes to an ADC, then the third leg goes to GND. To use this I’ve got to measure against Vcc. Really I’m going to have to toggle Vref back and forth so that I can cheaply measure both Vbat (against 1.1v using a divider) and also the pot (against Vcc).

You’re both correct. The error was in my thinking. It had not occurred to me to let the “high_w_turbo” supplant my “med” mode while reprogramming the turbo to default to a PWM level OTHER than the “high_w_turbo” setting. All is well and thanks for the help.

Crap - haven't checked this thread for a long time... Sorry. Someone get me up-to-date. Anyone (oops VOB) still need the hex file?

I've been having lots of troubles as of late - can't seem to program any of the custom BLF boards. I would even think programming a ATtiny13A detached should work, but can't get that to work either. Anyone know if that should be possible? I got 6 of the 8 pins wired - all have good continuity all the way back to the USB dongle. The cable setup I have works perfect with stock Nanjg boards.

Boy... Wonder if I got a bad batch of Tiny13A's, or the wrong flavor?

Every BLF custom board I’ve tried has been flashable… Ferrero Rocher F6DD, RMM BLF17DD, RMM BLF22DD, and RMM 32x7135 SRK. Some with off-time cap. Plus several flavors of nanjg/qlite.

If the soldering isn’t perfect, sometimes it’s finicky about connecting and I have to try a few times or forcefully hold the clip on, but usually it just works. However, when connecting the clip I usually wear a headlamp and sometimes stereo loupes so I can really see if the connection is good.

I have 6 pins connected, using a SOIC8 clip from Digikey and a cheap usbasp from fasttech. Some of the SOIC8 pins are getting worn though, so I might need another chip clip sometime.

With only 5 pins connected (oops, didn’t know at first I needed VCC), flashing was really flaky and verification never worked.

I use the Pomona SOIC clip - works fine, again, still worked well with Nanjg's. Have you ever tried programming a completely loose MCU? It clips up fine and continuity checks out all the way back to the dongle.

The MCUs I find that work are marked "ATMEL 1324" and the ones that don't work are marked "ATMEL 1222" or "ATMEL 1121". I'm trying to find out the meaning of the #'s but no luck so far -- looking thru the ATTiny13A datasheet now...

I've done lots of BLF DD boards before and programmed them fine. Not sure though - might be getting into a new batch of MCU's - this is why I'm sort of doubting the MCU now...

Update #1: They are all marked "SSU", so I believe that's the right type.

Update #2: Ok - think I found the meaning of the #'s - they are date codes, described here under Date Code Management: http://www.atmel.com/about/quality/faq.aspx#body_12

So the 2013's seem to work for me, while the 2011's and 2012's don't. Anyone got any guess's?

You’re welcome, glad it’s working!

They program fine bare. I have only experienced the opposite problem. Nanjg 105c’s from FT often don’t want to flash for me until I remove the chip from the PCB. Fresh ATtiny13A-SSU units from Mouser flash fine whether bare or mounted on a PCB. At least I think they do, I don’t keep super close track. I know I definitely flashed one of those A17DD-SO8 drivers with the MCU onboard. The PCB was w/ FET, diode, voltage divider resistors, & both caps: no problem.

I’ve been using the Pomona clip along with an USBasp I’ve had for a while, I forget the source. I’ve ordered a new USBasp from FT to see if I might get a “stronger” one. (If I do I plan to leave my current one hooked up to my ZIF socket where it always works.)

Please post the full top markings of one which is giving you trouble.

Marking for ones that don't work:

ATMEL 1222

TINY13A

SSU

Thanks Tom E. Unfortunately I think I’ve got nothing.

I’ve got to go to bed, but here’s a real hackjob I’ve been working on this evening. It compiles, but I don’t have time to flash it and assemble a driver before bed. There may be serious oversights.

This is intended as a proof-of-concept for a VaraPower style driver (rotary potentiometer chooses brightness) which includes low-voltage-warning and low-voltage-shutdown.

Here is what I did [thankfully not written in the order I did it]:

  1. used “STAR_1.1.c” as a base
  2. stripped out everything that I don’t think this style of driver needs, modes, turbo, etc
  3. replaced the main loop with the two-way ADC loop from the Nov 4, 2014 [1263cd98f9] version of MTN_momentary_temp.c
  4. changed the way the ADC loop switches ADC channel so that it toggles Vref back and forth as well - I think/hope? Bitwise operations are difficult for me.
  5. replaced the temperature stuff with a command to just patch that ADC value to PWM_level. Maybe ideally there would be a rolling average here, but that can come later.
  6. hacked up the LVP flashing to go full brightness during flashes
  7. hacked up the LVP to semi-function without modes. Ideally it should flash quickly 3 times every ~3 seconds until we hit critical, then flash 10 times and shutdown.
  8. copied and pasted a couple of variable initializations

* There are certainly some power savings tricks missing.

* I actually don’t see why we couldn’t add the potentiometer as a third ADC input and keep the temp monitoring.

* Come to think of it, now I can imagine how to include “stepdown” in a way that makes sense. After the 3 quick flashes, implement a ceiling value. Progressively half it or whatever is reasonable. Potentiometer throw remains the same, but the actual PWM value produced is capped @ whatever whenever it is set.

if (ADC > ceiling_value) {PWM_LVL = ceiling_value} else {PWM_LVL = ADC}

Bingo?

As far as hooking it up… I think PB2 (eg just like normal) should be voltage monitoring and PB3 [Pin 2, Star 4] should be for the pot. You hookup the pot between Vcc and GND with the sweeper hooked up to PB3.

Here it is: http://photo.jesusthepirate.com/blf/VeraPunk/v002.c

I’m sorry in advance. :wink: :wink: :wink:

When I get a chance I need to look at my code again. I built a custom one for police lights I was doing, and it functioned just as you describe. It also had the option to gradually ramp down over x number of seconds, instead of step down on the timeout. I thought I put that in the main program as a compile option, but if not I'll add it.

Sounds interesting. I have no hardware to run that on, but when you get it working I’d love to include it in my collection. :slight_smile:

Sorry, it's a little off topic bout the Tiny13A issues I'm having, but here's more info for those interested:

So far, all my problems seem to be from parts bought in one order here:

http://www.ebay.com/itm/5PCS-MCU-IC-ATMEL-SOP-8N-ATTINY13A-SSU-TINY13A-SSU-ATTINY13A-/250936543547?ssPageName=ADME:L:OC:US:3160

At the time, he sold in batch's of qty 10, so I bought 2 batch's for a total of $13 shipped (qty 20 total) back on June 23rd. This evening, I want to go back thru these pieces and see if any will program, and verify that all my non-working boards did come from that batch. I'm thinking this makes a lot of sense.

Anyone know if it's possible that legit Tiny13A's may not be programmable (locked) when purchased? They sure look legit and not counterfeit, but maybe there is a version that can't be programmed via the standard SOIC-8 method?