CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Address with the DS2438 battery monitor

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
global



Joined: 01 Feb 2005
Posts: 21
Location: Paris

View user's profile Send private message

Address with the DS2438 battery monitor
PostPosted: Mon Mar 27, 2006 6:39 am     Reply with quote

Hello,
I'm using the DS2438 for monitoring a 10V NiMh battery, i need to read the voltage register and the current register.
So in the datasheet, the current register is in the page 0 byte 3 and 4. So i don't know how to wrote the address in my program the page is the first byte and the byte the second;

0x03 for page 0 byte 3
0x12 for page 1 byte 2

This is my code to read the voltage register :

void ReadVoltage (void)
{
if(!Reset())
{
WriteByte(SkipNetAdress); // SkipNetAdress Command
WriteByte(Read); // Read Registers Command
WriteByte(0x03); // Voltage Register Address
Voltage=ReadByte();
Voltage= Voltage<<8;
Voltage = Voltage+ReadByte();
Tension=((float)Voltage)*1/100; //10mV volt/bit, la pr飩sion n'est


}
}
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Mon Mar 27, 2006 9:39 am     Reply with quote

I think you are confusing a nibble and a byte.
Quote:
the page is the first byte and the byte the second;

above where you state 0x03 is page0 byte 3, I think you want
0x0003
And in the code you would have an extra writebyte()
it would be

Code:
 
WriteByte(SkipNetAdress); // SkipNetAdress Command
WriteByte(Read); // Read Registers Command
WriteByte(0x00); // Voltage Register Address
WriteByte(0x03); // Voltage Register Address
Voltage=ReadByte();
Voltage= Voltage<<8;
Voltage = Voltage+ReadByte();
global



Joined: 01 Feb 2005
Posts: 21
Location: Paris

View user's profile Send private message

PostPosted: Wed Mar 29, 2006 1:46 am     Reply with quote

it doesn't working, i already use this code for the DS2770, i think i can use the same code, i just need to modify the adress. I don't know why it's not working.
global



Joined: 01 Feb 2005
Posts: 21
Location: Paris

View user's profile Send private message

PostPosted: Fri Mar 31, 2006 1:38 am     Reply with quote

Its now working, this is the code that we need to use, first read all the register, and to recover the data, we need to read the scratchpad:



if(!Reset())
{
WriteByte(0xCC); //skip ROM
WriteByte(0x44); //read temperature slot
}

if(!Reset())
{
WriteByte(0xCC); //skip ROM
WriteByte(0xB4); //read voltage slot
}

if(!Reset())
{
WriteByte(0xCC); //skip ROM
WriteByte(0xB8); //call memory page 00
WriteByte(0x00);

}

if(!Reset())
{
WriteByte(0xCC); //skip ROM
WriteByte(0xBE); //read page 00
WriteByte(0x00);
}

if(!Reset())
{
WriteByte(0xCC); //skip ROM
WriteByte(0xBE); //read scratchpad
WriteByte(0x00);
}

//read 9 bytes of data
Variable1=ReadByte();
Variable2=ReadByte();
Variable3=ReadByte();
Variable4=ReadByte();
Variable5=ReadByte();
Variable6=ReadByte();
Variable7=ReadByte();
Variable8=ReadByte();
Variable9=ReadByte();
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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


Powered by phpBB © 2001, 2005 phpBB Group