STAR Firmware by JonnyC - Source Code and Explanation

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?

Yes, it’s possible. If certain fuse bits are set during programming this can happen. At that point only “high voltage” programming can be used, the ISP type we normally use will not work. In this thread in posts #52-61 we discuss the issue a little and I link to a “rescue programmer” project.

I don’t know if it’s done at Atmel or elsewhere, but I’m told that pre-programmed AVRs can be purchased. They’d be reeled and everything, ready for pick-and-place. Maybe what you received are excess pre-programmed ones with the situation I described above?

Just a thought: use an old (clean) toothbrush and some rubbing alcohol and scrub the pins well. You can flash while still wet. Sometimes I can't get chips to program that must have flux and/or oxide buildup and this works miracles.

Ok, but I did continuity tests on all 6 pins clipped from the chip to the USB dongle and it worked. I posted the question to the vendor about not being able to program them, and asked if they were possibly pre-programmed.

I'm going to put in an order for a bunch of Tiny13A's with DigiKey this weekend - need time to figure all the parts I'll be needing - might as well be sure I'm stocked up. Might order another good clip just to have a good spare.

Thanks wight for that thread tip - read it, interesting...

You didn’t include it as a compile time option as far as I know, but you did include full instructions in your thread over here: First use of lathe - P60 pill for L2T - the instructions are spread across several posts in that (short) thread.

Everything is there, I know because I built a dropin with that code in the past week. I mentioned it in the OP here. It functioned just like you described, although I have not had time yet to properly sink the P60 and the OG XM-L I used starts at 9A so I’ve only run it for a few sec at a time and verified that it functions. I set mine up as medium and turbo w/ rampdown and that’s it.

Beginners may need a hand, but they might not. There are really very few code changes required! I’ve been thinking that as a room clearing light I’d like to add a 15s+ of solid turbo before the smooth rampdown. Should be straightforward to add, but that dropin is already together and unlikely to be rebuilt. I like the concept, so I’m sure I’ll have another chance to make that change and post the code.

You’re welcome. HV doesn’t have to be for rescue, nicer programmers can actually load a program using HV programming. I think you’re looking at a $30-60 programmer to get that feature though? I guess it still might be worthwhile in the very long term if you can save $0.30/ea or so per ATtiny13A… after about 100-200 chips you break even? Of course that’s assuming that these aren’t total fakes! They could be mislabeled/etc.

What error text does AVRDUDE give you?

[/quote]

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.

[/quote]

I for one would be very interested in the smooth ramp down. Thanks again for all the help. Wish I had something more to contribute developmentally.

I'll gladly eat the $13 spent on the bad parts rather than investing into the tool - agreed Smile. Thought the AVRDUDE error msg was the same as when it's mounted wrong or missing - not sure, @work now... DigiKey all the way now... Actually, I bought Tiny13A's from BangGood originally and they worked out well, even though they were individually wrapped - weird.

Wow, you know my posts better than I do! I still haven't done *%# with those builds. And wow, that looks like a great driver you built. I haven't even dabbled into the FET arena, I simply cannot keep up with all of the posts on the subject! If I ever want something other than a NAJNG, I'll just order it pre-built from Richard :)

I'll work on getting the "immediate turbo ramp" feature in the main code hopefully today. Then I need to start the port to the ATtiny25.