From f613b2764c21040314ad4922c5d8569e5695ee45 Mon Sep 17 00:00:00 2001 From: Brendan Bartels <bbartels@iastate.edu> Date: Sun, 12 Mar 2017 16:19:20 -0500 Subject: [PATCH] wip: trying to get a test working for PWMOutputDriver --- .../src/hw_impl_zybo_pwm_output.c | 4 +-- .../modular_quad_pid/src/hw_impl_zybo_tests.c | 33 +++++++++++++++++++ .../modular_quad_pid/src/main.c | 4 +-- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/quad/xsdk_workspace/modular_quad_pid/src/hw_impl_zybo_pwm_output.c b/quad/xsdk_workspace/modular_quad_pid/src/hw_impl_zybo_pwm_output.c index e4c75bd50..b5595e418 100644 --- a/quad/xsdk_workspace/modular_quad_pid/src/hw_impl_zybo_pwm_output.c +++ b/quad/xsdk_workspace/modular_quad_pid/src/hw_impl_zybo_pwm_output.c @@ -1,7 +1,7 @@ #include "hw_impl_zybo.h" -#define THROTTLE_PULSE_WIDTH_LOW 1000 // us -#define THROTTLE_PULSE_WIDTH_HIGH 2000 // us +#define THROTTLE_PULSE_WIDTH_LOW 100000 // 1us +#define THROTTLE_PULSE_WIDTH_HIGH 200000 // 2us #define PERIOD_WIDTH 222222 // 100000000 ns / 450 #define PULSE_WIDTH_ADDR_OFFSET 4 diff --git a/quad/xsdk_workspace/modular_quad_pid/src/hw_impl_zybo_tests.c b/quad/xsdk_workspace/modular_quad_pid/src/hw_impl_zybo_tests.c index 4cf1ae4d8..ca3583935 100644 --- a/quad/xsdk_workspace/modular_quad_pid/src/hw_impl_zybo_tests.c +++ b/quad/xsdk_workspace/modular_quad_pid/src/hw_impl_zybo_tests.c @@ -99,4 +99,37 @@ int test_zybo_pwm_inputs() { } } +/** + * Test for the PWMInputDriver. + * + * Instructions: + * 1) Connect the quad Zybo board to computer using USB. + * 2) Move jump on Zybo board to use JTAG instead of SD. + * 3) Turn on Zybo board and turn on Spektrum handheld controller. + * - Verify receiver on quad pairs with controller (orange LED should turn on) + * 3) Place breakpoint somewhere in the while loop of this function. + * 4) Set the RUN_TESTS macro in main.c + * 5) Uncomment only this test in main.c + * 6) Debug main. + * 7) Observe the values of pwm_inputs in debugger chaning as you use the + * Spektrum RC controller. + */ +int test_zybo_pwm_outputs() { + struct PWMOutputDriver pwm_outputs = create_zybo_pwm_outputs(); + pwm_outputs.reset(&pwm_outputs); + + unsigned long pwms[4]; + pwms[0] = 1000; + pwms[1] = 1000; + pwms[2] = 1000; + pwms[3] = 1000; + while (1) { + int i; + for (i = 0; i < 4; i += 1) { + pwm_outputs.write(&pwm_outputs, i, pwms[i]); + } + int temp = 0; + } +} + diff --git a/quad/xsdk_workspace/modular_quad_pid/src/main.c b/quad/xsdk_workspace/modular_quad_pid/src/main.c index b0b7ccf45..c49e2bed8 100644 --- a/quad/xsdk_workspace/modular_quad_pid/src/main.c +++ b/quad/xsdk_workspace/modular_quad_pid/src/main.c @@ -26,8 +26,8 @@ int main() #ifdef RUN_TESTS //test_zybo_mio7_led_and_system(); //test_zybo_i2c(); - test_zybo_pwm_inputs(); - //test_zybo_pwm_outputs(); + //test_zybo_pwm_inputs(); + test_zybo_pwm_outputs(); //test_zybo_uart(); //test_zybo_axi_timer(); return 0; -- GitLab