Attiny25/45/85 FW Development Thread

Yep.. Anyway, high is working, just not well. hmm, hoping it's a pin setting thing. Not sure. Mostly I haven't used turbo because the star isn't heat sinked. So will have to figure this out. The led shouldn't be able to drain C2, and if anything should help. Well I've got at least one idea to check so we'll see.

I don't know the cause of the high mode thing yet. Haven't had a chance to do any testing. I realize that one thing my power measurements missed, well that's the wrong word... they measured the mcu power draw. But there can also be a reverse current through the diode (I was feeding power forward through the diode so didn't measure that). I checked the specs on the diode in your digikey basket (likely the one I'm using, but I'm not sure) and it's not very good:

http://www.diodes.com/_files/datasheets/ZLLS410.pdf

At 25C it's around 1uA or less but at 85C it's around 80uA maybe. I wouldn't think my board is getting this hot (not sure, it's hanging in the air without a case to heat sink too, but it also has no led to heat it up), but it would only have to be 5ua to have the kind of effect I'm seeing. It's another case where I don't know how conservative the specs are. If it causes this issue or not though it's probably not ideal anyway. This would be a better choice I think:

http://www.onsemi.com/pub_link/Collateral/RB751V40T1-D.PDF

With the graphs indicating around 1uA at 85C. That diode is a bit fragile in comparison but should do the trick (with an R5 installed to protect it).

Of course all this brings the question, how good is the LDO at reverse current blockage? I lost the link to your new LDO. uA are small. Can it really work without an inline diode?

Psst…
Debug>>Properties>>Toolchain>>Optimization

Edit: Hmm. I guess I was reading an old post when I saw Texas_Ace was using a Linux virtual machine to compile with optimization.

Interesting points on the diode reverse voltage. If you find a better one that is obviously easy enough to change out. Although the LDO would be better if it works.

The latest LDO we have found is the LT3009, the real issue with it is the rather scarce availability compared to other options.

It must have been an old post. I do use Linux now (in a virtual machine simply because I don’t like having to walk over and use the Linux box lol).

Atmel complained constantly about things, Linux uses the same exact files and compiles it without any issues and the final size is smaller too boot. So I now just use that.

Yes, I know the -Os option. I'm well past that level of tricks now I hope, but it's a good tip thanks.

So, I took some measurements. At 3.3 V I'm at 8uA in sleep measured through the usual power chain, so the same as my much older tests in similar configuration. But I before I measured that I happened to be measureing at 4.2V which put me at 10uA, ok fine. But if instead I connected direct to Vcc, powering C2 directly with 500 ohms bleeder to ground upstream of the diode (the amount of resistance there really doesn't matter for diode reverse current since all the voltage will still be across the diode) then I got about 11.5uA. Ok, no big deal, seems like maybe there's 1.5uA of reverse leakage through the diode.

But I had taped a thermocouple to the diode body, and heated everything up (starting at 22C). By 55C it was 20 uA and by 70C it was at 33. Actually I stabilized at about 75 and took those numbers as it cooled because that seemed more stable than while blowing hot air on things. One time I cranked it up to 85 because the spec sheet has a line there, looks like aroun 70uA maybe on the spec sheet, and sure enough, it went off scale, somewhere pegged past 50uA. So it follows the specs pretty closely actually.

I'll look up your LDO, but this could be a real issue. I'll also try to see how warm things were getting on my high mode because I'm not sure yet that these are related issues. It's all I came up with so far though and it kind of checks out so far.

Oh, and I ran the same test powering it with forward current through the diode (with the bleeder removed), the normal way, and heating it, and the current did not go up past 12uA. Actually it dropped a little a few times, but came back to the same point. So I think that's pretty conclusive.

This backside powering is actually pretty handy because you can pull the wake pin up and down and trigger the interrupts at will while watching current. It's easy to setup too because you just power it through the Vcc pin on the programming clip.

I am not sure I am following exactly.

So the diode is leaking a lot more then expected but it doesn’t seem to actually effect the driver in real world use as you only get 12ua?

What is the new powering approach exactly, you are powering the MCU after the diode?

"real world" is still unknown. The diode is leaking as much as the spec sheet says it does, which is quite a lot at high temperature. Powering the mcu from downstream of the diode allows me to measure the effect. Powering it from upstream does not, because my power is going through the diode anyway. The fact that I see it one way and not the other, just confirms that the temp effect is the diode and not something else. However during sleep, the mcu is powered from downstream of the diode and the leakage will be a problem if it's hot. So yeah, that could definitely be a real world issue, and at those current levels, a pretty big one. I don't think 55C is unreasonable to expect and that's already going from 12 to 20 uA so that would impact turbo performance on this diode. I suspect your LDO is worse.

