From b965b3873037161a145f5210f7cc9f8578c312d3 Mon Sep 17 00:00:00 2001 From: Benjamin Perseghetti Date: Wed, 1 Jun 2022 13:36:40 -0400 Subject: [PATCH] ucan pwm enablement. --- ROMFS/cannode/CMakeLists.txt | 1 + ROMFS/cannode/init.d/CMakeLists.txt | 1 + ROMFS/cannode/init.d/rc.output_defaults | 32 +++++++++++++++++ ROMFS/cannode/init.d/rcS | 14 ++++---- ROMFS/cannode/mixers/CMakeLists.txt | 36 +++++++++++++++++++ ROMFS/cannode/mixers/IO_pass_ucan.main.mix | 12 +++++++ ROMFS/px4fmu_common/init.d/CMakeLists.txt | 1 + .../init.d/airframes/22222_generic_output | 21 +++++++++++ .../init.d/airframes/CMakeLists.txt | 2 +- ROMFS/px4fmu_common/init.d/rc.output_defaults | 25 +++++++++++++ boards/nxp/ucans32k146/default.px4board | 1 + boards/nxp/ucans32k146/init/rc.board_defaults | 7 +++- boards/nxp/ucans32k146/nxp_demo.px4board | 3 ++ 13 files changed, 147 insertions(+), 9 deletions(-) create mode 100644 ROMFS/cannode/init.d/rc.output_defaults create mode 100644 ROMFS/cannode/mixers/CMakeLists.txt create mode 100644 ROMFS/cannode/mixers/IO_pass_ucan.main.mix create mode 100644 ROMFS/px4fmu_common/init.d/airframes/22222_generic_output create mode 100644 ROMFS/px4fmu_common/init.d/rc.output_defaults diff --git a/ROMFS/cannode/CMakeLists.txt b/ROMFS/cannode/CMakeLists.txt index bb65f2439f..715a77e9cb 100644 --- a/ROMFS/cannode/CMakeLists.txt +++ b/ROMFS/cannode/CMakeLists.txt @@ -32,3 +32,4 @@ ############################################################################ add_subdirectory(init.d) +add_subdirectory(mixers) diff --git a/ROMFS/cannode/init.d/CMakeLists.txt b/ROMFS/cannode/init.d/CMakeLists.txt index 32a84764ad..36e37ffef2 100644 --- a/ROMFS/cannode/init.d/CMakeLists.txt +++ b/ROMFS/cannode/init.d/CMakeLists.txt @@ -33,4 +33,5 @@ px4_add_romfs_files( rcS + rc.output_defaults ) diff --git a/ROMFS/cannode/init.d/rc.output_defaults b/ROMFS/cannode/init.d/rc.output_defaults new file mode 100644 index 0000000000..f377711892 --- /dev/null +++ b/ROMFS/cannode/init.d/rc.output_defaults @@ -0,0 +1,32 @@ +#!/bin/sh +# +# UGV default parameters. +# +# NOTE: Script variables are declared/initialized/unset in the rcS script. +# + +# +# Enable servo output on pins 3 and 4 (steering and thrust) +# but also include 1+2 as they form together one output group +# and need to be set together. +# +set PWM_OUT 12 + +# +# PWM Hz - 50 Hz is the normal rate in RC cars, higher rates +# may damage analog servos. +# +set PWM_MAIN_RATE 50 + +# +# This is the gimbal pass mixer. +# +set MIXER_AUX pass +set PWM_AUX_OUT 12 + +param set-default PWM_MAIN_DISARM 1500 +param set-default PWM_MAIN_MAX 2000 +param set-default PWM_MAIN_MIN 1000 + +# Set mixer +set MIXER IO_pass_ucan diff --git a/ROMFS/cannode/init.d/rcS b/ROMFS/cannode/init.d/rcS index 6e53056245..6e86d8b7e8 100644 --- a/ROMFS/cannode/init.d/rcS +++ b/ROMFS/cannode/init.d/rcS @@ -65,8 +65,8 @@ unset BOARD_RC_DEFAULTS # # Start system state indicator. # -rgbled start -X -q -rgbled_ncp5623c start -X -q +#rgbled start -X -q +#rgbled_ncp5623c start -X -q # # board sensors: rc.sensors @@ -86,10 +86,10 @@ unset BOARD_RC_SENSORS . ${R}etc/init.d/rc.serial # Check for flow sensor -if param compare SENS_EN_PX4FLOW 1 -then - px4flow start -X & -fi +#if param compare SENS_EN_PX4FLOW 1 +#then +# px4flow start -X & +#fi -uavcannode start +#uavcannode start unset R diff --git a/ROMFS/cannode/mixers/CMakeLists.txt b/ROMFS/cannode/mixers/CMakeLists.txt new file mode 100644 index 0000000000..2197bb79b2 --- /dev/null +++ b/ROMFS/cannode/mixers/CMakeLists.txt @@ -0,0 +1,36 @@ +############################################################################ +# +# Copyright (c) 2018 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +px4_add_romfs_files( + IO_pass_ucan.main.mix +) diff --git a/ROMFS/cannode/mixers/IO_pass_ucan.main.mix b/ROMFS/cannode/mixers/IO_pass_ucan.main.mix new file mode 100644 index 0000000000..a5d8437474 --- /dev/null +++ b/ROMFS/cannode/mixers/IO_pass_ucan.main.mix @@ -0,0 +1,12 @@ +Passthrough mixer for PX4IO +============================ + +This file defines passthrough mixers suitable for testing. + +Channel group 0, channels 0-7 are passed directly through to the outputs. + +M: 1 +S: 0 0 10000 10000 0 -10000 10000 + +M: 1 +S: 0 1 10000 10000 0 -10000 10000 diff --git a/ROMFS/px4fmu_common/init.d/CMakeLists.txt b/ROMFS/px4fmu_common/init.d/CMakeLists.txt index 248350cd4e..5e0bc85c2e 100644 --- a/ROMFS/px4fmu_common/init.d/CMakeLists.txt +++ b/ROMFS/px4fmu_common/init.d/CMakeLists.txt @@ -55,4 +55,5 @@ px4_add_romfs_files( rc.vehicle_setup rc.vtol_apps rc.vtol_defaults + rc.output_defaults ) diff --git a/ROMFS/px4fmu_common/init.d/airframes/22222_generic_output b/ROMFS/px4fmu_common/init.d/airframes/22222_generic_output new file mode 100644 index 0000000000..6e2a248cbb --- /dev/null +++ b/ROMFS/px4fmu_common/init.d/airframes/22222_generic_output @@ -0,0 +1,21 @@ +#!/bin/sh +# +# @name Generic Output +# +# @maintainer +# +# @board bitcraze_crazyflie exclude +# + +. ${R}etc/init.d/rc.output_defaults + + +# Provide ESC a constant 1500 us pulse +param set-default PWM_MAIN_DISARM 1500 +param set-default PWM_MAIN_MAX 2000 +param set-default PWM_MAIN_MIN 1000 + +# Set mixer +set MIXER IO_pass + +set PWM_OUT 12 diff --git a/ROMFS/px4fmu_common/init.d/airframes/CMakeLists.txt b/ROMFS/px4fmu_common/init.d/airframes/CMakeLists.txt index d99b2d8d25..de6cea2786 100644 --- a/ROMFS/px4fmu_common/init.d/airframes/CMakeLists.txt +++ b/ROMFS/px4fmu_common/init.d/airframes/CMakeLists.txt @@ -147,7 +147,7 @@ px4_add_romfs_files( 18001_TF-B1 # [22000, 22999] Reserve for custom models - + 22222_generic_output 24001_dodeca_cox 50000_generic_ground_vehicle diff --git a/ROMFS/px4fmu_common/init.d/rc.output_defaults b/ROMFS/px4fmu_common/init.d/rc.output_defaults new file mode 100644 index 0000000000..4f4f3c47b1 --- /dev/null +++ b/ROMFS/px4fmu_common/init.d/rc.output_defaults @@ -0,0 +1,25 @@ +#!/bin/sh +# +# UGV default parameters. +# +# NOTE: Script variables are declared/initialized/unset in the rcS script. +# + +# +# Enable servo output on pins 3 and 4 (steering and thrust) +# but also include 1+2 as they form together one output group +# and need to be set together. +# +set PWM_OUT 12 + +# +# PWM Hz - 50 Hz is the normal rate in RC cars, higher rates +# may damage analog servos. +# +set PWM_MAIN_RATE 50 + +# +# This is the gimbal pass mixer. +# +set MIXER_AUX pass +set PWM_AUX_OUT 12 diff --git a/boards/nxp/ucans32k146/default.px4board b/boards/nxp/ucans32k146/default.px4board index 50b749dafb..c2798110cb 100644 --- a/boards/nxp/ucans32k146/default.px4board +++ b/boards/nxp/ucans32k146/default.px4board @@ -25,3 +25,4 @@ CONFIG_SYSTEMCMDS_TOP=y CONFIG_SYSTEMCMDS_TOPIC_LISTENER=y CONFIG_SYSTEMCMDS_VER=y CONFIG_SYSTEMCMDS_WORK_QUEUE=y +CONFIG_MODULES_CONTROL_ALLOCATOR=y diff --git a/boards/nxp/ucans32k146/init/rc.board_defaults b/boards/nxp/ucans32k146/init/rc.board_defaults index 31e41871a9..c42943cf14 100644 --- a/boards/nxp/ucans32k146/init/rc.board_defaults +++ b/boards/nxp/ucans32k146/init/rc.board_defaults @@ -3,7 +3,12 @@ # board specific defaults #------------------------------------------------------------------------------ -pwm_out mode_pwm1 start +# pre-arm stuff +param set-default SYS_CTRL_ALLOC 1 + +pwm_out start + +control_allocator start ifup can0 cyphal start diff --git a/boards/nxp/ucans32k146/nxp_demo.px4board b/boards/nxp/ucans32k146/nxp_demo.px4board index 802465cef8..6d7a51834b 100644 --- a/boards/nxp/ucans32k146/nxp_demo.px4board +++ b/boards/nxp/ucans32k146/nxp_demo.px4board @@ -4,3 +4,6 @@ CONFIG_DRIVERS_UAVCANNODE_GPS_DEMO=n CONFIG_MODULES_LIGHTING_STATE_CONVERTER=y CONFIG_CYPHAL_NODE_CLIENT=y CONFIG_CYPHAL_UORB_LIGHTING_STATES_SUBSCRIBER=y +CONFIG_DRIVERS_GPS=n +CONFIG_SYSTEMCMDS_ACTUATOR_TEST=y +CONFIG_SYSTEMCMDS_MOTOR_TEST=y