Author Topic: How do we know if software has way too many EEPROM writes?  (Read 10636 times)

0 Members and 1 Guest are viewing this topic.

Online Ice-Tea

  • Super Contributor
  • ***
  • Posts: 3070
  • Country: be
    • Freelance Hardware Engineer
Re: How do we know if software has way too many EEPROM writes?
« Reply #50 on: February 03, 2018, 09:36:28 pm »
Quote from: janoc

I

And a linear reg for dropping rectified mains (i.e. some 300V) down to 3.3-5V?!?! I do hope there is at least some pre-regulator there

In theory nothing wrong with that. Microchip has a few nice LDOs for this purpose.
 
The following users thanked this post: ocset

Offline ocsetTopic starter

  • Super Contributor
  • ***
  • Posts: 1516
  • Country: 00
Re: How do we know if software has way too many EEPROM writes?
« Reply #51 on: February 03, 2018, 10:11:44 pm »
Thanks, i have the main.c code now, but they still havent given me the header files.
We were just wondering, we realise that PIC16F1704  has 128 bytes of EEPROM.
Therefore, to  "Initialise" this flash, would need 5ms per byte?
That would mean about  640ms  seconds would be needed to erase and write each EEPROM byte at startup?
We realise this is still way short of the 15 seconds of continuous ~6-7mA of current draw that we are getting from the  2V5 rail.

(The other ICs on the 2V5 rail only draw 1mA.)
 

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13738
  • Country: gb
    • Mike's Electric Stuff
Re: How do we know if software has way too many EEPROM writes?
« Reply #52 on: February 03, 2018, 10:14:48 pm »
Why would you want to initialise EEPROM at runtime?
If you need specific defaults these can be programmed via the hex file when the code is written.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: ocset

Offline BrianHG

  • Super Contributor
  • ***
  • Posts: 7726
  • Country: ca
Re: How do we know if software has way too many EEPROM writes?
« Reply #53 on: February 04, 2018, 12:23:18 am »
I've come to the conclusion that this is all part of an elaborate troll. I wonder if this company that is the victim of all manner of unfortunate and improbable events really exists.
Based on treez's history of posts, I would say he has a company who doesn't have the budget & guaranteed forecast sales to warrant properly getting a loan of enough money to get the right test gear and the right engineers on hand as full time employees to achieve a small to medium sized one time custom purchase order they were lucky to get.  Or, unlucky if you take into account all the problems which will end up costing more in the long run than if the project was done with the appropriate budget and personnel from day one.
« Last Edit: February 04, 2018, 12:25:42 am by BrianHG »
 
The following users thanked this post: ocset

Offline MT

  • Super Contributor
  • ***
  • Posts: 1616
  • Country: aq
Re: How do we know if software has way too many EEPROM writes?
« Reply #54 on: February 04, 2018, 01:08:34 am »
If you've been paying attention (I don't mean this perjoratively: just that, others here have been following this slow-motion train wreck for dozens of threads :o ), you'll notice that treez thanks almost every post in reply, even the highly critical ones.
yes i haved noticed he thanks  even critical posts but is there a "requirement" to pay attention?
What if i just feel to be lazy and ignorant?

Anyho, no have not paid attention to Treez and the other threads but i'm perfectly fine with
everyone  else is paying attention to his his eventual train wreck.

Quote
Alas, words -- not even words, the mere press of a button rather -- are rather shallow.
Yes, i concur and when Dave implemented this i "verbally objected" to it as shallow.

Quote
I'll pay attention when "has thanked this post" turns into "has donated $5 in thanks for this post". ;D
Tim
I think you should request at least 10 bitcoins instead of Donald dullars. :)
 
The following users thanked this post: T3sl4co1l, ocset

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3785
  • Country: de
Re: How do we know if software has way too many EEPROM writes?
« Reply #55 on: February 04, 2018, 01:18:23 pm »
Quote from: janoc

I

