but lots of warnings. Here is also a "disabled" sensor config.range and resolution function , not tested - needs advices from experts. All functions which start with "s_" are for a unique device on bus - others require the ID for access a sensor on multiple sensors on bus.2010/8/18 vasi vasi <fun...@gmail.com>
>
> We don't have yet a 1wire library and I needed it for a DS18B20 temperature sensor.
> But I found one written by Vasile and adapted by Jean Marchaudon, included in
> Bert van Dam package. Is there a reason why not including it in Jallib?
Probably because no-one has spent the effort required. IMO it would be
good to have it. It is good to see there is a distinct between the
1-wire part and the device part. Like i2c, a well-designed interface
for the 1wire interface is important for future expansion with 1wire
devices.
Joep
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To post to this group, send email to jal...@googlegroups.com.
To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
Thank you for solution. You mean, JAL is more efficient than
assembler?

To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
The raw temperature on Arduino library is computed like this:
int16_t rawTemperature = (((int16_t)scratchPad[TEMP_MSB]) << 8) |
scratchPad[TEMP_LSB];
Is used a signed word.
Look at examples, I think library support also negative temperatures.
The temperature is computed later, in another procedure and a sign is
detected...
For an unique sensor on wire:
procedure s_temp_18B20(byte out inches, byte out fraction, bit out
signed)
procedure s_temp_18B20_CRC(byte out inches, byte out fraction, bit out
signed) is
To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
my 1_wire bus work good since 10 years ago without problemes, i use three
wires cables 20 metres long and fives probes ds1820 in the same bus.
sometime the crc is bad but one time in my (for 5 loop test) loop...never be
bad in my printer control which print all temperature every 15 min since 10
years !!
So your lib is probably good in real condition, because the 1-wire protocole
is make for noise environnement.
Have you play with a adressable switch ds2405, it can swicth on/off a relais
or read a press-buttom in a 1-wire_bus with multiples probes?
jean Marchaudon
Vasi
> read more �
--
You received this message because you are subscribed to the Google Groups
"jallib" group.
To post to this group, send email to jal...@googlegroups.com.
To unsubscribe from this group, send email to
jallib+un...@googlegroups.com.
hi Vasile,I am a poor farmer who is working his four small probes in +1 to +4°C environnement in a cold roomnot like you on the planet Mars with extreme environnement ;-) !

