The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: [OT] Some pic asm code help



Hi Ian

I currently have 2 moisture sensors connected and one should be giving a
high reading (wet) ie -64mV and the other should be a low reading (dry)
ie -20mV....
The dry sensor raw data was MSB F2h....LSB 18h

The wet sensor raw data was MSB F6h....LSB 28h

I have tried rotating the bits first before complementing them but my
results seem to be quite a bit different that what the opnode device is
reading...a very moist sensor should read approx -60mV..

Thanks for your help
Frank



----- Original Message -----
From: "Ian Davidson" <ian@xxxxxxx>
To: <ukha_d@xxxxxxx>
Sent: Sunday, September 09, 2007 6:45 PM
Subject: RE: [ukha_d] [OT] Some pic asm code help


> Hi Frank
>
> As a first test I would read the device and output the actual raw word
> value you read. Then manually convert this. This will prove if you are
> actually reading the correct value and converting wrong or if the raw
> value is wrong in the first place. If you want to post the raw values
I
> can convert them here and let you know what I get the result to be.
>
> Ok just reading your post again.
>
> I can see where this is going wrong. You need to do the rotating
first.
> If you don't then when you add the 1 and later rotate you rotate it
> straight off the end. In your case the bit 0 position starts at bit 3
so
> instead of adding 1 you would have to add 8 but it is easier just to
> rotate first then do the complementing. Also treat the two bytes as
one
> value so when you complement and add 1 only add 1 to the LSB. The only
> other point to watch out for is after you complement you can mask off
> the top nibble of the MSB as after rotating the first three are not
used
> and the next is just the sign bit which is not part of the 2's
> complement.
>
> I hope that made sense it far easier to talk it than write it!
>
> Ian D
>
>
> -----Original Message-----
> From: ukha_d@xxxxxxx [mailto:ukha_d@xxxxxxx] On Behalf
> Of Frank Mc Alinden
> Sent: 09 September 2007 08:31
> To: Ian
> Subject: Re: [ukha_d] [OT] Some pic asm code help
>
> Hi Ian
>
> Firstly thanks for your feedback much appreciated...
>
> What i have done is this firstly is test bit 7 of the MSB 0E and if it
> is
> set i compliment each byte and add 1  to each of them...??
>
> I then rotate right the LSB register OF  3 times each time clearing
the
> carry flag........
>
> I then shift bits 0,1,2 of the MSB into bits 5,6 +7 of the LSB and
> rotate
> the MSB 3 times.........???
>
> With the  result im using existing sub routines that i use to convert
> the
> ds18s20 results into temperature readings....
>
> The results im getting do not tally up with readings im getting using
> another device (opnode) which also has moisture sensors attached to
> it.........
>
> The moisture sensors use an external resistor so the range should go
> from
> +64mV  to -64mV
>
> Thanks again
> Frank
>
>
> ----- Original Message -----
> From: "Ian Davidson" <ian@xxxxxxx>
> To: <ukha_d@xxxxxxx>
> Sent: Sunday, September 09, 2007 12:11 PM
> Subject: RE: [ukha_d] [OT] Some pic asm code help
>
>
>> Hi Frank
>>
>> I've not used that ic before but looking at the data sheet it
works
> like
>> this.
>>
>> The value you read from the ic will be a word value. It is left
>> justified so you need to rotate the value right three times to get
the
>> LSB into the bit 0 position.
>>
>> Say you read
>> 00000000 01010000
>>
>> By rotating it 3 times it will become
>> 00000000 00001010
>>
>> Now you need to test bit 12, in the example it is a zero which
means
> the
>> number is a positive number. You can therefore just use that
number in
>> this case decimal 10. If you are using the internal resistor then
the
>> resolution is 0.625mA. 10 x 0.625mA is 6.25mA which is the current
the
>> device is seeing.
>>
>> Now if bit 12 was a 1
>>
>> I.e.
>> 00011111 11110110
>> Then that is a negative number. In two complement you need to
invert
> all
>> the bits and add one for all the bits below bit 12 so
>>
>> 00000000 00001001
>>
>> Add 1
>>
>> 00000000 00001010
>>
>> Which is 10 decimal times by 0.625mA equals -6.25mA
>>
>> I hope that made sense Frank.
>>
>> Ian D
>>
>>
>> -----Original Message-----
>> From: ukha_d@xxxxxxx [mailto:ukha_d@xxxxxxx] On Behalf
>> Of Frank Mc Alinden
>> Sent: 08 September 2007 23:45
>> To: Ian
>> Subject: [ukha_d] [OT] Some pic asm code help
>>
>> Hi Guys
>>
>> Sorry for the OT post but im hoping some of the pic coders can
help
>> me....Im
>> trying to add support for the Hobby Boards moisture sensor to my
Probe
>> system and im stuck trying to write some code to convert the
readings
>> from
>> the "current registers (OE +OF) " of the DS2760...(The
mositure sensor
>> uses
>> the current sense) ...I can read the DS2760 and get the values i
just
>> cant
>> work out how to convert it to mVolts.......Any help much
>> appreciated......If
>> i get this sorted i will then have a crack at their Humidity
>> sensor.......
>> Heres a link to the hobby boards sensor and the DS2760 PDF
>> http://datasheets.maxim-ic.com/en/ds/DS2760.pdf
>>
>>
> http://www.hobby-boards.com/catalog/product_info.php?cPath=22&products_i
>> d=70
>>
>> Thanks
>> Frank
>> www.armaghelectrical.com.au
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



UKHA_D Main Index | UKHA_D Thread Index | UKHA_D Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.