Attiny25/45/85 FW Development Thread

1922 posts / 0 new
Last post
Halo...
Halo...'s picture
Offline
Last seen: 4 years 8 months ago
Joined: 12/15/2011 - 02:39
Posts: 3304
Location: Halo island

ToyKeeper wrote:
I’m not sure a 50/50 indicates it should be early in the sequence. It’s more that the things people change frequently should be early. Options which only ever get touched once can be at the end.
I neglected to mention my rational. A lot of people seem to already have a preference when it comes to these config options. If you know what you like then you will only access a given config option once, if the default isn’t already want you want.

If the popularity of mode memory is 50/50 then regardless of what the default is, half of the users will be going in to change it. If the popularity of moon mode is 49/51 then the default should be whatever 51% prefers. And 49 out of a hundred users will be looking to change that config option.

What about people who don’t know what they like? Ah, ignore them! How could we predict how frequently they would toggle an option?

Muggle mode is the only one imo with the potential to be accessed semi-frequently by some users.

I see you switched the options around a bit in bistro 205, looks good to my eye. Of course it’s all a guess. Silly

FmC
FmC's picture
Offline
Last seen: 2 months 1 week ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU

I'm looking to purchase some 85v's, but there are a few different types.

http://au.rs-online.com/web/p/microcontrollers/7380690/

 

http://au.rs-online.com/web/p/microcontrollers/6962342/

 

Those two appear to have the shorter legs that can be folded to suit the 13a board footprint.

TomE, which one have you been using with your current e-switch firmware?

 

Cheers Beer

 

- edit -

This is the filtered list of 1.8volt Attiny's that are available to me, including the 25 & 45's.

ToyKeeper
ToyKeeper's picture
Online
Last seen: 2 min 53 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10648
Location: (469219) 2016 HO3

For tiny13 and 25, get the SSU package. For 45 and 85, get the SU package. It’s the closest available to SSU.

This should allow the chips to fit onto existing drivers and be flashed in place with a common SOIC8 clip.

FmC
FmC's picture
Offline
Last seen: 2 months 1 week ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU

Thanks TK.

I'm almost finished reading through this thread from the start;

I'm ordering some 85v-10SU's, & using TomE's files from post#304, I should be good to go, as long as my wiring on my clip is correct...

Tom E
Tom E's picture
Online
Last seen: 1 min 26 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14133
Location: LI NY

Sorry, haven't been keeping up with this thread as of late. I'm still working on my version - calling it: eswBrOutCfg for now (e-switch BrownOut w/Configuration settings).

The last 85's I bought are these: http://www.mouser.com/Search/ProductDetail.aspx?R=ATTINY85V-10SHvirtualkey55660000virtualkey556-ATTINY85V-10SH. I think I went with the SH because I tried the SU in the previous buy, so I thought I might have a long shot at programming them more reliably, but that was before I figured out the ground problem in my SOIC-8 clip wiring.

SH are matte tin leads, while SU are NiPdAu leads. Not sure if one is better than the other for our application of soldering - I use lead based solder. I'd say go with the cheapest, but dunno -- one may be better... I see Richard is selling SU's for the 25 and 85 - great prices, but not the "V" lower voltage spec version.

The config settings are pretty awesome. I changed the order around, hopefully for the better. 1 thru 6 now makes a whole lot more sense. Here's what I'm using now:

Mode Set Order

Mode Count

Mode Percentages

Notes

1

1

full only

(full is always max FET, no 7135)

2

2

10-full

max 7135, max FET

3

3

5-35-full

5=1/2 7135, 35=mixed

4

4

2-10-40-full

10=max 7135, 40=mixed

5

5

2-5-10-40-full

10=max 7135, 40=mixed

6

6

TK BLF A6 7 mode

6 well evenly spread

7

3

10-35-full

10=max 7135, 35=mixed

8

4

TK BLF A6 4 mode

4 well evenly spread

 

Moon mode has been broken out separately to enable/disable it.

FmC
FmC's picture
Offline
Last seen: 2 months 1 week ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU

Thanks Tom.

I noticed an SH version that is listed as only having 256B RAM, rather than the 512B of the others. Not sure if that will have any bearing for our usage or programming.

Tom E
Tom E's picture
Online
Last seen: 1 min 26 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14133
Location: LI NY

FmC wrote:

Thanks Tom.

I noticed an SH version that is listed as only having 256B RAM, rather than the 512B of the others. Not sure if that will have any bearing for our usage or programming.

