assuming tmpval is "int"
tmpval = (RATE / 16) & 0x8003 // preserving the sign bit, to save the if later on
then no need for the "if" block, just have:
checkword = ((((offset + tmpval) * 2) % 8 + 0x05) << 4
sorry I only just got round to replying.
I would recommend uint (i.e. UInt16) rather than int to avoid complications with sign bits - not likely a problem till lots of miles though!
Otherwise your code seems fine - and I think the problem is probably endianness in the programmer - as I thnk you've already spotted.
I'm sure there must be a way to do this my mathematics rather than loops - but it has been a few years since I last looked, and I've not thought much about it in between.
Glad it's of use to people anyway!
Kevin
I would recommend some protection, for example a series resistor in the region of 220 Ohms in line from the supply, followed by a 15V or 18V Zener between the IC supply and ground - this will clamp any transient high voltages caused by wipers etc, to avoid damaging up the timer IC.
Ok, i think its simpler to start with this: Take RATE, right shift 4 (/16), then logical AND with 0xFF, or 256 before wrapping the rest of the equation.
I haven't got a piece of paper handy, to work out the rest at the moment!
I think this will lead to a general rule for all rates, and satisfy the below 4096 case at the same time.
Kev
I'm kind of trying to get my brain switched back on to this, but it's been a while
@TSD: I think you're basically right with the observation that -11 is the equivalent of +5.
The /16 (or shift 4 places) does seem to tie up with the "4096" thing, as the top bit may become the sign/carry flag for an 8 bit micro: i.e. 4096 <<4 = 256 or 0 with carry.
Kev
You need the bolt on the top, not the side to catch the movement in the hitch when the nose unweights. The side nut is for removing side to side play.
Kev
A quick pic of mine, with NATO hitch. The M12 bolt on my drop plate just misses the NATO hitch. There's about 1/2 inch below the rear crossmember before the receiver tube.
I've always understood this to be the case, but the introduction of computerised records 'instant' update meant that you now flagged as failed, whereas the old paper system meant it took time for anyone official to realise. I don't of course condone that philosophy as safe practice...