# PWM Regulator-Mag D, JM-PhD-D1, UPDATE



## JimmyM (Mar 29, 2009)

The original thread has run a bit long, so I'm continuing it here.
The original can be found here
Part 1

I have a design that will work up to 40V and 12Amps or so. All of the testing I've done using bulbs like the 64623 and 64458 have failed to heat up the FET beyond what I would call luke warm.

I've purchased a bunch of equipment to do all the SMT assembly myself.
The board design is finalized and was sent out for quote.

I've added a few extra pads on the board to take advantage of unused I/O pins for future use by either me or by some enterprising individual who would like to roll their own code.
-------------------------------
*The JM-PhD-D1 is now for sale.*

Sales thread is open HERE


----------



## LuxLuthor (Mar 30, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

Thanks for the update. ETA?


----------



## ANDREAS FERRARI (Mar 30, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> The original thread has run a bit long, so I'm continuing it here.
> The original can be found here
> Part 1
> I've done using bulbs like the 64623 and 64458 have failed to heat up the FET beyond what I would call luke warm.
> ...


----------



## ANDREAS FERRARI (Mar 30, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

OMG, pressed the wrong button!


----------



## JimmyM (Mar 30, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



LuxLuthor said:


> Thanks for the update. ETA?


A few weeks to a month-ish. Maybe. I'm just buried with work.

Why am I even telling you this. You get one to beat-up before anyone else. :devil:


----------



## JimmyM (Apr 8, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

ALLLLLL RIGHTY THEN!
I orderd 200 boards yesterday afternoon. I also ordered a solderpaste stencil to aid assembly.
Last weekend I ran another test with the new solder paste I bought. I'm still getting a little solder beading/balling, but I haven't had time to mess around with the profile as much. I have one primary change to make. I'm going to try reducing the preheat and soak temperatures for a more gradual ramp from start to the beginning of the reflow ramp.
In any case, the boards and the stencil are on their way.
In another week or 2 I'll be ordering the components. Once they arrive these are the steps.
Build one set of 10 boards.
Program them and test them a little myself.
Send a couple to Lux to beat on.
Lux tests and reports.
If all is well, I start the sales thread and start knocking these babies out.


----------



## JimmyM (Apr 8, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



ANDREAS FERRARI said:


> JimmyM said:
> 
> 
> > The original thread has run a bit long, so I'm continuing it here.
> ...


Sorry I haven't gotten back to you regarding the 633. Lux will be able to give a full assessment under conditions like that. But, here's my take.
The 633 only draws 12.2 amps max. I've tested with up to 10-11 amps with no real heat issues. It's not the wattage of the bulb that would cause problems. It's the current. So a 633 should be no big deal.
I'd like to see Lux use his parallel bulb rig to test these so that current is in the 15-18 Amp range. I think that will start to cause heat problems and bear out the limits.


----------



## JimmyM (Apr 8, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

