Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Holding a value in a variable.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Sun Sep 13, 2015 5:33 pm    Post subject: Holding a value in a variable. Reply with quote

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
View user's profile
Duval JP

Bascom Member



Joined: 22 Jun 2004
Posts: 923
Location: France

france.gif
PostPosted: Sun Sep 13, 2015 6:00 pm    Post subject: Reply with quote

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 Wink
Back to top
View user's profile Visit poster's website
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Sun Sep 13, 2015 6:07 pm    Post subject: Reply with quote

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
View user's profile
Mrshilov

Bascom LCD Guru



Joined: 24 Jan 2009
Posts: 314
Location: Russia

russia.gif
PostPosted: Sun Sep 13, 2015 8:11 pm    Post subject: Reply with quote

Try FM24C64B - it has 100 trillion (10^14) write circles. You may write every 1ms till 3000 years.
Back to top
View user's profile
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Mon Sep 14, 2015 5:39 am    Post subject: Reply with quote

but is it so difficult that can,t be done in micro,s own flash....
regards
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Mon Sep 14, 2015 12:27 pm    Post subject: My two cents Reply with quote

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
View user's profile Visit poster's website
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Mon Sep 14, 2015 3:59 pm    Post subject: Reply with quote

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
View user's profile
Arera

Bascom Member



Joined: 23 Sep 2007
Posts: 375
Location: Wuppertal, Germany

germany.gif
PostPosted: Mon Sep 14, 2015 4:59 pm    Post subject: Reply with quote

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
View user's profile
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Mon Sep 14, 2015 5:42 pm    Post subject: Reply with quote

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
View user's profile
Arera

Bascom Member



Joined: 23 Sep 2007
Posts: 375
Location: Wuppertal, Germany

germany.gif
PostPosted: Mon Sep 14, 2015 7:13 pm    Post subject: Reply with quote

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
View user's profile
Meister

Bascom Member



Joined: 27 May 2010
Posts: 314

PostPosted: Mon Sep 14, 2015 7:26 pm    Post subject: Reply with quote

--
Had started a post- but should be deleted.
Back to top
View user's profile
bzijlstra

Bascom Ambassador



Joined: 30 Dec 2004
Posts: 1179
Location: Tilburg - Netherlands

netherlands.gif
PostPosted: Mon Sep 14, 2015 8:05 pm    Post subject: Not enough info Reply with quote

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
View user's profile Visit poster's website
Printpix52

Bascom Member



Joined: 18 Jun 2014
Posts: 222
Location: D.F.

mexico.gif
PostPosted: Tue Sep 15, 2015 2:51 am    Post subject: Reply with quote

When a load is connected the low voltage of 4.2 volts?
Back to top
View user's profile
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Tue Sep 15, 2015 6:42 am    Post subject: Reply with quote

@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
View user's profile
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Tue Sep 15, 2015 6:49 am    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum