Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
18b20.c library improvement
15-02-2013, 09:44 PM,
#1
18b20.c library improvement
Hi

The 18b20.c library work well but is possible read the temperature only in blocking mode.
With a 12bit sampling operation the wasted time is about 700mS, a life.

To avoid this situation I divided the DS18B20Read function in 2 parts, DS18B20Start which is used for start the acquisition phase and DS18B20Data to read data.
In this manner is possible use the acquisition time to make other job more useful.
There are not upper limits on the delay from acquisition start to the data read.


I attach a zip file with 18b20.c, 1wire.pdl32 and a sample temp18b20x2.pde.


Bye Bye, Moreno


Attached Files
.zip   18b20NEW.zip (Size: 8.14 KB / Downloads: 8)
Reply
09-04-2013, 11:50 AM, (This post was last modified: 09-04-2013, 11:50 AM by regis.)
#2
RE: 18b20.c library improvement
Sorry, I missed your message.

I would rename the data and startc functions to something more comprehensive.
I think we have to decide if we keep the read function or not. If we keep it, then I also think it should be renamed.

DS18B20.read -> ???
DS18B20.startc -> DS18B20.start and/or DS18B20.begin
DS18B20.data -> DS18B20.read

In my opinion we should also find a way to avoid repetition in :
DS18B20.startc(ONEWIREBUS1, SKIPROM, RES12BIT);
and
DS18B20.data(ONEWIREBUS1, SKIPROM, &t);

Maybe something like :
mySensor = DS18B20.begin(ONEWIREBUS1, SKIPROM, RES12BIT);
and
DS18B20.read(mySensor);

And last, it must be compatible with 8-bit version but it's not a big deal.

Does it makes sense for you ?

(15-02-2013, 09:44 PM)moreno Wrote: Hi

The 18b20.c library work well but is possible read the temperature only in blocking mode.
With a 12bit sampling operation the wasted time is about 700mS, a life.

To avoid this situation I divided the DS18B20Read function in 2 parts, DS18B20Start which is used for start the acquisition phase and DS18B20Data to read data.
In this manner is possible use the acquisition time to make other job more useful.
There are not upper limits on the delay from acquisition start to the data read.


I attach a zip file with 18b20.c, 1wire.pdl32 and a sample temp18b20x2.pde.


Bye Bye, Moreno
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
09-04-2013, 06:28 PM,
#3
RE: 18b20.c library improvement
I suggest every routine
name.other
just replaces the dot with an underscore
name_other

Much easier for humans to know what to look for rather than actually hunting through pdl etc files

John
Reply
09-04-2013, 07:37 PM,
#4
RE: 18b20.c library improvement
Already on my TODO list. I hope one day I will get the courage to do it Blush.

(09-04-2013, 06:28 PM)pingotg Wrote: I suggest every routine
name.other
just replaces the dot with an underscore
name_other

Much easier for humans to know what to look for rather than actually hunting through pdl etc files

John
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
09-04-2013, 07:56 PM,
#5
RE: 18b20.c library improvement
What could go wrong?

LOL
Reply
10-04-2013, 07:41 AM,
#6
RE: 18b20.c library improvement
Hi

(09-04-2013, 11:50 AM)regis Wrote: Sorry, I missed your message.
No problem
Quote:I would rename the data and startc functions to something more comprehensive.
I think we have to decide if we keep the read function or not. If we keep it, then I also think it should be renamed.

DS18B20.read -> ???
DS18B20.startc -> DS18B20.start and/or DS18B20.begin
DS18B20.data -> DS18B20.read
Any name is opinable, at this point is better use an extended name
ConversionStart
ConversionRead
Quote:In my opinion we should also find a way to avoid repetition in :
DS18B20.startc(ONEWIREBUS1, SKIPROM, RES12BIT);
and
DS18B20.data(ONEWIREBUS1, SKIPROM, &t);

Maybe something like :
mySensor = DS18B20.begin(ONEWIREBUS1, SKIPROM, RES12BIT);
and
DS18B20.read(mySensor);

And last, it must be compatible with 8-bit version but it's not a big deal.

Does it makes sense for you ?
I do this to maintain a backward compatibility with previous routines.
From my point of view the better solution is use a structure and pass the pointer to the routines.

something like this:

typedef struct tagDS18B20Dat
{
u8 pin,
u8 num,
u8 resolution,
u8 sign; // sign (1=negative)
u8 integer; // integer part
u16 fraction; // fractional part
} DS18B20Dat;


Bye Bye, Moreno
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)