Here's a picture.
[URL=http://img27.imageshack.us/my.php?image=jmphdd1.jpg]

[/URL]


----------



## Bimmerboy (Apr 8, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

Excellent! Gives me about enough time to save up for these after some other purchases, and to decide what voltages to run my bulbs at. Tough decision ya' know. Always the back and forth... brightness, or bulb life?

It's not easy being a flashaholic.


----------



## LuxLuthor (Apr 8, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> Sorry I haven't gotten back to you regarding the 633. Lux will be able to give a full assessment under conditions like that. But, here's my take.
> The 633 only draws 12.2 amps max. I've tested with up to 10-11 amps with no real heat issues. It's not the wattage of the bulb that would cause problems. It's the current. So a 633 should be no big deal.
> I'd like to see Lux use his parallel bulb rig to *test these so that current is in the 15-18 Amp range*. I think that will start to cause heat problems and bear out the limits.



 I bet you are one of those "whips and chains" kind of guys too! 

As always, Jimmy thanks for all the great work. That chip image detail is unreal!

Anyone looking at bulbs that suck up > 8-10 Amps will need lots of battery capacity...like parallel IMR-18650 or a 26700 cell, or they will run out so fast.


----------



## JimmyM (Apr 8, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



LuxLuthor said:


> Anyone looking at bulbs that suck up > 8-10 Amps will need lots of battery capacity...like parallel IMR-18650 or a 26700 cell, or they will run out so fast.


I'll leave the whips and chains comment alone for now.... :devil:

But 8-10 amps is no worse than a lot of folks running the 64623s, 64458, 64625s, etc on 2/3As.
This unit won't be able to support the huge current flows placed on the JM-SST, but it should be more than enough for most D-Cell applications.

Maybe try 2 64623s in series with a 30V input and 28V output? That would be over 200W.
The parallel bulb setup will probably spell doom for the FET if you really push it. But what the heck. The FET will be the only casualty.


----------



## wquiles (Apr 8, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> ALLLLLL RIGHTY THEN!
> I orderd 200 boards yesterday afternoon. I also ordered a solderpaste stencil to aid assembly.
> Last weekend I ran another test with the new solder paste I bought. I'm still getting a little solder beading/balling, but I haven't had time to mess around with the profile as much. I have one primary change to make. I'm going to try reducing the preheat and soak temperatures for a more gradual ramp from start to the beginning of the reflow ramp.
> In any case, the boards and the stencil are on their way.
> ...



That is awesome Jim - nice progress. Everything seems to be falling in place :thumbsup:

Will


----------



## JimmyM (Apr 25, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

Update:
Boards have been delivered. 
So has the solder paste stencil. I'll see about some pics tomorrow.
I placed the order for all the parts today.

I smell regulators. Do you?


----------



## Bimmerboy (Apr 25, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> I smell regulators. Do you?



*snifffff* Ahhhh...

Just like the kind Grandma used to make.


----------



## wquiles (Apr 25, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> Update:
> Boards have been delivered.
> So has the solder paste stencil. I'll see about some pics tomorrow.
> I placed the order for all the parts today.
> ...



Awesome dude :twothumbs

Will


----------



## SafetyBob (Apr 25, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

Yippee!!!!!


----------



## JimmyM (Apr 28, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

Digikey should ship today ot tomorrow. But Maxim Semiconductor will ship MAY 13th. Oy Veh.

Any way. I have some samples from them that I can use to build the first 5 for testing.
Funny story...
My family and I were on our way out to dinner one evening. I got out of the car to get the mail. Once back in, I held up a large white envelope and said "Whoo Hooo. MAXIM!". My wife said. "You get Maxim"? I said "yeah, my samples have arrived from Maxim Semiconductor." She said "Only you would get more excited over THAT Maxim"


----------



## Bimmerboy (Apr 28, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

Hahaha... if she only knew the number of guys around here that would say  upon receiving some IC chips.

Come to think of it, you might actually want to get a copy of _THAT_ Maxim to cover any semiconductor documentation while reading it, especially in public. 

Looking forward to the results of the test units!


----------



## wquiles (Apr 28, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> "Whoo Hooo. MAXIM!". My wife said. "You get Maxim"? I said "yeah, my samples have arrived from Maxim Semiconductor." She said "Only you would get more excited over THAT Maxim"



That is pretty funny 

Will


----------



## Alan B (Apr 28, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

Jim, it is great to see your project's progress.

I shipped out the first article drop-in to beta testing this morning, and it looks like yours is not far behind.

How is your software doing, and what features are going to be in the first units?


----------



## JimmyM (Apr 28, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



Alan B said:


> Jim, it is great to see your project's progress.
> 
> I shipped out the first article drop-in to beta testing this morning, and it looks like yours is not far behind.
> 
> How is your software doing, and what features are going to be in the first units?


Good news about your testing unit.
I've been busy with work and hardware design/construction for a while so I haven't had much time for software development.

I don't have a ton of features due to the manner of use, but the physical design will allow for software upgrades to use it like yours is used.
Current version will be controlled by either powering the unit on or off so leakage power consumption will be that of the FET alone.
It will softstart and regulate to a point set by a pot (read on the fly for continuous adjustability).
A low voltage warning (pulsing brightness) will kick in at a point set by another pot (again, read on the fly).
A high temp setting will dim the unit until power cycled.

Some variables will be compile-time values that the user can mess with as they see fit. Pulsation speed, softstart speed.

For future features and use, I have extended 3 unused pins out to pads that are not currently in use. This way, the power input can be left on and a pushbutton can be used at another pin to control what ever the user wants. Like yours.
I'm using the Tiny44. It's actually cheaper than the Tiny24. So the 4K of memory should allow for a nice feature set.
Once I have a few prototypes built, I'll give the software another once-over to "tweak" things. The program size is rather tidy considering I'm using a couple of 32-bit words.


----------



## LuxLuthor (Apr 28, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> Update:
> Boards have been delivered.
> So has the solder paste stencil. I'll see about some pics tomorrow.
> I placed the order for all the parts today.
> ...



My dog just farted, so that's all I'm smelling at the moment.


----------



## JimmyM (Apr 28, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



LuxLuthor said:


> My dog just farted, so that's all I'm smelling at the moment.


Oh my God. My wife brought home different dog food a few weeks ago. We figured we'd mix what he had left of the old stuff wth the new stuff until he got used to it. It was a 5 day long seige of gas that would make the inside of a coffin look like a welcome repreive. I can't put into words the olfactory assault that came out of that dog every few minutes. It made me want to weep. If pure evil could be placed in a gasseous form and forced into your nose. That was it.


----------



## Bimmerboy (Apr 29, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> If pure evil could be placed in a gasseous form and forced into your nose. That was it.


Now THAT'S funny! 

BTW, canine flatulence is not exactly what LL was getting at. 

Happy as long as my boards get here by late July/early August, in time for my first chance at quality darkness, off long island, in two years... OR ELSE!!! 

No pressure, Jimmy. 

(j/k... sort of)


----------



## smflorkey (Apr 29, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> Good news about {Alan B's} testing unit.


Good news indeed. I've been watching the development thread and both your application threads. These are looking great!


JimmyM said:


> It will softstart and regulate to a point set by a pot (read on the fly for continuous adjustability).
> A low voltage warning (pulsing brightness) will kick in at a point set by another pot (again, read on the fly).
> A high temp setting will dim the unit until power cycled...


This is looking very nice. I hope I have enough in my pocket when you are ready to sell. I think I'll also have to find a splash-resistant pot to tweak the output level. I'm looking forward to a 2-D Mag with some flexibility and some wow factor. 

Thanks, 
Steve


----------



## JimmyM (Apr 29, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



smflorkey said:


> Good news indeed. I've been watching the development thread and both your application threads. These are looking great!
> 
> This is looking very nice. I hope I have enough in my pocket when you are ready to sell. I think I'll also have to find a splash-resistant pot to tweak the output level. I'm looking forward to a 2-D Mag with some flexibility and some wow factor.
> 
> ...


The pots are already sealed to allow for washing after reflow to remove flux. They're 10 turn pots.


----------



## Starlight (Apr 29, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

What does a 10 turn pot mean?


----------



## Alan B (Apr 29, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



Starlight said:


> What does a 10 turn pot mean?



It turns 10 times while changing while the wiper moves along the pot. On board mount pots it is usually a screw type drive moving the wiper along the resistive material.

The end result is nice fine control of the position and a tendency to stay put after adjustment.


----------



## smflorkey (Apr 29, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> The pots are already sealed to allow for washing after reflow to remove flux. They're 10 turn pots.


Thanks. I was thinking of mounting an appropriate pot near the switch (in place of the switch?) to adjust brightness the old, intuitive way. Since this would put at least the shaft outside the nicely sealed flashlight, it seemed like I should find a pot that could dodge a few rain drops.  Then again, this is all just a pipe dream until I find some spare change in my pocket.

Shalom!
Steve


----------



## Starlight (Apr 30, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

Alan B,
Thanks for the reply. I was hoping that was what he meant. There was a pot mentioned in a thread one time with a life that was limited to so many turns. I just wanted to check on this one.


----------



## JimmyM (Apr 30, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

The documentation shows 200 cycles as the life of the pot. It's the best I could find.
I can't imagine, however, wearing one out any time soon. 200 full cycles is a lot. That's 2200 turns. I was mistaken before. They're 11 turn pots.


----------



## JimmyM (May 4, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

I've opened up a new thread to discuss a "C" cell version.
It can be found here.


----------



## JimmyM (May 7, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

UPDATE:
First set of boards have been assembled. I need to work on the amount of paste put down by the stencil. I think I may have been a little sloppy. I had some bridging on the AVR, but a little solder wick cleared it up.
I powered one up.
14.1V in, 5.007V to the AVR. Nice.
So I hooked it up to the programmer and Voila! Read the signature just fine.
I'm going to build a programmer to header jumper that will power the AVR via the programmer instead of having the solder leads to the pads.






It's a little blurry, but you get the idea.
Once I've tested and programmed them, I'll send a couple off to Lux.


----------



## wquiles (May 7, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

AWESOME :twothumbs

Will


----------



## LuxLuthor (May 7, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> UPDATE:
> First set of boards have been assembled. I need to work on the amount of paste put down by the stencil. I think I may have been a little sloppy. I had some bridging on the AVR, but a little solder wick cleared it up.
> I powered one up.
> 14.1V in, 5.007V to the AVR. Nice.
> ...



Damn, those look pretty. Not Alessandra Ambrosio pretty, but inspiring none the less.


----------



## JimmyM (May 8, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



LuxLuthor said:


> Damn, those look pretty. Not Alessandra Ambrosio pretty, but inspiring none the less.


At first I was like "Who's Alessandra Ambrosio"? So I did a search.
I'm still a little woozy.

You're right. They're pretty, but not Alessandra Ambrosio pretty.


----------



## LuxLuthor (May 8, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

Yeah, if she was in front of me, my brain would stop for at least 10 minutes.


----------



## JimmyM (May 8, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

OK. First batch of 10 is complete. All programmed and test good using a power supply rig and my oscilloscope. Turned each pot to check that the voltage adjusted and that the low voltage cut in point functioned.
Here's a closeup of a completed unit.





I'm going to do a little more testing on one of them at full power.


----------



## wquiles (May 8, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> OK. First batch of 10 is complete. All programmed and test good using a power supply rig and my oscilloscope. Turned each pot to check that the voltage adjusted and that the low voltage cut in point functioned.
> Here's a closeup of a completed unit.
> 
> I'm going to do a little more testing on one of them at full power.



Looking good Jim 

Will


----------



## Mr Happy (May 8, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> Here's a closeup of a completed unit.


Just an observation, but I notice lots of spots -- especially around the FET at the lower right?


----------



## JimmyM (May 8, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



Mr Happy said:


> Just an observation, but I notice lots of spots -- especially around the FET at the lower right?


Most of the spots are just dust. 3 of them, are indeed solder beads. 1 on the lower right of the FET and 2 on the upper left.
They're stuck to the board by the flux residue that has since been washed away. No more beads. I'll be adjusting my thermal profile and paste application to reduce this as much as possible. I had some bridging on the Tiny84s, but cleaned that up pretty quickly.
Actually I got better results than I thought I was going to get for a first run.


----------



## Bimmerboy (May 9, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> OK. First batch of 10 is complete. All programmed and test good using a power supply rig and my oscilloscope. Turned each pot to check that the voltage adjusted and that the low voltage cut in point functioned.



Sweet, sweet, SWEET!!!

Yes, I'm a flashlight nerd, and I don't care... this is exciting stuff.

Awesome work, Jimmy! :thumbsup:


----------



## JimmyM (May 10, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

I ran some tests yesterday using a 64625 and a 64447 (65W IRC).
The 64625 on 13V from a 17V source made the FET just barely warm after more than 30 minutes of run time.
The 64447 at 18V from a 39.9V source didn't even warm up the FET.
I'm sending 2 units to Lux to beat on a bit. If all goes well, I'll have the first batch of 100 ready to do pretty quicly. I've already got 20 built.


----------



## cnjl3 (May 10, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

Wow! Your new regulator looks fantastic. 
Why 39.9volts. Is the input limit 40volts?


----------



## JimmyM (May 10, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



cnjl3 said:


> Wow! Your new regulator looks fantastic.
> Why 39.9volts. Is the input limit 40volts?


Yes. 40V max.


----------



## LuxLuthor (May 12, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

Jimmy, just replied to PM. I should have my fluke189 late this week, as it was just mailed yesterday.


----------



## JimmyM (May 12, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> OK. First batch of 10 is complete. All programmed and test good using a power supply rig and my oscilloscope. Turned each pot to check that the voltage adjusted and that the low voltage cut in point functioned.
> Here's a closeup of a completed unit.
> 
> 
> ...


 
Are links to pictures on picture hosting sites no longer allowed? There was one in the quoted post, but now it's gone.


----------



## Mr Happy (May 12, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



JimmyM said:


> Are links to pictures on picture hosting sites no longer allowed? There was one in the quoted post, but now it's gone.


I see the thumbnail and the link OK.


----------



## JimmyM (May 13, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*



Mr Happy said:


> I see the thumbnail and the link OK.


That's weird. It doesn't show up at all in my browser. I'm going through a corpoate proxy at the moment, so maybe that's it.
I'll check later.
Thanks for checking my sanity.


----------



## JimmyM (May 13, 2009)

*Re: Hotwire PWM Regulator for Mag D body, JM-PhD-D1, Pt 2*

*The JM-PhD-D1 is now for sale.*

Sales thread is open HERE


----------



## LuxLuthor (May 21, 2009)

Jimmy, I found that whole topic of USB powering the AVR to power the chip as essential information. I did not know that the chips had to be powered to program them. I assume you had some way of powering these chips to upload the code you are running, but wonder *how you did it before learning of Alan's link to that mod of USB.* I'm asking because I'm not sure I want to make this change to my AVR if there is an easy way to safely power chip with adjustable PS, or I even have a 9V battery powered 5V power supply I got at Petrev's suggestion for powering an LED display that I could use for this.

I understand that making screw POT adjustments does not involve re-encoding the chip, so this is more for future reference. I guess the same question would apply to Alan's chip, as to how he independently powers the chip so the AVR works with it.


----------



## JimmyM (May 21, 2009)

LuxLuthor said:


> Jimmy, I found that whole topic of USB powering the AVR to power the chip as essential information. I did not know that the chips had to be powered to program them. I assume you had some way of powering these chips to upload the code you are running, but wonder *how you did it before learning of Alan's link to that mod of USB.* I'm asking because I'm not sure I want to make this change to my AVR if there is an easy way to safely power chip with adjustable PS, or I even have a 9V battery powered 5V power supply I got at Petrev's suggestion for powering an LED display that I could use for this.
> 
> I understand that making screw POT adjustments does not involve re-encoding the chip, so this is more for future reference. I guess the same question would apply to Alan's chip, as to how he independently powers the chip so the AVR works with it.


To initially program the chip, I just power it via the ground and control power connection as it would be poewred in the light. Any voltage between 5.5 and 40 will do. I built a little jig to apply power to the connections while the board is on the bench.

Alan's is always connected to power as long as there are batteries in the light. So you just plug in the programmer via his programming board.


----------



## Alan B (May 21, 2009)

I have powered my board several different ways for programming. Some programmers provide an option to power the board. I did it that way before I got the AVR ISP MkII which does not have that option built in.

Once the regulator is mounted in the flashlight, just having the flashlight batteries installed is sufficient to power the regulator for programming.

I'll have to check the Atmel Dragon board - that is my smallest USB programmer that I believe can power the target board without mods (may require a jumper but that is not really a mod). My kit programmer, the TinyUSB, will power the target board. It requires a batch file to do the programming so it is not as easy to use and I'm not really recommending that one.

This is not really a problem with my drop-in regulator design since the flashlight batteries power it. It is more of a problem with the board level products where it is not convenient to program after installation.

As Jim mentioned the requirements for programming power are simple - 6 to 40V at 100ma or less. For example a 9V battery would do the job. Or modify your AVR ISP MkII to have the switch, but at the risk of voiding the warranty.


----------



## LuxLuthor (May 22, 2009)

Alan B said:


> As Jim mentioned the requirements for programming power are simple - 6 to 40V at 100ma or less. For example a 9V battery would do the job. Or modify your AVR ISP MkII to have the switch, but at* the risk of voiding the warranty*.



I'm more worried about blowing out my USB computer circuit.


----------



## Roland (May 22, 2009)

from : https://www.candlepowerforums.com/posts/2959468&postcount=111



JimmyM said:


> I'm going to incorporate a bit of code to shut down the light if the voltage drops to a percentage of the Vlow set point. When this point is reached, the light has to be power cycled to get out of that mode. If you power cycle with dead batteries, the light will try to start, then just shutdown again as soon as the voltage drops.
> 
> I'm thinking of 87.5% (just because I can multiply by 7 then divide easily by 8).
> That works out to...
> ...


It does not sound good to me. Consider the following:

A V-low is set to set a minimum voltage to protect batteries. Now one has to set V-low 12% higher to obtain the same protection. Then what is V-low for? Consider the following:

Why not set a maximum run time untill shut-down when below V-low. Like the flashlight runs for 2 minutes below V-low and then shuts down. If you turn it back on it comes on alternating and again shuts down after 2 minutes (because batteries are still below v-low.)

This makes shure:
- If you leave the flashlight unattended for a moment it does not run down to 12% beleow V-low.
- you always have a reserve if you have an emergency and want risk hurting your batteries.
- you never think the light is broke if you put in batteries that are below v-low.


----------



## JimmyM (May 22, 2009)

LuxLuthor said:


> I'm more worried about blowing out my USB computer circuit.


While it's possible to overload your USB port. The chip being programmed will only consume a few milliamps. I'm going to make the mod. So, I can test it out and let you know how it goes.


----------



## Alan B (May 22, 2009)

JimmyM said:


> While it's possible to overload your USB port. The chip being programmed will only consume a few milliamps. I'm going to make the mod. So, I can test it out and let you know how it goes.



I'd be tempted to put a picofuse or a polyfuse into that mod. Just in case.


----------



## JimmyM (May 22, 2009)

Alan B said:


> I'd be tempted to put a picofuse or a polyfuse into that mod. Just in case.


Oh, SURE! Go ahead and do things the right way and be safe. :kiss:

Now, of course, having said that, I'll be putting a fuse in my mod to avoid Mr Murphy's law. I have a few 250mA fuses, I think, left over from my Radio Shack DMM.


----------



## petrev (May 22, 2009)

Hi Jimmy

Vlow ? ? ?
Firstly - Any protection provided by a Vlow setting is way better than we have at the moment for unprotected Hi-current formulations
:thumbsup:

How about something like this !
When the regulator detects Vlow power is cut to say 30% (or 50% or 20% or) and blinks off every 10 seconds providing a usable lamp to find your backup etc...
While in Vlow mode the batteries will bounce back to a higher level so if Vlow is crossed again while in Vlow-Blink mode then the regulator could cut out entirely.

Or something like that maybe - I am no expert !

JM-PhD-D1 :thumbsup::thumbsup::thumbsup::thumbsup:

Cheers
Pete


----------



## JimmyM (May 27, 2009)

petrev said:


> Hi Jimmy
> 
> Vlow ? ? ?
> Firstly - Any protection provided by a Vlow setting is way better than we have at the moment for unprotected Hi-current formulations
> ...


I've got software written to start a timer when it goes into low voltage mode. When it does, you have 2 minutes before complete shutdown. After power cycling, it will start up as usual unless the vlow point is exceeded for 0.25 seconds, if it does, it starts the 2 minute timer again.
I haven't had time to test it just yet.


----------



## LuxLuthor (May 27, 2009)

Jimmy did you do the USB powering mod on your AVR?


----------



## Alan B (May 27, 2009)

JimmyM said:


> I've got software written to start a timer when it goes into low voltage mode. When it does, you have 2 minutes before complete shutdown. After power cycling, it will start up as usual unless the vlow point is exceeded for 0.25 seconds, if it does, it starts the 2 minute timer again.
> I haven't had time to test it just yet.



It is difficult to come up with a good algorithm for this. On a high power flashlight operating for 2 minutes with batteries below minimum voltage is perhaps too long.

If the battery voltage protection is going to protect sensitive cells such as unprotected li-ion, it must not run when the voltage is too low.

In my implementation the load is reduced (light is dimmed) until the battery voltage stays above the threshold. If reducing the load doesn't accomplish this the light shuts off. Operation is not allowed below the threshold voltage beyond about 1 second. The 1 second is to allow the battery voltage to recover from soft-starting, but I don't want the cells delivering power below the safe voltage.


----------



## JimmyM (May 27, 2009)

Alan B said:


> It is difficult to come up with a good algorithm for this. On a high power flashlight operating for 2 minutes with batteries below minimum voltage is perhaps too long.
> 
> If the battery voltage protection is going to protect sensitive cells such as unprotected li-ion, it must not run when the voltage is too low.
> 
> In my implementation the load is reduced (light is dimmed) until the battery voltage stays above the threshold. If reducing the load doesn't accomplish this the light shuts off. Operation is not allowed below the threshold voltage beyond about 1 second. The 1 second is to allow the battery voltage to recover from soft-starting, but I don't want the cells delivering power below the safe voltage.


Yeah, this is a tricky one. I'll have to do a little thinking about it.


----------



## JimmyM (May 27, 2009)

LuxLuthor said:


> Jimmy did you do the USB powering mod on your AVR?


Not yet. I just got home today.

Any testing results?


----------



## cnjl3 (May 27, 2009)

Jimmy you posted this on your 'SELL' thread on May 18:



JimmyM said:


> I'm going to be converting my favorite Mag275 from AWRs hot driver to the JM-PhD-D1. During the process I'll be documenting the whole thing in pictures. I use unprotected Li-Ion D cells. 2 of them. So my settings will be 7.15V Vbulb and 6.0V Vlow. I do have a 3D body, so I may try a 3xLi-Ion Mag275 on 7.15V with a Vlow=9.3V
> 
> EDIT: Correction. I'll be using the Philips 5761 instead. It has comparable lumens at 7.2V, uses fewer amps, and has a longer projected life.


 
Bulb 5761 Voltage 7.2V with 3 D size li-ions as a power plant is exactly what I ordered from Alan's thread but apparently it will be a while....Soooo I know you are a busy man but have you had a chance to 'kick the tires and light the fires' as you described above? I am still working on exactly what my 2nd driver from you might be and as of today I think it will be 19.5V IRC (since I seem to have quite a stash of 35w 50w and 60w IRC bulbs).


----------



## JimmyM (May 28, 2009)

LuxLuthor said:


> Jimmy did you do the USB powering mod on your AVR?


I've completed the mod to the AVR ISP MkII.
I have a green LED to indicate power. I have a 510 Ohm resistor in series with the ground leg of the LED. It only draws 8 mA. This way, when the AVR Programmer Power Switch is OFF and the Board itself is powered, the LED lights up but doesn't get the full 5V.
It works very nicely.
TIP: Plug the programmer into the board first, then flip the Programmer Power Switch. You get the Green Programmer LED and everything is ready to go.
If you turn the Programmer Power Switch ON first, you get a flashing Orange Programmer LED. If you already have the programmer plug connected, just turn off the switch, wait for a Red LED, then flip the switch back on. You'll get a Green Programmer LED.


----------



## Roland (May 29, 2009)

Alan B said:


> It is difficult to come up with a good algorithm for this. On a high power flashlight operating for 2 minutes with batteries below minimum voltage is perhaps too long.
> 
> If the battery voltage protection is going to protect sensitive cells such as unprotected li-ion, it must not run when the voltage is too low.
> 
> In my implementation the load is reduced (light is dimmed) until the battery voltage stays above the threshold. If reducing the load doesn't accomplish this the light shuts off. Operation is not allowed below the threshold voltage beyond about 1 second. The 1 second is to allow the battery voltage to recover from soft-starting, but I don't want the cells delivering power below the safe voltage.


It is more than just nice to have some light reserve or notification before the light turns off because of low batteries. It can be very important.

The question is how fast batteries deplete around v-low AND how big the risk is you will not notice v-low is reached and can react yourself. 

The ramping up and down below v-low or blinking or whatever one can come up with, will not only attract attention it also lowers power usage.

To explain my thoughts:
If you use a high power bulb (above 100 watts) you will probably not leave them unattended. If it switches on unattended by accident you will probably have started a fire and have other problems than v-low. You immediately see when it goes below v-low and can react. 

If you use something like a 5761 (around 40 watts) which is more like a all purpose light or work light you might leave it unattended for a while. Also a 2 minute low power mode is extremely usefull for a work light. 

A one minute or 90 second low power mode is also usefull. Especially if one can turn the light on again several times for yet another one minute or 90 second low power mode cycle.


----------



## JimmyM (May 29, 2009)

I like the 2 stage low voltage mode.
At Vlow, it pulsates or dims. At 7/8 or 15/16's of Vlow, it shuts down after a period of time. Maybe 60, 90, or 120 seconds.



Roland said:


> It is more than just nice to have some light reserve or notification before the light turns off because of low batteries. It can be very important.
> 
> The question is how fast batteries deplete around v-low AND how big the risk is you will not notice v-low is reached and can react yourself.
> 
> ...


----------



## petrev (May 29, 2009)

JimmyM said:


> I've completed the mod to the AVR ISP MkII.
> I have a green LED to indicate power. I have a 510 Ohm resistor in series with the ground leg of the LED. It only draws 8 mA. This way, when the AVR Programmer Power Switch is OFF and the Board itself is powered, the LED lights up but doesn't get the full 5V.
> It works very nicely.
> TIP: Plug the programmer into the board first, then flip the Programmer Power Switch. You get the Green Programmer LED and everything is ready to go.
> If you turn the Programmer Power Switch ON first, you get a flashing Orange Programmer LED. If you already have the programmer plug connected, just turn off the switch, wait for a Red LED, then flip the switch back on. You'll get a Green Programmer LED.


 
Hi Jimmy



I haven't got the hardware yet but I am trying to understand your LED usage ? ? ? 

I think I need a schematic (and some photos maybe)

You are using the fitted RED/Yellow/Green status led as your green led ? not the USB activity led ? ? 

"Programmer Power Switch " ? Is this the extra switch added or is there a power switch on the Programmer already that I haven't found in the documentation ?

Sorry ! I am confused but maybe it will make more sense when I get my hardware . . .

Can't Wait . . .

Cheers
Pete


----------



## JimmyM (May 29, 2009)

Yes, the programmer power switch is the additional switch added to enable/disable 5V power to the programmed device.

I have added a green LED. I'll get togther a schematic of my mod this weekend. But, you don't need the additional LED. You can just perform the mod per the instructions on the internet.



petrev said:


> Hi Jimmy
> 
> 
> 
> ...


----------



## petrev (May 29, 2009)

JimmyM said:


> Yes, the programmer power switch is the additional switch added to enable/disable 5V power to the programmed device.
> 
> I have added a green LED. I'll get togther a schematic of my mod this weekend. But, you don't need the additional LED. You can just perform the mod per the instructions on the internet.


 
Thanks

:thumbsup:


----------



## Roland (May 30, 2009)

JimmyM said:


> I like the 2 stage low voltage mode.
> At Vlow, it pulsates or dims. At 7/8 or 15/16's of Vlow, it shuts down after a period of time. Maybe 60, 90, or 120 seconds.


I think the optimum solution would be:
Pulsating (ramping up and down) action below v-low for a full 2 minutes.
If you turn the light on again it pulates (ramping up and down) for another 2 minutes.
At or below 7/8 of v-low no pulsating (ramping up and down) action anymore but just 2 short blinks.


----------



## Raoul_Duke (May 30, 2009)

JimmyM said:


> I like the 2 stage low voltage mode.
> At Vlow, it pulsates or dims. At 7/8 or 15/16's of Vlow, it shuts down after a period of time. Maybe 60, 90, or 120 seconds.



I like the Two stage Idea also...but If the V low is there to protect the cells, 60 seconds seems like a very long time, as far as cell protection goes...(1 second below the actual cells V low is too long for me.)

I will be using A123 cells mainly with this ( & emoli ) ( 100+W builds) but when A123 reach the end of their cappacity they realy drop off fast, so I'd set my V low as high as possible to catch the initial drop on 6 series cells, ( as the cell with the least cappacity would be the one to nose dive first, going way under 2V, whilst leaving all the others still above their safe threshold, if thats for 60 odd seconds...the first cell would be at 0V...not so good) So, the sooner the light shuts off the better for me.

Flashing is good approaching V low...but a time limit, is not as good as measuring pack voltage, and doing something based just on pack voltage, rather than start a timer, and hope the cells are good for that time, 60 seconds in a 30W build is very different to a 100+W build.

I'd opt for straight off, thats how my protected li-ion cells work ATM, and I just reach for one of the other lights I carry. 

Come on, how many of us are using these lights in a life or death situation, where they might need 'extra time'?
Prehaps the people that need extra time should carry more lights ( 1=0 & 2=1)

What happens if the cells are put in this the wrong way? Does it blow the circuit, or does it go into direct drive...as if its the latter there is the emergency light...just swap around & squeeze your cells dry, if you have to.


----------



## Alan B (May 30, 2009)

Cells in backwards are direct drive through the inherent body diode in the FET, and there is NO OFF. Have to remove tailcap to turn off.


----------



## Raoul_Duke (May 30, 2009)

Alan B said:


> Cells in backwards are direct drive through the inherent body diode in the FET, and there is NO OFF. Have to remove tailcap to turn off.



Sweet....That's the 'emergency light' sorted then 

LOL, at this moment I have a 6D infront of me (with 6 x A123 in it running the 64458 direct drive,) but the modded stock mag switch ( with Kiu on top) has melted inside, so it clicks on, but not off ( without a lot of coaxing ) So the only relable way to turn off is to slightly back off the tailcap ( no need to remove while the threads have ano. on them).

The lamp is sweet, and has a great beam & spot, but its too hot at 18Vbulb So I will have to go to a lower heat lamp as this regulator relys on the mag D switch holding up somewhat. Still thats what the JMSSR is for 

BTW this particular Kiu'd mag switch has seen alot of action for years, but I probably shoulden't have run it indoors for 5+ minutes the other night...it did get warm.:devil:


----------



## JimmyM (May 30, 2009)

Raoul_Duke said:


> The lamp is sweet, and has a great beam & spot, but its too hot at 18Vbulb So I will have to go to a lower heat lamp as this regulator relys on the mag D switch holding up somewhat. Still thats what the JMSSR is for


This is wired in just like the JM-SST. The Mag switch doesn't carry any real current. The Mag switch only carries the power required to run the internal electronics. A few milliamps.


----------



## JimmyM (May 30, 2009)

Alan B said:


> Cells in backwards are direct drive through the inherent body diode in the FET, and there is NO OFF. Have to remove tailcap to turn off.


There is no reverse polarity protection. If you insert the batteries backwards, it had better be a real emergency, because it's going to cost you one regulator. You need to insert the batteries in the standard fashion.


----------



## JimmyM (May 30, 2009)

Raoul_Duke said:


> I like the Two stage Idea also...but If the V low is there to protect the cells, 60 seconds seems like a very long time, as far as cell protection goes...(1 second below the actual cells V low is too long for me.)
> 
> I will be using A123 cells mainly with this ( & emoli ) ( 100+W builds) but when A123 reach the end of their cappacity they realy drop off fast, so I'd set my V low as high as possible to catch the initial drop on 6 series cells, ( as the cell with the least cappacity would be the one to nose dive first, going way under 2V, whilst leaving all the others still above their safe threshold, if thats for 60 odd seconds...the first cell would be at 0V...not so good) So, the sooner the light shuts off the better for me.
> 
> ...


To customize the "timer" duration, you'll need to get a programmer, change the timer variable, and reprogram your regulator.
I haven't decided on the Vlow behavior yet, but I have the broad strokes.
Basically, Step one kicks in at the Vlow point set by the pot. It will dim or pulse the light. Step 2 would kick in at a percentage of Vlow and either shut it down immediately or shut it down after a set time.


----------



## petrev (May 31, 2009)

Hi

*V*low ? What to do ? ? ?

Lets not forget that for High-Current Hotwires there is very significant Voltage bounce when current is lowered. 

Reducing power to say 50%-70% would allow the cells to rebound to a higher Voltage. It is the resting voltage of the cells that causes the real problems if it gets too low. Crossing the Vlow point again while in *V*low dimmed mode should be another event that triggers final shutdown or a further reduction and then shutdown.

This is of course just my laymans view and :thumbsup: any protection is better than we have at the moment for these chemistries. 
Having a pot allows us all to tweak this functions set point to our hearts content once a behaviour is programmed in. 
This project is an open source collaboration so we may well end up with quite a few different *V*low behaviours to suit different peoples needs. 

This is what I love about Jimmy's regulator and the whole PhD project - as an early adopter I have ordered a programmer so that I can update as any changes are made and choose the options that fit my needs while keeping everyday use as simple as possible.

:twothumbs

Cheers
Pete

ps. Lux has posted some more results for the AlanB sled version showing very big bounce with the Modamag high current monster light

*AlanB's Sled Meets Modamag's TK Monster - Review & Pix* 


LuxLuthor said:


> . . .
> 
> After full drainage shuttoff, and one repeat that again shutdown, I measured the ending pack voltage as 33.89V. When I took the pack apart and measured each battery, they were almost all exactly 3.77V which amazed me. This is great news on the low battery protection issue, as this represents a bounce back after the low voltage shutoff.
> 
> .


----------



## JimmyM (May 31, 2009)

Exactly. What to do.
I've modified the software in rev2. I have user configurable options that are set at compile time.
Vlow Warning Type 1 = Pulsing
Vlow Warning Type 2 = Dimming
Vshutdown Trigger Type 1 = 87% or 94% of Vlow setting
Vshutdown Trigger Type 2 = User settable time

Vlow is triggered when the voltage drops below the user's setting for about 0.5 seconds. If, the battery voltage recovers while in Vlow Warning mode, it switches back to normal mode.

The boune issue is another thing entirely. There's the bounce of voltage upon shutdown. As well as the bounce of voltage during discharge where cell voltage drops a lot only to recover later in the discharge. This is mostly seen only during really heavy loads beyond that which the regulator is capable.


----------



## JimmyM (May 31, 2009)

I've taken pictures of a build I did yesterday. I'll be incorporating them into a document in the next day or so. It should be quite comprehensive.

I built it for a 3 x D Li-Ion 5761. It's really sweet. Vset = 7.15V, Vlow=9.0

I also took pictures of my AVR ISP MkII mod.




http://img195.imageshack.us/my.php?image=avrispmkiimod1.jpg


----------



## petrev (May 31, 2009)

AVR ISP MkII mod

Nice

:thumbsup::thumbsup::thumbsup::thumbsup::thumbsup::thumbsup::thumbsup:

LOW :Options:

 :twothumbs


----------



## petrev (Jun 2, 2009)

From The Sales Thread



niner said:


> Tested Jimmy's regulator (high voltage version) with OSRAM 64663 400W bulb with success. After killing a few of these expensive bulbs, I found 42V is the "safe" set voltage. The FET is operating at too close to the max voltage rating for my liking, but IRFR1018E is highest I can find in the DPAK package. Now, I will use Jimmy's excellent instruction and install all these stuff in a Colossus.
> 
> 64663 at about 40V
> 
> ...


 
Hi Niner

Looking Good. Nice mod - What is the BIG resistor for in your test rig ?

Looked up the FET and the datasheet for the IRFr1018epbf and it says Max 60V and Max 56A(79A) so that seems pretty good to a layperson.

Is the LM2936HV regulator below TO-252 or SOT-223 ? Nice work fitting it in by the way.



niner said:


> I modified one of my regulator to high voltage duty. So far it is working fine with 12x 18650 and 64657. Regulator is set at 28.5V, while battery pack was peak at 49.6V.
> 
> Next, I will try 64663.
> 
> A picture of the regulator. (Yeah, I know. I need to replace the pot that I touch w/ my iron)


 

Cool HV version
Cheers
Pete


----------



## niner (Jun 2, 2009)

Sorry Jimmy, didn't mean to trash your sales thread.

I measured last night. Testing on my bench without any cooling or heatsinking, the case temp of the FET rised to 105C in 3 minutes. Does KIU base provide any cooling to the MOSFET? I haven't put them together in a light yet.


----------



## niner (Jun 2, 2009)

Hi Pete,

The big resistor is there to provide a load when I don't have a bulb in the socket.

LM2936HV is in SOIC case.

VDSmax for IRFR1018E is 60V. In the beginning, I set my bench power supply at 51V (max possible voltage for x12 cells), and it doesn't sag like batteries. During the on/off transitions, I have seen voltage spike over 62V across the FET. In fact, I killed a couple IRFR1018E because of that. When I switched over to batteries supply, the spike is max at 55V. That's why I rather to have a FET that has VDSmax at 75V.


----------



## petrev (Jun 2, 2009)

Hi

Didn't think you were trashing but if I had carried on the discussion there I probably would have been guilty (again :shakehead)

OK - Got it - 8-pin SOIC and you are grounding the middle 4 pins and patching to IN and OUT 

Cool

Not an expert so all than nasty inductive ? spike stuff is beyond me but sounds like you have it sorted for starters while hunting for a 75V DPAK.

If you want to heatsink to the KIU then you will need a block to conduct to the KIU base and really need to fill the airgap to the Mag body with thermal compound - Arctic-Ceramic or similar. Trouble is there will be quite a bit of heat coming the other way from the bulb too - so . . . 

Keep us posted :thumbsup:

Cheers
Pete


----------



## JimmyM (Jun 2, 2009)

Nice mod. And thanks for the consideration for my sales thread. I appreciate it.


----------



## littlejohnle (Jun 4, 2009)

I would like to say thanks to JimmyM for his good work.
I just recieved my regulator and installed as per instructions.
What can I say, its works as describe and im very happy with it. No more insta-flashing bulbs, just set and forget which I liked as Im not a very technical person.
I had it delivered preset to Vo=7.2v Vlow=6v and using it with 5761 bulb & 2 unprotected li-ions.
The light will pulsate when Vlow is reached which is a feature I really liked as Im running unprotected cells.

Will be looking forward to further progress whith this regulator and keep up the good work.:twothumbs


----------



## JimmyM (Jun 6, 2009)

Glad it got there OK and you're happy with it.
Tell your friends.


----------



## Starlight (Jun 7, 2009)

Jimmy, I need some help here. I don’t see any way to change the settings on the regulator, while it is installed in a light, without using a true RMS meter. I can put wires into the socket and put a resistor or bulb outside the light. That will let me get access to the pots, but I don’t see a way to get battery voltage measurements with the battery inside the light. Is there a trick that I am missing?


----------



## JimmyM (Jun 7, 2009)

Starlight said:


> Jimmy, I need some help here. I don’t see any way to change the settings on the regulator, while it is installed in a light, without using a true RMS meter. I can put wires into the socket and put a resistor or bulb outside the light. That will let me get access to the pots, but I don’t see a way to get battery voltage measurements with the battery inside the light. Is there a trick that I am missing?


"are you missing something"? No. No one has detailed a way to do this. However, there is a little mod you can do to make the battery (+) connection available to you by drilling 2 small holes. You can run a small wire from the Bat(+) connection to the cavity under the switchboot. I've done it on other lights to read the "under load" battery voltage.


----------



## Alan B (Jun 7, 2009)

Starlight said:


> Jimmy, I need some help here. I don’t see any way to change the settings on the regulator, while it is installed in a light, without using a true RMS meter. I can put wires into the socket and put a resistor or bulb outside the light. That will let me get access to the pots, but I don’t see a way to get battery voltage measurements with the battery inside the light. Is there a trick that I am missing?



The battery voltage should be present between one side of the bulb and the case. Those should be available even when installed.


----------



## JimmyM (Jun 7, 2009)

Under normal operation, this regulator uses about 4.4 mA. When it's off, it's completely off and consumes zero current. The only current that will flow is about 0.10 uA (measured on uA scale) because of the FET leakage.
However, in the REV-2 version of the software, after the low voltage warning has been in effect for X period of time, it will shut down. In the shut-down mode, it shuts off the bulb and then the CPU goes to sleep. Reducing current flow to 0.12 mA (120 uA). That equates to about 8.3 hours to drain down 1 mAH of battery capacity.


----------



## Alan B (Jun 7, 2009)

Probably meant uA rather than nA above..


----------



## JimmyM (Jun 7, 2009)

Alan B said:


> Probably meant uA rather than nA above..


Corrected. Thanks. I also re-measured the leakage current using the uA range.


----------



## petrev (Jun 7, 2009)

Hi Jimmy

Rev-2 ? ? ? 

Sounds like a Push-Button version . . . Multi Levels . . . ? ? ? 

Now ! I have been trying to get ahead of the game waiting for my AVRISP-II to arrive and I can't seem to find any mention in the AVR literature about a compiler/assembler or whatever to get from your .c file to a .hex file as that seems to be what the Studio program loads ! ! !

So . . . What I am asking is :naughty: 
Can you do a step by step How-2 for the AVRISP-II to load up the new software updates please.

Also . . . is it OK to cut a big hole in the KIU to allow full in-situ reprogramming ? ie. Access to the port from above while in the torch ? Too much heat from above ? ? ? Or just a stupid idea ?

Cheers
Pete


----------



## JimmyM (Jun 7, 2009)

petrev said:


> Hi Jimmy
> 
> Rev-2 ? ? ?
> 
> ...


Sorry, that would be Rev3.
To compile your code, you need WinAvr. That can be found here http://sourceforge.net/project/showfiles.php?group_id=68108
Download and install it. I just put the install folder in the root of my C drive. When given the option, let it add entries to your windows PATH.
Then, when you start AVRStudio it will find the WinAVR directory and "building" your project will create the hex files.
Create a new windows folder for your new project. 
During project creation select "AVR GCC" and change the location to the new folder you created. Give your project a name.
Click Next.
For the debug platform, select AVR Simulator then select the ATtiny44 in the right hand pane.
click finish.
Then copy the c file into the project folder. From the navigation tree in the left window right-click on the "Source files" folder and select add existing source file. Select your C file. Then you can double click the c file as it appears under the "Source Files" folder and it will be opened up the code editor.
You can remove the "test" C file from the "Source Files" folder.
From the main menu at the top, select Tools->Program AVR->Connect.
In the connect window select the AVRISP MkII, the port should be USB.
After you click Connect another window will appear. In the HW Settings tab, click Upgrade at the bottom. Another window will appear. Click start upgrade.


----------



## petrev (Jun 7, 2009)

JimmyM said:


> Sorry, that would be Rev3.
> To compile your code, you need WinAvr.
> 
> . . .
> ...


 
Thanks Jimmy

Just what I needed to help me get started.

Cheers
Pete


----------



## Starlight (Jun 7, 2009)

Jimmy, I have another question. Is there enough room on your chip to copy AlanB's code to your regulator? I would like to have some of the options in his code like ramping. I was wondering if I could do it wholesale rather than trying to figure out how to add them in individually. OR, if you are planning on adding to your code, then we could copy things in later.


----------



## JimmyM (Jun 7, 2009)

Starlight said:


> Jimmy, I have another question. Is there enough room on your chip to copy AlanB's code to your regulator? I would like to have some of the options in his code like ramping. I was wondering if I could do it wholesale rather than trying to figure out how to add them in individually. OR, if you are planning on adding to your code, then we could copy things in later.


I will be adding multi-mode stuff like Alan's later on. That's what I ultimately had in mind. It will require a little different wiring of the control power connection. You also have 3 unused AVR ports to mess around with.
Alan's code can't just be written to my regulator because they're different chips, the registers are different, their capabilities are a little different. The code will fit into memory with no problem. It just won't work once it's there.
You can use his code and the Tiny84 datasheet to adapt his code to work with the Tiny84.


----------



## JimmyM (Jun 7, 2009)

petrev said:


> Also . . . is it OK to cut a big hole in the KIU to allow full in-situ reprogramming ? ie. Access to the port from above while in the torch ? Too much heat from above ? ? ? Or just a stupid idea ?
> 
> Cheers
> Pete


Sure, you can do this. But I'd suggest using some insulation over an aluminum sheetmetal donut style cover. While in use, the insulation will hold the donut in place and isolate the "gut". The programming plug is black, so if it ever had direct exposure to the bulb while on, it would melt after some time.


----------



## petrev (Jun 7, 2009)

JimmyM said:


> Sure, you can do this. But I'd suggest using some insulation over an aluminum sheetmetal donut style cover. While in use, the insulation will hold the donut in place and isolate the "gut". The programming plug is black, so if it ever had direct exposure to the bulb while on, it would melt after some time.


 
Thanks Jimmy

Nice idea

:thumbsup:


----------



## Starlight (Jun 7, 2009)

Jimmy, if I need an RMS meter, how about the fluke 87 series III. They seem to be cheaper than the newer models.


----------



## JimmyM (Jun 7, 2009)

Starlight said:


> Jimmy, if I need an RMS meter, how about the fluke 87 series III. They seem to be cheaper than the newer models.


It has to say True RMS. I'm not sure about the 87III. You might want to email Fluke and ask them about square wave and PWM signals.
If you can find one, get the Fluke 189. It's more expensive, but worth EVERY PENNY if you do anything with non-DC voltages. I was thinking about picking up another. But haven't had the extra $$$ lately.


----------



## Starlight (Jun 7, 2009)

I checked some more on the meters. Most of Fluke's meters say they measure true rms, but only the 187, 189, 287, and 289 seem to have the AC + DC function, when measuring voltage or current. It seems that several people have said that this summing function is what we need to be measuring to set the regulators.


----------



## wquiles (Jun 7, 2009)

It is not enough to be True RMS. The meeter has to have the function/capability of measuring a signal with a duty cycle away from the normal/typical 50%. There might be other meters/brands that have this capability, but we know hands-on that the 4 Fluke models listed above have the "AC+DC" function that correctly measures the PWM signal generated by the PhD drivers.


----------



## JimmyM (Jun 7, 2009)

The 187 is the cheapest of those listed above.
Will, is right. True RMS is not enough. The AC+DC mode is able to measure the equivalent of an AC wave form with a DC offset. Which is pretty much what our PWM is.
Search eBay for "Fluke 187"


----------



## LuxLuthor (Jun 7, 2009)

JimmyM said:


> The 187 is the cheapest of those listed above.
> Will, is right. True RMS is not enough. The AC+DC mode is able to measure the equivalent of an AC wave form with a DC offset. Which is pretty much what our PWM is.
> Search eBay for "Fluke 187"



Just to confirm again, my 179 says "True RMS" but no AC + DC capability. I ended up getting a 189 on EBay for a great price (under $200). Pristine condition. Look at the photos, and details...for example this is a good one if price stays low.


----------



## petrev (Jun 8, 2009)

Hi

Yippee - Mine arrived - Now the work begins . . .

Fluke 189 Rules

Cheers
Pete


----------



## JimmyM (Jun 8, 2009)

petrev said:


> Hi
> 
> Yippee - Mine arrived - Now the work begins . . .
> 
> ...


Excellent, Pete. Let us know how it does.
You're right. the 189 rules. However, I still want the 287/289


----------



## petrev (Jun 8, 2009)

JimmyM said:


> Excellent, Pete. Let us know how it does.
> You're right. the 189 rules. However, I still want the 287/289


 
287/289 = Mucho Dinero

but NICE

Fitted a little 5V switch into my AVRISP programmer

Drilled my KIU adapter but the provided template didn't quite match my JM-PHD-D1 so I have made a new one using photos and adjusted to fit my 2 samples - just the tiniest variation in the assembly process.

PDF here .

Feel free to copy it to your host if you want to let people use it as an alternative template. 

Re-Drilling my Mag Switch body to fit JM-PhD (slightly different to my FET switch of course)

. . . 

Cheers
Pete


----------



## JimmyM (Jun 8, 2009)

petrev said:


> 287/289 = Mucho Dinero
> 
> but NICE
> 
> ...


Thanks, Pete. I'll use yours. That's wierd though. I made that drill template from the PCB design.
Oh well.
Yeah, mucho dinero is right. But sooooo pretty.


----------



## petrev (Jun 8, 2009)

Hi Jimmy

Fitted everything

Using the 64333 set
1. 64633(6xA123) - Set *V*bulb 16.8 *V*low 17.4

Checked with a 64458 and the 6xA123

Steady 16.68V AC+DC

but noticed occasional overshoot so switched to MAX and found

17.48V MAX 16.68V Steady Regulation
(upto 17.63 max variable not every time.)

and occasional 
variable up to 17.815 MAX spike during switch off

Went ahead and fitted a 64333 in the hope that this was just a very brief transient that would not cause problems 
but 64333 intstaflash.

Let me know what you think . . .

Cheers
Pete


----------



## petrev (Jun 8, 2009)

JimmyM said:


> Thanks, Pete. I'll use yours. That's wierd though. I made that drill template from the PCB design.
> Oh well.
> Yeah, mucho dinero is right. But sooooo pretty.


 
Mmmmmm So Pretty - and useful too.

Did you use the middle of the component position on the PCB layout ? Depends what size drill people are using too I guess and the little screws are right in the corner.

I am using 3mm drill holes and I managed to get a bit of drift with one of them so the little screw is right at the edge again ! Ah well.

Better check mine is right by your eye too.

Cheers
Pete


----------



## JimmyM (Jun 8, 2009)

petrev said:


> Hi Jimmy
> 
> Fitted everything
> 
> ...


During softstart it ramps in 5 PWM step (each step is 0.09775%) increments until it exceeds computed output, then ramps back to steady state in 1 PWM step increments. However, the steps happen 244 times per second. So it's only 5 steps above (Maximum. It could between 1 thru 4) the set point for 1/244th of a second (One pulse). 5 steps is 0.2V. Then it can take as long as 5/244th of a second to reach equilibrium. That's only 20 mS.
Keep in mind that the Fluke does take time to settle in at it's RMS voltage. On a scope, you can't see the the overshoot because the overshoot is only a few pulses. If your steady state loaded RMS voltage is 16.68V, then the most it could overshoot by is 0.20V and that's too quick for the Fluke to capture in an accurate manner.
Do you have your AVR programmer set up yet?


----------



## petrev (Jun 8, 2009)

Hi Jimmy

I have downloaded and installed Studio and WinAVR and installed the USB driver in the process . . .

I haven't tried any actual programming yet ! ! ! but I have your step by step guide.

On the measurements front - it is not consistent - the overshoot on power up happens maybe 1 in 3 and the spike before switch off similarly but those are the readings from the old Fluke with the peak hold(MAX) function to capture what I noticed first by eye ! and the bulb did flash.

Maybe a faulty bulb but I don't want to risk another without checking it all with you.

Cheers
Pete

ps. Can't find your bannerad - but your sig line looks good.


----------



## JimmyM (Jun 8, 2009)

petrev said:


> Hi Jimmy
> 
> I have downloaded and installed Studio and WinAVR and installed the USB driver in the process . . .
> 
> ...



I just looked at the code. It is as I described above. Let me work on a couple of things. I may send you a piece of experimental software to try out. I still don't think that it's the software. I've tested 64275s at 7.15V with a 40V source. If that overshoot existed as an overall design flaw it would blown that bulb sure enough.
Let me work for a bit.

The banner just isn't in rotation yet.


----------



## Starlight (Jun 8, 2009)

Jimmy, I had some voltage setting problems too. You sent me one regulator set up for 18v output and 26v low battery. I put it in a light with 7 emoli cells and a 64458 bulb, but the low voltage pulsing occurred. I then put in an 8th cell. Pack voltage was 32.4v but it still pulsed. I had the turn the pot more than one turn to get the pulsing to stop. There is no way that 10 amps should take a 32v pack below 26v. I intend to get a meter soon to check voltages myself.


----------



## JimmyM (Jun 8, 2009)

Starlight said:


> Jimmy, I had some voltage setting problems too. You sent me one regulator set up for 18v output and 26v low battery. I put it in a light with 7 emoli cells and a 64458 bulb, but the low voltage pulsing occurred. I then put in an 8th cell. Pack voltage was 32.4v but it still pulsed. I had the turn the pot more than one turn to get the pulsing to stop. There is no way that 10 amps should take a 32v pack below 26v. I intend to get a meter soon to check voltages myself.


Yes, please do. If the setting is off and you can't seem to correct it to your satisfaction, I'll cross-ship you another and refund you the postage.
I'll cross ship you another, in any case, if you want.


----------



## JimmyM (Jun 8, 2009)

I'll be shipping all new regulator purchases with updated software.
Upgrades include:
- Faster response to low voltage and over temp conditions. 0.25 seconds versus 0.5 seconds.
- After the low voltage mode (pulsing) has been in place for 30 seconds, it will shutdown and go to sleep.
- Over temp mode will reduce bulb voltage to 35% of the set voltage instead of 25%
- The higher softstart ramp will disengate before reaching regulation point to eliminate any overshoot of more than 0.04V.
- More adaptive battery voltage sampling. It will average 4 or 8 readings per cycle depending on duty cycle.
- Multiple averaged readings of Vbulb and Vlow pots.

I'll be posting the updated software soon for those who want to re-program theirs.


----------



## Starlight (Jun 8, 2009)

Jimmy, I wasn't complaining, I was just providing feedback in case it would help you. I like your regulator so much, I'm about to order 2 more. I will put specs in the paypal message.


----------



## LuxLuthor (Jun 8, 2009)

Thank you sir! Great improvements. I want to get 4 more of these.

"It's Gold, Jerry. Gold!"


----------



## JimmyM (Jun 8, 2009)

Starlight said:


> Jimmy, I wasn't complaining, I was just providing feedback in case it would help you. I like your regulator so much, I'm about to order 2 more. I will put specs in the paypal message.


I didn't mean to sound terse. Not at all. I just want to support my customers they way I'd like to be supported after a sale. I want to provide a quality product. If there is indeed something amiss. I will make it right.


----------



## wquiles (Jun 8, 2009)

petrev said:


> 287/289 = Mucho Dinero
> 
> but NICE





JimmyM said:


> You're right. the 189 rules. However, I still want the 287/289





petrev said:


> Mmmmmm So Pretty - and useful too.



I have one of each, 189 and 289. The 189 is smaller, lighter, and does the AC+DC as good as the 289, so you are not missing anything with the 187/189


----------



## JimmyM (Jun 9, 2009)

wquiles said:


> I have one of each, 189 and 289. The 189 is smaller, lighter, and does the AC+DC as good as the 289, so you are not missing anything with the 187/189


Bragger! . There's no debating that the 189 is super capable. But the 287/289 is just so cool. QVGA screen.:naughty:


----------



## wquiles (Jun 9, 2009)

Not bragging, but trying to make you guys feel better in that you really don't gain anything "significant" going to the 28x series. The 18x is the bomb


----------



## JimmyM (Jun 9, 2009)

wquiles said:


> Not bragging, but trying to make you guys feel better in that you really don't gain anything "significant" going to the 28x series. The 18x is the bomb


Don't get me wrong. If I had them both, I'd brag.


----------



## petrev (Jun 9, 2009)

Hi 

Further testing now with 2 setups and I think the over-read is probably measurement error and everything is working as designed. 

My problem is probably that the 10Hr LuxLuthor point may be a bit too close after all and I have tried the 64625 at the 20Hr 13.00V setting and all is fine.

I didn't think I had been using my 6xA123s that much in this testing, but time flies you know . . . and JM's trusty LowBatt warning kicked in spot on 17.4V as set, which was a great event in my life - saved a cell too as while 5 were at 3.21V, one was at the edge on 2.68V - Perfect Catch :thumbsup: 

Thanks Jimmy

Anybody else with settings tested ? please post your results.

Cheers
Pete

ps. 
The Fluke 189 I bought when I first got a PIR1 has been totally brilliant by the way - TrueRMS AC+DC - Duty Cycle and I used to think that for simple Voltage and Resistance measurements a $20 meter was fine. No.

Having used the Fluke 189 next to one there is no comparison. 

The Fluke showed an Open-Circuit as metered on ElCheapo to actually be a few millon Ohm and this was enough to just light an LED with the microAmps that were flowing.


----------



## Alan B (Jun 9, 2009)

I have also noticed that my 189 reads high momentarily as the regulator ramps up. This is with different code than Jim's, and this code does not overshoot, so I suspect it is a characteristic of the way the meter reads. It settles down to the right value right away, just one or maybe two readings a bit higher.


----------



## JimmyM (Jun 9, 2009)

Alan B said:


> I have also noticed that my 189 reads high momentarily as the regulator ramps up. This is with different code than Jim's, and this code does not overshoot, so I suspect it is a characteristic of the way the meter reads. It settles down to the right value right away, just one or maybe two readings a bit higher.


I've sent petrev a slightly updated firmware for testing which prevents any overshoot other than the +1 pwm count as part of regulation.
This is included in the new firmware that will go out.
I'm also going to work out an "S"-curve soft start.


----------



## petrev (Jun 9, 2009)

Alan B said:


> I have also noticed that my 189 reads high momentarily as the regulator ramps up. This is with different code than Jim's, and this code does not overshoot, so I suspect it is a characteristic of the way the meter reads. It settles down to the right value right away, just one or maybe two readings a bit higher.


 
Hi Alan

Thanks for that confirmation. 

Seems like the poor Fluke is seeing some part of the waveform and giving a more instantanious estimate rather than a true reading. The Fluke does a brilliant job of trying to interpret what is happening but it can't get it right every time when things are happening so fast -  - Sampling at just the wrong time is my guess.

I think my problem was starting right at the bleeding edge. Having backed a little away from the visual cliff I can see the bright new vista stretching out ahead . . . too mix a few metaphores :thinking:

Cheers
Pete

ps New software loaded really nicely thanks to JM's guidance 

(PhD +AVRISP-II +Studio +WINAVR +little Switch and some wire = Happiness)


----------



## LuxLuthor (Jun 9, 2009)

petrev said:


> My problem is probably that the 10Hr LuxLuthor point may be a bit too close after all and I have tried the 64625 at the 20Hr 13.00V setting and all is fine.



Please keep in mind that part two of my intended destructive testing was to verify Lux & actual survival at projected Life that was taken from AWR Hotrater which is not that useful without verification. I would look at my Bulb Life projections, as "better than nothing."

I think you are better using a % OD between default Vbulb and my Vflashed level, taking into account the advertised Life @ spec, and the range between default & flash voltage. I'm sure there could be another Excel display to present this.

For example, the Phiips 5761 (100 Hrs) has a very narrow, delicate tolerance for OD, and the Osram 64458 & IRC's (4,000 Hrs) are beasts.


----------



## Alan B (Jun 10, 2009)

Lux, do we need to build an automated test setup to do life testing? Something that would chart output and run the bulb through some cycle under computer control? Perhaps that old computer could be set up to do that? Is your power supply capable of omputer control? If not we could make a serially controlled PWM switch from one of the regulators and just allow the computer to turn the bulb off and soft start it with the power supply set to a fixed voltage. Then a serial readout light meter and a program for the computer would complete it. Then a bulb life test would take a day or so.


----------



## LuxLuthor (Jun 10, 2009)

Alan, I did it for a small number of bulbs (like 5 or 6)....just enough to realize what a time consuming pain in the bumpkiss it is. With a couple of the bulbs, their output (from fatigue) _*dropped to about 40%*_ of starting Lux about halfway through the projected life from spreadsheet, and failed at 125% (longer than predicted). 

When I saw that huge drop off, that became a whole other factor that I had not anticipated, and for practical purposes the rest of the bulb's life was nearly worthless. I repeated it with another bulb to make sure it was not a spurious result (alas, it was reproduced). Then I had to repeat the process at a lower OD voltage...trying to find the sweet spot of ideal OD Lux vs. Life. 

Keeping an eye on the bulb (never knowing when it would flash), taking lux measurements, keeping track of logged life, not to mention the cost of 2-3 more bulbs per listing (after the 2-3 already destroyed)...and the hours involved....it stopped being a fun project, so I gave up on part two.


----------



## Alan B (Jun 10, 2009)

Fair enough. A computer setup could help by cycling the power and reading the light output. The tests could be terminated when the light output has dropped by some set factor. But the cost of the bulbs remains. Plus the cost of a computer output light meter and a serial controlled power supply or PWM switch, plus effort in some custom software.

Probably too expensive.


----------



## petrev (Jun 11, 2009)

Hi 

All Lovely and Hunky Dory

:twothumbs

Jim spent 24hours sorting me out.

I was trying to get straight to the max point and after a few firmware updates we are there now.

Regulators are rock steady at their set points. 
Softstart rise is softened a bit and there is no chance of overshoot.

Jim is working on even better functions for soft start and sampling as I understand it ? ? ? 

Upgrading firmware is an absolute doddle with WINAVR and AVR-Studio and Jim's help.

Updated FULL version 1.4
with LL notes added 
and extra pics (2)
HowToLoadYourPhD1.4FullPics.pdf

Single Page Version 1.4
HowToLoadYourPhD1.4SinglePage.pdf

Edit: New Updated

Full (more Pics)
and extra Links
HowToLoadYourPhD1.61FullPics.pdf

1 Page QuickGuide
HowToLoadYourPhD1.6SinglePage.pdf


v1.6


> *How to: Load New Software to your PhD*​
> Requires *Atmel AVRISP-mkII* - (Hardware inc. AVR-Studio 4 and USB driver)
> Install*AVRStudio - *Install *USB Driver* during *AVRStudio *install
> Only after *AVRStudio* is installed should you Plug *AVRISP-mkII* to USB cable
> ...


 
Cheers 
Pete

ps. Feel free to copy .pdf to your server and link guide if you want to.
Should be the same method for other PhDs as far as I know ? ? ?


----------



## Alan B (Jun 11, 2009)

Jim and Pete, this is nicely done. Can I use some of it in my documentation? It has been so long since I set this stuff up it is hard to remember what needs doing.

As I recall the above procedure does not load software into the regulator. It upgrades the AVR ISP with new code from Atmel. There are a couple more steps to load code into the AVR CPU.

However all the steps above need to be done just the first time. After that just the last few (missing) steps are done to load the code into the regulator.


----------



## petrev (Jun 11, 2009)

Hi Alan

This was the method I used and it seems to work.
What are the missing steps . . .

Cheers
Pete


----------



## Alan B (Jun 11, 2009)

I don't see where the C program was compiled to produce the binary. Nor where the binary was selected and loaded to the target AVR in the regulator. The Upgrade button upgrades the AVR ISP programmer itself (as I recall). It doesn't load code to the target AVR.

Perhaps there are some changes in the newer program, my version is a little older than present ones.


----------



## petrev (Jun 11, 2009)

Alan B said:


> I don't see where the C program was compiled to produce the binary. Nor where the binary was selected and loaded to the target AVR in the regulator. The Upgrade button upgrades the AVR ISP programmer itself (as I recall). It doesn't load code to the target AVR.
> 
> Perhaps there are some changes in the newer program, my version is a little older than present ones.


 
Hi Alan

You could be right there ? 

Just tried without a PhD attached and it went through the cycle as before . . .

How strange as before doing this my PhD was Instaflashing and now it isn't ? ? ? ?

Let me know if/what steps need adding ?

Cheers
Pete

ps. When I first attached my AVRISP the Studio prog it alerted me to a Firmware update and loaded it at that time - the above Update seems to be an automatic method for update of the ISP-attached board - but I am less than an expert . . .


----------



## Alan B (Jun 11, 2009)

*Compiling and loading the program to the Regulator*

Make any changes needed to source code file
Save (File/Save or Control-S)
Compile the program with Build/Build or F7
Review the messages in the Build window for errors and warnings
If anything needs fixing return to the Make Changes step
Bring up Programmer with Tools/Program AVR/Auto Connect or the AVR button
On the Main Tab (the first time, does not need to be done each time)
- insure ATTiny45 is selected
- insure ISP Mode is selected
- under Settings select 250 khz (may need to be lower the first time)
- click "Read Signature" to verify the connection to the target board
On the Program Tab; in the ELF sub-window,
- select the input ELF file (the first time only, will remember it)
- click the Program button to program the chip!!!!!
- review the messages
-- if there are errors reducing the ISP frequency may help (the first time on a new unprogrammed chip)
-- make sure the CPU type is the same in both the project build and in the programmer settings, they are separate


----------



## petrev (Jun 11, 2009)

Alan B said:


> *Compiling and loading the program to the Regulator*
> 
> Make any changes needed to source code file
> Save (File/Save or Control-S)
> ...


 
Hi Alan

That's more like the computer gobbledy-gook stuff I was expecting to not understand :thinking: actually I do understand it a bit !

? Jim's is an ATTiny44 ? - OK
Cool just compiled Rev1.bb5000 version and found a ; missing
Found it and put it in and now it compiles . . .

I'll try the rest - ie. actually fitting to PhD and programming in a minute . . .

Is this wise . . .

Cheers
Pete

ps what is the ELF file exactly ?


----------



## petrev (Jun 11, 2009)

Hi Alan

Is that the program button in the ELF Sub-Pane ?

There are Program buttons in the FLASH and EEPROM SubPanes but you haven't mentioned them so . . .

Cheers
Pete

Clicked ELF Program button and seems OK ! ! !



> Getting isp parameter.. SD=0x06 .. OK
> Validating ELF input file.. OK!
> Reading FLASH input..OK!
> No EEPROM contents in ELF file.
> ...


 
Re-fitted in Mag and still works - Yippee

So ? How come I was blowing up bulbs left right and centre and then updated software (or NOT) and stopped blowing the bulbs ? ? ?


----------



## Alan B (Jun 11, 2009)

Only use one Program button, the one in the Elf panel.

Right, Jim used a different chip. This list was for mine.

Good Work!


----------



## Alan B (Jun 11, 2009)

ELF is a file format. There are several different formats that can be used.


----------



## petrev (Jun 11, 2009)

Alan B said:


> ELF is a file format. There are several different formats that can be used.


 
Thanks Alan

Updating .pdf 
Please use as you wish . . . 

Cheers
Pete


----------



## Alan B (Jun 11, 2009)

Did you leave out a bunch of output lines in the elf programming report? There should be more... Such as programming flash, eeprom. Wonder if the build is making a proper Elf file?


----------



## niner (Jun 11, 2009)

I have to make my own regulator holder for a couple of reasons:

1) I'm putting it in Modamag's Colossus, which has the built-in ridge for switch stop. To install KIU's socket + switch assembly, it requires the clip to be removed in a Mag, but that's not an option for Colossus or FM's Elephant II.

