View previous topic :: View next topic |
Author |
Message |
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Sun Sep 13, 2015 5:33 pm Post subject: Holding a value in a variable. |
|
|
Hi
In my code i am reading a battery voltage by putting a load on the battery.. but I want to find the DELTA-V which is V2-V1.the problem here is that the single adc is reading the battery, I want V2 to remain unchanged and holds its value and then read the V1 after battery discharges, now please help me out how to avoid V2 from changing to the value of V1 without using ERAM as the eeprom will expire very soon by writting multiple times..
Thanks and Regards..
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
Duval JP
Joined: 22 Jun 2004 Posts: 1161 Location: France
|
Posted: Sun Sep 13, 2015 6:00 pm Post subject: |
|
|
hello,
Sorry but maybe I misunderstood
so I propose 2 solutions
1) Why don't you use a external flash memory as a SDcard with AVRdos ?
2) I suppose that you need to keep V2 for few times, why don't you use a array like dim var(50) as word then an other one to sort
something like :
for jbyte =1 to 50
kbyte=jbyte+1
oldvar(jbyte)= var(kbyte)
next
Bon courage
JP |
|
Back to top |
|
|
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Sun Sep 13, 2015 6:07 pm Post subject: |
|
|
I think there may be a very simple solution in someone,s mind and waiting for that. and ys thanks for your solution i will give it a try if nothing come out simple..
regards |
|
Back to top |
|
|
Mrshilov
Joined: 24 Jan 2009 Posts: 314 Location: Russia
|
Posted: Sun Sep 13, 2015 8:11 pm Post subject: |
|
|
Try FM24C64B - it has 100 trillion (10^14) write circles. You may write every 1ms till 3000 years. |
|
Back to top |
|
|
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Mon Sep 14, 2015 5:39 am Post subject: |
|
|
but is it so difficult that can,t be done in micro,s own flash....
regards |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Mon Sep 14, 2015 12:27 pm Post subject: My two cents |
|
|
My calculation when using the internal eeprom
100000 write/cycles for the eeprom
100000/365 days a year is 274 years writing one time a day
100000/365/24 hours is writing every hour during 11 year
===
Try to figure out if a page is used when writing to the eeprom
Keep a counter in eeprom and go to another page when this specific eeprom page wears out.
===
Connect a intelligent RTC with some eeprom in it as a swappable unit and replace this module every year/month.
Have fun
Ben Zijlstra |
|
Back to top |
|
|
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Mon Sep 14, 2015 3:59 pm Post subject: |
|
|
OK agree, but once when I equate V2 =ERAM and adx start to decline due to drain the equation will remain the same and eram value will also declined so its a zero sum game I think, or you people may. Have a better idea... |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Mon Sep 14, 2015 4:59 pm Post subject: |
|
|
I still don't get what you are trying to do.
Afaiu you get the bat voltage, then put a load on the bat and measure again.
This way you find the inner resistance, right?
Then you repeat this to find out what? |
|
Back to top |
|
|
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Mon Sep 14, 2015 5:42 pm Post subject: |
|
|
Yes Arera, when i plug a battery to a adc pin adc will read read the first voltage lets say that is 4.2V, after putting a load the batt. voltage will decline and so does the ADC. this new voltage is V1. the problem is how to hold V2 so that V2-V1 can be found.. which is needed in finding the internal resistance. V2 needs to kept constant at the first reading...
regards |
|
Back to top |
|
|
Arera
Joined: 23 Sep 2007 Posts: 386 Location: Wuppertal, Germany
|
Posted: Mon Sep 14, 2015 7:13 pm Post subject: |
|
|
I almost do not dare to ask you:
Do you know how to use variables?
Dim V1 as word
Dim V2 as word |
|
Back to top |
|
|
Meister
Joined: 27 May 2010 Posts: 319
|
Posted: Mon Sep 14, 2015 7:26 pm Post subject: |
|
|
--
Had started a post- but should be deleted. |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Mon Sep 14, 2015 8:05 pm Post subject: Not enough info |
|
|
The initial question just gives not enough information.
Could you give us more information.
Is the equipment turned on/off frequently?
Ben Zijlstra |
|
Back to top |
|
|
Printpix52
Joined: 18 Jun 2014 Posts: 282 Location: D.F.
|
Posted: Tue Sep 15, 2015 2:51 am Post subject: |
|
|
When a load is connected the low voltage of 4.2 volts? |
|
Back to top |
|
|
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Tue Sep 15, 2015 6:42 am Post subject: |
|
|
@Arera.
Yes both variable are dimentioned and then converted in to singles and displayed using FUSING.
V2 and V1 cant be differentiated as both are reading the same adc and cell. |
|
Back to top |
|
|
naseerak
Joined: 08 Nov 2008 Posts: 138
|
Posted: Tue Sep 15, 2015 6:49 am Post subject: |
|
|
the calculations may be enough for the 1 session only, there are 8 cells which will be calculated this way and after calculating the resistance the cells would be pulled off and new ones inserted for the test...
regards |
|
Back to top |
|
|
|