That must be a typo - I don't believe the Atmel spec sheets say that. I'd trust the Atmel data on this. I'm using Atmel Studio 7.0 now, and Studio definitely sets the 85 (any 85) for 512 bytes RAM.

FmC
FmC's picture
Offline
Last seen: 2 months 1 week ago
Joined: 03/31/2013 - 05:23
Posts: 2197
Location: Brisbane, AU

Tom E wrote:

 

That must be a typo - I don't believe the Atmel spec sheets say that. I'd trust the Atmel data on this. I'm using Atmel Studio 7.0 now, and Studio definitely sets the 85 (any 85) for 512 bytes RAM.

 

That makes more sense.

Are you planning on adding the "eswBrOutCfg" to the Repository?

Tom E
Tom E's picture
Online
Last seen: 1 min 26 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14133
Location: LI NY

Ohhh - actually I'm workin on it now - trying to add the n.n voltage level blinky feature. Didn't post it anywhere yet - gong slower to get it done than I thought.

I have a lock-out feature that works with the light OFF, do 2 quick clicks followed by an extra long hold -- it indicates lock-out by 4 quick blinks. Once locked-out, you have to do the same sequence to unlock it (2 quick clicks followed by a extra long hold).

For voltage monitoring, I want to do something similar. Plan is from OFF, do one click followed quickly by a long hold. Instead of strobe it will blink out the voltage (ex: for 4.1v, 4 blinks, pause, then 1 blink).

The lock-out feature so far is working great. The SupFire M2-Z (from MtnE) is a great light to test this on, since it has a very easily activated side switch plus it has bare threads so can't easily be locked out by twisting the loose the tailcap.

texaspyro
Offline
Last seen: 1 year 10 months ago
Joined: 04/29/2011 - 12:43
Posts: 4593
Tom E wrote:
(e-switch BrownOut w/Configuration settings).

Note that enabling the AVR brown-out detector can at least double your parasitic battery drain. My SRK driver draws around 6 microamps without brown-out, over 30 microamps with brown out.

Halo...
Halo...'s picture
Offline
Last seen: 4 years 8 months ago
Joined: 12/15/2011 - 02:39
Posts: 3304
Location: Halo island

Brown out detection can also be disabled in software just before going to sleep. So you can keep the benefit but lose the power drain. Not sure if software BOD disable is available in the non-V attinys though. I’ve read someone say it’s not available.

ToyKeeper
ToyKeeper's picture
Online
Last seen: 2 min 53 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10648
Location: (469219) 2016 HO3

Tom E wrote:
… trying to add the n.n voltage level blinky feature. Didn’t post it anywhere yet – gong slower to get it done than I thought.

If it helps, the code I used is copy-able. Not sure if it fits into your code easily, but it’s available if you want it. The files are tk-voltage.h, tk-calibration.h, and bistro.c; look for “BATTCHECK_VpT” to find the relevant sections.

The method I used is a table listing the raw ADC value followed by a packed number of blinks. So, two bytes per entry — 8 bits of ADC value, 3 bits of 1.0V blinks, 5 bits of 0.1V blinks. It iterates over that table to find the correct entry, unpacks the blink values, then, um, blinks. This was the most compact way I could think of to do it without sacrificing accuracy.

A smaller but less accurate method is to assume that 0.1V equals exactly 5.0 ADC units. This eliminates the table. But in my testing, it’s usually in the range of 4.4 to 4.8 ADC units per 0.1V, so it will skew as it gets farther from its origin value. This effect could be reduced by using the full 10 bits of ADC measurement and doing everything in 16-bit math, but that takes extra room too.

Tom E
Tom E's picture
Online
Last seen: 1 min 26 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14133
Location: LI NY

Yes - I should be able to use it. Just dnld'ed it. Thanks!

Tom E
Tom E's picture
Online
Last seen: 1 min 26 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14133
Location: LI NY

texaspyro wrote:
Tom E wrote:
(e-switch BrownOut w/Configuration settings).
Note that enabling the AVR brown-out detector can at least double your parasitic battery drain. My SRK driver draws around 6 microamps without brown-out, over 30 microamps with brown out.

Funny, because "I think" my brownout support isn't actually turning ON brown out detection. I'm using fuses: E2/DF/FF and it still works fine. So guess I should have called it simply NOINIT or something equivalent? I believe I tried it disabled and enabled at 1.8V and notice no difference.