However, I just teste this setup on turbo (2A limited though), and it rises a degree or two just if I set the board near the star, and leave it a minute or so (which is as long as I dare anyway without a heat sink). So I don't think that's the issue affecting high modes at the moment. I suspect it could be a pin state thing, but I don't really know yet.

Ah, ok that makes more sense.

I've finished up the features, testing, and so-on for the next NarsilTriple release. This is v1.3 now, and includes a full NarsilTriple v1.3 manual, listing all the features, configuration settings and modes. I also made a pass through the source code, and a "notes.txt" file included to update the comments and descriptions accordingly.

I've been testing it on a Lumintop SD26, which came out pretty nice, using the green LED's mounted on the switch PCB for the Indicator LED function of Narsil. Been using it with a 4.7K resistor to reduce the standby power when the LED's are on.

I really could write up a 2nd doc just for tweaking settings in the source code - there's a ton of them.

Link for full source (fully set up for Atmel Studio 7.0) and manual in docx and pdf formats:

My Google Drive Share for NarsilTriple

Brief summary of V1.2 to V1.3 changes

  • New Features: add code from DEL's test driver for doing voltage reading from the internal 1.1V reference, and use temperature sensor readings
  • config UI changes, and add a mode to blink out the temperature (calibration done in constants in the firmware code)
  • tweaks to ramping tables: seems to work well now!!
  • New Feature: for ramping, blink the ind. LED to indicate what channel the output is on
  • add compile switch to use only ind. LED for several usages: power-on blinks, config blinks

Summary Of Features

  • Ramping – smooth 150 level ramping, simple click&hold ramps, 1 click ON to last level, 1 click OFF, direction of ramping will toggle unless you remain at a level more than 1.2 seconds
  • Mode Sets - Simple 1 click ON, 1 click OFF, navigate to next and previous modes
  • 8 mode sets to choose from, 1 to 7 modes/output levels can be configured, and then saved
  • Modes can be arranged for low to hi, or hi to low
  • Multiple strobe and beacon modes can be accessed, total of 5 special modes (16 Hz strobe, police strobe, bike strobe, 2 sec beacon, and 10 sec beacon)
  • Low Voltage Protection (LVP) – output is decreased starting at ~3.2V, shut off at ~3.0v, both with blink warnings
  • Temperature Regulation: drops output at high temps, with blink warnings, blink out temperature in C
  • Turbo timeout can be enabled/disabled, and the time be set (works for high output levels in Ramping too)
  • When power is applied, 2 blinks indicate it’s ready
  • An Indicator LED (SMD LED) is supported as a locator LED and low voltage indicator
  • Battery Check – blink out the voltage level (ex: 3.7V would be 3 blinks, pause, then 7 blinks)
  • Very low standby power (parasitic drain) without Indicator LED on
  • Lock-out feature for the side switch – enabled and disable by a special click sequence
  • 20 second button press safety lock-out feature (engages lock-out after 20 secs being held)
  • Mode memory can be enabled to quickly restore the last used mode setting, but not recommended
  • A power tail switch can be used to change modes w/memory

Amazing effort Tom that we all appreciate. Thanks.

Very nice, I will have to give it a try if I build anymore e-switch lights.

Thanks All! But ... Found a couple of minor issues with the v1.3 posted. I updated the source and resulting files. It's all updated now. The changes, as noted in the source code header are:

  • bug fix: error in modeSetCnts for Mode #8: would not have worked
  • reduced timeout from OFF to standby/sleep from 10+ secs to 5 secs
  • change default of twoDigLedOnly from enabled to disabled (Batt/Temp/Vers Ind. LED Only)

I posted a ZIP file of the HEX only, but it has limited use because there are so many compile time settings.

Updated in the same location as linked to before: My Google Drive Share for NarsilTriple. Please note the ZIP files are todays date, time of 5:45 PM (not sure how that works across time zones).

Tom, I am very appreciative of your efforts! This is an exciting firmware and will be implemented right away. You’ve thought through so many things and it allows someone like me to have something to keep my mind engaged. My mind needs to learn complicated things yet I am unable to learn as I once could learn which means I need these complicated to be easy complicated things. :wink: Sounds like it doesn’t make sense but to me it is a big deal.