I haven't had a look at the lib yet, perhaps this fits badly... But how about giving the read temperature, abd a flag if the CRC was ok? The lib user can then decide in his program what to do with that.
Greets,
Kiste
The equivalent polynomial function of the CRC (ROM or scratchpad) is:
CRC = X8
+ X5
+ X4
+ 1
The bus master can re-calculate the CRC and compare it to the CRC values
from the DS18B20 using the
polynomial generator shown in Figure 9. This circuit consists of a shift
register and XOR gates, and the
shift register bits are initialized to 0. Starting with the least
significant bit of the ROM code or the least
significant bit of byte 0 in the scratchpad, one bit at a time should
shifted into the shift register. After
shifting in the 56th bit from the ROM or the most significant bit of byte 7
from the scratchpad, the
polynomial generator will contain the re-calculated CRC. Next, the 8-bit ROM
code or scratchpad CRC
from the DS18B20 must be shifted into the circuit. At this point, if the
re-calculated CRC was correct, the
shift register will contain all 0s. Additional information about the Maxim
1-Wire cyclic redundancy check"
----
if somebody has understand something after that !!! bravo
my loop test juste the value of crc that the ds1820 has send and compute
itself.
If you want to compute the crc value of nnbytes with this algorithm, perhaps
the loop will do the job !
test it, i have not time yet....but i will be very happys to use a crc_libs,
of course ;-)
-- not industrial standart procedure ;-)-
procedure d1w_read_byte_with_CRC( byte in nbre_byte, byte out GOOD_crc ) is
var byte bb = 0, n = 0 , crcbyte = 0 -- ! crcbyte must be set to 0
var bit bb_bit0 at bb : 0
var bit crcbyte_bit0 at crcbyte : 0 , crcbyte_bit2 at crcbyte : 2
var bit crcbyte_bit3 at crcbyte : 3 , crcbyte_bit7 at crcbyte : 7
var bit crcbit
for nbre_byte loop -- 8 bytes for readrom ID, 9 bytes for read
temp
d1w_read_byte( bb )
n = n + 1 -- �ne byte
if n == 1 then d1 = bb end if -- note d1 to d9 are globals
var
if n == 2 then d2 = bb end if --
if n == 3 then d3 = bb end if --
if n == 4 then d4 = bb end if --
if n == 5 then d5 = bb end if
if n == 6 then d6 = bb end if
if n == 7 then d7 = bb end if
if n == 8 then d8 = bb end if
if n == 9 then d9 = bb end if
-- ---calcul of crc---------------
for 8 loop
crcbit = crcbyte_bit0 ^ bb_bit0
crcbyte = crcbyte >> 1
crcbyte_bit7 = crcbit
crcbyte_bit2 = crcbyte_bit2 ^ crcbit
crcbyte_bit3 = crcbyte_bit3 ^ crcbit
bb = bb >> 1
end loop
-- ---------------------------------
end loop
if d5==0x_FF & d6==0x_FF & d7==0x_FF & d8==0x_FF & d9==0x_FF then --
control
crcbyte = 1 -- probe is not present, all read to 1 == 0x_FF
d1=198 -- reset temp with error scale 99�c
end if
if crcbyte == 0 then
GOOD_crc = true
else
GOOD_crc = False
end if -- crcbyte must be 0 for crc without error
end procedure
good luke
jean Marchaudon
----- Original Message -----
From: "funlw65(Vasi)" <fun...@gmail.com>
To: "jallib" <jal...@googlegroups.com>
Sent: Tuesday, December 14, 2010 9:04 PM
Subject: [jallib] Re: One wire library
Vasi
--
> [...]
> i = i + 1
> if ((i == max_crc_errors) & (GOOD_crc == 1)) then
> exit loop
> end if
> until GOOD_crc == 0
I think this is a quite complicated implementation of something like
[...]
i = i + 1
until ( GOOD_crc == 0 ) | ( i == max_crc_errors )
And, GOOD_crc is not checked after the loop. So bad readings are processed just the same way as good readings. Only the probability to have a good reading is increased. That should not be the goal, I think.
Greets,
Kiste
> procedure s_temp_18B20_CRC([...], byte in max_crc_errors) is
> var byte i = 0
> repeat
> [...]
> i = i + 1
> until ( GOOD_crc == 0 ) | (i == max_crc_errors)
Comparisons between two variables take more code space, more data space and more execution time than comparisons between a variable and a constant. And, a comparison between a variable and "zero" takes even fewer code space and execution time than a comparison between a variable and any other constant. So this one would be more efficient:
procedure s_temp_18B20_CRC([...], byte in max_crc_errors) is
var byte crc_retries
crc_retries=max_crc_errors
repeat
[...]
crc_retries = crc_retries - 1
until ( GOOD_crc == 0 ) | (crc_retries == 0)
You don't have to change it if it's more readable the other way, the difference is not very big for byte variables. Just my bit of academic smartassing...
Greets,
Kiste
Your're welcome!
I hardly understand C at all, my favourite languages are JAL and assembler for PICs, and Pascal on PCs. Sometimes I have to use C, but it takes me days to even get a few lines to compile, let alone run ;-)
Greets,
Kiste
What is the status of this library? Does it work?
As far as I know it is not part of jallib yet. I see a lot of authors,
in combination with GPL license. Did you get permission to release
this code under zlib? If not, can you obtain this so we can add it to
the repository?
Thanks,
Joep
2010/12/15 vasi vasi <fun...@gmail.com>:
> The files until now.
>
> --
> Vasi
>
> If I remember well, Marchaudon said it
> is ok. Remains Vasile and Bert.
To change the license, I'd like to have the conformation from all
three. Will you look into this?
The license need to be changed to add the library to jallib.
Joep
for me, it's ok .
this part my work is completely free, you can use and reuse it.
jean Marchaudon
----- Original Message -----
From: "funlw65(Vasi)" <fun...@gmail.com>
To: "jallib" <jal...@googlegroups.com>
Sent: Tuesday, January 11, 2011 9:41 AM
Subject: [jallib] Re: One wire library
--
Thanks for you work. I will start working on this library set (I have
the chips now ;)
Joep
2011/1/11 funlw65(Vasi) <fun...@gmail.com>:
In your 15-12 version, 1_wire.jal is missing. When I grab the one you
original posted and try to compile it I get:
jal 2.4n (compiled Jun 2 2010)
generating p-code
18f2550_ds18b20_therm2.jal:17: unknown pragma target: voltage pragma
18f2550_ds18b20_therm2.jal:21: unknown pragma target: ccp2mux pragma
1_wire.jal:95: "x" not defined
1_wire.jal:96: unexpected token: "end"
ds18b20.jal:248: "t" not defined
ds18b20.jal:248: unexpected token: "t"
18f2550_ds18b20_therm2.jal:134: unexpected token: ""e""
7 errors, 0 warnings
It seems that all three files have issue's. E.g. in the crc routine of
ds18b20, line 248 is "t tmp_1_7 shared at tmp[1] : 7", which is not
valid JAL. Also there are some fuse-related messages.
Are you compiling against the svn version of jallib? And can you post
a compilable set of files?
Thanks,
Joep
2011/1/12 funlw65(Vasi) <fun...@gmail.com>:
If fixed part of the problem: the garbage in the files came either
from gmail or Microsoft :(
Only the pragma issue remains. I don't understand why, but this is not
relevant since I'll move it to a board file anyway.
Just to be certain: I have the 18-8 version of 1wire.jal. Is this the
correct one?
Thanks,
Joep
2011/1/12 Joep Suijs <jsu...@gmail.com>:
I start working on it but had not much time. With a bit of luck, I can
spend a few hours tonight and probably send you some questions.
For now, I am okay ;)
Joep
2011/1/13 funlw65(Vasi) <fun...@gmail.com>:
Can you confirm that thermometer.jal is intended for a single device
on the 1wire bus and thermometer2.jal potentially supports more
devices?
If so, it is probably best to start a test file with thermometer that
shows the use of all the relevant functions of the lib. There are
quite a few procedures and there function is 'quite briefly'
documented and not shown in the samples. And the ones that are used,
have no explanation (in contrast to the lcd use ;). So some work to
do.
An other thing is the parameter max_crc_errors. I think this is the
maximum number of retries. Correct?
Such a parameter suggests crc errors are quite common. How often do
you get CRC errors? Also, does it make sense to pass this as a
parameter? If it is a fixed value, we could add a constant. But when
there is a limited number of retries, there remains a chance that get
invalid reading back. And how would you act upon this? Maybe it makes
more sense to have a constant that either says unlimited retries or no
(automatic) retries at all, but return a succes indicator. If your
program has to handle the error, it will probably has some retry
mechanism anyway. Or do I miss something?
Once the first test-file is done, it would be good to create a second
one to show the use of multiple devices on the bus. Are you able to
create a program (like termometer2) which works with two (or more)
devices on the same bus? Does the library support discovery of devices
on such a bus or should one first determine the ID of each device when
they are alone?
Joep
2011/1/13 Joep Suijs <jsu...@gmail.com>:
Joep
2011/1/13 funlw65(Vasi) <fun...@gmail.com>:
Joep Suijs <jsu...@gmail.com> wrote:
>>> 2011/1/13 funlw65(Vasi) <fun...@gmail.com>:
>>>> For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
And I want to point out that this was not me ;-)
Greets,
Kiste