2) I'm pushing a lot of power (400W 64663 at 40V, 50V input) through this regulator. I would like to put the board/MOSFET on a heatsink.

Here's my creation:

Custom McClicky switch holder:






It holds Jimmy's regulator on the battery end, away from the heat:









I'm waiting for some material to make a battery contact board.


----------



## petrev (Jun 11, 2009)

Alan B said:


> Did you leave out a bunch of output lines in the elf programming report? There should be more... Such as programming flash, eeprom. Wonder if the build is making a proper Elf file?


 
That was it as I copy/pasted it ! ! !

EDIT

Wrong copy and paste see below . . .


----------



## petrev (Jun 11, 2009)

Hi Alan + Jim

Does this look OK



> EDIT​
> see above​


----------



## Alan B (Jun 11, 2009)

niner said:


> I have to make my own regulator holder for a couple of reasons:
> 
> 1) I'm putting it in Modamag's Colossus, which has the built-in ridge for switch stop. To install KIU's socket + switch assembly, it requires the clip to be removed in a Mag, but that's not an option for Colossus or FM's Elephant II.
> 
> ...



Very nice. Looks familiar!


----------



## Alan B (Jun 11, 2009)

I think we missed a step.

I have selected output file <filename>.elf in the project options. That builds the output file that should be loaded by the programmer into the chip.