So a big thank you to all you guys involved in helping me interact with these exciting and mind stretching projects!!!

Looks like some great work. I haven't really looked much into narsil honestly, but I can appreciate the work anyway.

I played a little with a genaralized function to interpolate sparse tables. A straight forward implementation added about 180 bytes vs the full lookup table, and that was after probably saving about 30 in the table itself. Some hacking up a division algorithm brought that down by 30 bytes, but also added more constraints (no gaps greater than 31 in ADC channel, with 8 step intergap resolution). You'd need really several tables before this wins.

There are probably better ways to just make a single simple straight line (or more tailored implementations of the same way possibly). These machines can multiply, they just can't divide, but 8 bits makes everything tricky (you can't multiply anything bigger than 15*16 without going to 16 bit).

So these things are heavy I'm afraid, as gchart also found.

I'm polishing off a few little adc stability things that Vcc and some OTSM related powersaving caused. Then I'll probably put this out for others to test.

Speaking of narsil though, I just realized that this bistro OTSM code, possibly with as little as one preprocessor define to change the pin ID, would turn bistro into an e-switch firmware (if that doesn't already exist somewhere, not sure). OTSM is essentially just an eswitch anyway, just that it measures how long the switch was pressed. It would just need a check to prevent the counter overflow, and at the same time probably switch over to longer watchdog times after a couple or few seconds of wakes. Why wouldn't that all work?

...

Oh, yeah.. just remembered, the e-switches are momentary? Just a push to make switch? So it would need a little extra for the toggle. How do these e-switch softwares work, long press for off? Short press/medium for controls then?

I was wondering bout that. I might not fully understand what OTSM is exactly and how it works, but think'n it just might convert a power switch into an e-switch. Bistro certainly is not designed that way. Power switching and e-switching are two different architects. e-switch firmware requires somewhat precise measurement of button press's. The common implementation is the 16 msec timer being used to poll for button presses and releases, with simple debounce logic. Having the capabilities of Bistro and adding e-switch support would normally add a considerable amount of code. Big reason why I went to the 85.

In Narsil, the critical stuff is done in the watchdog timer because it's so sensitive in acting on switch state transitions, mode based. The main loop acts on events detected by the timer. You can easily get caught up in trying to do everything in the timer, but that's a mistake - the timer should simply schedule things for the main loop to execute, such as controlling the LED output, doing the low batt signals, acting on over temp conditions, blinking out statuses, etc. If you keep to the rules, generally things will work fine. I mostly get into trouble when I break those rules, and then get into conflicts/time sync issues between the timer and the main loop.

For Bistro, it's actually much simpler, single threaded, one main loop. More like a straight sequential programming model.

Yeah, I've been struggling with exactly those model differences. I was almost going toward having the main loop process interrupts, and adding a global timer, and having adc multiplexing in background between thermal, Vcc and whatver. But in the end I did things differently. There's an interrupt that senses the switch go down, and puts it into a watchdog loop, counting times on wakes. A final pin high interrupt wakes it the last time where the real trick happens (I'll get there). For eswtich instead could just use a faster watchdog at first, and slow it down later, but I need a slow(1/4s) watchdog to save power for OTSM so the extra pin wake makes it respond faster. This is all a very nested/re-entrant web of interrupts that's very non-recommended, but works great anyway, and all to avoid the recommended way of setting a flag and handling the interrupt in the main loop. As you say bistro just isn't designed for that. I went through seeing what that would take, and it's possible of course, not even terrible probably, but definitely more work, less incremental, and more chance to create more problems.

Anyway at the wake, have to back up, the trick is that the main loop is not main() anymore. main() just sets some default values for cold starts, and calls a function that is the main loop, run(). At the wake up I reset the stack pointer to RAMEND (very uncivilized but effective) and call run(), restarting the program but bypassing initialization of main() thus keeping the wake counter and anything else I want. So I've created a goto out of the interrupt back to the beginning.

So I guess the light shouldn't go off during short clicks on e-switch. Ok, so just replace sleep with delay until the few second threshold I described. I think it could work.

Ahh, ok. The change of frequency would be a complication I suppose, can be handled though. Also wondering bout the switches. True e-switches are generally made for that. The mechanical rev and fwd clickies are generally not designed for frequent use. I'm pretty fussy bout the feel of the switches on e-switch lights. I much prefer an easier engaged switch, which they seem to be going away from. Mechanical switches to use as an e-switch? Dunno, I'd have to check a few and see.