Adventures in TinyAVR 1-Series

276 posts / 0 new
Last post
Mike C
Mike C's picture
Offline
Last seen: 2 days 21 hours ago
Joined: 01/22/2014 - 08:03
Posts: 2582
Location: Sweden

I’ve never tried running the system on the ULP clock, it does look interesting for OTSM. Your test #1 and #13 suggest that I could use pretty low rated caps for OTSM, and with TCD I see no reason to use any other clock for the system. One of these days I have to test how much reliable off time I can get from a 10uF cap at both 3.33MHz and 32kHz ULP.

gchart
gchart's picture
Offline
Last seen: 12 hours 19 min ago
Joined: 03/19/2016 - 11:57
Posts: 3158
Location: Central IL

gchart wrote:
The dev board PCBs arrived today and I made one up tonight. Looks like I’ve got some programming to do!

I think I’ll start with RampingIOS to test out the board (since I already know that works) and will move up to NarsilM and Andúril.

Well… it only took me a year to get the time to work on this. Facepalm To my defense, I brought home my 5th child (yes, 5) just a couple weeks after getting the PCBs in the mail.

In the past few days, I have managed to (1) flash the dev board using Linux (previously I had only used Atmel Studio for these newer chips) and (2) completely ported over Anduril to run on the AVR 1-Series! I’ve got it running seemingly flawlessly on the dev board. Code can be found here. I’ve tested: ramping/stepped modes, batt check, temp check, flashy modes (candle, lightning, bike, etc), button aux LEDs, etc.

Next up: get this on a proper driver and in a flashlight. This will aid in verifying full thermal regulation, battery warnings, sleep mode current draw, etc.

Agro
Agro's picture
Online
Last seen: 1 min 25 sec ago
Joined: 05/14/2017 - 11:16
Posts: 6811
Location: Ślōnsk

gchart wrote:
gchart wrote:
The dev board PCBs arrived today and I made one up tonight. Looks like I’ve got some programming to do!

I think I’ll start with RampingIOS to test out the board (since I already know that works) and will move up to NarsilM and Andúril.

Well… it only took me a year to get the time to work on this. Facepalm To my defense, I brought home my 5th child (yes, 5) just a couple weeks after getting the PCBs in the mail.

In the past few days, I have managed to (1) flash the dev board using Linux (previously I had only used Atmel Studio for these newer chips) and (2) completely port over Anduril to run on the AVR 1-Series! I’ve got it running seemingly flawlessly on the dev board. Code can be found here. I’ve tested: ramping/stepped modes, batt check, temp check, flashy modes (candle, lightning, bike, etc), button aux LEDs, etc.

Next up: get this on a proper driver and in a flashlight. This will aid in verifying full thermal regulation, battery warnings, sleep mode current draw, etc.

Party Thank you gchart! It’s a really important step for our drivers!
Tom E
Tom E's picture
Offline
Last seen: 20 min 18 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14685
Location: LI NY

This is great news! Nice Job!!

MRsDNF
MRsDNF's picture
Offline
Last seen: 2 months 5 days ago
Joined: 12/22/2011 - 21:18
Posts: 13473
Location: A light beam away from the missus in the land of Aus.