----------



## petrev (Jun 11, 2009)

niner said:


> I have to make my own regulator holder for a couple of reasons:
> 
> 1) I'm putting it in Modamag's Colossus, which has the built-in ridge for switch stop. To install KIU's socket + switch assembly, it requires the clip to be removed in a Mag, but that's not an option for Colossus or FM's Elephant II.
> 
> ...


 
Hi Niner 

That looks really good
:thumbsup:


----------



## niner (Jun 11, 2009)

Thanks. Can't wait to put it in the host, and turn on the light!


----------



## petrev (Jun 11, 2009)

Alan B said:


> I think we missed a step.
> 
> I have selected output file <filename>.elf in the project options. That builds the output file that should be loaded by the programmer into the chip.


 
Hi Alan

That appears to be in by default and I added it as you said it was needed and filled in that bit on the requester

Not sure when to use the save button ? fuses ? lockbits? etc. . . 





EDIT ADDED

Hi

Re-flashed my 2nd JM-PhD and this is the the Log Window output / ELF readout


> Getting isp parameter.. SD=0x06 .. OK
> Validating ELF input file.. OK!
> Reading FLASH input..OK!
> No EEPROM contents in ELF file.
> ...


 
The previous post must have been from a readout of something else ?
This looks better !
Pete


----------



## JimmyM (Jun 11, 2009)

That was just a brief giude to create a project and update the firmware of his AVR ISP.
I never intended it to be a step by step guide to compiling and loading.
But it seems you guys have evrything sorted.


----------



## petrev (Jun 11, 2009)

Hi jimmy

Sorry - we have been knocking this one back and forth to thrash out a guide. Hope it's allright ? Just tidying it up a bit.
If I can take any of the load (eg this documentation) then it frees you guys up to do the hard stuff - designing and programming.

Cheers
Pete

EDIT revised post #136 above

Updated FULL version 1.4
with LL notes and advice added 
and extra pics (2)
http://www.box.net/shared/37hvbf3a77

Single Page Version 1.4
http://www.box.net/shared/ng6xt74r7q


----------



## JimmyM (Jun 11, 2009)

petrev said:


> Hi jimmy
> 
> Sorry - we have been knocking this one back and forth to thrash out a guide. Hope it's allright ? Just tidying it up a bit.
> If I can take any of the load (eg this documentation) then it frees you guys up to do the hard stuff - designing and programming.
> ...



No. No problem at all. I just didn't want you to think THAT was my guide to programming the regulator. That's all.
Go nuts fellas. I'm testing code tonight.


----------



## petrev (Jun 11, 2009)

JimmyM said:


> No. No problem at all. I just didn't want you to think THAT was my guide to programming the regulator. That's all.
> Go nuts fellas. I'm testing code tonight.


 
Hi Jimmy

Have fun testing.

Just trying to help with some sort of guide - hopefully it is a start and a proper one can be done by someone who actually knows what they are doing ! 

Cheers
Pete


----------



## JimmyM (Jun 11, 2009)

Sure, do whatever you like. Share and share alike!


Alan B said:


> Jim and Pete, this is nicely done. Can I use some of it in my documentation? It has been so long since I set this stuff up it is hard to remember what needs doing.
> 
> As I recall the above procedure does not load software into the regulator. It upgrades the AVR ISP with new code from Atmel. There are a couple more steps to load code into the AVR CPU.
> 
> However all the steps above need to be done just the first time. After that just the last few (missing) steps are done to load the code into the regulator.


----------



## JimmyM (Jun 11, 2009)

I've made more changes to the Rev2 firmware.
Upgrades include:
- Faster response to low voltage and over temp conditions. 0.25 seconds versus 0.5 seconds.
- After the low voltage mode (pulsing) has been in place for 30 seconds, it will shutdown and go to sleep.
- Over temp mode will reduce bulb voltage to 35% of the set voltage instead of 25%.
*- An adaptive S-curve softstart ramp. Duty will be ramped slowly at first, then speed up. Depending on the Vbulb/Vbat ratio, the softstart will take between 0.3 and 0.6 seconds.*
- The higher softstart ramp will disengage before reaching the regulation point to eliminate any overshoot of more than 0.04V.
- More adaptive battery voltage sampling. It will average between *2 and 32* readings per cycle depending on duty cycle.
- Multiple averaged readings of Vbulb and Vlow pots for smoother response.

I'll be posting the updated software soon for those who want to re-program theirs. Within the software, there are compile-time variables that the user can set to tweak their functionality.


----------



## Alan B (Jun 11, 2009)

petrev said:


> Hi Alan
> 
> That appears to be in by default and I added it as you said it was needed and filled in that bit on the requester
> 
> ...



Great! You got it!! The ... programming flash... is the important part.

The Save Button is not used here. Just the Program button.


----------



## petrev (Jun 11, 2009)

JimmyM said:


> I've made more changes to the Rev2 firmware.
> Upgrades include:
> - Faster response to low voltage and over temp conditions. 0.25 seconds versus 0.5 seconds.
> - After the low voltage mode (pulsing) has been in place for 30 seconds, it will shutdown and go to sleep.
> ...


 
:thumbsup:

Tweaker Approved


----------



## wquiles (Jun 11, 2009)

JimmyM said:


> I've made more changes to the Rev2 firmware.
> Upgrades include:
> - Faster response to low voltage and over temp conditions. 0.25 seconds versus 0.5 seconds.
> - After the low voltage mode (pulsing) has been in place for 30 seconds, it will shutdown and go to sleep.
> ...



Nice 

Good job dude!


----------



## JimmyM (Jun 11, 2009)

Thanks, guys. I rather like the code functionality.

But the code size has grown quite a bit. I'm up to 28-29% of the Tiny44. I was down between 19% and 21% depending on compile-time options.

Alan, you have a TON of functionality in your code, but your code is barely larger than mine. I'm sure it has a lot to do with HOW it's written.
Could I get a copy of your code somewhere to how you've packed so much into such a small code space? I'd really appreciate it.


----------



## wquiles (Jun 11, 2009)

JimmyM said:


> Could I get a copy of your code somewhere to how you've packed so much into such a small code space? I'd really appreciate it.


+1 - I would also like to please get the latest code for the Tiny85.

I will be assembling my first PhD-M6 board soon, and I will then start with the firmware part of the project, so I rather start with something stable/proven, before I make the small M6-specific modifications.


----------



## Alan B (Jun 12, 2009)

Jim,

I think it is mostly in the more than 8 bit arithmetic. I try very hard to minimize the 16 bit stuff and do nothing beyond that, and minimize the different types of operators as they bring in libraries. FP9 is a good example (it is already on the web).

I'm not quite ready to release FP10. It is still a bit of a mess. FP9 is a lot easier to work with. FP10 is much larger and more complex with all the autoranging at compile time, bulb and battery definitions, etc. There's a lot more sourcecode, but most of it is crunched by the compiler so the executable is not all that much larger. A lot of what is in FP10 is also UI stuff that won't apply to the M6. FP9 may even be a better starting point - cleaner, simpler and I think it is stable. I run it in one of my flashlights.


----------



## JimmyM (Jun 12, 2009)

Alan B said:


> Jim,
> 
> I think it is mostly in the more than 8 bit arithmetic. I try very hard to minimize the 16 bit stuff and do nothing beyond that, and minimize the different types of operators as they bring in libraries. FP9 is a good example (it is already on the web).
> 
> I'm not quite ready to release FP10. It is still a bit of a mess. FP9 is a lot easier to work with. FP10 is much larger and more complex with all the autoranging at compile time, bulb and battery definitions, etc. There's a lot more sourcecode, but most of it is crunched by the compiler so the executable is not all that much larger. A lot of what is in FP10 is also UI stuff that won't apply to the M6. FP9 may even be a better starting point - cleaner, simpler and I think it is stable. I run it in one of my flashlights.


The thing is, I had all of the 16-bit and 32-bit integer stuff in there before I added this latest functionality. Before it was only ~20%, now it's jumped quite a bit. I was hoping to see what kind of logical operators (if/then/else, switch/case, inequalities, etc you're using)

Will, since you're not using much UI stuff, Just ON-OFF. You should be able to get away with something rather simple. Just, power up, read the DIP switch settings, then start looping through reading the ADC and setting the PWM.


----------



## Alan B (Jun 12, 2009)

Nothing fancy, no switch-case for example. One thing is to watch the size grow as you make changes. See what is costing. Investigate the expensive stuff, there may be a problem or a better way. 

Calling functions with arguments is quite expensive. I try to avoid that. Making beautiful structured functional or OO C is not good for a small CPU. I had one function call with no arguments that was costing a lot. Didn't make sense. I don't recall what fixed that, but it did get better when I tried a few things.

Some of the library calls are expensive too. Not only do you get the calling sequence code but also the library parts, possibly more than expected. Sometimes just doing it takes less code.

Putting things in the right order helps. Find the 'natural' order to avoid extra flags, extra copies, extra calls to the same routine. Inline it. No call needed. Again, not the best coding style, but it can be fine with clean commenting and plenty of whitespace.

The other thing is don't fret about the size too much. If it fits thats good enough. It is amazing how much code will fit, but also amazing how much time is soaked up by working on it and optimizing it. Good enough is the goal.


----------



## wquiles (Jun 12, 2009)

Alan B said:


> Jim,
> 
> I think it is mostly in the more than 8 bit arithmetic. I try very hard to minimize the 16 bit stuff and do nothing beyond that, and minimize the different types of operators as they bring in libraries. FP9 is a good example (it is already on the web).
> 
> I'm not quite ready to release FP10. It is still a bit of a mess. FP9 is a lot easier to work with. FP10 is much larger and more complex with all the autoranging at compile time, bulb and battery definitions, etc. There's a lot more sourcecode, but most of it is crunched by the compiler so the executable is not all that much larger. A lot of what is in FP10 is also UI stuff that won't apply to the M6. FP9 may even be a better starting point - cleaner, simpler and I think it is stable. I run it in one of my flashlights.


Good point Alan. That being the case, FP9 should be all I need to start making my mods. What is the link again to download the Firmware source code?




JimmyM said:


> Will, since you're not using much UI stuff, Just ON-OFF. You should be able to get away with something rather simple. Just, power up, read the DIP switch settings, then start looping through reading the ADC and setting the PWM.



Yes, at a high level it will be that simple. In my case, I have to also detect if there is a lamp/bulb in place or not, to know when to start regulation, but again, like you said, it will be much simpler code than what you and Alan are implementing.

Of course another small variation will be reading the loaded battery voltage and deciding if either the battery is depleted, or if the duty cycle reaches 100% (regulation stops and it is just DD). The old LVR from Willie Hunt did some ON/OFF cycles to let the user know that it was in DD mode. We will see that we do, depending on what folks want 

Will


----------



## Alan B (Jun 12, 2009)

wquiles said:


> Good point Alan. That being the case, FP9 should be all I need to start making my mods. What is the link again to download the Firmware source code?
> 
> Yes, at a high level it will be that simple. In my case, I have to also detect if there is a lamp/bulb in place or not, to know when to start regulation, but again, like you said, it will be much simpler code than what you and Alan are implementing.
> 
> ...



FP9 is in the "Programming" thread, one of the first posts.

Interesting idea about announcing DD mode. Would be interesting to know that, actually. Have thought about that but not decided on a good scheme. Times like this wish I had an LED on the switch board and the switch cover was translucent.


----------



## JimmyM (Jun 12, 2009)

Alan B said:


> Times like this wish I had an LED on the switch board and the switch cover was translucent.


I wish I could find translucent covers too. I have extra pins I could use for that. It would be neat.


----------



## JimmyM (Jun 12, 2009)

Deleted. Double post.


----------



## smflorkey (Jun 12, 2009)

Alan B said:


> Times like this wish I had an LED on the switch board and the switch cover was translucent.





JimmyM said:


> I wish I could find translucent covers too. I have extra pins I could use for that. It would be neat.


See https://www.candlepowerforums.com/threads/212718 where Sabrewolf was threatening to make molds and produce translucent or GITD button covers for a variety of popular lights. His last post says it is a back burner project for now, but it is one possibility -- at some unknown point in the future. They look like they'll be wonderful quality (as we expect from Sabrewolf) but his production schedule may not fit yours.

Northern Lights and flashlife discuss some techniques and materials to make button covers in https://www.candlepowerforums.com/threads/213940. This seems to have enough information to let you make translucent button covers any priority that fits your copious spare time. :laughing:

Hope that helps, 
Steve


----------



## JimmyM (Jun 12, 2009)

That is cool. I found that link earlier.

I have an update regarding the bahavior of the low voltage warning.
Now, by default (or later depending on how you config the software).
The low voltage warning kicks in where the user sets it by adjusting the pot. It will pulse for 30 seconds then shutdown UNLESS the voltage drops to 94% of the Vlow point before those 30 seconds are up. The it shuts down immediately. I figured this would please both sides of the voltage shut-down fence. Of course, if the voltage recovers before shutdown, it goes back into normal mode. Once it's shutdown, you have to power cycle the light. If the voltage is still too low after restarting, it will try to start, but it will drop back into low voltage mode even before the light reaches regulation.

Alan, I rearranged some stuff in my code. Changed some of the math, moved procedures into the main body of code, etc and got the program back down to 24% from 29%. Of course, then I added some other stuff, so it's back up to 28% depending on compile-time options.


----------



## Bimmerboy (Jun 12, 2009)

Excellent work, Jimmy! I'm almost ready for a couple of these things, and Rev2 sounds great. :thumbsup:


----------



## petrev (Jun 13, 2009)

Hi Jimmy

Revised post #136 . . .

New PDF Format Programming Guides

1-Page QuickGuide

FullGuide with Pictures

Looking forward to Rev2


Cheers
Pete


----------



## JimmyM (Jun 13, 2009)

petrev said:


> Hi Jimmy
> 
> Revised post #136 . . .
> 
> ...


Thanks, Pete.


----------



## petrev (Jun 13, 2009)

JimmyM said:


> Thanks, Pete.


 
Hi Jimmy

Alan has had problems getting them from the Mediafire site so I sent them to him direct. If you and he approve the guide(s) then hopefully he will be able to upload them to his site so they can be linked directly. 

Cheers
Pete


----------



## Alan B (Jun 13, 2009)

Great effort and a big thanks to Pete for tackling this documentation. It is a lot of detail work.

I can put the files in Jim's directory if he wants.

There may be a little tuning to do. For example, I let Studio create the initial C file and then overwrite it with the correct one rather than having to add the file to the project later (not sure if that was done in the procedure). Either way should work. Which is easier for the new user?

I'm working on some other things this weekend so don't have a lot of time for review.


----------



## JimmyM (Jun 13, 2009)

Alan B said:


> Great effort and a big thanks to Pete for tackling this documentation. It is a lot of detail work.
> 
> I can put the files in Jim's directory if he wants.
> 
> ...



Alan, that would be great. Thanks a lot.

I've been messing around with this regulator and software for HOURS this week. It's addictive. "Hmm, I wondor if it would be better to do xyz before or after ABC".
I've now changed the sampling schema to add/remove averaged samples depending on duty cycle, between 2 and 32 samples and also to move the Vbulb and Vlow pot ADC reads to keep them away from switch events. S-Curve softstart ramps are adaptive, on the fly, depending on the Vbat and Vbulb values. Regulation is just about dead on. a few hundredth/thousandths here and there, bu tif your bulb is so overdriven that a 4 hundredths of a volt is the difference between survival and , you're in need of mental help.
I've been messing around with 122Hz PWM frequency and sent a file to Lux to test with to see what the heat results are like. I tested here with a 62625 at 13.6V on a ~18V input. The soft start ramp works great, but I can't really test under load like Lux can.
It's truly an addiction. I'm not sure if I should be thanking you for this new "hobby" or not.


----------



## petrev (Jun 13, 2009)

Alan B said:


> Great effort and a big thanks to Pete for tackling this documentation. It is a lot of detail work.
> 
> I can put the files in Jim's directory if he wants.
> 
> ...


 
Hi Alan

Thanks - Whenever you get time.

That was the way I found logical but just let me know any text or other changes you want.

Keep up the good work you guys.

Cheers
Pete


----------



## LuxLuthor (Jun 13, 2009)

petrev said:


> Hi Jimmy
> 
> Revised post #136 . . .
> 
> ...



Would be great to get Full Guide file. Mediafire is a disaster to use. I'd rather poke my eyes out with dull forks.


----------



## Alan B (Jun 13, 2009)

I'll put them up on my website in a minute...


----------



## Alan B (Jun 13, 2009)

Here are petrev's pdfs:

http://akbeng.com/flash/hwreg/jm/HowToLoadYourPhD1.31FullPics.pdf

http://akbeng.com/flash/hwreg/jm/HowToLoadYourPhD1.31SinglePage.pdf


----------



## LuxLuthor (Jun 13, 2009)

Thank you! 

Petrev, seriously, I tried and failed to download from mediafire at least 25 times. Even opened I.E. to try and got peppered with non-stop popups. Won't ever go there again. It is an evil site. So far I have had good luck with using the free www.box.net version that allows I think up to 25mb file & 1 GB storage in total. Beyond that you have to pay.

Now the great news....Petrev, that new file with color images is superb....and the kind of thing that makes using this easy. One other thing for those of us who did not get around to doing the USB powered mode with the switch yet. You can bring power to the chip by connecting it to a 9V Transistor battery with thin wire wrapped around terminals from these points. You may also want to note that you must compile/build the ".c" file (even if no changes) to obtain the ELF file which is used to program the chip. 

Also important to do separate folders and projects if you are working with both Alan's & Jimmy's PhD boards...and to double check the ATtiny44 45 and .elf files, as the last used version shows as default even if starting a new project. Big thanks for doing this.


----------



## petrev (Jun 14, 2009)

LuxLuthor said:


> Thank you!
> 
> . . .
> 
> ...


 
Hi Lux

Updated FULL version 1.4
with LL notes and advice added 
and extra pics (2)
AlanB Hosted HowToLoadYourPhD1.4FullPics.pdf
or http://www.box.net/shared/ng6xt74r7q

Single Page Version 1.4
AlanB Hosted HowToLoadYourPhD1.4SinglePage.pdf
or http://www.box.net/shared/37hvbf3a77

Let me know further :thinking: . . .

Cheers
Pete

ps. Box.net much better :thumbsup:

Now: Updated

Full (more Pics)
and extra Links
HowToLoadYourPhD1.61FullPics.pdf

1 Page QuickGuide
HowToLoadYourPhD1.6SinglePage.pdf


----------



## Alan B (Jun 14, 2009)

I uploaded Pete's new files to my web:

http://akbeng.com/flash/hwreg/jm/HowToLoadYourPhD1.4FullPics.pdf

http://akbeng.com/flash/hwreg/jm/HowToLoadYourPhD1.4SinglePage.pdf

Thanks for a nice job, Pete!


----------



## LuxLuthor (Jun 14, 2009)

