howto: Use Atmel AVR Studio 5 to make a .hex file

The Tiny13A gets all the attention, deservedly so, but I'm liking the Tivo532 Z8 setup so far. It's really nice to be able to reprogram on-the-fly by just plugging in the connector to the exposed back of the driver. I'm using it in a P60 (L2T) and it's really nice to try different PWM levels, and turn around your source code changes to actually testing in a light in seconds. First couple of times you try it, think anyone will be amazed when coming from the Tiny13A environment. The Z8 has 8K bytes of program space - 8X more than the Tiny13A, so plenty of space to put in all the bells and whistles, not to mention 7135 regulation combined with direct drive mode.

Sorry to go little off topic here, but I'm thinking this Z8 setup may be getting hot soon so don't get too used to AVR Studio and Tiny13A's . I got 4.7A in a P60 on a Pana PF (over 1,300 lumens), in turbo mode, then Hi mode at a regulated 1.5A, and a nice low, then moonlight level -- nice...

I use Atmel Studio 6.1 without problem. Well, in fact there was one problem with luxdrv 0.30b source code, where there is “PROGMEM byte modes={ MODES };” I had to change it to “const PROGMEM byte modes={ MODES };”.
I found this on the big tread for AVR.

I stick to luxdrv code because I really like the short term memory and I’m not skilled enough to implement that short term memory in minidrv.

Yesterday I received a Convoy S6 from banggood, I flashed it right away.
My method is to use extreme burner AVR to check connection, erase chip (mainly to release lockbit fuse) and set low and high fuse. Then I use avrdude to flash hex as extreme burner AVR can’t do it properly (why?)

And in the end of the tutorial, once buildt, it should appear in “my documents”, you don’t need to save hex again.

AS5 takes whatever I paste into it and spits out a hex file ready to use, I don't really care other than that.

I know the project folder created as soon as you hit 'build' contains the .hex, but it also has a bunch of other files that aren't needed. I find it easier to save the hex directly on its own, give it a name that identifies it, instead of going through all the crap of naming the AVRGCC projects. Paste, build, save, then I'm done with it and don't want to see it anymore. I do all the editing of the input files in notepad beforehand, unless I miss something and it fails to build correctly. Even then, after I make changes and get it to go through so I know it works, I copy the source from the AS5 window and paste it back into the txt file I keep in the folders with each version of FW (along with a .bat file with the avrdude commands in it, so I can just connect to a driver and double-click, no futzing with opening command windows for me please, unless I just have to).

I have WinAVR installed, just because it automatically sets up avrdude - I'm sure there's a way to do it without the unneeded WinAVR stuff, but this works for now, it should work for anybody else who just wants to stick firmware onto a driver and isn't really interested in launching a new career as a (apologies in advance for the following link) software developer. I only care about this stuff to the extent it lets me make better flashlights. :p

Driver for the USBASP programmer is libusb-win32, again, no real reason other than because it works and that's really all I care about.

Brilliant!!!

I have AVR Studio 6 so I will be building the .hex file soon...just waiting on my daggum programmer!

There is this combobox that says ‘debug’. I’d switch it to ‘release’ if you are not planning on actually using a debugger. That debug stuff just uses up space in the controller for nothing then.
Very nice how-to! It’s no fun to find out all that stuff alone if you are not to familiar with that kind of software!

I don’t have anything against that Z8, but keep in mind that that 13A is not exactly the pinnacle of the Tiny family, more like an ancient dinosaur or something. :wink: Some of them have really nice features (like 16bit timers for more pwm steps than you will ever want for dimming), and they are just a few lines of code away if you already have invested time and money in the AVR platform.

It's also very good to use Notepad++ (portable) to read the *******.c file to edit ;)

Thanks Comfychair,

That was very clear, much better than just words written in the flashlight wiki, or the long thread...

For a good overview, could you post a few links in your OP with other useful information about the setup, different firmware etc to keep it all easy to find...

Really appreciate your work!

thanks Comfy, that’s a great help. I knew that if I procrastinated long enough the good peeps on here would help me get started with the minimum of fuss. I’ll bookmark this and come back to it in a few days to kick myself into gear. This electronics/ code stuff doesn’t come easily to me!

Added a paragraph at the top with links to the free-to-use firmwares.

Great help, thanks

Tido's code is missing

