Electronics > Projects, Designs, and Technical Stuff
Cheap Chinese Cree XM-L T6 modification
<< < (3/6) > >>
0xdeadbeef:

--- Quote from: Rick Law on December 12, 2015, 07:07:30 pm ---Detecting the clicky:  You don't.  But you know if it got turn off, and the chip has EEPROM to save that.
--- End quote ---
Well, writing to EEPROM in a situation where you are about to lose power is certainly a bit risky.
Without further checking, I'd assume the 100k cycles are most probably not given for worst case conditions (like high temperature and low voltage).
Besides I still think that with a proper circuit design, it would be possible to detect the click without undervoltage/reset.
E.g. larger capacitor for the tiny's VCC separated by a diode so it only supports the tiny.



--- Quote from: Rick Law on December 12, 2015, 07:07:30 pm ---If you are a beginner, don't make that your first project.  Start with the Arduino UNO or NANO first.  You have more examples and room on the chip to learn. (32K flash...)
[...]
If you are interested in doing your own, you need to learn programming.  As I said, Arduino may be a good place to start, and Arduino makes a good ISP programmer for the Nanjg105c.  The only additional hardware you may need would be an SOIC clip.  Software wise, beyond Arduino, you will need to learn how to use WinAVR/AVRDude.  There are lots of examples on the web on doing that.  I recommend searching for "STARS" by JonnyC, and "Dr. Jones Minimalist driver".

--- End quote ---
Hm, if you'd knew how funny this is ;)
Rick Law:

--- Quote from: 0xdeadbeef on December 12, 2015, 07:44:39 pm ---
--- Quote from: Rick Law on December 12, 2015, 07:07:30 pm ---Detecting the clicky:  You don't.  But you know if it got turn off, and the chip has EEPROM to save that.
--- End quote ---
Well, writing to EEPROM in a situation where you are about to lose power is certainly a bit risky.
Without further checking, I'd assume the 100k cycles are most probably not given for worst case conditions (like high temperature and low voltage).
Besides I still think that with a proper circuit design, it would be possible to detect the click without undervoltage/reset.
E.g. larger capacitor for the tiny's VCC separated by a diode so it only supports the tiny.

--- End quote ---

No no...  I didn't take the approach of brown-out detect to write.  The EEPROM is written before the choice-blinks are on.  It then blinks N times each lasts over 1 second.  If it didn't get turned off (ie:did not select), then it proceed to write the original state back.


--- Quote from: 0xdeadbeef on December 12, 2015, 07:44:39 pm ---
--- Quote from: Rick Law on December 12, 2015, 07:07:30 pm ---If you are a beginner, don't make that your first project.  Start with the Arduino UNO or NANO first.  You have more examples and room on the chip to learn. (32K flash...)
[...]
If you are interested in doing your own, you need to learn programming.  As I said, Arduino may be a good place to start, and Arduino makes a good ISP programmer for the Nanjg105c.  The only additional hardware you may need would be an SOIC clip.  Software wise, beyond Arduino, you will need to learn how to use WinAVR/AVRDude.  There are lots of examples on the web on doing that.  I recommend searching for "STARS" by JonnyC, and "Dr. Jones Minimalist driver".

--- End quote ---
Hm, if you'd knew how funny this is ;)

--- End quote ---

Hmm...  Now you have me curious.  What can I bribe you with so you tell me?  I can part with a 1 Mega Ohm metal film 1/4W resister.  A whole million ohms!  Million!  With 6 zeros after the one.  Even if you use 100 ohms a day, it will last you a life time.  Send to a Swiss account of your choice so it is untraceable.

(I think you mean you are already experienced programmer or hacker.  But I can't forgo the chance of making a joke...)
0xdeadbeef:

--- Quote from: Rick Law on December 12, 2015, 09:05:04 pm ---No no...  I didn't take the approach of brown-out detect to write.  The EEPROM is written before the choice-blinks are on.  It then blinks N times each lasts over 1 second.  If it didn't get turned off (ie:did not select), then it proceed to write the original state back.
--- End quote ---
Anyway, if the Tiny is switched off more or less immediately when the flashlight is switched off, this could happen during an EEPROM write. And that's pretty bad for data integrity, most probably also for data retention.
I mean, OK, it's just a flashlight an you know when you shouldn't switch it off, but I'd had my concerns to bring something like this into production.


--- Quote from: Rick Law on December 12, 2015, 09:05:04 pm ---
--- Quote from: 0xdeadbeef on December 12, 2015, 07:44:39 pm ---Hm, if you'd knew how funny this is ;)

--- End quote ---

Hmm...  Now you have me curious.  What can I bribe you with so you tell me?  I can part with a 1 Mega Ohm metal film 1/4W resister.  A whole million ohms!  Million!  With 6 zeros after the one.  Even if you use 100 ohms a day, it will last you a life time.  Send to a Swiss account of your choice so it is untraceable.
(I think you mean you are already experienced programmer or hacker.  But I can't forgo the chance of making a joke...)

--- End quote ---
Well, letting aside that I'm into programming for >30years and that I design and develop embedded software for a living since nearly 17 years, but most importantly I lost my interest in AVR development years before the first Arduino board was developed ;)
Rick Law:

--- Quote from: 0xdeadbeef on December 13, 2015, 12:24:18 am ---
--- Quote from: Rick Law on December 12, 2015, 09:05:04 pm ---No no...  I didn't take the approach of brown-out detect to write.  The EEPROM is written before the choice-blinks are on.  It then blinks N times each lasts over 1 second.  If it didn't get turned off (ie:did not select), then it proceed to write the original state back.
--- End quote ---
Anyway, if the Tiny is switched off more or less immediately when the flashlight is switched off, this could happen during an EEPROM write. And that's pretty bad for data integrity, most probably also for data retention.
I mean, OK, it's just a flashlight an you know when you shouldn't switch it off, but I'd had my concerns to bring something like this into production.

--- End quote ---

Can't think of better ways to "click select" with just an On Off button.  The sequence is:
- write the select bit into eeprom
- blinkLow N times for choice N then Stay HI for 2 seconds, turned off to select
- rewrite the original byte resetting the select bit
- Increase N and reloop
So I am indeed exposed to the light being turned off while writing.  If it has just one more button... 




--- Quote from: 0xdeadbeef on December 13, 2015, 12:24:18 am ---

--- Quote from: Rick Law on December 12, 2015, 09:05:04 pm ---
--- Quote from: 0xdeadbeef on December 12, 2015, 07:44:39 pm ---Hm, if you'd knew how funny this is ;)

--- End quote ---

Hmm...  Now you have me curious.  What can I bribe you with so you tell me?  I can part with a 1 Mega Ohm metal film 1/4W resister.  A whole million ohms!  Million!  With 6 zeros after the one.  Even if you use 100 ohms a day, it will last you a life time.  Send to a Swiss account of your choice so it is untraceable.
(I think you mean you are already experienced programmer or hacker.  But I can't forgo the chance of making a joke...)

--- End quote ---
Well, letting aside that I'm into programming for >30years and that I design and develop embedded software for a living since nearly 17 years, but most importantly I lost my interest in AVR development years before the first Arduino board was developed ;)

--- End quote ---

Hats off to you!  Really.  I thought you were just starting off with the Arduino.  Most less matured or less "nice" individuals (regardless of age) would have taken the opportunity to "set me right" or "dress me down" since I talked to you as if you were a beginner.  You acted in ways I wish I do.  So hats off to you.
0xdeadbeef:
Ok, while I guess the EEPROM approach could be made pretty robust to also cover (undervoltage) resets during writing, I still wonder if the EEPROM is really needed with the according circuit.
I understand that using the EEPROM is the common solution for the Nanjg boards, so take this as merely academic comment.
I attached a simplified circuit of what I have in mind. It would all a bit easier to imagine if the switch would disconnect the plus pole, but usually the minus pole is disconnected which kinda leaves the ground floating.

Nevertheless, I guess it should be possible to supply the Tiny from its "own" capacitor for a while after the flashlight was switched off. In the grossly simplified circuit diagram I attached, the Tiny is represented by the 1MOhm resistor. Which is a bit optimistic obviously, but just to get the idea. The problem is obviously that the charge stored in the capacitor would be used up by the rest of the circuit - mainly the LED of course (again massive simplification with a low current LED and 1k resistor for current limitation). So we need a diode that forbids that. But since the minus pole is switched, we need it between the capacitor's virtual ground and the ground used by the rest of the circuit.

Obviously the diode's forward voltage will introduce a voltage drop on the capacitor and thus also on the Tiny's supply voltage. However using a Schottky diode and considering the rather low current flowing through the diode, the voltage drop should be acceptable. I understand the Tiny works down to 1.8V, so even a voltage drop of 0.4V would mean it would work until the battery voltage drops below 2.2V - which would be a seriously dead Li-Ion. Anyway, the diode also influences the voltage measurement as the Tiny's ground reference will be like 0.4V above that of the battery -> voltage difference has to be measured physically and considered in the Tiny's calculation.

So let's say we have a 3.6V battery voltage and a 10µF capacitor: this means the charge is 36e-6 Coulomb or 36e-6 As. Which can be read as 36µA for one second.
Now the Tiny is said to consume 190µA at 1.8V when active (1MHz) but that seems to be only possible with an external oscillator. With the internal 4.8Mhz oscillator, it's probably more in the 1mA range.
Probably above that due to driving pins, ADC etc.
Still, I guess the Tiny could survive a voltage drop for seconds if would switch to idle mode when it detects the dropping voltage (through ADC) fast enough.

I must admit though that this approach would need additional parts (increased costs and space needed) and id probably trickier to implement that the EEPROM solution.
Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod