From 2a300b943855c2b46bf51e56b1b9b0e9c51a8c62 Mon Sep 17 00:00:00 2001 From: Peter McGoron Date: Thu, 20 Oct 2022 15:42:24 -0400 Subject: [PATCH] write total value to dac, not adjustment vlaue --- firmware/rtl/control_loop/control_loop.v | 84 +++++++++++++------ .../rtl/control_loop/control_loop_cmds.vh | 2 +- 2 files changed, 61 insertions(+), 25 deletions(-) diff --git a/firmware/rtl/control_loop/control_loop.v b/firmware/rtl/control_loop/control_loop.v index 7ed3ce9..4518447 100644 --- a/firmware/rtl/control_loop/control_loop.v +++ b/firmware/rtl/control_loop/control_loop.v @@ -1,10 +1,3 @@ -/* TODO: The control loop outputs the adjustment value, not the - * total value to the DAC. Write code that gets the value from - * the DAC and writes the adjusted value to it. - * - * This can be in another module which only gets the value from - * the DAC on reset. - */ /************ Introduction to PI Controllers * The continuous form of a PI loop is * @@ -126,11 +119,8 @@ module control_loop * ERR_WID (ADC_WID + 1). */ parameter ERR_WID_SIZ = 6, - parameter ADC_POLARITY = 1, - parameter ADC_PHASE = 0, - parameter DAC_POLARITY = 0, - parameter DAC_PHASE = 1, - parameter DATA_WID = CONSTS_WID + parameter DATA_WID = CONSTS_WID, + parameter READ_DAC_DELAY = 5 ) ( input clk, @@ -139,7 +129,7 @@ module control_loop output adc_arm, input adc_finished, - output signed [DAC_WID-1:0] to_dac, + output reg signed [DAC_WID-1:0] to_dac, input signed [DAC_WID-1:0] from_dac, output dac_ss, output dac_arm, @@ -164,9 +154,21 @@ reg signed [ERR_WID-1:0] err_prev = 0; /****** State machine * - * -> CYCLE_START -> WAIT_ON_ADC -> WAIT_ON_MUL -\ - * \------\------------ WAIT_ON_DAC