Didn't realize (or forgot) bout the extra parasitic drain. Is there anything more to it? Any other initialization I'm unaware of? I'm thinking the extra parasitic drain is coming from enabling it via the fuses?

I use this var in my code:

// OFF Time Detection
volatile byte noinit_decay __attribute__ ((section (".noinit")));

and it seems to work fine. I don't think there's any other initialization needed. This is in my main start-up code:

  if (OffTimeEnable)
  {
     if (!noinit_decay)
     {
        // Indicates they did a short press, go to the next mode
         next_mode(); // Will handle wrap around's
         SaveConfig();
     }
  }
  else
      modeIdx = 0;
     
  if (modeIdx == 0)
  {
     TCCR0A = PHASE;
     blink(2);
  }
  
  // set noinit data for next boot
  noinit_decay = 0// will decay to non-zero after being off for a while

Tom E
Tom E's picture
Online
Last seen: 1 min 26 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14133
Location: LI NY

Never sure how you guys measures amps and voltages at so low of levels. Obviously my DMM can't go that low, so what's the method?

texaspyro
Offline
Last seen: 1 year 10 months ago
Joined: 04/29/2011 - 12:43
Posts: 4593
Tom E wrote:

Never sure how you guys measures amps and voltages at so low of levels. Obviously my DMM can’t go that low, so what’s the method?

HP-3458A multimeter Party

I have other meters that can measure down to femtoamps…

Tom E
Tom E's picture
Online
Last seen: 1 min 26 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14133
Location: LI NY

So for just $5,500 for a refurbished unit, I too can make these measurements? Smile  Hhhhhmmmmmm......

Halo...
Halo...'s picture
Offline
Last seen: 4 years 8 months ago
Joined: 12/15/2011 - 02:39
Posts: 3304
Location: Halo island

Is Brown Out Detection needed for the memory decay trick? :~

BOD can be disabled in software but I don’t think it can be enabled in software if the fuses are set to BOD disable.

Tom E
Tom E's picture
Online
Last seen: 1 min 26 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14133
Location: LI NY

Halo... wrote:
Is Brown Out Detection needed for the memory decay trick? :~ BOD can be disabled in software but I don't think it can be enabled in software if the fuses are set to BOD disable.

I'm thinking not because it seems to work, least for me...

Halo...
Halo...'s picture
Offline
Last seen: 4 years 8 months ago
Joined: 12/15/2011 - 02:39
Posts: 3304
Location: Halo island

Tom E wrote:

So for just $5,500 for a refurbished unit, I too can make these measurements? Smile  Hhhhhmmmmmm……


You can measure down to picoamps with a µCurrent adapter.
texaspyro
Offline
Last seen: 1 year 10 months ago
Joined: 04/29/2011 - 12:43
Posts: 4593
Tom E wrote:

So for just $5,500 for a refurbished unit, I too can make these measurements? Smile  Hhhhhmmmmmm……

Well, actually any volt-nut worth his salt needs three of them… man with two clocks never knows what time it is…

With a little patience, you can probably find a decent used one for less than $3000. I paid around $2400 for each of mine.

Proper calibration will probably set you back $500. I have the equipment to calibrate them (the SR104 10K resistor retails for $10K, you don’t want to know what the Fluke 732A/732B voltage references cost). There is a 3458A on Ebay right now that is up to $2000… calibrated… closes in 3 days.

Tom E
Tom E's picture
Online
Last seen: 1 min 26 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14133
Location: LI NY

Halo... wrote:
Tom E wrote:

So for just $5,500 for a refurbished unit, I too can make these measurements? Smile  Hhhhhmmmmmm......

You can measure down to picoamps with a "µCurrent adapter.":http://eevblog.myshopify.com/products/ucurrent[/quote]

That device looks cool! Still $66 USD, plus shipping I'm thinking but in a reasonable range. I gotta talk to my EE friends at work - I think they've done this without high end instruments. We got scopes, bench PS's, signal generators, flukes, etc., but don't think we have anything like that bench DMM -- not sure though.

texaspyro
Offline
Last seen: 1 year 10 months ago
Joined: 04/29/2011 - 12:43
Posts: 4593

Actually, any decent quality multimeter should be able to read down to micro-amps. I use Tektronix DMM912/914/916 meters. No longer made (?) but usually available on Ebay. With some patience you can probably snag one for less than $100.

light junkie
light junkie's picture
Offline
Last seen: 10 months 3 days ago
Joined: 02/03/2013 - 23:36
Posts: 1696
Location: Sw Az
seems lime you guys are speaking a totally foreign language lol ,this is way above my pay grade