And a linear reg for dropping rectified mains (i.e. some 300V) down to 3.3-5V?!?! I do hope there is at least some pre-regulator there

In theory nothing wrong with that. Microchip has a few nice LDOs for this purpose.

Then I am very curious about model numbers because even an LDO will have to dissipate significant amount of power with such a large voltage drop.

If I assume 0.1V LDO drop, I still have:

300V - 2.5V - 0.1V = 297.4V, let's say the micro takes 10mA -> that's almost 3W of power to dissipate somewhere. If the thing doesn't have a good heatsink it will likely get really toasty and possibly stop working due to the thermal protection kicking in.

What am I missing? Sounds like a very marginal design to me.
« Last Edit: February 04, 2018, 01:29:20 pm by janoc »
 
The following users thanked this post: ocset

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21658
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: How do we know if software has way too many EEPROM writes?
« Reply #56 on: February 04, 2018, 01:50:14 pm »
Obviously not very practical for such high currents.

If typical operating current is a few mA, it's more or less practical.  Most small offline switching regulators are powered this way, at least during startup.  The efficiency is poor, but it's a 5V 1A USB charger, say; who cares, right?

A dropping capacitor on the AC side can also be used.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: ocset

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13738
  • Country: gb
    • Mike's Electric Stuff
Re: How do we know if software has way too many EEPROM writes?
« Reply #57 on: February 04, 2018, 02:28:11 pm »
Quote from: janoc

I

And a linear reg for dropping rectified mains (i.e. some 300V) down to 3.3-5V?!?! I do hope there is at least some pre-regulator there

In theory nothing wrong with that. Microchip has a few nice LDOs for this purpose.
It wouldn't be an LDO as you don't care about dropout voltage if the input voltage is high - just a linear reg ( vs. switching) .
You may want to have a resistor on the input to spread the dissipation and improve surge/transient resilience

e.g.
https://www.digikey.co.uk/product-detail/en/microchip-technology/LR8N8-G/LR8N8-GTR-ND/4902851
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: ocset

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3785
  • Country: de
Re: How do we know if software has way too many EEPROM writes?
« Reply #58 on: February 04, 2018, 03:29:47 pm »
Quote from: janoc

I

And a linear reg for dropping rectified mains (i.e. some 300V) down to 3.3-5V?!?! I do hope there is at least some pre-regulator there

In theory nothing wrong with that. Microchip has a few nice LDOs for this purpose.
It wouldn't be an LDO as you don't care about dropout voltage if the input voltage is high - just a linear reg ( vs. switching) .
You may want to have a resistor on the input to spread the dissipation and improve surge/transient resilience

e.g.
https://www.digikey.co.uk/product-detail/en/microchip-technology/LR8N8-G/LR8N8-GTR-ND/4902851

Thanks Mike, I was wondering about this.

However, still at least a resistor or a capacitive dropper would be the thing I would prefer to use, followed by a normal regulator, especially if it is meant for outdoors use and things can (and do) get hot.

If the OP's regulator is cooking itself because the MCU is drawing 7mA, something isn't right with that design, IMO. An extra cap or resistor would be only marginally more expensive and avoid that problem.
 
The following users thanked this post: ocset

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13738
  • Country: gb
    • Mike's Electric Stuff
Re: How do we know if software has way too many EEPROM writes?
« Reply #59 on: February 04, 2018, 03:53:27 pm »
Quote from: janoc

I

And a linear reg for dropping rectified mains (i.e. some 300V) down to 3.3-5V?!?! I do hope there is at least some pre-regulator there

In theory nothing wrong with that. Microchip has a few nice LDOs for this purpose.
It wouldn't be an LDO as you don't care about dropout voltage if the input voltage is high - just a linear reg ( vs. switching) .
You may want to have a resistor on the input to spread the dissipation and improve surge/transient resilience

e.g.
https://www.digikey.co.uk/product-detail/en/microchip-technology/LR8N8-G/LR8N8-GTR-ND/4902851

Thanks Mike, I was wondering about this.

However, still at least a resistor or a capacitive dropper would be the thing I would prefer to use, followed by a normal regulator, especially if it is meant for outdoors use and things can (and do) get hot.

If the OP's regulator is cooking itself because the MCU is drawing 7mA, something isn't right with that design, IMO. An extra cap or resistor would be only marginally more expensive and avoid that problem.
Yes, if it really needs 7mA then it needs a cap dropper or switcher. However it appears maybe it was designed on the basis of drawing a lot less and bad software is making it draw  more than it should for reasons that are still unclear.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: ocset

Online Ice-Tea

  • Super Contributor
  • ***
  • Posts: 3070
  • Country: be
    • Freelance Hardware Engineer
Re: How do we know if software has way too many EEPROM writes?
« Reply #60 on: February 04, 2018, 04:57:58 pm »
Then I am very curious about model numbers because even an LDO will have to dissipate significant amount of power with such a large voltage drop.

LR645. Available in TO-220, so you can cool it without much issue.

Quote
What am I missing? Sounds like a very marginal design to me.

With decent SW and HW design (not to mention choosing a decent mcu), I don't see why the design has to be marginal.
 
The following users thanked this post: ocset

Online mariush

  • Super Contributor
  • ***
  • Posts: 5016
  • Country: ro
  • .
Re: How do we know if software has way too many EEPROM writes?
« Reply #61 on: February 04, 2018, 05:02:36 pm »
I think he should also investigate at what frequency is the microcontroller running? Maybe he's running it at 16-24 Mhz, while it could work at 1-2 Mhz or even lower and use less than 1mA of current.

As for eeprom, no need to erase or initialize it, makes no sense.  By default, the memory is either  0 (0xx) or 255  (0xFF) and you can program it when you program the microcontroller for the first time.  ( or, you could add a tiny pad or something on the circuit board that, when connected to ground and you start the light, it does the eeprom erase once)

You can reduce the eeprom "wear and tear" by spreading the writes across a larger part of memory.

