No announcement yet.

4D-ViSi Knob problem

  • Filter
  • Time
  • Show
Clear All
new posts

  • 4D-ViSi Knob problem

    I am having a problem with the knob graphic in 4D-ViSi.

    If I set the Maxvalue at 120 or higher the program crashes as soon as the dial is rotated above 119. For instance a Maxvalue of 150 works but only if the dial position is below 120. Once rotated past there the program freezes.

    I tried this in the demo program provided as well and had the same results.

    Is there a limit that can be set for the the knob "Maxvalue"?

    I would like to use the knob to adjust motor speed from 0% to 125%.

  • #2

    Consider the following line in the sample

    posit := degrees * 100 / 270 ; // convert degrees to position

    if degrees were 270 then the first part of the equation would have an intermediate result of 27000, which is ok.

    For your proposed max value of 125 the intermediate result would be 33,750 which is past the maximum signed 16bit value of 32767.

    You can still do it, you just need to be a bit sneaky
    Rather than say

    posit := degrees * 125 / 270 ; // convert degrees to position


    posit := degrees * 25 / 54 ; // convert degrees to position

    This will result in the same (from, say, a 32 bit integer perspective) answer, but will work with a 16bit signed integer.


    • #3

      Thank you. That works fine.