Pete, I'm glad I looked at your improvements closely....you used my old photo from the review I did, and I had the connector on the wrong way in that photo. The #1 pin in this new programming stick "PD2" version is marked on board. (I did check that there is continuity between the two locations since they are on opposite sides) It requires the AVR dongle (I love that word) to be attached opposite of what you show. In fact, this stick not having a black mark....I again attached the AVR pin connector the wrong way...but this time into a fully powered light (tailcap closed) the way you showed. The light was standing reflector down, and imagine my surprise when the light came on. It was the Modamag Colossus 250W, no less.  

I have since added a red mark on the side. Correct dongle attachment to the stick is shown in this pix (thumbnail).

​Alan also recommended that I plug in the computer==>USB AVR==>Light BEFORE installing flashlight battery tailcap (which turns on the AVR LED lights). When done, he recommended to remove tailcap (battery source), THEN take out AVR Programming stick, then remove USB connection to PC.

I don't see that "*First Time AVRISP Connection*" in the longer PDF that upgrades the AVR to the latest firmware, and was glad I had your one page guide for that. Probably should include it for new users, and put it up front in PDF.

Otherwise, it looks good. Also of note, some of the things Alan had in his Programming Information thread (such as setting CPU frequency), he told me is not necessary, and may confuse people (myself for one).


----------



## petrev (Jun 14, 2009)

LuxLuthor said:


> Pete, I'm glad I looked at your improvements closely....you used my old photo from the review I did, and I had the connector on the wrong way in that photo. The #1 pin in this new programming stick "PD2" version is marked on board. (I did check that there is continuity between the two locations since they are on opposite sides) It requires the AVR dongle (I love that word) to be attached opposite of what you show. In fact, this stick not having a black mark....I again attached the AVR pin connector the wrong way...but this time into a fully powered light (tailcap closed) the way you showed. The light was standing reflector down, and imagine my surprise when the light came on. It was the Modamag Colossus 250W, no less.
> 
> I have since added a red mark on the side. Correct dongle attachment to the stick is shown in this pix (thumbnail).
> 
> ...


 
Hi Lux

I'll just change it to read "Red stripe to Pin1" unless Alan wants to put the red mark on all the dongles ?

I have 
"Remove Power from the *[FONT=Arial,Bold][FONT=Arial,Bold]PhD *[/FONT][/FONT]and remove ribbon cable "
but I can make it more specific for Sled users if needed !
 
I changed first time AVRISP connection to reflect the fact that Studio4 now asks you if you want to upgrade firmware automatically when you first connect the AVRISP - at least that was what mine did !!!

I can always add it back in if you are finding that yours didn't do it automatically.

I'll do some more tweaking in the morning (over this side of the pond)

Cheers
Pete


----------



## LuxLuthor (Jun 14, 2009)

Or feel free to include my above pix, or I can take another one of it when plugged into light. My use of "the dongle" referred to the AVRISPmkII plug connector on ribbon. I use "Programming Stick" as what Allen calls his device. You might add (again because I didn't know) that the extra button on Alan's stick (don't go "Freudian" on my here) functions as the normal short plug-in switch, so you can check function of programmed button clicks after flashing.

My first time did *not *ask me if I wanted to automatically check/upgrade the firmware. Rather your *"**First Time AVRISP Connection*" description was how it appeared, and your text was perfect as you had it in previous version. It gave certainty to me as a first time user which I think is what these guides are written for. When I saw that starting the first time, I closed down the program, as I was assuming it would be programming the PhD chip. I didn't know anything about this device/software. Not until later did I realize it was updating the firmware of the AVRISPmkII device. So I would recommend you add it back to both documents just like it was:*First Time AVRISP Connection* _(Device firmware needs to be upgraded)_


From the main menu at the top, select *Tools*==>*Program AVR*==>*Connect*.
In the Connect window, select the *AVRISPmkII*, the Port should be *USB*.
After you click Connect, another window will appear.
In the HW Settings tab, click *Upgrade *at the bottom.
Another window will appear. Click *Start Upgrade*.
Little LED's flash. When prompted, remove and re-connect USB to AVRISP-mkII
Thanks again for your work on this.


----------



## petrev (Jun 15, 2009)

Hi Lux

Try these ! ! !

Full
HowToLoadYourPhD1.5FullPics.pdf

1 Page
HowToLoadYourPhD1.5SinglePage.pdf

:shrug:

Cheers
Pete

Edit: Now updated

Full (more Pics)
and extra Links
HowToLoadYourPhD1.61FullPics.pdf

1 Page QuickGuide
HowToLoadYourPhD1.6SinglePage.pdf


----------



## LuxLuthor (Jun 16, 2009)

Couple final suggestions via email, then looks done to me. Thanks for all this, Pete.


----------



## petrev (Jun 16, 2009)

LuxLuthor said:


> Couple final suggestions via email, then looks done to me. Thanks for all this, Pete.


 

Hi Lux



Full (more Pics)
HowToLoadYourPhD1.6FullPics.pdf
and extra Links
HowToLoadYourPhD1.61FullPics.pdf

1 Page QuickGuide
HowToLoadYourPhD1.6SinglePage.pdf



Cheers
Pete


----------



## LuxLuthor (Jun 16, 2009)

Pete, really fabulous job. These enhancements make it all crystal clear.

New users should note that this file has some differences from Alan's current (draft) post in his thread, and with utmost respect for him, at the current time, I would encourage users to follow Petrev's guide.

Two things came to mind reading it this time...the 2nd may be very important to add. 
*1) Might want to insert links to relevant CPF threads--both a a reference and acknowledgement of their work.

2) I know Alan has said after programming, the PhD needs to disconnected and tested with DMM for calibration, with information entered back into the Studio for one more flash cycle. I'm not exactly sure how to do this, and what to change in the programming, and I don't see it on his draft programming thread. I also don't know if Jimmy's also needs the calibration that Alan mentioned to me. I'll PM him about this.
*​BTW, another nice thing about Box.net as a download source is when you log back into your account you use to upload, it displays how many downloads there have been of your file.


----------



## petrev (Jun 17, 2009)

LuxLuthor said:


> Pete, really fabulous job. These enhancements make it all crystal clear.
> 
> New users should note that this file has some differences from Alan's current (draft) post in his thread, and with utmost respect for him, at the current time, I would encourage users to follow Petrev's guide.
> 
> ...


 
Hi Lux

I'll see what links I can fit in - although I think all users of this guide will have come from the threads I would link to as they will have, or be interested in, the PhD first ! I'll try to select the main thread that would link to others and put that in.

Box.net is great - 5 Downloads so far.

So what do you other 4 think ?

Cheers
Pete


----------



## JimmyM (Jun 17, 2009)

I like it. Well done.


----------



## Alan B (Jun 17, 2009)

LuxLuthor said:


> *...** 2) I know Alan has said after programming, the PhD needs to disconnected and tested with DMM for calibration, with information entered back into the Studio for one more flash cycle. I'm not exactly sure how to do this, and what to change in the programming, and I don't see it on his draft programming thread. I also don't know if Jimmy's also needs the calibration that Alan mentioned to me. ....*​



Jim's board is "calibrated" when you adjust the pots. Changing firmware on his board might change calibration, it depends on the changes that have been made, but for the most part it should not unless he is changing the regulation code. Changes to the averaging, for example, can change the "calibration".

On my sled the calibration may change if the voltage range changes, or if the regulation code is changed. There are some instructions in the source code. We will work out the details of these instructions soon.


----------



## petrev (Jun 17, 2009)

Hi Lux (Alan+Jimmy !)



Full - more Pics
and extra Links
HowToLoadYourPhD1.61FullPics.pdf

1 Page QuickGuide
HowToLoadYourPhD1.6SinglePage.pdf

This is the same as 1.6 just with the extra links
Single page remains the same as a quick reference guide.
I think this is the final version (?) 

Cheers
Pete


----------



## LuxLuthor (Jun 17, 2009)

Done in my opinion. Thanks a million for all your work and patience. :thumbsup:


----------



## Roland (Jun 18, 2009)

Received my board and built it into a flashlight. Have not tested it much but seems to work great. What struck me however is that when I turn the light on there is first a flash at the beginning of the softstart.

I would keep the ramping time as I have now. (not slower)


----------



## JimmyM (Jun 18, 2009)

What battery/bulb/voltage combo are you using?


----------



## Roland (Jun 18, 2009)

JimmyM said:


> What battery/bulb/voltage combo are you using?


I am using 10.000 mah LSD nimh D-cells. Seven of them in an extended maglite.
Bulb is philips 5761.
You set the voltage for me to 7,2 v-bulb and 6,6 v-low.


----------



## JimmyM (Jun 18, 2009)

Roland said:


> I am using 10.000 mah LSD nimh D-cells. Seven of them in an extended maglite.
> Bulb is philips 5761.
> You set the voltage for me to 7,2 v-bulb and 6,6 v-low.


There shouldn't be any sort of "flash" on startup.
So it flashes, then starts up?


----------



## Roland (Jun 18, 2009)

JimmyM said:


> There shouldn't be any sort of "flash" on startup.
> So it flashes, then starts up?


Yes. The startup is a flash and then a ramping up to a steady voltage. This all takes a fraction of a second.


----------



## wquiles (Jun 18, 2009)

Actually, I experienced that as well many months ago, when doing my own bench testing. Alan made a simple suggestion, and after I implemented it in my code, the problem went away for ever. I seem to recall it had to do with the Tiny processors having that output enable by default as soon as the PWM starts, which is what produces the short pulse, only to be "caugth" by the algorithm shortly thereafter. The problem only showed its ugly face with lower voltages since only a lower voltage bulb would ever "notice" the very short pulse. On larger voltage bulbs, the bulb would not even flicker.

Looking at my old code, the code looks like it was just adding one line to the init routine:

void init ()
{
.
.
OCR1B = 255; //cleanup first pulse (NOTE THIS IS THE ONLY ADDITIONAL LINE THAT WAS NEEDED TO SOLVE THE PROBLEM)
GTCCR = _BV(PW<1B)+_BV(COM1B0); // enable B pwm
.
.
}


I hope this helps 

Will


----------



## JimmyM (Jun 18, 2009)

Yup. My code has this already. As soon as the PWM is initiated, it sets the duty to 0. He has to set his duty to 255 because his output is inverted. mine is non-inverted.


----------



## wquiles (Jun 18, 2009)

OK, just trying to help :thumbsup:

Will


----------



## Roland (Jun 18, 2009)

I have no clue about what you 2 are talking. 
I just know startup should be "slow" to minimize stress on the bulbs.


----------



## LuxLuthor (Jun 19, 2009)

Roland said:


> I have no clue about what you 2 are talking.
> I just know startup should be "slow" to minimize stress on the bulbs.



Roland, I'm not exactly sure what Jimmy means about your scenario needing to change duty to 255, or his setup being non-inverted vs. yours inverted.

However, if you look at the original code file that Jimmy linked, (PhD_Tiny84_reg_1_10bit.c) line #61 says this:

*OCR1A = 0; // Force Duty to 0% (0/1023) *​I'm suspecting that he is saying that your value needs to be set at *255* and recompiled and uploaded to the chip. (_trying to be helpful, but I'm not sure what is causing the difference between your setup and his)._


----------



## Roland (Jun 19, 2009)

LuxLuthor said:


> Roland, I'm not exactly sure what Jimmy means about your scenario needing to change duty to 255, or his setup being non-inverted vs. yours inverted.
> 
> However, if you look at the original code file that Jimmy linked, (PhD_Tiny84_reg_1_10bit.c) line #61 says this:
> *OCR1A = 0; // Force Duty to 0% (0/1023) *​I'm suspecting that he is saying that your value needs to be set at *255* and recompiled and uploaded to the chip. (_trying to be helpful, but I'm not sure what is causing the difference between your setup and his)._


Thanks for the answer LuxLuthor,

What do I use to program then. I ordered a programmable magswitch with programming adapter and USB adapter too and will that programmer be usable for this one as well? 

And when I sometime might be tempted tu use it for a high powered light I have to reprogram again or can I leave it? (I drilled holes above the screws) I hate pulling all this stuff apart to re-program it.

On the other hand even for high power bulbs a "comparatively mild" startup flash does not sound ideal.


----------



## petrev (Jun 19, 2009)

Roland said:


> Thanks for the answer LuxLuthor,
> 
> What do I use to program then. I ordered a programmable magswitch with programming adapter and USB adapter too and will that programmer be usable for this one as well?
> 
> ...


 
STOP

Do not change that variable.

Jimmy is saying that Alan's Hardware is different and needs different software not that you should change anything.

There should be no need to change the programming unless told to by Jimmy. To use a higher powered lamp you need to change the regulated output voltage and the low batt cut off using the little screws. You need a dummy load (resistor) or a much larger power bulb that will not blow as you adjust the power up (I use a 64458 for the settings for 64625, 64623 and 64633). 

You also need a multi-meter to read the output voltage at the bulb or the dummy load. A standard multimeter will give you average voltage and you use a little formula to convert this to RMS voltage.

This is an extract from Jimmy's post in the JM-PhD sales thread



JimmyM said:


> *What functions / features exist*? I have tried to future proof the hardware design as much as possible. There are 2 11-turn pots onboard for adjustment. I’ve used 11-turn pots to allow very fine adjustment. There are also 3 additional pads that connect to unused pins on the Tiny84 to allow the future use of pushbuttons or LEDs for things like mode selection, voltage level selection or adjustment, low battery indication, rotary encoder, etc, etc, etc. There is a 6-pin programming header onboard to allow for software updates. The programming header is female to avoid shorts, so a male-male adapter is required to connect it to the programmer. I have a bunch of them and will include one with each order until I run out.
> 
> *Current Software Functions*: The software currently developed is designed to have the control voltage to the regulator switched on or off by the existing Mag switch. When turned on, the regulator will softstart to the set voltage. The 2 pots onboard are used to adjust output voltage and low voltage set point.
> *Pot 1*: Adjusts desired output voltage between 0 and 40V. (Clockwise increases) If you set the output to a voltage above the battery voltage, the FET will be turned on 100% of the time and you will only be able to get the pack voltage.
> ...


 
Jimmy will let you know anything that needs to be done in your case.

The programmer (AVRISP-mkII) that you are getting from Alan (programmable magswitch with programming adapter) is the same for the JM-PhD. See my How-To (HowToLoadYourPhD1.61FullPics.pdf) if you wish to read up on the re-programming process.

Cheers
Pete


----------



## JimmyM (Jun 19, 2009)

LuxLuthor said:


> Roland, I'm not exactly sure what Jimmy means about your scenario needing to change duty to 255, or his setup being non-inverted vs. yours inverted.
> 
> However, if you look at the original code file that Jimmy linked, (PhD_Tiny84_reg_1_10bit.c) line #61 says this:*OCR1A = 0; // Force Duty to 0% (0/1023) *​I'm suspecting that he is saying that your value needs to be set at *255* and recompiled and uploaded to the chip. (_trying to be helpful, but I'm not sure what is causing the difference between your setup and his)._


No no no.
My code and hardware is different than Alans. He uses the inverted PWM output for his design. Therefore 0% duty for him is 255 (He uses 8-bit PWM, 255 is the maximum). My PWM output is non-inverted and therefore 0 = 0% duty. So no code change is required.

Roland, do you have the facilities (An AVR ISP MkII) to reprogram your regulator? The flash before startup shouldn't happen. There may be something else at work. It almost sounds like the chip is resetting during startup like it's plugged into the programmer. Did you, by chance, install the board with the programming adapter plugged into the board?

Sorry, I didn't catch all of your above post. Barring any malfunction, you do not need to re-program the regulator to use different bulbs. You simply set the output voltage and low voltage point via the 2 onboard pots.

But since it appears that you do have the ability to re-program the regulator, we can probably straighten things out easily by applying a new firmware update if necessary. That will require re-programming, but it isn't something you need to do every time you change settings. Don't worry, we'll get things all sorted out for you. Even if I have to cross ship you a new board. You won't be stuck with something thing that doesn't satisfy your expectations.


----------



## LuxLuthor (Jun 19, 2009)

JimmyM said:


> Yup. My code has this already. As soon as the PWM is initiated, it sets the duty to 0. *He* has to set his duty to 255 because his output is inverted. mine is non-inverted.



Oh, sorry about my two cents trying to help Roland. I had assumed the "*He*" in your post was Roland, but I see it referred to Alan. Roland, ignore what I said.


----------



## JimmyM (Jun 19, 2009)

LuxLuthor said:


> Oh, sorry about my two cents trying to help Roland. I had assumed the "*He*" in your post was Roland, but I see it referred to Alan. Roland, ignore what I said.


Damn pronouns! That's for trying to help though.


----------



## Alan B (Jun 19, 2009)

The JM-PHD powers up when the light's onswitch is depressed, so the CPU goes through initialization each time the light is turned on. It is tricky to avoid any glitching at all but it should be possible.

I briefly reviewed the code and I notice that the output port that drives the FET gate is enabled before the PWM registers are set up, then the PWM registers, and finally the PWM value is loaded. It is possible that the order of doing these allows a brief pulse to be generated.

I would suggest trying some experiments to see if changing this order solves the problem. For example, enabling the output port after the PWM is configured and set to zero might prevent any glitches that are generated from reaching the FET. Or clearing the PWM counters at the right moment may help.

It is likely that this pulse does not contain enough energy to endanger a bulb. As was mentioned we had a similar issue early on with the drop-in regulator. In that case the PWM hardware ran a one cycle pulse out to the filament when the batteries were installed. It was fixed by a minor adjustment to the initialization code.


----------



## JimmyM (Jun 19, 2009)

Alan, Thanks for the feedback. I haven't been seeing the flash in any of my tests. I'll do some more testing with a Vbulb that is coded to 0 to see if my scope can catch anything on startup.


----------



## Alan B (Jun 19, 2009)

Using an LED and resistor for the bulb will have a quicker response than a filament. The scope is good too and will give some indication of the duration of the pulse which would be interesting and possibly useful to know.


----------



## JimmyM (Jun 19, 2009)

Alan B said:


> Using an LED and resistor for the bulb will have a quicker response than a filament. The scope is good too and will give some indication of the duration of the pulse which would be interesting and possibly useful to know.


I figured I'd set the scope trigger to one-shot and see what happens.


----------



## Roland (Jun 19, 2009)

JimmyM said:


> No no no.
> My code and hardware is different than Alans. He uses the inverted PWM output for his design. Therefore 0% duty for him is 255 (He uses 8-bit PWM, 255 is the maximum). My PWM output is non-inverted and therefore 0 = 0% duty. So no code change is required.
> 
> Roland, do you have the facilities (An AVR ISP MkII) to reprogram your regulator? The flash before startup shouldn't happen. There may be something else at work. It almost sounds like the chip is resetting during startup like it's plugged into the programmer. Did you, by chance, install the board with the programming adapter plugged into the board?
> ...


I ordered a programmer from Alan.
I did not install the programming adapter in the boaard under the kiu.
I hope you can reproduce what I experience.
There is a lot of combined knowledge here.


----------



## JimmyM (Jun 20, 2009)

Roland said:


> I ordered a programmer from Alan.
> I did not install the programming adapter in the boaard under the kiu.
> I hope you can reproduce what I experience.
> There is a lot of combined knowledge here.


I tested for the pulse using rev 2 software. No pulse. The gate drive is flat until the first pulse of the softstart ramp. I'm going to try it again using earlier software. I'm just getting over a cold and my wife is just getting one, so she needs a lot of help with the kids. SO by the end of the day I'm too tired to get down to the shop. I have some time planned over the next couple of evenings to do some thorough testing of several things.


----------



## ANDREAS FERRARI (Jun 20, 2009)

Jimmy-what are you doing up at this ungodly hour-only Canadians(who are going fishing) and madmen are up this early!!!LOL


----------



## JimmyM (Jun 20, 2009)

I think there's a time zone setting that's off.
Yeah. It's 9:29AM here on my NIST updated Windows clock. It says I posted it at 8:17AM. My profile timezone is set for GMT-5 + Adj for DST.
Oh well.


----------



## Starlight (Jun 20, 2009)

Jimmy, I hope you are thinking about how to add voltage ramping to your boards. That is the function that I really would like to have. It would make the light more "multi purpose".


----------



## JimmyM (Jun 20, 2009)

Starlight said:


> Jimmy, I hope you are thinking about how to add voltage ramping to your boards. That is the function that I really would like to have. It would make the light more "multi purpose".



Yes, actually. The first couple of firmware releases are for the "standard" turn on - turn off type that doesn't require any reprogramming or anything else to change. I'm very close to releasing Rev 2. It has a lot of "bulb care" improvements as well as improvements in regulation.

I've just started thinking about what kind of new UI functionality I'll start with.

I was thinking about a 3 level set up. OFF->(click)->ON(low)->(click)->Med->(click)->High->(click)->Low, etc. Click/hold will turn off.
The 3 levels could be determined by percentages of the Vbulb pot setting. Or something like that. Of course there would be compile time options for other things.
There are so many ways to program one of these things that I couldn't possibly write options for everything. These things don't use copyright protected code or anything like that, so it would be neat to have people develop their own code too.
After releasing Rev 2, I'm going to start looking more deeply into code efficiency and things like that. Since my regulator has to do a lot on-the-fly, the code has gotten bigger as a result. I'd like to clean things up and make sure there's plenty of room for UI code. Although right now you could stack Alan's code and mine into the same 4K chip with room for more.


----------



## JimmyM (Jun 20, 2009)

I've changed a bunch of stuff in the regulation code. Yet again. But this is pretty much the final code. It's running at 248Hz measured frequency. I was toying with adding an option for 124Hz if it made a noticable improvement in heat reduction, but further testing is required. As it is, it will still handle any single bulb you can put in a Mag bodied mod and stay within the voltage range of 5.5-40V.

1) Moved some math operations around for better sensitivity to pack voltage.
2) I'm averaging the squares, instead of squaring the average Vbat readings for better Vbat sampling.
3) Adaptive sampling rates (between 2 and 32 per cycle) depending on duty cycle.
4) 3 Soft-start ramp profiles. Fast, Med, and Slow (slow is quite slow. For those really pushing a bulb near its limit). Selectable during compile time. Units will ship with the Medium setting in place.
5) 12-bit PWM. It's a very small improvement over 10-bit and is still largely constrained by the 10-bit ADC, but it is an improvement so I've included it.
6) A "Fastband" adjustment. Since the PWM can only adjust 1 count per cycle. 12-bit PWM (4095 steps) can be slow to keep up with a fast falling pack voltage. This fixes that. 
7) Low voltage warning and behavior updates...
---Behavior 1 - Pulsing between 50% and 71% of Vbulb setting.(values configurable in software)
---Behavior 2 - Dimming to 50% of Vbulb setting.(Value configurable in software)
---Shutdown trigger 1 - If Vbat falls to 87 or 94% of Vlow setting it will shutdown immediately.(Selectable in software)
---Shutdown trigger 2 - If Vbat is below Vlow for X seconds it will shutdown. (time configurable in software).
---Combined triggers 1 & 2 - If either of the triggers are met, it will shutdown.
Default conditions will be 94% and 30 seconds.
8) Selectable Overtemperature behavior and shutdown...
---Software selectable shutdown temperature. (default is 70C)
---Software optional overtemp shutdown. If in an over temp condition for more than X seconds it will shutdown. (time configurable in software)
In Shutdown mode the regulator only draws 0.10mA. It requires a power cycle to reset.
If any conditions that caused a shutdown or low voltage warning are still in place, the regulator will attempt to start, but will go into either low voltage mode or shutdown even during a softstart ramp.


----------



## Bimmerboy (Jun 20, 2009)

JimmyM said:


> 7) Low voltage warning and behavior updates...
> ---Behavior 1 - Pulsing between 50% and 71% of Vbulb setting.(values configurable in software)
> ---Behavior 2 - Dimming to 50% of Vbulb setting.(Value configurable in software)
> ---Shutdown trigger 1 - If Vbat falls to 87 or 94% of Vlow setting it will shutdown immediately.(Selectable in software)
> ...



This thing keeps getting better and better! 

Quick question. Will you be able to configure these additional preferences for individual buyers, similar to setting our Vbulb's, and Vlow's for us? In essence, I'd like to install these regulators with an "already set, so I can forget" mentality... at least for now.

Granted, the cool factor of programming your own flashlight (an incan no less!) via the PC is just simply the dog's danglies! But, it's not on my agenda until I follow up more on that aspect of things (knowledge requirements/learning curve, equipment cost, etc.).


----------



## JimmyM (Jun 20, 2009)

Bimmerboy said:


> This thing keeps getting better and better!
> 
> Quick question. Will you be able to configure these additional preferences for individual buyers, similar to setting our Vbulb's, and Vlow's for us? In essence, I'd like to install these regulators with an "already set, so I can forget" mentality... at least for now.
> 
> Granted, the cool factor of programming your own flashlight (an incan no less!) via the PC is just simply the dog's danglies! But, it's not on my agenda until I follow up more on that aspect of things (knowledge requirements/learning curve, equipment cost, etc.).


I suppose I could. I'll have to put together an "options" page to standardize the ordering process.


----------



## Bimmerboy (Jun 20, 2009)

Thanks, Jimmy.  Did my question just open a can of worms though? I wasn't sure if these additional features were meant to only be accessable to those with a PC interface, and program editor, or if you were planning on offering them as standard options for the general user.

If such a service requires an additional fee, I'm more than happy to pay for it.


----------



## JimmyM (Jun 21, 2009)

Bimmerboy said:


> Thanks, Jimmy.  Did my question just open a can of worms though? I wasn't sure if these additional features were meant to only be accessable to those with a PC interface, and program editor, or if you were planning on offering them as standard options for the general user.
> 
> If such a service requires an additional fee, I'm more than happy to pay for it.


It's a can of worms that bears opening. Why leave the non AVR programming guy/gal out of the fun right? I'll get an ordering guide together for the new options. The standard config is rather standard. There aren't as many options as Alan has, so it shouldn't be all that complicated.


----------



## petrev (Jun 21, 2009)

Hi Jimmy

Great Work 
Cheers
Pete


----------



## Alan B (Jun 21, 2009)

petrev said:


> Hi Lux (Alan+Jimmy !)
> 
> 
> 
> ...



Nice work, Pete.

I have uploaded these files to Jimmy's directory and removed the earlier versions.

I've ordered a netbook so I'll have a chance to go through a fresh install and review the instructions soon. There will undoubtedly be some minor suggestions as we go forward, but this is a great start.


----------



## petrev (Jun 21, 2009)

Alan B said:


> Nice work, Pete.
> 
> I have uploaded these files to Jimmy's directory and removed the earlier versions.
> 
> I've ordered a netbook so I'll have a chance to go through a fresh install and review the instructions soon. There will undoubtedly be some minor suggestions as we go forward, but this is a great start.


 
Hi Alan

Let me know as it is difficult to remember what happened in a fresh install.
Good to go through all the steps and check.

Cheers
Pete


----------



## Starlight (Jun 21, 2009)

Jimmy, I have 2 more regulators ordered. I was waiting for Rev2 firmware, but I will wait longer if you might add some UI. The bulb care improvements in Rev2 are excellent. Adding UI will give the regulators much more flexibilty and should be an added selling point.

The 3 level set up you talked about is all I would need. Levels as a percentage of set point voltage is fine. The percentages could be changed later if desired. I don't know enough about the source codes at this point to do any of it myself. I have the programmer and adapter ordered from AlanB. Once they arrive, I think I will be able to make changes to existing codes, but I may never get involved enough to write new code.

I don't want to cut into the "fun" you are having with streamling your code. If you don't enjoy what you are doing, it just becomes another job.


----------



## JimmyM (Jun 21, 2009)

Starlight said:


> Jimmy, I have 2 more regulators ordered. I was waiting for Rev2 firmware, but I will wait longer if you might add some UI. The bulb care improvements in Rev2 are excellent. Adding UI will give the regulators much more flexibilty and should be an added selling point.
> 
> The 3 level set up you talked about is all I would need. Levels as a percentage of set point voltage is fine. The percentages could be changed later if desired. I don't know enough about the source codes at this point to do any of it myself. I have the programmer and adapter ordered from AlanB. Once they arrive, I think I will be able to make changes to existing codes, but I may never get involved enough to write new code.
> 
> I don't want to cut into the "fun" you are having with streamling your code. If you don't enjoy what you are doing, it just becomes another job.


It's funny you just posted this. I just added a reply to you in the Sale thread asking about settings. I'm not even close to having a multi-level UI yet. I have to start that next. It's a real departure from the mode of operation I have now. So it's going to take a while. It will also require a change to the wiring during install.


----------



## JimmyM (Jun 21, 2009)

Roland said:


> I ordered a programmer from Alan.
> I did not install the programming adapter in the boaard under the kiu.
> I hope you can reproduce what I experience.
> There is a lot of combined knowledge here.


Roland. I tested every version of software I have and none produces a flash.
I have new firmware, would you feel comfortable reprogramming your board with it to see if that fixes it?


----------



## Alan B (Jun 21, 2009)

There was some discussion of the temperature shutdown on the sales thread. One thing to keep in mind about this temperature detection is that it requires calibration to be accurate. This calibration is due to differences in the chip temperatue sensor and to the voltage reference that is used to measure it. 

Without calibration the accuracy of the temperature measurement is not precise. It can be off more than ten degrees. Calibrating the temperature measurement would be a bit of a chore.

The chip can handle up to 125 degrees C. The batteries can handle only 60 degrees C.

If the calibration is 10 degrees off and we set the shutdown for 80 the batteries might see 90 or more before shutdown. The batteries also may be hotter than the chip if they are self-heating, which can easily happen due to their internal resistance and the contact resistance.


----------



## JimmyM (Jun 21, 2009)

Alan B said:


> There was some discussion of the temperature shutdown on the sales thread. One thing to keep in mind about this temperature detection is that it requires calibration to be accurate. This calibration is due to differences in the chip temperatue sensor and to the voltage reference that is used to measure it.
> 
> Without calibration the accuracy of the temperature measurement is not precise. It can be off more than ten degrees. Calibrating the temperature measurement would be a bit of a chore.
> 
> ...


There's really nothing that can be done about battery temperature. The thermal shutdown is there to protect the circuitry. Without an external temperature probe the temperature of the chip can't be extrapolated to mean anything about the cells. The regulator might get to 90C but the cells are at 50C. At some piont the designer / builder of the light has to be aware of these things. They would exist without regulation.


----------



## Starlight (Jun 21, 2009)

JimmyM said:


> It's funny you just posted this. I just added a reply to you in the Sale thread asking about settings. I'm not even close to having a multi-level UI yet. I have to start that next. It's a real departure from the mode of operation I have now. So it's going to take a while. It will also require a change to the wiring during install.



I have all the "play toys" I need right now. I will wait to see what develops.


----------



## Alan B (Jun 21, 2009)

If the cells are generating a lot of heat they may have a temperature higher than the regulator. If they are very efficient (such as lithium iron) they will be cooler. In that case the regulator will be hotter than the cells. In either case the temperature of the regulator can indicate something about the temperature of the cells. It is not precise, but if the regulator is at 80C the cells will soon be also.

If the cells are running hotter than the regulator we can set the temperature of the regulator lower to help protect them. As you point out, it is not ideal.

If the cells are cooler than the regulator we can set the regulator for a hotter shutdown, but by how much?

LuxLuthor's Colossus test showed a relationship between cell temperature and regulator temperature that is probably reasonable for many high powered lights. I recall that the batteries and regulator were not too far apart in temperature, and that the cells slightly exceeded the 60C point. That was with a 60C setting on the regulator shutdown. Based on that I reduced the default setting on my software to 50C but made it a power reduction level, and about 10 degrees higher it ramps to off. 60C is a maximum for the cells, it is prudent to never quite go there.

The Kiu base is a bit closer to the bulb, and the plastic [email protected] switch will delay the heatwave to the cells a little so settings on the JM-PhD can be a bit higher than the drop-in sled. It would be interesting to get some temperatures from a similar test with the JM-PhD, it might provide some guidance for the selections.

It is up to the customer to select the settings but it is good to discuss them and perhaps caution against going too high. I would rather the regulator shuts down a bit early and the cells never see 60C.


----------



## Roland (Jun 21, 2009)

JimmyM said:


> Roland. I tested every version of software I have and none produces a flash.
> I have new firmware, would you feel comfortable reprogramming your board with it to see if that fixes it?


Lets try that. It will be a while before I will receive the programmer from Alan so it will have to wait for that. 

Strange however that 2 people can experience it and it cannot be reproduced. Must be complex stuff inside that regulator.


----------



## JimmyM (Jun 21, 2009)

Roland said:


> Lets try that. It will be a while before I will receive the programmer from Alan so it will have to wait for that.
> 
> Strange however that 2 people can experience it and it cannot be reproduced. Must be complex stuff inside that regulator.


What 2 people? Alan's issue was early on and we have the same fix in place to prevent it.
We'll get it worked out.
In reading this again, it sounded snippy. I didn't mean it that way. What I meant was... I know you're having an issue, we'll get you fixed up, should I be aware of someone else that needs some attention?


----------



## petrev (Jun 21, 2009)

Hi Jimmy



Rev2 Kicks ! ! ! !

Oh Yeah - Loverly Regulation - Rock steady 

With a 625 the Slow SoftStart is great - Just looks like a BIG lamp starting up
The extended S ramp is beautiful - Can't really see the last bit of the slow rise which is perfect.

I'll play more with the other new options later but overall - Totally Great.

Cheers 
Pete


----------



## JimmyM (Jun 21, 2009)

petrev said:


> Hi Jimmy
> 
> 
> 
> ...


The "SSSLOW" option is quite slow. It's really intended for those pushing close to the limit of their bulbs.
Glad you like it. Test the heck out of it. Play around. Just don't select the SSFAST option with a big bulb that close to the edge. The 0.02V variation is about as tight as it's gonna get. At that point there will be competing errors. The PWM adjusting and the Fluke "locking" on to a duty cycle that is changing slightly as the battery voltage falls. The math works out a little tighter than that, but there's noise in the sampling circuit, and I'm not sleeping the CPU to read the ADC. But I think 0.02V is quite acceptible. Don't you? 
Your question regarding "crest factor" is a valid one, but the 189 is capable to a crest factor of 10. A crest factor of 10 is a shorter pulse. The longer the duty cycle the lower the crest factor. The best crest factor you're going to get with a square wave is at 50% duty. Someone correct me if I'm wrong.


----------



## JimmyM (Jun 21, 2009)

petrev said:


> Hi Jimmy
> 
> 
> 
> ...


I've sent the C file to Alan to post, so when it's done, I'll update the sales thread. I'm sure he'll look it over, just out of curiosity. I hope he doesn't laugh too hard at my "child with a crayon" coding, but I'm looking forward to some feedback. He and I have been chatting about integers and overflow. There is one place where overflow might occur and I have tested the regulator is that area. Like setting the Vbulb to >39 volts (or something like that), but saw no odd behavior under testing.
The code is quite large for not having a complex UI, but the AVR needs to learn what conditions it's in rather than having the advantage of being told via compile-time settings or jumpers. Things like Vbat to Vbulb ratio. That affects the soft-start ramp rates, so it has to read them as it's running. It could just read them at startup, but that might cause confusing behavior while setting. Like if the regulator tool a while to respond because the input voltage and Vbulb were changed significantly during user set-up. It would correct itself the next time it was started, but I figured I should just let it do it on the fly and remove all confusion. It doesn't slow it down, so might as well just do it. The first design principle of this regulator was to be friendly to those who don't have a programmer or the desire to mess with that stuff. Especially since I'm running the CPU at 8MHz now instead of the original 4MHz


----------



## Alan B (Jun 21, 2009)

C file is posted. Not a lot of time here to look at it. I did look a bit at the first part. There are lots of ways to use defines.


----------



## LuxLuthor (Jun 22, 2009)

I followed Alan's lead ordered one of those snazzy Acer Netbooks from NewEgg just now....cause my old water cooled Koolance PC may be a longer fix.

I'm sending a 15 cell pack (2/3A Elite 1500mAh) to Jimmy today for more of his diabolical testing, rather than PS results.

The thing about the temps that was discussed a few posts back...in reality, once the heat reaches 50° C (122°F) the light is getting obviously hot to the touch. 

In all the incan high output mods I have done, by using common sense towards heat management, I have never cracked a Boro/UCL lens, nor peeled a reflector. I don't think you can program thermal protection to adequately counteract a lack of cranial gray matter.


----------



## JimmyM (Jun 23, 2009)

LuxLuthor said:


> I followed Alan's lead ordered one of those snazzy Acer Netbooks from NewEgg just now....cause my old water cooled Koolance PC may be a longer fix.
> 
> I'm sending a 15 cell pack (2/3A Elite 1500mAh) to Jimmy today for more of his diabolical testing, rather than PS results.
> 
> ...


After just 5-8 minutes my Mag458 was too hot to touch near the head. That was using 1/2D-NiMHs. 17 of them. I put the thermal limit in to protect the electronics from the user, not the user from himself.

I'm really looking forward to feedback from Rev 2.


----------



## LuxLuthor (Jun 25, 2009)

JimmyM said:


> After just 5-8 minutes my Mag458 was too hot to touch near the head. That was using 1/2D-NiMHs. 17 of them. I put the thermal limit in to protect the electronics from the user, not the user from himself.
> 
> I'm really looking forward to feedback from Rev 2.


 
I understand your reason for the thermal limit...and it is a good one. My post was more of a practical common sense one of like you say the 458 was too hot to hold. My guidelines are also to prevent reflector peeling, battery damage, etc.

Now that I got my snazzy (and I do mean snazzy) "El Cheapo" Acer Aspire One 11.6" and used the wonderful "New PC DeCrapifier" to get rid of all the snot, I'm ready to do some Rev 2 flashing.


----------



## petrev (Jun 25, 2009)

LuxLuthor said:


> I understand your reason for the thermal limit...and it is a good one. My post was more of a practical common sense one of like you say the 458 was too hot to hold. My guidelines are also to prevent reflector peeling, battery damage, etc.
> 
> Now that I got my snazzy (and I do mean snazzy) "El Cheapo" Acer Aspire One 11.6" and used the wonderful "New PC DeCrapifier" to get rid of all the snot, I'm ready to do some Rev 2 flashing.



Hi Lux

Cool ++++
That's the new model then (which number is it ?) ! What is the processor and where did you get it from . . .
Stick it in a PM if this is too far off topic . . .

Cheers
Pete


----------



## JimmyM (Jun 25, 2009)

Lux, I'll be interested to see what you think about the compile time options.

I'll be dedicatiing more time in the near future to Rev 3. The functionality of Rev 2 is about as good as it's going to get with respect to bulb care and regulation. So Rev 3 will be a UI that controls the functionality of Rev 2.
I'll be starting out simply with a 3 level pushbutton arrangement. Off-low-med-high-low-med-high (etc). HOLD-->off. I figure the pots will still be used as they are now, but the low and medium settings will be percentages of "high" which is set by the Vbulb pot. The 87%,94%,100% values easily achieved Seem like decent candidates for low,med,high. For a High = 13.2V, Low and Med would work out to 11.48V and 12.41V respectively. Of course I'm open to suggestions.
Along the way, I might work on trying to allow the selection of SoftStart speed as a button configurable option whose value is stored in memory to survive power cycles.


----------



## Starlight (Jun 25, 2009)

Hooray! Bring on Rev3.


----------



## petrev (Jun 27, 2009)

JimmyM said:


> Lux, I'll be interested to see what you think about the compile time options.
> 
> I'll be dedicatiing more time in the near future to Rev 3. The functionality of Rev 2 is about as good as it's going to get with respect to bulb care and regulation. So Rev 3 will be a UI that controls the functionality of Rev 2.
> I'll be starting out simply with a 3 level pushbutton arrangement. Off-low-med-high-low-med-high (etc). HOLD-->off. I figure the pots will still be used as they are now, but the low and medium settings will be percentages of "high" which is set by the Vbulb pot. The 87%,94%,100% values easily achieved Seem like decent candidates for low,med,high. For a High = 13.2V, Low and Med would work out to 11.48V and 12.41V respectively. Of course I'm open to suggestions.
> Along the way, I might work on trying to allow the selection of SoftStart speed as a button configurable option whose value is stored in memory to survive power cycles.


 
Hi Jimmy

Rev.2 seems positively great . . .:thumbsup:

I like the simple comment in/out method - all pretty self explanatory.

I also like the use of real values eg. 244counts/sec so that users could define times not given in the list (40seconds=9760 etc.) 

Not sure how the overtemp is worked out as the differences between 10º increments are not the same ? 7381 . 8328 . 7887 but presumably a Mad Tweaker could pick a mid point(?) and get say ~65ºC as an option.

In a similar manner how about providing for Super Tweakability in your Rev.3 offering . . .

Instead of OFF-LOW-MED-HIGH why not OFF-L1-L2-L3 where each level could be assigned any 1/16th level value so you could get 
eg. OFF-56%-87%-100% 
([L1=9]-[L2=14]-[L3=16]) 
or however you set this up in your programming ? ? ?

and user could program a Reverse Cycle simply by specifying L1-L2-L3 in the reverse order ?
OFF-100%-87%-75%
[L1=16]-[L2=14]-[L3=12]
thus getting OFF-HIGH-MED-LOW

The PIR1 had the option that if a value was set to ZERO [eg L2=0]
then that level was not available 
This allows for simple setup of a 2 level HIGH-LOW / LOW-HIGH system
or indeed a push-button single level system if that was wanted for some reason ? :thinking:

Button config. SS-Speed ? If you can do it then why not. 
Maybe as a comment out option for people who don't want it available.

Super Stuff
Cheers
Pete


----------



## JimmyM (Jun 27, 2009)

petrev said:


> Hi Jimmy
> 
> Rev.2 seems positively great . . .:thumbsup:
> 
> ...


 
All good stuff, Pete.
There will be the "default settings" for those who don't want to bother with programming, then of course the "tweakers" can mess with the compile-time options. I could have the code just move to the next level if the selected level is zero.

The temperature is....
((DegC*1.16)+300)^2... Or something like that. Of course I could just have the math done at compile time, but I figured, how many temperature options does there really need to be?


----------



## JimmyM (Jul 2, 2009)

OK. I've got some stuff working in the multi-level button interface.

When batteries are inserted, the regulator immediately goes to sleep. You don't want it turning on right off the bat.
A button press turns it on to low mode, then each successive press steps up through the levels. It recycles to low after high. A press&hold for more than 1 second turns off the output. This indicates to the user that the light has shut off and the button can be released. The regulator is actually still running until the button is released. Then it goes into sleep mode.
It all works quite well. 0.10-0.09 mA current consumption while off.
I'm just working on the user set voltage percentages. Right now 87%, 94%, and 100% are the values I'm using for testing. That works out to 7.2V @ 100%, 6.7V @ 94%, and 6.2V at 87%. Pretty good actually for a 5761.
But I'll get something together to let the user fiddle with the levels if they want to at compile time.
I've also made changes to the ADC settings for better 10-bit readings of the pots as well as changed some of the ADC read timing with respect to the PWM cycle. It seems to have improved the setting granularity at low voltages. I've incorporated these ADC/Timing changes into Rev2b as well.

Every time I start messing with the AVR code I get all psyched over what we can do with these things without changing a single piece of hardware.


----------



## wquiles (Jul 2, 2009)

Great progress Jim


----------



## LuxLuthor (Jul 2, 2009)

Sweetness!


----------



## JimmyM (Jul 2, 2009)

Thanks, guys. It's a work in progress. It was a bigger task to get the button to do what I want it to do rather than integrating the new button functions into the existing regulation code. Which, I must say, is quite nice with respect to regulation "tightness" and adaptability. Especially the S-curve softstart. I also have an option to move to the next voltage as quickly as it can (using the FastBand adjustment) or use the soft start code to "soft ramp" to the next voltage.
Once I get the user settable voltage percentages working, I'll have to go through the code and clean things up for efficiency. I'm SURE there's a lot of tweaking to be done.


----------



## LuxLuthor (Jul 2, 2009)

I'll be honest, with my dog's surgery and needing to watch him almost every minute, I have not even tested ver 2 out yet. My apologies, Jimmy, as I know how anxious you are for feedback. I can sit here on the keyboard with him in my field of vision, but once I go "tinkering," I seem to go into another world for hours at a time.


----------



## smflorkey (Jul 2, 2009)

JimmyM said:


> I'm SURE there's a lot of tweaking to be done.


I'm enjoying your progress and the wonderful things I'm reading about this regulator. I ordered a Kiu socket kit for a D Maglite I don't even have yet, just so I'll be ready when I have a few more spare dollars for this regulator. I'm really looking forward to a sleeper light that will surprise people.

Having said that, and acknowledging that I have a tendency to build brick outhouses, I would like to remind you of Alan's suggestion to define a reasonable feature set and release the code when those features work. There will always be things to tweak. My biggest challenge when programming is to quit when it's good enough. It sounds like you may share that bug. 


LuxLuthor said:


> I'll be honest, with my dog's surgery and needing to watch him almost every minute, I have not even tested ver 2 out yet. My apologies, Jimmy, as I know how anxious you are for feedback. I can sit here on the keyboard with him in my field of vision, but once I go "tinkering," I seem to go into another world for hours at a time.


You are wise to avoid the distraction while your dog still needs attention. My wife and daughter have learned that I can get so wrapped up in a program that I wouldn't know if the house fell down around me. Here's to a speedy recovery!


----------



## JimmyM (Jul 3, 2009)

LuxLuthor said:


> I'll be honest, with my dog's surgery and needing to watch him almost every minute, I have not even tested ver 2 out yet. My apologies, Jimmy, as I know how anxious you are for feedback. I can sit here on the keyboard with him in my field of vision, but once I go "tinkering," I seem to go into another world for hours at a time.


Lux, Please don't appologize. It's only flashlights, dude. Take care of your dog and get to this when you have time, not before.


----------



## JimmyM (Jul 3, 2009)

smflorkey said:


> I'm enjoying your progress and the wonderful things I'm reading about this regulator. I ordered a Kiu socket kit for a D Maglite I don't even have yet, just so I'll be ready when I have a few more spare dollars for this regulator. I'm really looking forward to a sleeper light that will surprise people.
> 
> Having said that, and acknowledging that I have a tendency to build brick outhouses, I would like to remind you of Alan's suggestion to define a reasonable feature set and release the code when those features work. There will always be things to tweak. My biggest challenge when programming is to quit when it's good enough. It sounds like you may share that bug.


I am guilty of the same, but having something work isn't quite enough. It should be done right. This is my first attempt at a microcontroller based design, so I'm trying to build good habits and a solid coding methodology. For example, I know I'm redefining the same variable more than I have to in the loop just to make sure. I want to step through the code and remove superfluous code that just eats up cycles and space.


----------



## JimmyM (Jul 3, 2009)

OK. For the multiple level UI How does this sound...
Default values will be 87%, 94%, and 100%, in that order.

Compile time options will allow the setting of low-med-high values as any value you want in 32nds of the squared Vbulb, in any order you want. If you set one to 0, it skips that level and you now have a 2 level light. Set 2 to 0 and you have an ON-OFF interface.
You can set them all to levels < 32 if you want, but that doesn't make a lot of sense.
These percentages are all relative to the Vbulb value set by the pot.

In addition, the Vlow shutdown point is now configurable by the same 32nds values as above as well. If you set it to 0, it reverts to 50% of Vlow, If you set it to 32, it immediately shuts down.


----------



## petrev (Jul 3, 2009)

Hi Jimmy

:thumbsup::thumbsup::thumbsup:

Nailed It

Spot on
Cheers
Pete


----------



## Starlight (Jul 3, 2009)

EXCELLENT! Jimmy, that is perfect for me. As soon as you get this revision done, I will be ready for my other two regulators.


----------



## JimmyM (Jul 3, 2009)

Well, rev3b is ready to go. It can do everything 2a & 2b can do, but includes compile time options for a multi level UI. I just finished testing pretty much every compile time option combination I can, and things work quite nicely.
I'll be posting source code and a new connection diagram. To use the new UI, you need to wire it a little differently.


----------



## JimmyM (Jul 3, 2009)

Starlight said:


> EXCELLENT! Jimmy, that is perfect for me. As soon as you get this revision done, I will be ready for my other two regulators.


Starlight. In the Sale thread, I need to know what options you want. 
Vbulb(max):
Level1 Percentage:
Level2 Percentage:
Level3 Percentage:
Soft Start Speed: Slow, Med, Fast
Soft Ramping between levels: Yes/No
Vlow:
Vlow behavior: Pulse or dim
Vlow Timed shutdown: Yes/No, if Yes, how many seconds?
Vlow Undervolt shutdown: Yes/No if Yes, What percent?
Overtemp Warning temp: 50,60,70,80C
Overtemp Shutdown: Yes/No, if Yes, how many seconds


----------



## petrev (Jul 3, 2009)

JimmyM said:


> Well, rev3b is ready to go. It can do everything 2a & 2b can do, but includes compile time options for a multi level UI. I just finished testing pretty much every compile time option combination I can, and things work quite nicely.
> I'll be posting source code and a new connection diagram. To use the new UI, you need to wire it a little differently.


 
Hi Jimmy

Brilliant 

Just one thing :thinking: 
If it were possible to use a switched POS for the input to your pad A2 that would make wiring marginally easier - POS is available without rewiring from the newly momentary-modded switch ! To get the NEG you have to isolate the Pos-Slug and solder wire from the battery side of the switch module to the Neg grubscrew . . . 

but it's probably not an option ? and it's not much extra work !

Battery Side - Solder and flatten the old contact a bit !






Tape Isolation - Just in case . . .





Overall totally brilliant and it's arrived much quicker than I ever thought possible.

Cheers
Pete


----------



## JimmyM (Jul 3, 2009)

I hear ya Pete. That would be nice. But unless you only pass 5V to A2, you'll cook it. The exact same way I cooked one yesterday. I accidentally touched the A2 wire to 22V+. I heard a little spark, then it was shot. I have to replace the AVR now. Nice, Jimmy. Real nice.
To isolate the B+ spring cup from the switch internals, I pop the cup out with a screwdriver from the top side. Then place a small disk of plastic I cut out of a soda bottle. Then I pop the cup back in place. A piece of overhead transparency material would work nice too. Any kind of thin hard plastic.
I'll be doing a tutorial document of the process as soon as I can.


----------



## LuxLuthor (Jul 4, 2009)

JimmyM said:


> Compile time options will allow the setting of low-med-high values as any value you want in 32nds of the squared Vbulb, in any order you want. If you set one to 0, it skips that level and you now have a 2 level light. Set 2 to 0 and you have an ON-OFF interface.
> You can set them all to levels < 32 if you want, but that doesn't make a lot of sense.
> These percentages are all relative to the Vbulb value set by the pot.
> 
> In addition, the Vlow shutdown point is now configurable by the same 32nds values as above as well. If you set it to 0, it reverts to 50% of Vlow, If you set it to 32, it immediately shuts down.



Whoah.....Slow down there Bubba-Louie. I'm getting dizzy. I didn't follow that, and would like to. It would probably help if I looked at the code. Can you clarify what you mean by "compile time options" ? Is that the same as making changes in the code, or does it only refer to a specific functional feature?

Also, isn't the stock Mag switch considered momentary? So the control power in this scenario is always connected. Hooking up the new wire to the lug is how AWR did his Hotdriver connection which is pretty easy. Probably good to keep Rev 2 as well as 3 once it is also posted.


JimmyM said:


> To isolate the B+ spring cup from the switch internals, I pop the cup out with a screwdriver from the top side. Then place a small disk of plastic I cut out of a soda bottle. Then I pop the cup back in place.


I'm trying to figure out why you need to isolate the B+ spring/cup, but it will probably be obvious once I look at the new wire layout and your tutorial showing this new setup.

I'm a little concerned that the average user won't be able to keep up with all the changes if they haven't been following this regularly. I can see why AWR did the assembly for people who essentially wanted a drop-in. I would recommend a completely separate Tutorial for each Rev just so people don't get it confused.

Great work again!


----------



## JimmyM (Jul 4, 2009)

LuxLuthor said:


> Whoah.....Slow down there Bubba-Louie. I'm getting dizzy. I didn't follow that, and would like to. It would probably help if I looked at the code. Can you clarify what you mean by "compile time options" ? Is that the same as making changes in the code, or does it only refer to a specific functional feature?


Compile-time options mean that in specific places (instructions given in the code) you can change a value or comment-out/comment-in a line that changes what the compiled code does. This really only affects those users that choose to reprogram their regulators. Just one line changes the regulator from a multi-level UI to the original ON OFF. Once you see the code, it's pretty straight forward. Rev3b supercedes Rev2a in that Rev3B can do everything.


LuxLuthor said:


> Also, isn't the stock Mag switch considered momentary? So the control power in this scenario is always connected. Hooking up the new wire to the lug is how AWR did his Hotdriver connection which is pretty easy. Probably good to keep Rev 2 as well as 3 once it is also posted.


Nope. The stock mag switch CAN be used as momentary, but once you push it until it clicks it statys either on or off. That won't work for the pushbutton interface. It needs to be normally open and closes when pushed, then opens when released. When NOT using the multi-level UI, the original wiring method is still used. You ONLY have to use the different wiring if you want to use the Multi-level UI. Once you have changed the wiring to the Multi-level UI method, you can use the compile-time options to make the regulator act as though it's just a 1-level on-off regulator if you want. If you have it wired in already by the original method, you just don't use the compile time option for the multi-level UI. The design of this regulator is VERY versatile. You can go simple, like the HotDriver, or more complex like Alan's regulator. Don't even think about rotary encoders yet.:devil:


LuxLuthor said:


> I'm trying to figure out why you need to isolate the B+ spring/cup, but it will probably be obvious once I look at the new wire layout and your tutorial showing this new setup.


 The spring cup no longer connects to the switch. The switch (using the multi-level UI) connects the A2 pad to B-. If you allow the B+ spring cup to touch the switch, BAD things happen. It would be a dead short from B+ to B-.


LuxLuthor said:


> I'm a little concerned that the average user won't be able to keep up with all the changes if they haven't been following this regularly. I can see why AWR did the assembly for people who essentially wanted a drop-in. I would recommend a completely separate Tutorial for each Rev just so people don't get it confused.
> 
> Great work again!


I have to make an update to the sale thread explaining the diferences.


----------



## JimmyM (Jul 4, 2009)

Starlight said:


> EXCELLENT! Jimmy, that is perfect for me. As soon as you get this revision done, I will be ready for my other two regulators.


Starlight, I need to know what options you want. Unless you want to program your own. I haven't posted the new formware on Alan's site yet, but I can email it to you if you want.


----------



## petrev (Jul 4, 2009)

Hi Jimmy

NOTE to Pete : Must not post late at night if any brain input required !

Forgot totally about Logic+ and Batt+ :shakehead

The new Rev3b is just superb.

Love the way that as posted it acts just as Rev2. 
Then if you want to do the re-wire, and have multi-level Push-Button UI, you just Un-Comment one line and all the defaults are there . . .
(Ready for Play-Time !)

Wicked
Pete


----------



## Alan B (Jul 4, 2009)

You could use a resistor and zener to protect the micro input, or an opto. Then the [email protected] switch would not need to be rewired to split off the plus. Just taking the splines off one part would convert to momentary. It would be a lot easier but would require two more parts on the board.


----------



## JimmyM (Jul 4, 2009)

Alan B said:


> You could use a resistor and zener to protect the micro input, or an opto. Then the [email protected] switch would not need to be rewired to split off the plus. Just taking the splines off one part would convert to momentary. It would be a lot easier but would require two more parts on the board.


That depends on what you mean by "easier". Yes, it would work and allow the use of "switching the positive", but adding components seems more difficult than just running new wires (that you have to add anyway) a little differently. If the only possible use for the A2 connection was the pushbutton interface then I would have designed a little zener/resistor into the board. But that would have limited the use of the A2 pad. Hardware flexibility was the first goal of adding the extra ports to the board. Right now, the B0 and B1 ports are unused except for diagnostic output, but I envision using them for a rotary encoder input at some point. Or they could be used for outputs to LEDs under the switch cover. Lots of flexibility. I suppose I could have added an additional port, closer to the center, as a dedicated Vbat+ input for a pushbutton. But hindsight is 20/20.


----------



## JimmyM (Jul 4, 2009)

petrev said:


> Hi Jimmy
> 
> NOTE to Pete : Must not post late at night if any brain input required !
> 
> ...


Have at it, Pete. I see this as THE version for folks to use if they don't mind the additional wires. Even if you just want ON-OFF, it's just a compile time option away.


----------



## petrev (Jul 4, 2009)

JimmyM said:


> Have at it, Pete. I see this as THE version for folks to use if they don't mind the additional wires. Even if you just want ON-OFF, it's just a compile time option away.


 
Yeah - Cool to just have one hardware setup for 1/2/3 levels - only downside is standby drain - 0.1mA vs 1uA (?) still very small either way.

The Latching Single Power Wiring Method also allows for a tail-switch set-up so Mac (etc.) can make super shorty mods regulated too.

Cheers
Pete


----------



## JimmyM (Jul 4, 2009)

petrev said:


> Yeah - Cool to just have one hardware setup for 1/2/3 levels - only downside is standby drain - 0.1mA vs 1uA (?) still very small either way.
> 
> The Latching Single Power Wiring Method also allows for a tail-switch set-up so Mac (etc.) can make super shorty mods regulated too.
> 
> ...


Yeah. There's always a tradeoff. But, look at it this way. A 2400 mAh battery will take >24,000 hours to drain. That 1000 days. If you leave your batteries unattended for that long you need to turn in your Flashaholic badge.


----------



## petrev (Jul 4, 2009)

JimmyM said:


> Yeah. There's always a tradeoff. But, look at it this way. A 2400 mAh battery will take >24,000 hours to drain. That 1000 days. If you leave your batteries unattended for that long you need to turn in your Flashaholic badge.


 
Oh My God ! Who took my badge ? ? ?

:mecry:


----------



## Alan B (Jul 4, 2009)

JimmyM said:


> That depends on what you mean by "easier". Yes, it would work and allow the use of "switching the positive", but adding components seems more difficult than just running new wires (that you have to add anyway) a little differently. If the only possible use for the A2 connection was the pushbutton interface then I would have designed a little zener/resistor into the board. But that would have limited the use of the A2 pad. Hardware flexibility was the first goal of adding the extra ports to the board. Right now, the B0 and B1 ports are unused except for diagnostic output, but I envision using them for a rotary encoder input at some point. Or they could be used for outputs to LEDs under the switch cover. Lots of flexibility. I suppose I could have added an additional port, closer to the center, as a dedicated Vbat+ input for a pushbutton. But hindsight is 20/20.



Modding the [email protected] switch is a chore with all the drilling, cutting, grounding the switch, etc. There is a lot of potential for a short with the tight clearances. Reducing this to just making it momentary but still positive going is a lot less fuss. I would put the resistor/zener on the board for that, it is such a common situation. Even if the pads for the parts are on the board they don't have to be loaded. But the boards are already etched, so it is something for a future board. 

Back to work...


----------



## Starlight (Jul 4, 2009)

JimmyM said:


> Starlight, I need to know what options you want. Unless you want to program your own. I haven't posted the new formware on Alan's site yet, but I can email it to you if you want.



Jimmy, I can't program my own yet, because I ordered the equipment from AlanB and I don't have it. What I would like to do is return one of my first 3 regulators for you to convert to Rev3 code. Then you could send it back with the last 2 that I ordered. If that is okay, just send me an email with your address.


----------



## petrev (Jul 4, 2009)

Edit in


> #define BUTTONUI
> 
> 32 100% (L3 Default)
> 31 99%
> ...


 
BUILD

Program: 1576 bytes (38.5% Full) (32.8% for Single Level)

Not much room left then ! ! ! for LEDs / Rotary etc. :devil:

FLASH - Rev3b One Level (Rev2 Emulation) Works :thumbsup:

FLASH - Rev3b - Default 3 Levels Works too :thumbsup: :thumbsup: :thumbsup:

Ha Ha Found an extra feature already.

Based on 
2-Clicks from OFF straight to Level2
3-Clicks from OFF straight to Level3

2-Clicks from Level1 jumps to Level3 
2-Clicks from Level3 jumps to Level2 (down 1)
2-Clicks from Level2 jumps to Level1 (down 1)

Round and round we go . . .

Perfect

Works for me

Cheers
Pete


----------



## petrev (Jul 4, 2009)

Hi Jimmy

COOOOOL

L1 - Low Default is too bright for indoor daytime use with a 633 so I expect I can go lower and get extra runtime with a very usable (if slightly off-white) Low level



Can't wait for darkness to fall

Cheers
Pete


----------



## JimmyM (Jul 4, 2009)

Alan B said:


> Modding the [email protected] switch is a chore with all the drilling, cutting, grounding the switch, etc. There is a lot of potential for a short with the tight clearances. Reducing this to just making it momentary but still positive going is a lot less fuss. I would put the resistor/zener on the board for that, it is such a common situation. Even if the pads for the parts are on the board they don't have to be loaded. But the boards are already etched, so it is something for a future board.
> 
> Back to work...


See, but the thing is, for those who don't like the actual building of the light. Your regulator is the better solution. It's just a drop in. For those of us that enjoy the building part, it's no worse than installing a KIU on a Mag switch base. To each his own, I suppose. For those who like the building part, mine are much cheaper option for the Do-It-Yourselfer. Excatly the folks that I targeted with this design.
I'll consider the additional Bat+ button pad for a furure design.


----------



## JimmyM (Jul 4, 2009)

petrev said:


> Program: 1576 bytes (38.5% Full) (32.8% for Single Level)
> 
> Not much room left then ! ! ! for LEDs / Rotary etc. :devil:
> 
> Pete


 Kidding, right? There's a TON of room left. Most of that code space is taken up with the 32-bit math required to get full 10-bit ADC readings and 12-bit PWM. I'm actually stepping the pwm in steps of 2 to keep response to falling voltage tighter. But I could use single steps. So in effect I'm only using 11-bit PWM. But the frequencies and everything else worked out nicely. Alan has a S**T load more bells and whistles but slightly smaller code size, because his design only requires 16-bit math. He uses 8-bit ADC and 8-bit PWM. So the resulting code required for regulation is much smaller.
The UI features don't require as much space. So in the remaining 60% I could make this thing flash the star spangled banner. Or, in your case, God Save the Queen.
If you want to try using the full 12-bit PWM, edit the source code.
Towards the very bottom is a section like below...
---------
else
{
if ((vbatsqpwm < (vbulbsq - fastband)) || (vbatsqpwm > (vbulbsq + fastband)))

{
pwmstep = fastadj;
}
else
{
pwmstep = 2;
}
}
----------

Change "pwmstep = 2;" to "pwmstep = 1;" Happy hacking. :devil:


----------



## JimmyM (Jul 4, 2009)

petrev said:


> Oh My God ! Who took my badge ? ? ?
> 
> :mecry:


I just converted a 2xD-Lion Mag275 from an AWR HotDriver (personal comments witheld) to the JM-PhD-D1 using the Multi-Level UI. It took me a little while to figure out the best way, but I've figured it out. So when I do the tutorial document everything will work out nicely.


----------



## petrev (Jul 4, 2009)

Just Kidding 

Shed loads of room - amazing !

Thanks for the hack - Still playing with levels at the moment 

Just converted my Rev2 to a Rev3 - no problem.

My tunnel for the BIG Pos was quite big enough for a little extra wire and a couple of little grooves in the top for the extra Pos and the wire to A2 were all that was needed for the body.

Cut off the lower splines from the latching mech with a craft knife and did the NEG switch mod as shown above in my photos. #268

Not much effort at all . . .

Cheers
Pete


----------



## petrev (Jul 5, 2009)

Hi Jimmy

Having JM-PhD fun over here . . .

I have set my 633 to L1=20, L2=32, L3=12

This gives me MED : HIGH : Xtra.LOW
but I can get High with a Double BLIP
or Single BLIP for on MED or Triple BLIP for on X.LOW

Double BLIP for a 2 level HIGH:MED:HIGH: etc.

I have also found that when the OverTEMP kicks in I still get 3 levels at the reduced level - Neat.
But my counter seems not to work as OTShutdown doesnt happen after 30sec as set in default ? left for 60 seconds and still no shutdown !! 
No biggy for me but just wondering why it wasn't shutting down ?

One time I got the LOW-Batt warning and then soon after got the OverTEMP so it went into OT-DIM mode this didn't time out - the LOW-Batt may have stopped with the bounce from the reduced power output ? ? Not sure how your nested (?) multiple (?) logic works ! ! !

Yep - I am having FUN 

Cheers
Pete


----------



## JimmyM (Jul 5, 2009)

petrev said:


> Hi Jimmy
> 
> Having JM-PhD fun over here . . .
> 
> ...


Nice catch Pete. I was using the over temp event counter as the over temp timer as well. However it was only an 8-bit variable, so it could never count high enough. I also made a couple of other changes to "clean things up" when it comes out of a power-down condition.
I'll email you the code and forward the Rev3c version to Alan.

Once the over temp mode is triggered, it no longer looks for low voltage. The light can't be in low-voltage and over-temp conditions at the same time. Over-temp mode supercedes low-voltage mode. Once in over-temp mode, it will dim then, if desired, shutdown. However, in normal mode or low voltage mode it still checks for an over temp condition. Once in over-temp mode, the only way to get it out is to shut off the light and turn it back on. This is by design. However, in low-voltage mode it will go back into normal mode if the battery voltage recovers.


----------



## petrev (Jul 5, 2009)

:thumbsup:


----------



## Roland (Jul 5, 2009)

JimmyM said:


> Nice catch Pete. I was using the over temp event counter as the over temp timer as well. However it was only an 8-bit variable, so it could never count high enough. I also made a couple of other changes to "clean things up" when it comes out of a power-down condition.
> I'll email you the code and forward the Rev3c version to Alan.
> 
> Once the over temp mode is triggered, it no longer looks for low voltage. The light can't be in low-voltage and over-temp conditions at the same time. Over-temp mode supercedes low-voltage mode. Once in over-temp mode, it will dim then, if desired, shutdown. However, in normal mode or low voltage mode it still checks for an over temp condition. Once in over-temp mode, the only way to get it out is to shut off the light and turn it back on. This is by design. However, in low-voltage mode it will go back into normal mode if the battery voltage recovers.


The order sounds illogical to me. I believe that low voltage mode should do its work wether at the same time in overtemp mode or not.


----------



## JimmyM (Jul 5, 2009)

Roland said:


> The order sounds illogical to me. I believe that low voltage mode should do its work wether at the same time in overtemp mode or not.


OK. Sounds like an opportunity here.
Once in Over temp mode, I can make it still scan for low voltage, but what should it do if the condition is detected? It's already dimmed to 35% of Vbulb.
What behavior should it exibit if a low voltage condition is detected while in Over Temp mode?
Perhaps this...
If it's already dimmed by Over temp, it could blink off every few seconds if low voltage is detected. Then it would be a race to see what shuts it down first... Over Temp shutdown timer, Low voltage warning shutdown Timer, or the Under Voltage % trigger...


----------



## petrev (Jul 5, 2009)

JimmyM said:


> OK. Sounds like an opportunity here.
> Once in Over temp mode, I can make it still scan for low voltage, but what should it do if the condition is detected? It's already dimmed to 35% of Vbulb.
> What behavior should it exibit if a low voltage condition is detected while in Over Temp mode?
> Perhaps this...
> If it's already dimmed by Over temp, it could blink off every few seconds if low voltage is detected. Then it would be a race to see what shuts it down first... Over Temp shutdown timer, Low voltage warning shutdown Timer, or the Under Voltage % trigger...


 
Hi Jimmy

Blinking Off sounds good to me. :thumbsup:

I will probably not use the OTemp timer so to protect the batteries I think continuing to monitor for LowBatt is a good idea and use the same as normal - LVTimer/UV%Trigger/Both

Cheers
Pete


----------



## JimmyM (Jul 5, 2009)

OK. I'll see what I can work out.


----------



## JimmyM (Jul 5, 2009)