For example, if the data you need to store in memory is 2 bytes, then you can use 3 bytes for each record, and store the last 16-32 records in 96 bytes, leaving you the other bytes for other settings. That one byte you use to keep track of which record is the last and all that, for example just use numbers between 1 and 254 (because 0 and 255 tell you it's unused eeprom memory)
So at boot, quickly read up to 32 bytes (one byte per record) to determine which is the newest  measurement and which is the oldest, then read the 2 bytes associated with the newest record .
When you want to write, you overwrite the oldest measurement or use some of the unitialized memory (which you detect by reading 0 or 255 in those header bytes)
 
The following users thanked this post: ocset

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13738
  • Country: gb
    • Mike's Electric Stuff
Re: How do we know if software has way too many EEPROM writes?
« Reply #62 on: February 04, 2018, 05:03:23 pm »

With decent SW and HW design (not to mention choosing a decent mcu), I don't see why the design has to be marginal.
Exactly.

Which is why it makes no sense to do this sort of stuff with a third-party software person in one contry and  and a hardware person in another unless both are so experienced in embedded design that useful specs can be communicated.
In practice one person doing both will be far more productive.
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: ocset

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 2051
  • Country: nl
Re: How do we know if software has way too many EEPROM writes?
« Reply #63 on: February 04, 2018, 08:41:12 pm »
Damn, I never would have guessed this from a thread on excessive eeprom writes. Comedy gold! :popcorn:
 
The following users thanked this post: ocset

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 2051
  • Country: nl
Re: How do we know if software has way too many EEPROM writes?
« Reply #64 on: February 04, 2018, 09:04:03 pm »
OMG, another "treez production" story.  :popcorn: :popcorn:
You mean there is more? ;D This was highly entertaining! I'm saving those other threads for later this week. Always good to have some comic relief on standby!  :-+
 
The following users thanked this post: ocset

Offline TJ232

  • Frequent Contributor
  • **
  • Posts: 331
  • Country: 00
  • www.esp8266-projects.org
    • ESP8266 Projects
Re: How do we know if software has way too many EEPROM writes?
« Reply #65 on: February 05, 2018, 06:29:01 am »
OMG, another "treez production" story.  :popcorn: :popcorn:
You mean there is more? ;D This was highly entertaining! I'm saving those other threads for later this week. Always good to have some comic relief on standby!  :-+

Oh, yeah! Just search the forum for treez posts  :popcorn: :popcorn:
ESP8266 Projects - www.esp8266-projects.org
MPDMv4 Dimmer Board available on Tindie: https://www.tindie.com/stores/next_evo1/
 
The following users thanked this post: ocset

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21658
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: How do we know if software has way too many EEPROM writes?
« Reply #66 on: February 05, 2018, 07:56:02 am »
Oh, yeah! Just search the forum for treez posts  :popcorn: :popcorn:

Easier to follow the link on the user's profile:
https://www.eevblog.com/forum/profile/?area=showposts;sa=topics;u=139928

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: ocset

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14445
  • Country: fr
Re: How do we know if software has way too many EEPROM writes?
« Reply #67 on: February 05, 2018, 05:06:49 pm »
That's a good one!  :-DD

Do you have just one software engineer at your company and isn't anyone else capable of reading and reviewing the code he wrote? If so, you have a bigger problem than you may think anyway.

Additionally, the fact that nobody at your company seems to know what your product actually does and that you're thinking of shipping it is very concerning as well. :palm:

That aside, most EEPROMs are rated for around 1 million of write cycles or more. In your case, I don't know if it's actual EEPROM or just Flash used as an embedded EEPROM in the µC (didn't check). If it's Flash-based, the number of write cycles is a lot less. So that may be even more concerning. There are schemes to circumvent the write cycles limitation, such as distributing the writes evenly in the whole memory space, and of course avoiding unnecessary writes.
 
The following users thanked this post: ocset

Offline Quarlo Klobrigney

  • Frequent Contributor
  • **
  • Posts: 967
  • Country: pt
  • This Space For Rent
Re: How do we know if software has way too many EEPROM writes?
« Reply #68 on: February 05, 2018, 05:27:08 pm »
Yes correct and so on.. Here's an example of a wrong cycle...
Voltage does not flow, nor does voltage go.
 
The following users thanked this post: ocset

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13738
  • Country: gb
    • Mike's Electric Stuff
Re: How do we know if software has way too many EEPROM writes?
« Reply #69 on: February 05, 2018, 06:14:49 pm »
Looking at that datasheet - this PIC doesn't have EEEPROM, it has a high-endurance (100K) flash area with a 32 byte row erase size.
If you were to do something like write individual values to the whole area one at a time, maybe using a manufacturer library with a "write single byte" API call , chances are it would be reading the row, updating one value then doing a row erase and 32 byte rewrite every time.

Datasheet indicates 2ms for row erase and byte writes, so although in principle you could write the whole 128 bytes in 128*2+4*2= about 250mS, it could be a lot longer if the code doing the writes didn't have visibility of the calling code, and so did an read/erase/rewrite for each byte written, which would be around (32+1)*128ms = 4.2 secs, so in the rough ballpark for the OPs quoted 15s time
 
The data shows a supply current during programming of 10mA max. Again, in the quoted ballpark.

10mA for 128mS from an LDO from mains would be OK, but if the writing was being done in a stupid way, the reported 15s would probably not.

or it may be that something is simply browning out and it's getting stuck in a write loop.


« Last Edit: February 05, 2018, 06:17:16 pm by mikeselectricstuff »
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 
The following users thanked this post: ocset

Offline Buriedcode

  • Super Contributor
  • ***
  • Posts: 1611
  • Country: gb
Re: How do we know if software has way too many EEPROM writes?
« Reply #70 on: February 05, 2018, 07:30:56 pm »
Its pretty clear that if the OP wants help here, he is going to have to post the code, and preferably the schematic.

Although one generally wouldn't post code for products in a public forum - the fact treez regularly comes here to ask questions and discuss problems (which is worrying, as surely debugging is part of his job) means he might as well go the whole nine and post the design files.  Otherwise we're going to get a steady stream of vague questions as to what *he* believes causes the issues, rather than the issues themselves.

 
The following users thanked this post: ocset

Offline MT

  • Super Contributor
  • ***
  • Posts: 1616
  • Country: aq
Re: How do we know if software has way too many EEPROM writes?
« Reply #71 on: February 05, 2018, 09:36:36 pm »
Oh, yeah! Just search the forum for treez posts  :popcorn: :popcorn:

Easier to follow the link on the user's profile:
https://www.eevblog.com/forum/profile/?area=showposts;sa=topics;u=139928
Tim
You have to give some credit to Treez for saying "Hello" in every thread start except for the one that was political! :D
 
The following users thanked this post: ocset

Online nctnico

  • Super Contributor
  • ***
  • Posts: 26892
  • Country: nl
    • NCT Developments
Re: How do we know if software has way too many EEPROM writes?
« Reply #72 on: February 05, 2018, 10:11:53 pm »

With decent SW and HW design (not to mention choosing a decent mcu), I don't see why the design has to be marginal.
Which is why it makes no sense to do this sort of stuff with a third-party software person in one contry and  and a hardware person in another unless both are so experienced in embedded design that useful specs can be communicated.
In practice one person doing both will be far more productive.
Yes and no. There aren't enough engineers capable of doing both hardware and software and it will be easier to find a good software engineer and a good hardware engineer. I have been involved in several projects where the software and hardware where done by seperate persons. In the end it comes down to having engineers which are capable of doing a good job.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 
The following users thanked this post: ocset

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3785
  • Country: de
Re: How do we know if software has way too many EEPROM writes?
« Reply #73 on: February 05, 2018, 10:35:33 pm »
With decent SW and HW design (not to mention choosing a decent mcu), I don't see why the design has to be marginal.

That assumes a lot of things being right, IMO. If this is for an outdoors lighting fixture where large temperature swings are the norm, where a bug in the code can fry it ... I don't know, that doesn't sound like there is a lot of margin for error.

Could it be made to work? Probably. Is it robust? I somehow doubt that, especially given the history of OP's posts (like the one about the overvoltage in UK's mains) and the fact that the code is being written by a 3rdparty the OP doesn't control.

At the very least a capacitor to reduce the load on the regulator would be my choice. Then the micro can do whatever it wants and it won't kill the device because of some silly EEPROM writing code or something else that will make it draw few mA of current more or longer than usual. Or because the Sun is heating the enclosure up so much that the regulator cannot cope with the extra heat due to the MCU current anymore and shuts off. 

That's a few cents of hw buying a lot extra margin & protection against newbie mistakes by some intern somewhere who got tasked with writing that code. In the worst case it would be a wasted few cents for an over-engineered solution. There are worse things to waste them on, IMO.

Belts and braces ...
« Last Edit: February 05, 2018, 10:46:19 pm by janoc »
 
The following users thanked this post: ocset

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3785
  • Country: de
Re: How do we know if software has way too many EEPROM writes?
« Reply #74 on: February 05, 2018, 10:44:21 pm »
Yes and no. There aren't enough engineers capable of doing both hardware and software and it will be easier to find a good software engineer and a good hardware engineer. I have been involved in several projects where the software and hardware where done by seperate persons. In the end it comes down to having engineers which are capable of doing a good job.

Exactly. Usually the hw guys are not that great in software and the sw guys tend to give hw engineers grey hair. And on some projects it is simply unfeasible to do have a single person do everything due the size and complexity.

What is more important is to have those two persons/teams actually sit together and constantly communicate and test, not just ship out specs to some outsourcing/contracting outfit and expect working code/hw back (as it often happens - with predictable results).
 
The following users thanked this post: ocset


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf