Maker Pro
Maker Pro

mega8, 1wire eeprom (DS2431) and bascom

wing23

Jan 5, 2012
4
Joined
Jan 5, 2012
Messages
4
Hey all :)

I'm no engineer but I have to find a solution for my problem.
I tried to study the DS2431 datasheet to no satisfaction, I googled a lot, now I'm here hoping to find someone who could help me out for a min.

The problem shouldn't be too hard IMO, I bet it's something that could be done in less than 5 min.


I'm making a circuit that checks if a lamp is working/alive by measuring the current that its electronic ballast draws.
This part works already (current sense hall element, several opamps, finally fed into the ADC of a mega8).

Now I have to make a runtime hours counter by increasing a value that resembles minutes. After 8000 hrs a LED should light up.
I'm already this far that I use timer1 to increase a value and after 5 minutes (to save eeprom write cycles) I want to write it into a 1wire eeprom, a DS2431

now my 1st question is (and I googled a lot and somehow didn't find anything): if I use the ADC (I need 2 ADC ports), can I connect the 1wire eeprom to an unused ADC port without problems?

the 2nd problem I have is: I want to read and write the runtime counter's value into the eeprom.
I read the datasheet and googled a lot again, but I only found hints to read out ds18b20 temp. sensors.

I use bascom to make the code.
Would it be possible for you to write me 2 routines for reading the eeprom value (as on startup) and for writing it to the eeprom (like every 5 min)?
I only need the code for read and write!

additional info and ideas:
in the code I use these commands already:
config ADC = single (etc)
config timer1 = timer, Prescale = 256 , Compare A = Disconnect , Clear Timer = 1
Enable Compare1a
Enable Interrupts

I write this since I'm not sure what other ports I could use, because interrupts and compare ports are enabled and I also have to connect 4 LEDS and a switch
There's not that much room left for alternatives ...

another idea I had (depending on how easy this could be done): the eeprom should contain a branding string, for example "wing23".
on startup it reads the string at address x and compares.
If it finds "wing23" in the eeprom it continues to read the stored timer value at address y and if the lamps are alight, it starts increasing the just read value and every 5 min it stores it back into the eeprom.
Shouldn't be too hard, I guess D:


Thanks a lot for your help and time
Nik
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
Your question suffers from the "Too much information" problem. There's so much to think about that it just seems like too much effort.

Make your questions simpler.

I think your questions can be summarised as:

1) I am using an ATMega8 uC with analog inputs to ADC 1 and 2. Can I use the ADC 3 input for 1-wire communication to a DS2413?

2) How do I read and write to the eeprom of the DS2413?

In answering (1) I need to ask why you specifically want to connect it to the ADC3 input? A little googling gave me this page which talks about doing 1-wire interfacing with an ATMega8. It looks like there's some code there. I have no idea if this can be used at the same time as the ADCs, but it really shouldn't matter. If there's any conflict you can set up the ADCs, do readings of these, then set up for the 1-wire comms and do that.

presumably the code will lead you in the direction of answering the second part of the question.
 

wing23

Jan 5, 2012
4
Joined
Jan 5, 2012
Messages
4
Hello Steve!

due to my past experiences I usually give more details to prevent 1000s of questions from people who want to help :)

I have to connect to an unused ADC port because I already have a display connected to the mega8, plus 4 LEDs, a switch and also use the mega8 times with enabled compare1a and enabled interrupts.

Due to lacking knowledge I'm not sure if I can use the left over ports with these things enabled.
I tried to google and read the manual but nothing helpful was found till now D:

I also found websites and code for the DS18B20, I already use this temp. sensor in other circuits but the eeprom looks way more difficult to me :/
 
Top