From 2afb88ef5f7474dbcccd1bd78bfff9ea573259b0 Mon Sep 17 00:00:00 2001 From: torque Date: Thu, 11 Jul 2024 19:15:11 -0700 Subject: [PATCH] controller: make controller info printout more useful This has a lot more relevant information now. Anyway, this has been tested on real hardware, and it appears to work pretty well. I am considering changing the control loop so that it isn't always operating on stale feedback (two LabJack calls per loop when actively controlling pointing). Also the calibration routines need to be implemented. --- src/YaesuController.zig | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/YaesuController.zig b/src/YaesuController.zig index 8cfe177..beff42f 100644 --- a/src/YaesuController.zig +++ b/src/YaesuController.zig @@ -180,7 +180,21 @@ const Controller = struct { }; } - fn signDeadzone(offset: f64, deadzone: f64) enum { negative, zero, positive } { + const Sign = enum { + negative, + zero, + positive, + + pub fn symbol(self: Sign) u8 { + return switch (self) { + .negative => '-', + .zero => '=', + .positive => '+', + }; + } + }; + + fn signDeadzone(offset: f64, deadzone: f64) Sign { return if (@abs(offset) < deadzone) .zero else if (offset < 0) @@ -224,11 +238,23 @@ const Controller = struct { drive_signal[config.controller.elevation_outputs.increase.io] = elsign == .positive; drive_signal[config.controller.elevation_outputs.decrease.io] = elsign == .negative; - log.info("drive: az = {s}, el = {s}. outputs: {any}", .{ @tagName(azsign), @tagName(elsign), drive_signal }); - const raw = try self.labjack.readAnalogWriteDigital(2, inputs, drive_signal, true); + const angles = lerpAndOffsetAngles(raw); - return lerpAndOffsetAngles(raw); + log.info( + "az: {d:.1}° ({d:.2} V) {d:.1}° => {c}, el: {d:.1}° ({d:.2} V) {d:.1}° => {c}", + .{ + angles.azimuth, + raw[0].voltage, + pos_error.azimuth, + azsign.symbol(), + angles.elevation, + raw[1].voltage, + pos_error.elevation, + elsign.symbol(), + }, + ); + return angles; } fn run(self: *Controller) !void {