Peter Goldsbury
Member
I have a tipping bucket ranguage and need to convert tips to rain in mm . Here is the start of my code::
; Now calibrate the rain pulses from tipping bucket and converts them to cumulative rain mm x 0.1
; each tip is around 6.25 cc and we get around 160 pulses per litre so pulses represents around 0.28 mm of rain
;
the input pulse count is between 0 and 3000
the output of rainfall is in range 0 to 10000 with 1/ 0th of a mm resolution
;Formula::: note: rain (in mm x 0.1) = rain_pulsecount*10000/(rain_pulsesperlitre*rain_mlpercm) x 10
;
let w1 = rain_pulsesperlitre * rain_mlpercm ; this fits into 16 bit word (around about 35040)
let w2 = rain_pulsecount ** 10000 ; needs 32 bit, so store high word here
let w3 = rain_pulsecount * 10000 ; needs 32 bit, so store low word here
I now need to divide the 32 bit number held in w2 (High) and W3 ( low) by the 16 bit number in w1 but despite my eforts cant semm to get my head around doing it. Can anyone help with the code to do this please
; Now calibrate the rain pulses from tipping bucket and converts them to cumulative rain mm x 0.1
; each tip is around 6.25 cc and we get around 160 pulses per litre so pulses represents around 0.28 mm of rain
;
the input pulse count is between 0 and 3000
the output of rainfall is in range 0 to 10000 with 1/ 0th of a mm resolution
;Formula::: note: rain (in mm x 0.1) = rain_pulsecount*10000/(rain_pulsesperlitre*rain_mlpercm) x 10
;
let w1 = rain_pulsesperlitre * rain_mlpercm ; this fits into 16 bit word (around about 35040)
let w2 = rain_pulsecount ** 10000 ; needs 32 bit, so store high word here
let w3 = rain_pulsecount * 10000 ; needs 32 bit, so store low word here
I now need to divide the 32 bit number held in w2 (High) and W3 ( low) by the 16 bit number in w1 but despite my eforts cant semm to get my head around doing it. Can anyone help with the code to do this please