I'm going to leave the behavior the same for over-temp (dimming), but just implement the shutdown timer/voltage limitations for the low voltage warning selected as options..
The over-temp behavior (dimming) will supercede the low voltage warning bahavior (dimming or pulsing), but it will still keep monitoring for low voltage. If the low voltage level is tripped during over-temp mode it will start the low voltage timer and monitor for the undervolt %. If the conditions are met for shutdown under low voltage conditions while in over-temp mode (even if overtemp shutdown is not selected) the light will shutdown.
If you are already in low-voltage mode when over-temp is triggered, the low voltage timer is reset to 0 and the count begins again.
If, while in over-temp mode, the batteries recover, the low voltage timer is reset.


----------



## JimmyM (Jul 6, 2009)

So guys? How does that sound? I've written the code and tested it using my hot air rework station to "over heat" the chip in my test setup. I set the code to under 50C for testing purposes. I didn't want to heat it to 80C just for testing.

I uploaded the new code to my own Mag5761 and left it running. It went into over temp mode while the head of the light was still only very warm to the touch. So I added insulation between the bulb and KIU base. Now the head gets very hot (not 80C hot) and the regulator doesntt shut down in over temp.


----------



## JimmyM (Jul 7, 2009)

In an effort to screw around and possibly learn more AVR programming techniques I've been messing with the Rev3d code. In multi-level mode I have to declare some global variables which eats up code space. But several of them are simple things like 1 or 0 for startup mode.
So I figured why not try out the General Purpose I/O registers (GPIOR). In the process I've also split the "mode" (normal, low voltage, and over temp) into 2 parts. LVMODE 1/0, and OTMODE 1/0. So now, the regulator CAN be in both low voltage mode and over temperature mode. This allows me to carry over the low voltage timer if the regulator goes into over temp mode while in low voltage mode. So once in low voltage mode the low voltage timer just keeps running until shutdown even if it does into over temp mode 1 second before the low voltage timer is up.
The results of the above are both good and bad. In multi-level mode my memory usage has dropped a little, but the standard mode has risen a little.
Any way. I still want to keep messing around and testing with this before I call it good (functionally), so it's not an official release. There's still one more GPIO register to tinker with.


----------



## JimmyM (Jul 7, 2009)

I keep replying to myself. Oh well.
With some more tinkering... I've kept the low voltage timer carryover, gotten rid of the global variables, not used the GPIO registers, I've made the number of available levels 5 instead of 3, Just don't use the ones you don't want.
AND shrunk the code more.


----------



## Bimmerboy (Jul 8, 2009)

JimmyM said:


> I keep replying to myself. Oh well.



And we're still reading! :wave: Clichéd as this may sound... more great work, Jimmy. 

OK, enough bologna from my end... I'm ready to order (freakin' finally! ).

Sending PM tomorrow to ask a final question or two, then bombs away!


----------



## Raoul_Duke (Jul 8, 2009)

JimmyM said:


> I keep replying to myself. Oh well.
> With some more tinkering... I've kept the low voltage timer carryover, gotten rid of the global variables, not used the GPIO registers, I've made the number of available levels 5 instead of 3, Just don't use the ones you don't want.
> AND shrunk the code more.





Well just to let you know I'm also still reading...and keep hovering over the PP button, but you keep improving things.....(+ I have been too busy to follow closely)...but i'm still at least good for two ( maybee more) when you stop fiddling 

I think you have all the stuff I wanted (and more), but may look to swap things about, like have one set up for a fast-straight to high for a "tactical type bump in the night light" with the option of going down modes for runtime, and one regular for torch type duties.....So many posibilities...Great Work


----------



## JimmyM (Jul 8, 2009)

Thanks, guys.
But I'm not sure what else I can do to the software right now. It does everything I want it to. Once testing on this code is done I'll release it. Although it doesn't really improve much over Rev3d. Then, I'm going to give it a rest for a while. At some point I'll start working on code for a rotary encoder. I'm still working on other designs; X1 (L14K regulator), P1 (Mag bulb slide mounted ROP/Mag85 regulator).

The only hanging question posed a while back was that of battery temperature. That you couldn't really use the internal temperature sensor of the AVR to predict the temperature of the batteries.
But, remember those additional pads? You could use one to monitor a thermistor mounted in the battery section. If anyone wants to get that adventurous, I'll help you out with wiring and code. But since it's a hardware hack too, it won't be part of the normal release code.


----------



## petrev (Jul 8, 2009)

Mag C ?


----------



## JimmyM (Jul 8, 2009)

petrev said:


> Mag C ?


Yeah. The C1.......
I'm just not sure how it would be incorporated into the switch. On the bottom, it would need special protection from impact from the batteries. On the top, it would need protection from the heat of the bulb since it can't sit under the KIU base like the D1. Then there's the matter of the switch mod to enable pushbutton operation. The B+ tab on the switch is the same piece of metal that is one of the internal switch contacts. I'd have to come up with a process or modding methodology, then build/assemble the switches myself. I still have some thinking to do about that one.


----------



## petrev (Jul 8, 2009)

:thinking:

:candle:

Good Luck !


----------



## LuxLuthor (Jul 8, 2009)

I'm getting freaked out how behind I am becoming in this thread, while preoccupied. "Petrev has the con!" (as in submarine "con").


----------



## JimmyM (Jul 8, 2009)

LuxLuthor said:


> I'm getting freaked out how behind I am becoming in this thread, while preoccupied. "Petrev has the con!" (as in submarine "con").


Yeah, Lux. Can't turn your back on us for a minute.


----------



## JimmyM (Jul 9, 2009)

Pete, Lux,
Care to do a little testing of Rev3e for me? I've tested all I can, care to give it a go?


----------



## petrev (Jul 9, 2009)

JimmyM said:


> Pete, Lux,
> Care to do a little testing of Rev3e for me? I've tested all I can, care to give it a go?


 
:thumbsup:

Willco


Waiting for e-mail . . .

Arrived . . . Thanks
Build 44.1%
Working as expected . . . 5 Levels


----------



## JimmyM (Jul 9, 2009)

petrev said:


> :thumbsup:
> 
> Willco
> 
> ...


Things get smaller with fewer levels. After re-coding things it got smaller. It used to be 45+% with just 3 levels. Have you changed the adcvalue = ADCW code yet?


----------



## petrev (Jul 9, 2009)

JimmyM said:


> Things get smaller with fewer levels. After re-coding things it got smaller. It used to be 45+% with just 3 levels. Have you changed the adcvalue = ADCW code yet?


 
This is using the latest (last) code you sent 

while(ADCSRA & _BV(ADSC)); // Wait for conversion to complete.
adcvalue = ADCW; // Read ADC value to a variable using ADCW Macro
// adcvalue = ADCL; // Read ADCL value to a variable
// adcvalue |= ( ADCH << 8 ); // Add Left shifted ADCH value to existing adcvalue
adcsum = adcsum + (uint32_t)adcvalue * adcvalue; // Square the ADC value and force to 32-bit


I haven't changed the code but I have changed to the latest !

Seems OK ! is that what you meant me to do ?

Cheers
Pete

EDIT: 
Changed to my Standard 3 levels plus 2 extra intermediate levels to prove the 5 levels
OverTemp working . . .


----------



## JimmyM (Jul 9, 2009)

I found a problem with the adaptive soft start. It wasn't computing the "vratio" correctly. As a result, the larger the difference between Vbulb and Vbat, the steeper the soft start ramp gets. I'll forward a fix. So far, no one's configuration has a big difference between Vbat and Vbulb to make much of a difference, but it's a correction that bears correcting. This leads me to want to investigate further my ADC reading squaring math as well.
I'll forward code after I've done some more research.


----------



## Bimmerboy (Jul 9, 2009)

No problem here until I want an Ellie II powered Strion with fast ramping. 

Really, Jimmy... the speed in which you're improving and developing this thing is impressive.

Here comes the cliche once again. Great work!


----------



## petrev (Jul 10, 2009)

JimmyM said:


> I found a problem with the adaptive soft start. It wasn't computing the "vratio" correctly. As a result, the larger the difference between Vbulb and Vbat, the steeper the soft start ramp gets. I'll forward a fix. So far, no one's configuration has a big difference between Vbat and Vbulb to make much of a difference, but it's a correction that bears correcting. This leads me to want to investigate further my ADC reading squaring math as well.
> I'll forward code after I've done some more research.


 
Hi Jim

I am just getting around to a 5-6A123 with a 5761 fitted so that might be in the ball park to test this !

Thanks for the updates seems to be working well. Will build the 5761 when you get the vratio fix out.

Cheers
Pete


----------



## JimmyM (Jul 10, 2009)

petrev said:


> Hi Jim
> 
> I am just getting around to a 5-6A123 with a 5761 fitted so that might be in the ball park to test this !
> 
> ...



I've tested the fixed adaptive ramping using 35V Vin with a 10V Vbulb. It now works as intended. I've checked my math in other areas too and it's all working fine.
The "broken" code would show up too if you wanted a slow start with a 13.4V 64625 using a high voltage pack. You would get a faster start up than wanted.


----------



## petrev (Jul 10, 2009)

JimmyM said:


> I've tested the fixed adaptive ramping using 35V Vin with a 10V Vbulb. It now works as intended. I've checked my math in other areas too and it's all working fine.
> The "broken" code would show up too if you wanted a slow start with a 13.4V 64625 using a high voltage pack. You would get a faster start than up wanted.


 
Hi Jimmy

Nice quick work :thumbsup:

I'll be waiting by the (e)mailbox

Cheers
Pete


----------



## JimmyM (Jul 10, 2009)

I was stepping through the code and realized that I had an extra section of code to check low voltage from within the over temp routine. I don't need that any more since I'm checking it all the time, outside the overtemp behavior, now any way. So I chopped it out. 41.6% down to 40.4%.

Pete, code emailed.


----------



## LuxLuthor (Jul 11, 2009)

Sent an email about latest Ver 3 matchup, as I want to test it in the Delorean to regulate the 1.21 Gigawatts into flux capacitor, and was concerned about the fixed adaptive ramping.


----------



## petrev (Jul 11, 2009)

Hi Jimmy

3-Levels - Build 40.4% Full 

Setup for 5761

Measuring - Variations in method . . .



> Fluke AC+DC
> 100% = 6.85V
> 79% = 5.37V (-0.04V error -0.7% vs expected)
> 61% = 4.12V (-0.06V error -1.3%)
> ...


So people ? ? ?
What is the "real" output ?

I am using* SQRT(Vin*Vbulb) *for now to be on the safe side as this is my last 5761 - looks nice and white at 100%

Back to topic - Regulator is working superbly
6xA123 driving a 5761 at about 7V (7.2V?) from 20V batt pack
My fav 3 levels and looks lovely.

:thumbsup:
Cheers
Pete


----------



## JimmyM (Jul 11, 2009)

petrev said:


> Hi Jimmy
> 
> 3-Levels - Build 40.4% Full
> 
> ...



I just assume that the Fluke is the truth if it's given a few seconds to settle down. But that can be tough given that the battery voltage is falling. The fact that the PWM variations are so small while in regulation (1/4095), may make it easier to the Fluke to give a correct reading.
Your calculation using duty cycle is different. I've never seen it implemented that way. Usually I use...
RMS = SQRT((Vbat^2)*Duty) 
Thus...
RMS = SQRT((19.36^2)*0.1655))
RMS = 7.876
So it's right, but I've just not seen it worked that way.
There are so many ways to measure things and so many errors that can be intruduced, I think the only truly accurate way would be to use a good scope to measure duty and the peak voltage at the bulb. I know that the 64725 is a very sensitive bulb. It really doesn't like voltage over 7.2. I've been using one at 7.15V (measured by Fluke 189 AC+DC) for a while now, and it seems to be lasting.


----------



## Alan B (Jul 11, 2009)

The various techniques with scope and averaging meter only work correctly for flat-top square waves. This occurs under light loads such as a 10K resistor. Under heavy loads the waveform shape can change and then they are not accurate. True AC+DC RMS meters take the shape into account and will be more accurate within their duty cycle range. At very low duty cycles they also have problems. Measurements have their limits.


----------



## petrev (Jul 11, 2009)

Hi

Thanks guys 

My thoughts were that the Fluke should be the closest as it takes the waveform into account so good to get your input. Just need to find another Fluke so that I can physically check they are reading the same.

64275AX is a wicked bulb (especially as the AXial filament makes the beam so nice) but as you say very sensitive, so really needs a regulator to get the ultimate from it.

Your formula is the same as mine (found it here RMS Calculator - nice little tool) 

SQRT((Vbat^2)*Duty) = SQRT(Vbat^2)*SQRT(Duty) = Vbat*SQRT(Duty)

Cheers
Pete


----------



## JimmyM (Jul 11, 2009)

petrev said:


> Hi
> 
> Thanks guys
> 
> ...


I agree, they're the same. I just hadn't seen it reduced that way before.

So, what's next for the JM-PhD-D1?
Starlight's email to me a couple of days ago has developed into a bit of a firestorm in my head. His email led me to slap together a loose design for a "slave board" of sorts. It would allow the JM-PhD-D1 to operate in an 80V environment of almost unlimited current. It wouldn't fit under a KIU base.

On a separate board use a regulator capable of 80V input to supply 12V output. That can supply the JM-PhD-D1 with power and supply an FET driver with voltage to drive 1, 2, 3, or more Big FETs Like the IRFS3107 (75V).

The second board could even have a place to mount the JM-PhD-D1.


----------



## JimmyM (Jul 22, 2009)

I've been doing some messing around with an LCD ScreenKey. I have a Tiny84 that does all the regulation that my current driver does, plus it drives a small LCD display. It displays the level, over current or low voltage condition and changes the color of the back-light depending on condition.
It may be possible to connect the LCD to the D1's Tiny44, but displayed messages would be a lot more rudimentary due to the reduced storage/ram available on the Tiny44.
The "full" version will run on a different chip and will probably offload the LCD clock and data bit-banging to a Tiny25. The real storage and continuous regulation duties would be done by a more robust chip. Probably the ATMega324/644. This for the X1, but thought that the folks here might like an update.


----------



## lctorana (Sep 9, 2009)

Hi Jimmy,

Just starting to get interested in these.

_(Up until now, I've been a strict direct-drive man, with the occasional NTC my only deviation from the strait and narrow.)_

My question is this: If I want to use one of these outside a Maglite, to what sort of heatsink, and how big, does this board need to be connected? Or is a heatsink not necessary?

_I'm getting interested, because I've been experiencing expensive bulb failures in my big-power sealed-beam lantern hotwires due partly, I suspect, to relay contact bounce. This module would totally eliminate that. The context is PAR36 lanterns, the second-biggest of which is 28V 250W - within your module's capability._


----------



## ^^Nova^^ (Sep 9, 2009)

Hi LC,

When these are installed into mags, there is no heatsink, they sit loose under the KIU base. In a bigger light I would think there is even less of a problem (just don't place it right beside the monster bulb). Besides, there is overtemp cutout to protect the driver if it gets too hot.

Cheers,
Nova


----------



## petrev (Sep 10, 2009)

Hi Jimmy

X1 

? ? ? ? ? ? ?

How did I miss that . . .

Just checking out the thread !

Great stuff - must read more . . .

Love the digital rotary pot - nice idea with the display etc. - etc.

Cheers
Pete


----------



## JimmyM (Sep 10, 2009)

lctorana said:


> Hi Jimmy,
> 
> Just starting to get interested in these.
> 
> ...



Nova's correct. At 28V/250W (<10A) no heatsinking is necessary.
This regulator also gives you the opportunity to add a few extra cells if you have room. This will increase runtime without having to worry about the bulb.


----------



## JimmyM (Sep 10, 2009)

petrev said:


> Hi Jimmy
> 
> X1
> ? ? ? ? ? ? ?
> ...


Oh, I thought you knew about that thread. Sorry. I was thinking last night about involving you in the development since you seem to like the big lights and have a bit of experience there.


----------



## petrev (Sep 10, 2009)

JimmyM said:


> Oh, I thought you knew about that thread. Sorry. I was thinking last night about involving you in the development since you seem to like the big lights and have a bit of experience there.


 
Hi Jimmy

Just found I need one more than I thought !

My old PK1000W has a new problem ? I got some new DeWalt A123 packs and they seem too powerful - holding 35V+ after charge and not dropping as much under load ! ! ! So I really need a regulator now not just a soft starter to control the extra oomph . . .

All in all great news you are developing one - let me know how I can help

Cheers
Pete


----------



## JimmyM (Sep 10, 2009)

petrev said:


> Hi Jimmy
> 
> Just found I need one more than I thought !
> 
> ...


Will do. Keep an eye on the X1 thread.


----------



## lctorana (Sep 13, 2009)

Hi Jimmy,

Now I have three more questions.

1) What is the current draw of the "control power" circuit? A few mA?
_(just wondering about whether I can get away with a switch that has high resistance in the contacts)_

2) Would an NTC in series with the regulator (e.g. built into the battery) upset the operation of the regulator?
_(just wondering about the effects of internal impedance)_

3) Fuse ratings question.
Normally with full direct drive of incan bulbs, you rate the fuse at 3.5 times the operating current.
So for a 10A bulb, you use a 35A fuse.
Obviously, with your soft-start and soft-ramp features, the extra inrush current is reduced, but by how much?
For a 10A bulb switched by this regulator, how low can I go with my fuse?

Sorry to be a pain with all these questions, but lantern hotwire design differs from Mag modding in several subtle ways. Thanks for your patience, and order coming soon.


----------



## ^^Nova^^ (Sep 13, 2009)

I'm not sure of 2 & 3, but I asked Jimmy about the switch current in the sales thread. IIRC he said about 5mA of current, basically any switch will do. 

Just had a thought, that was for the multimode version I asked, but I imagine the standard on/off version would be similar. It only needs enough current to drive the FET.

Cheers,
Nova


----------



## JimmyM (Sep 14, 2009)

^^Nova^^ said:


> I'm not sure of 2 & 3, but I asked Jimmy about the switch current in the sales thread. IIRC he said about 5mA of current, basically any switch will do.
> 
> Just had a thought, that was for the multimode version I asked, but I imagine the standard on/off version would be similar. It only needs enough current to drive the FET.
> 
> ...


Nova's right about #1. About 5ma running, 0mA off in standard mode, and 0.1mA in multi-level mode.

#2. The NTC would only serve to dissipate power as heat. It will still run, but your runtime will be reduced a little by the heat generated by the NTC.

#3 I'd use a 15A. Fuses blow because if the power they consume during over current. They melt. So they are rated by RMS amps. Even though your light may be drawing 40A during start up, it's only drawing that 40A in tiny spikes, the RMS rating is much lower. So 15A should work out just fine. Don't use a Fast-Blow fuse. Just use a standard fuse.


----------



## lctorana (Sep 14, 2009)

Awesome, thanks!

I'm still working on design parameters, in particular, puzzling over how much overdrive to set the regulator at.

Order coming soon!


----------



## Juggernaut (Sep 21, 2009)

lctorana said:


> Awesome, thanks!
> 
> I'm still working on design parameters, in particular, puzzling over how much overdrive to set the regulator at.
> 
> Order coming soon!


 
What bulb do you want to use?


----------



## lctorana (Sep 21, 2009)

Juggernaut said:


> What bulb do you want to use?


The Q4509, one of which I blew last year, and the 4596.

Actually, now I'm posting in this thread again, one more question:

I do need to provide reverse-polarity protection for the regulator, don't I?


----------



## JimmyM (Sep 21, 2009)

lctorana said:


> The Q4509, one of which I blew last year, and the 4596.
> 
> Actually, now I'm posting in this thread again, one more question:
> 
> I do need to provide reverse-polarity protection for the regulator, don't I?



Yes, you do. I'd suggest polarized battery connectors.


----------



## lctorana (Sep 21, 2009)

JimmyM said:


> Yes, you do. I'd suggest polarized battery connectors.


Thanks - I really had thought so.

Polarized connectors are literally impossible, so I'll be going with a suitably rated diode. And yes I DO know that means a giant stud-mounted job that will drop a whole volt and need room and a heatsink. This means a metal host.

Just another reason why lantern hotwire design differs from Maglite hotwiring.


----------



## Mr Happy (Sep 21, 2009)

lctorana said:


> Polarized connectors are literally impossible, so I'll be going with a suitably rated diode. And yes I DO know that means a giant stud-mounted job that will drop a whole volt and need room and a heatsink. This means a metal host.


How about if you get creative and put the diode in a different place?

This may be just a brain fart, but I'm thinking this:

```
V+ o---[~]-----+----------->
        F1     |
              ---
              / \ D1     to driver
              ---
               |
0  o-----------+----------->
```
If you connect the battery the wrong way round it will blow the fuse with a momentary reverse voltage to the driver that does not exceed the diode voltage drop. Unless the driver is very sensitive it will probably survive this.

Workable? Or crazy?


----------



## lctorana (Sep 21, 2009)

I love your thinking, as always Mr Happy, but I am just not brave enough to have my reverse-polarity protection of a massive 30V battery straight into a foward-biassed diode.

It would work, of course, but with a VERY big bang. Remember I'm talking about a 30V, 20+A-capable battery protected by a 15A cartridge fuse.

This would also necessiate a fast-blow fuse, whereas the incan lamp requires a slow-blow. Two fuses - no this is already getting complicated, quite apart from the fear factor.

I'm a scaredy-cat at heart, and I like my foolproofing to be gentle.


----------



## Mr Happy (Sep 21, 2009)

I respect your caution. It is after all a rather outrageous idea.

On a different subject however, do you still need a slow blow fuse when you have a soft start driver in the loop?


----------



## lctorana (Sep 21, 2009)

Mr Happy said:


> do you still need a slow blow fuse when you have a soft start driver in the loop?


Post #333 suggests so.


----------



## Mr Happy (Sep 21, 2009)

lctorana said:


> Post #333 suggests so.


Ah, noted. Actually I was thinking that a "slow blow" fuse is something different from a standard fuse. Post #333 just advises to use a standard fuse.


----------



## lctorana (Sep 21, 2009)

Me too, but he said "_*Don't use a Fast-Blow fuse*. Just use a standard fuse._"

Now to me, a "fast-blow" and a "standard" fuse are totally synonomous. Therfore I assumed he must have been referring to slow-blow when he said "standard".


----------



## JimmyM (Sep 22, 2009)

lctorana said:


> Me too, but he said "_*Don't use a Fast-Blow fuse*. Just use a standard fuse._"
> 
> Now to me, a "fast-blow" and a "standard" fuse are totally synonomous. Therfore I assumed he must have been referring to slow-blow when he said "standard".


OK. Perhaps I wasn't clear enough.
Just use an AGC (or similar) type automotive fuse. Not a specially labelled slow-blow fuse. That should be fine.


----------