Lj

Tom E
Tom E's picture
Online
Last seen: 1 min 26 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14133
Location: LI NY

Ok - think I got the new "n.n" battery status blinking working pretty well, thanks from T_K Wink.

I've partially integrated in her new headers, and tweaked the "n.n" blinking. With the default values for blink timing/rates she had, I really couldn't figure it out. The values I'm using now are more like the blink timing/rate a NiteCore MH20 does on it's switch LED. I took out the period blinking and made the blinks longer/slower. I find it really nice this way. I used the PWM values for voltages T_K had defined, measured by Dale for the wight FET+1 driver. There were only 5 values defined for the original 1-5 blinks, so I filled in all the values in-between for the full 2.0v to 4.4v levels. I tested it on a few cells at various levels and seems to always be within 0.1v. Probably could be tweaked a little but seems very close and reliable.

So far I'm pretty happy with how it's working in the UI - from OFF, do 1 click followed quickly by a click&hold - then the first digit of the volts blinks out (2-4 times), then pauses, then the 2nd digit blinks (0-9 times). This repeats over and over with a 2 sec delay in-between. One click aborts it.

ToyKeeper
ToyKeeper's picture
Online
Last seen: 2 min 53 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10648
Location: (469219) 2016 HO3

Oops, did I make it do the readout too fast? I tried to make it quick but not too quick, but maybe I went too far?

BTW, if you want to get all the necessary voltage values, simply measure a full cell and an empty cell with battcheck.c, then feed the values into battcheck.py and it’ll spit out ADC values for each 0.1V value. Example input files are in battcheck/readings/*.volts .

It may then require minor tweaking to get things just right, but the values should at least be pretty close.

It’s weird having to offload all floating-point math since the attiny is terrible at it. I’m spoiled by full-featured CPUs where floating point is quick and easy.

Tom E
Tom E's picture
Online
Last seen: 1 min 26 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14133
Location: LI NY

Really dunno. Did you test it? The msec values looked really low. Was wondering then if they were actually intended to be in msecs?

I tried it with your values and could not distinguish the blinks from each other. The ratio of 1:4 of ON:OFF doesn't seem appropriate for this type of thing. Dunno if it's just my ol eyes/reaction or what. But I found the MH20 NiteCore really clean - very easy to follow, so sort of modeled the timing after it.

Edit: Nevermind. Think I didn't have the same BLINK_SPEED as you had - I did something wrong. Look'n again at the bistro.c code, you have 500 msecs pauses around the period - that's not how I ran it... Still, I like the way it came out.

ToyKeeper
ToyKeeper's picture
Online
Last seen: 2 min 53 sec ago
Joined: 01/12/2013 - 14:40
Posts: 10648
Location: (469219) 2016 HO3

Yes, I have it running on a few lights. I found the speed just about right.

The timing I used was…

  • Volts: Repeat (on for 62ms, off for 250ms) a few times.
  • Period: Wait 500ms, blink very briefly, wait 750ms.
  • Tenths: Repeat (on for 62ms, off for 250ms) a few times.
  • Wait 2 full seconds.
  • Start over.

The blink speed is adjustable at the top via a #define.

Tom E
Tom E's picture
Online
Last seen: 1 min 26 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14133
Location: LI NY

Ooops, see above Foot in Mouth.

Might have to re-visit your implementation, but for now, I like the way this is look'n.

For those asking/interested, the latest source code for this 45/85 version is posted here:

https://drive.google.com- 25-45-85 stuff

It's in a ZIP file called: eswBrOutCfg10-25.zip

I zipped up the whole solution/project. There's 3 required header files now - they are required to be in the same folder as the main source code file (eswBrOutCfg.c). It requires Atmel Studio 7.0 now to use it as-is. That google drive folder also has the batch files for doing the AVRDude stuff: fuses, dnld, etc. The fuses haven't changed.

Next: expand simple strobe to a bunch of blinky modes.

 

Tom E
Tom E's picture
Online
Last seen: 1 min 26 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14133
Location: LI NY

Mike C wrote:
I've though of some of these and have implemented them in my dual switch firmware, but I have not started with a power switch only version. What I've got running in my dual switch firmware, or am currently developing: ...

Mike - this sounds awesome btw! Sounds like you got about everything covered. I haven't looked into this much because of not having a dual switch light to use it on. I recall seeing a thread or post w/details on this mod, but not sure where now. I think

Pages