I have created a code for Boeing chronometer that runs with stepper motor and hall sensor for calibration. Everything works kinda ok, except that everytime the needle passes the sensor, it tries to calibrate again. Is there a way to include in code that it calibrates only once? And then ignores the Hall sensor after calibration is done. Thanks!
Here is the code:
Code: Select all
NEEDLE = hw_stepper_motor_add("CHRONO", "4WIRE_4STEP", 2048, 30)
hw_stepper_motor_position(NEEDLE, nil, "ENDLESS_CLOCKWISE")
function hall_sensor(position)
if position == 0 then
hw_stepper_motor_calibrate(NEEDLE, 0.52)
hw_stepper_motor_position(NEEDLE, 0.0)
end
end
timer_start(10000, function ()
function chronometer(data)
hw_stepper_motor_position(NEEDLE, 1/60 * data)
end
xpl_dataref_subscribe("laminar/B738/clock/captain/chrono_seconds_needle", "FLOAT", chronometer)
end)
hw_switch_add("SENSOR ", 1, hall_sensor)