#define F_CPU 4800000 in the BLF_VFD zip file

It fails to compile the driver.c code in the main dir, the sub directories (Fixed Modes, Programmable, Simple) have pre-compiled .hex files in them based upon the default driver.c code, has 3 mode levels...I compiled one with the mode setting to 5 with nothing else changed (but it's untested)

This is under Atmel Studio 6.1

Don't use 6.1, it just doesn't compile these, the 5.1 as mentioned above works like a champ...go figure

Pardon me while I smack myself in the forehead and have a V8

Why do y’all sometimes speak English and sometimes Swahili? Or Greek? Russian? I don’t know what it is but there’s big chunks of it I just plain can’t make head or tails out of!

Thanks Comfy for pointing me/us in the write direction. I have bitten off my first chunk and ordered the programmer and clip. Now I see it’s all in Chinenglish and barely decipherable. Oh well, off to get me a box of Capn Crunch for the mystic decoder ring…

Swahili? Or Greek? Russian?

It's actually code...programming nerd language :D

All that text gobbledy gook, plug into a compiler [the copy/paste thing], the computer then takes the text (from the links above) and builds a .hex file which is the program in "computer language" the chip can then run

The ATtiny13A is actually a 20mhz computer with a 1Kb "solid state harddrive" inside it EEPROM...a very limited computer but it allows with the above coding to turn on and off different pins at different frequencies and stuff for the different levels

Makes sense. Haven’t looked at any of that since keypunch class. But I’m game. May not be the best to start this late at night, so tomorrow I’ll come back in here and start opening stuff up and digging around. Maybe I’ll learn something!

I’m really not as bad as all that, even though it’s not anything I’ve done before the layout has some sense to it…once I figure out what buttons to press and in what order the problem will be remembering it. :wink:

Not trying to insult your intelligence...I just find if I simplify an explanation down to where "I" can understand it...usually anyone else can too

and Google is your friend..I taught myself linux by using Google (I know it enough, more or less a "power user" the guys that write that stuff are the geniuses!)

I can always get Comfy to knock it down to size and email me the hex file. :slight_smile: Then I could hook up my big jumper cables to it and wait for lightning….“It’s ALIVE!”

For a simple one like minimo all you have to change is the PWM levels. '0' is off, '255' is 100%.

So take the line in the original that says:

uint8_t modes[]={0, 8,90,255}; //PWM values, 5..255 - LEAVE THE "0" THERE

and change it to:

uint8_t modes[]={0,3,9,28,85,255}; //PWM values, 5..255 - LEAVE THE "0" THERE

(or, if you'd like to try it with the levels descending instead of ascending, do:

uint8_t modes[]={0,255,85,28,9,3}; //PWM values, 5..255 - LEAVE THE "0" THERE

and each short press will decrease one level instead of increase.)

(PWM values under 5 only work with the FETs, 7135s will sometimes work at 4 but not always reliably; stick to 5 as the lower bound for a 7135 driver)

luxdrv 0.30b works just the same, though the code is much more complex. You can edit the number of levels and their PWM values just the same. It gets more complicated if you want to do stuff like delete the ramping or strobe modes, you just have to comment out (add a '//' at the beginning of the line) the obvious stuff, then see if it builds without errors. It will tell you if anything is left behind that was tied to the part you commented out.

The software you'll need, at least to see the same things I see on my screen (that helps when following a step-by-step), is:

WinAVR: http://sourceforge.net/projects/winavr/ (install guide)

libusb-win32 for the driver for the USBASP programmer: http://sourceforge.net/projects/libusb-win32/

and AVR Studio 5.1.208. (try this: https://docs.google.com/file/d/0Bz85IxvlZQErdlpFYUhpbjYtZGM/edit - if you can get it to download, it should be the non-broken version of the installer, it's the right filesize)

This is a huge help. Parts are on order. Hope to begin in about 2 weeks from now.

Comfy, the step by step screenshots are a fantastic idea! Handholding, as it were. Thanks, this just might get me through it…

I plan to install AS5 today and wade in, look around, see if I can figure it out. With some luck, I’ll also attack the clip today and get the wires in the correct places for the ATiny13.

USB Programmer hasn’t shown up yet, but I’ve ordered components for the new FET board and eagerly await the direction to order the boards themselves.

Thanks again for leading me off into parts unknown…