I do not follow the conversation well enough to speak in context, but in doing a similar thing I found the solution to calculate direction and distance separately; then, once I'd accurately calculated these, dump off those variables to a routine that "swung the needle". I did not need to worry about "round" however as I was programming to mimic analog gauges.
Last, to simulate MOD subtract the integer value from the single value - that decimal portion which remains...
Last edited by Amoque; - 22nd January 2016 at 14:48.
Hi A,
Here's another explanation, again using the clock:
1/ The HAND is at 3. Input FACE 5. HAND<FACE = cwise. HAND moves and counts. HAND=4. HAND<FACE=cwise. HAND moves and counts. HAND=5. HAND=FACE =BRAKE.
2/ The HAND is at 12. Input FACE=1 HAND>FACE = ccwise NOT CORRECT.
I want FACE to cover FACE+1 and FACE-1.
3/ The HAND is at 12. Input FACE=1 Now FACE-1= -1.
This is difficult for me to understand.
I am also trying to understand the MOD suggestions. I will need to check the program to see if I can use MOD, as I get to understand it more.
Thanks. C.
C.
Last edited by camerart; - 22nd January 2016 at 15:38.
Is it the MODulus operation you're having problems with or its implementation?
I had to get a pencil and paper out and do some modulus operations before my extremely thick skull was pierced enough to see how the modulus operator worked. Once understood it's pretty neat. Now if I could only get the */ thingy figured out.
Hi,
The program itself is fine at the 12 to 0 changeover, but with a DEADBAND, it complicates things.
Ioannis suggested Modulus also using a 24Hr clock.
After trying to get to know Modulus, for a while, I can only guess, that it won't correct my problem. The problem is a DEADBAND, so 'say' 3 with a DEADBAND of 1 would be 2 to 4. At o it will be -1 to 1. I don't get the impression that Modulus works with minus numbers.
I experimented with the 24 hour clock, and as the clock goes round and round, eventually it will be 24 then 0 again, so a similar problem. I finally only use 24Hr for a small section around 12 or 0. then revert back to 12 hour, this works fine.
Thanks for all suggestions, C.
Normally you won't count to 24 but up to 23:59. But I have missed the point of -/+1 here.
Ioannis
Bookmarks