gchart][quote=gchart wrote:
I brought home my 5th child (yes, 5) just a couple weeks after getting the PCBs in the mail.

Congratulations mate. My wife would be totally envious. Beer

 

djozz quotes, "it came with chinese lettering that is chinese to me".

                      "My man mousehole needs one too"

old4570 said "I'm not an expert , so don't suffer from any such technical restrictions".

Old-Lumens. Highly admired and cherished member of Budget Light Forum. 11.5.2011 - 20.12.16. RIP.

 

gchart
gchart's picture
Offline
Last seen: 12 hours 19 min ago
Joined: 03/19/2016 - 11:57
Posts: 3158
Location: Central IL

MRsDNF wrote:
gchart wrote:
I brought home my 5th child (yes, 5) just a couple weeks after getting the PCBs in the mail.

Congratulations mate. My wife would be totally envious. Beer

Thanks, Moose! He appears to be a ReyLight fan, so I think I did ok Wink

MRsDNF
MRsDNF's picture
Offline
Last seen: 2 months 5 days ago
Joined: 12/22/2011 - 21:18
Posts: 13473
Location: A light beam away from the missus in the land of Aus.

Your going tyo have to teach him not to look at the light when he turns the torch on. Smile
Have you planned any more? My oldest turns 27 today.

 

djozz quotes, "it came with chinese lettering that is chinese to me".

                      "My man mousehole needs one too"

old4570 said "I'm not an expert , so don't suffer from any such technical restrictions".

Old-Lumens. Highly admired and cherished member of Budget Light Forum. 11.5.2011 - 20.12.16. RIP.

 

Tom E
Tom E's picture
Offline
Last seen: 20 min 18 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14685
Location: LI NY

My youngest is 30, so the pic is more like a grand kid to me (got 2), which is all good smileembarassed

WTF
Offline
Last seen: 8 months 4 weeks ago
Joined: 03/05/2017 - 20:13
Posts: 318

gchart wrote:

In the past few days, I have managed to (1) flash the dev board using Linux (previously I had only used Atmel Studio for these newer chips) and (2) completely ported over Anduril to run on the AVR 1-Series! I’ve got it running seemingly flawlessly on the dev board. Code can be found here. I’ve tested: ramping/stepped modes, batt check, temp check, flashy modes (candle, lightning, bike, etc), button aux LEDs, etc.

Next up: get this on a proper driver and in a flashlight. This will aid in verifying full thermal regulation, battery warnings, sleep mode current draw, etc.

This is great news. I immediately thought of your pic12 adapter board but am not sure how easy it would be to replace a pic with an 816. Programming the 816 shouldn’t be too bad, either using an explained board or maybe an arduino. Probably switch out the battery voltage divider resistors to match anduril and remove the ntc if the light has one for temperature sensing.

Is moving the switch input and the outputs around on the 816 fairly straight forward?

gchart
gchart's picture
Offline
Last seen: 12 hours 19 min ago
Joined: 03/19/2016 - 11:57
Posts: 3158
Location: Central IL

For programming adapters, I just used the AVR JTAG ICE for the first time. It’s similar in appearance and price to a AVRISP. It worked well.

In Anduril, it’s incredibly easy to switch pins thanks to the “hwdef” (hardware definition) files that contain pinout info for a specific driver.

Now that Anduril is working, I plan on trying one of those PIC adapter boards soon. SC31B? FC11? TS70? Not sure which should be my first candidate. Hmm… After finally getting it ported over, my modding interested has finally piqued again.

WTF
Offline
Last seen: 8 months 4 weeks ago
Joined: 03/05/2017 - 20:13
Posts: 318

Those JTAG ICE programmers are pretty expensive. There is a little five dollar clone on aliexpress that seems ok but shipping to Canada is pretty horrible right now.

Where you able to use the hwdef files without modification? That would make things easier for someone with programming skills as bad as mine. Solving invisible problems gets frustrating and I usually end up with the same two questions. Why can’t they do anything normal and how can I make a four pound hammer a solution to the problem.

PIC hunting seems fun though. Can’t wait to replace high, low, flashy with anduril.

gchart
gchart's picture
Offline
Last seen: 12 hours 19 min ago
Joined: 03/19/2016 - 11:57
Posts: 3158
Location: Central IL

WTF wrote:
Those JTAG ICE programmers are pretty expensive. There is a little five dollar clone on aliexpress that seems ok but shipping to Canada is pretty horrible right now.

Where you able to use the hwdef files without modification? That would make things easier for someone with programming skills as bad as mine. Solving invisible problems gets frustrating and I usually end up with the same two questions. Why can’t they do anything normal and how can I make a four pound hammer a solution to the problem.

PIC hunting seems fun though. Can’t wait to replace high, low, flashy with anduril.


Yeah, sorry… I was referring to the ~$5 clones, like what is referred to in this guide

But if you’re going to use Atmel Studio (or compile avrdude on your own), then an Atmel dev board like the ~$8 416 Xnano is perfect.

Hwdef files do need modification, but that should be expected. It’s a different MCU, so a different layout.

Part of what I’m curious about /hopeful for… These 1 Series chips come with up to 32KB of memory. If TK can fit Anduril in 8KB, what can she do with 4x as much space? Big Smile

Agro
Agro's picture
Online
Last seen: 1 min 25 sec ago
Joined: 05/14/2017 - 11:16
Posts: 6811
Location: Ślōnsk

Hey…nice find with that jtag ice Smile
The best combination of simple and cheap that I’ve seen so far. Smile
Does it allow debugging 1 series chips or programming only?

gchart
gchart's picture
Offline
Last seen: 12 hours 19 min ago
Joined: 03/19/2016 - 11:57
Posts: 3158
Location: Central IL

Not that I’m aware of, though I haven’t researched that.

I have used the 416 Xnano to debug in Atmel Studio. That worked very nicely! You just disconnect the onboard MCU and then you can use it as a programmer/debugger for any of the newer chips (using the onboard mEDBG).

nickelflipper
nickelflipper's picture
Offline
Last seen: 5 months 1 week ago
Joined: 10/20/2012 - 09:31
Posts: 497
Location: Oregon

1+ for the 416-Xnano. Pros are that you can power the target with 5V from the Vref pin on the programmer side, has a CDC TX so you can talk with a terminal, user button and led, plus all the pins are labeled on the device side silkscreen, very nice and easy way to get going.

Kent

gchart
gchart's picture
Offline
Last seen: 12 hours 19 min ago
Joined: 03/19/2016 - 11:57
Posts: 3158
Location: Central IL

I also have the 817 Xmini, which is very nice but overkill if all you want is a programmer / debugger. Real nice dev board though. And still inexpensive.

nickelflipper
nickelflipper's picture
Offline
Last seen: 5 months 1 week ago
Joined: 10/20/2012 - 09:31
Posts: 497
Location: Oregon

Same here, if one is into it, not much trouble to get an Multifunctional Expansion Board Shield kit for the UNO to sit on top of that 817-Xmini.

Kent

WTF
Offline
Last seen: 8 months 4 weeks ago
Joined: 03/05/2017 - 20:13
Posts: 318

gchart wrote:

Hwdef files do need modification, but that should be expected. It’s a different MCU, so a different layout.

Part of what I’m curious about /hopeful for… These 1 Series chips come with up to 32KB of memory. If TK can fit Anduril in 8KB, what can she do with 4x as much space? Big Smile

It doesn’t sound like moving I/O between port a and port b is very hard so that’s good.

I once asked TK if she’d prefer to abandon the 85 altogether and just use a new one series with an adapter board but she prefers to keep the 85 for backwards compatibility. The amount of work she does to squeeze everything onto the 85 seems like a lot, especially for a volunteer. I’d like to she what she could come up with if she had IOT connectivity to work with.

Agro
Agro's picture
Online
Last seen: 1 min 25 sec ago
Joined: 05/14/2017 - 11:16
Posts: 6811
Location: Ślōnsk

gchart wrote:
Not that I’m aware of, though I haven’t researched that.

I have used the 416 Xnano to debug in Atmel Studio. That worked very nicely! You just disconnect the onboard MCU and then you can use it as a programmer/debugger for any of the newer chips (using the onboard mEDBG).


How do you debug flashlight firmware in a board that does not resemble a flashlight driver at all?
SammysHP
SammysHP's picture
Offline
Last seen: 6 hours 59 min ago
Joined: 06/25/2019 - 14:35
Posts: 981
Location: Germany

You don’t need the LED driver circuit to develop the firmware. For most parts of the development an oscilloscope or logic analyzer is enough. Or hook up a small LED with a current limiting resistor to a free pin.

gchart
gchart's picture
Offline
Last seen: 12 hours 19 min ago
Joined: 03/19/2016 - 11:57
Posts: 3158
Location: Central IL

For initial firmware development and debugging, SammysHP hit it on the head. But also…

These Xnano and Xmini dev boards give you the ability to disconnect their onboard MCU. You can then wire the programming/debugging chip on the Xnano/Xmini to any of the 0-Series or 1-Series chips thru the 1 wire (plus power and ground) UPDI (unified program and debug interface). So you can actually debug code running on an actual flashlight driver.

Tom E
Tom E's picture
Offline
Last seen: 20 min 18 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14685
Location: LI NY

Boy, I'd love to get into this development setup, if only I had the time. 32 KB is a whole lot, and would really like to see what can be done with 2 switches and multi-channel, multi-LED. If only I had more time.

I got in a Amutorch E3 - 21700 triple LED, standard MCPCB, std triple optics. It's light weight and compact, but they made the cavity above the driver extremely small - 2.4 mm clearance over the driver, so I can't piggyback a small board in. Only option is driver replacement and it's got 2 screw holes for mounting - great idea really but no std OSHPark driver will fit, plus with a board mounted switch. Love to build up a OSHPark board for the E3 with this MCU.

gchart
gchart's picture
Offline
Last seen: 12 hours 19 min ago
Joined: 03/19/2016 - 11:57
Posts: 3158
Location: Central IL

Man, driver mounted switches can be a pain. Means you usually need a custom one-off driver. Got pics of the driver?

Tom E
Tom E's picture
Offline
Last seen: 20 min 18 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14685
Location: LI NY

gchart wrote:
Man, driver mounted switches can be a pain. Means you usually need a custom one-off driver. Got pics of the driver?

Actually CerealKiller did a OSHPark board with a driver mounted switch and I've used it a couple times. Not sure if I have pics - will take some and post.

 

This is one: https://oshpark.com/shared_projects/yoNxPZWi, this is his whole collection: https://oshpark.com/profiles/Cereal_Killer. I used this one: AT-008_V2

 

 

 

Tom E
Tom E's picture
Offline
Last seen: 20 min 18 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14685
Location: LI NY

I already took pics but didn't post. It's a classic FET+1 design with the FET markings rubbed off, 10 pin MCU - not sure what it is, but here's the manufacturer's page: http://www.sonix.com.tw/category-en-947

gchart
gchart's picture
Offline
Last seen: 12 hours 19 min ago
Joined: 03/19/2016 - 11:57
Posts: 3158
Location: Central IL

Ohh, I do like how compact that looks. Appears to be a good candidate for a driver swap. Anybody have one of these that they want to get rid of? Wink I wouldn’t mind putting a driver together for it.

Tom E
Tom E's picture
Offline
Last seen: 20 min 18 sec ago
Joined: 08/19/2012 - 08:23
Posts: 14685
Location: LI NY

Hhmm. Maybe you can have this one. Neal gave it to me, actually, with my last order. It's a one piece shell, but the switch is a bit squishy - too far off from the mech switch. I told Neal, he said he'd pass it along.

gchart
gchart's picture
Offline
Last seen: 12 hours 19 min ago
Joined: 03/19/2016 - 11:57
Posts: 3158
Location: Central IL

Naw, I don’t need you to let go of yours Tom. Half of the reason for acquiring one would be to put together a board you could play with!

HarleyQuin
HarleyQuin's picture
Offline
Last seen: 10 months 3 weeks ago
Joined: 03/29/2013 - 04:47
Posts: 588

Hi all,

thanks for sharing your ideas, I’m reading with interest what you are up to here and I might as well join in with a board or two.

It’s not that my wishes exceed the 85’s 8kB. I customized FSM/Anduril to my liking within 8kB, but I would very much like to have the possibility to have more resolution for PWM. Especially in the moon region and at the seams of the PWM channels.

If I read the datasheet right the 1616 supports more than 8 bit PWM, that would be THE argument for me to migrate.

I’m already converting a brd for a future project and like the idea of the 20pin 3×3mm versions best, hence my eye is on the 1616.

My next obvious question now would be: Which function at which pin? Where should the PWM go, where the switch pin, where the indicator LEDs?

Or does the multiplexer allow to connect every pin with every feature? And do all ports allow for higher PWM resolution? I saw gchart using port B (PB0-2) and adding the aux led on PA1, which I presume was more or less random. And which function would profit from the energy efficient Timer/Counter D (pwm, switch, indicator)?

I welcome your input. I got some spare time and I’m looking forward for some board design. But 600+ pages of datasheet is quite a burden for me, and I even did not fully fathom this multiplexer thing, yet.

Thanks
HQ

Oshpark Boards:
HQ ProgKey: Universal Driver Programming Key . Boost: HQ 15mm/17mm programmable boost driver with ATtiny13A
46mm Triple-Channel: BLF SRK FET v3 . 17mm Linear: HQ10D / HQ4D / HQ4S . Contact Boards: 22/24/26mm

gchart
gchart's picture
Offline
Last seen: 12 hours 19 min ago
Joined: 03/19/2016 - 11:57
Posts: 3158
Location: Central IL

HQ, good to see you around!

Timer/Counter A and B are both 16 bit. Timer/Counter D is 12 bit. The advantage of using TC-D is the ability to have clocked separately from the main CPU clock. While it could have many applications, I feel like the main benefit for us would be to use the 32 kHz ultra-low-power clock for the main CPU and then we could still use PWM at a high rate without the CPU sucking up a lot of current. For the sake of comparison, say you wanted a 10-bit PWM (1024 steps) and a fast PWM rate (like 19 kHz). Using TC-A, the main clock would need to run at the full 20 MHz and the MCU would be drawing ~10.6 mA. But if we used TC-D and ran the main clock at 32 kHz, the MCU would only draw around 970 uA (less than 1mA). If we used this for moon levels, it could greatly extend runtime.

In choosing pins, there’s quite a bit of flexibility. I typically refer to the two charts shown below (from the datasheet).

Some things worth noting:

  • TC-A is 16-bit and normally has 3 compare outputs: WO0, WO1, and WO2. But you can run TC-A in split mode which gives you 6× 8-bit compare registers WO0-WO5.
  • TC-D technically has 4 output pins, but WOC and WOD (if enabled) generally mirror WOA and WOB… they’re not configured independantly
  • I haven’t played with the multiplexing much, but yes… there are certain functions that can be re-routed to other pins (as noted below)

Pages