paparazzi-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Paparazzi-devel] Fwd: [paparazzi-commits] [5050] PWM output for ch


From: antoine drouin
Subject: Re: [Paparazzi-devel] Fwd: [paparazzi-commits] [5050] PWM output for channels 1-4 for lisa stm32 passthrough
Date: Thu, 15 Jul 2010 09:31:04 +0200

Hi Eric

You should be able to have 6 servos output on Lisa ( 6 is the magic
number for helis ). I'll look into the code asap

Regards

Poine

On Thu, Jul 15, 2010 at 8:12 AM, Eric Parsonage <address@hidden> wrote:
> Hi All
> I just notice the commit below. I am interested in having 5 or more pwm
> outputs from Lisa and probably wont need. Is this going to be possible ?
> Regards
> Eric
>
> Begin forwarded message:
>
> From: Allen Ibara <address@hidden>
> Date: 15 July 2010 1:59:49 PM ACST
> To: address@hidden
> Subject: [paparazzi-commits] [5050] PWM output for channels 1-4 for lisa
> stm32 passthrough
> Reply-To: address@hidden
>
> Revision: 5050
>          http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=5050
> Author:   aibara
> Date:     2010-07-15 04:29:49 +0000 (Thu, 15 Jul 2010)
> Log Message:
> -----------
> PWM output for channels 1-4 for lisa stm32 passthrough
>
> Modified Paths:
> --------------
>    paparazzi3/trunk/conf/autopilot/lisa_passthrough.makefile
>    
> paparazzi3/trunk/sw/airborne/booz/arch/stm32/actuators/booz_actuators_pwm_hw.c
>    paparazzi3/trunk/sw/airborne/fms/fms_autopilot_msg.h
>    paparazzi3/trunk/sw/airborne/fms/fms_spi_autopilot_msg.c
>
> Modified: paparazzi3/trunk/conf/autopilot/lisa_passthrough.makefile
> ===================================================================
> --- paparazzi3/trunk/conf/autopilot/lisa_passthrough.makefile 2010-07-14
> 03:09:25 UTC (rev 5049)
> +++ paparazzi3/trunk/conf/autopilot/lisa_passthrough.makefile 2010-07-15
> 04:29:49 UTC (rev 5050)
> @@ -56,10 +56,14 @@
> pt.CFLAGS += -DRADIO_CONTROL_LINK=Uart3
>
> # Actuators
> -pt.srcs += $(SRC_BOOZ)/actuators/booz_supervision.c
> -pt.CFLAGS += -DACTUATORS_ASCTEC_V2_PROTOCOL
> -pt.srcs += $(SRC_BOOZ)/actuators/booz_actuators_asctec.c
> -pt.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c
> +#pt.srcs += $(SRC_BOOZ)/actuators/booz_supervision.c
> +#pt.CFLAGS += -DACTUATORS_ASCTEC_V2_PROTOCOL
> +#pt.srcs += $(SRC_BOOZ)/actuators/booz_actuators_asctec.c
> +#pt.srcs += i2c.c $(SRC_ARCH)/i2c_hw.c
> +#
> +#pt.CFLAGS += -DACTUATORS_ASCTEC_DEVICE=i2c1
> +#pt.CFLAGS += -DUSE_I2C1
>
> -pt.CFLAGS += -DACTUATORS_ASCTEC_DEVICE=i2c1
> -pt.CFLAGS += -DUSE_I2C1
> +# PWM actuator
> +pt.srcs += $(SRC_BOOZ)/actuators/booz_actuators_pwm.c
> +pt.srcs += $(SRC_BOOZ_ARCH)/actuators/booz_actuators_pwm_hw.c
>
> Modified:
> paparazzi3/trunk/sw/airborne/booz/arch/stm32/actuators/booz_actuators_pwm_hw.c
> ===================================================================
> ---
> paparazzi3/trunk/sw/airborne/booz/arch/stm32/actuators/booz_actuators_pwm_hw.c
> 2010-07-14 03:09:25 UTC (rev 5049)
> +++
> paparazzi3/trunk/sw/airborne/booz/arch/stm32/actuators/booz_actuators_pwm_hw.c
> 2010-07-15 04:29:49 UTC (rev 5050)
> @@ -29,11 +29,12 @@
> #include <stm32/misc.h>
> #include <stm32/tim.h>
>
> +#define PCLK 72000000
> +#define ONE_MHZ_CLK 1000000
> +#define SERVO_HZ 40
> +
> void booz_actuators_pwm_hw_init(void) {
>
> -  /* System clock */
> -  /* PCLK1 = HCLK/4 */
> -  RCC_PCLK1Config(RCC_HCLK_Div4);
>   /* TIM3 clock enable */
>   RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
>   /* GPIOB and GPIOC clock enable */
> @@ -52,50 +53,44 @@
>   TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;
>   TIM_OCInitTypeDef  TIM_OCInitStructure;
>   /* Time base configuration */
> -  TIM_TimeBaseStructure.TIM_Period = 56249;
> -  TIM_TimeBaseStructure.TIM_Prescaler = 15;
> +  TIM_TimeBaseStructure.TIM_Prescaler = (PCLK / ONE_MHZ_CLK) - 1; // 1uS
> +  TIM_TimeBaseStructure.TIM_Period = (ONE_MHZ_CLK / SERVO_HZ) - 1;
>   TIM_TimeBaseStructure.TIM_ClockDivision = 0;
>   TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
>
>   TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
>
> -  uint16_t CCR1_Val = 2250;
> -  uint16_t CCR2_Val = 2250;
> -  uint16_t CCR3_Val = 2250;
> -  /* PWM1 Mode configuration: Channel1 */
> +  /* PWM1 Mode configuration: All Channels */
>   TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
>   TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
> -  TIM_OCInitStructure.TIM_Pulse = CCR1_Val;
> +  TIM_OCInitStructure.TIM_Pulse = 0; // default low (no pulse)
>   TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
>
> +  /* PWM1 Mode configuration: Channel1 */
>   TIM_OC1Init(TIM3, &TIM_OCInitStructure);
> -
>   TIM_OC1PreloadConfig(TIM3, TIM_OCPreload_Enable);
>
>   /* PWM1 Mode configuration: Channel2 */
> -  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
> -  TIM_OCInitStructure.TIM_Pulse = CCR2_Val;
> -
>   TIM_OC2Init(TIM3, &TIM_OCInitStructure);
> -
>   TIM_OC2PreloadConfig(TIM3, TIM_OCPreload_Enable);
>
>   /* PWM1 Mode configuration: Channel3 */
> -  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
> -  TIM_OCInitStructure.TIM_Pulse = CCR3_Val;
> -
>   TIM_OC3Init(TIM3, &TIM_OCInitStructure);
> -
>   TIM_OC3PreloadConfig(TIM3, TIM_OCPreload_Enable);
>
> +  /* PWM1 Mode configuration: Channel4 */
> +  TIM_OC4Init(TIM3, &TIM_OCInitStructure);
> +  TIM_OC4PreloadConfig(TIM3, TIM_OCPreload_Enable);
> +
>   /* TIM3 enable counter */
>   TIM_Cmd(TIM3, ENABLE);
>
> }
>
> +/* set pulse widths from actuator values, assumed to be in us */
> void booz_actuators_pwm_commit(void) {
> -  TIM_SetCompare1 (TIM3, booz_actuators_pwm_values[0]);
> -  TIM_SetCompare2 (TIM3, booz_actuators_pwm_values[1]);
> -  TIM_SetCompare3 (TIM3, booz_actuators_pwm_values[2]);
> -
> +  TIM_SetCompare1(TIM3, booz_actuators_pwm_values[0]);
> +  TIM_SetCompare2(TIM3, booz_actuators_pwm_values[1]);
> +  TIM_SetCompare3(TIM3, booz_actuators_pwm_values[2]);
> +  TIM_SetCompare4(TIM3, booz_actuators_pwm_values[3]);
> }
>
> Modified: paparazzi3/trunk/sw/airborne/fms/fms_autopilot_msg.h
> ===================================================================
> --- paparazzi3/trunk/sw/airborne/fms/fms_autopilot_msg.h 2010-07-14 03:09:25
> UTC (rev 5049)
> +++ paparazzi3/trunk/sw/airborne/fms/fms_autopilot_msg.h 2010-07-15 04:29:49
> UTC (rev 5050)
> @@ -5,6 +5,8 @@
> #include "math/pprz_algebra_int.h"
> #include "airframe.h"
>
> +#define LISA_PWM_NB 6
> +
> /*
>  * Testing
>  */
> @@ -92,11 +94,7 @@
>
> struct __attribute__ ((packed)) AutopilotMessagePTDown
> {
> -  int16_t command_pitch;
> -  int16_t command_roll;
> -  int16_t command_yaw;
> -  int16_t command_thrust;
> -  int16_t actuators[SERVOS_NB];
> +  uint16_t pwm_outputs_usecs[LISA_PWM_NB];
> };
>
> union AutopilotMessagePT
>
> Modified: paparazzi3/trunk/sw/airborne/fms/fms_spi_autopilot_msg.c
> ===================================================================
> --- paparazzi3/trunk/sw/airborne/fms/fms_spi_autopilot_msg.c 2010-07-14
> 03:09:25 UTC (rev 5049)
> +++ paparazzi3/trunk/sw/airborne/fms/fms_spi_autopilot_msg.c 2010-07-15
> 04:29:49 UTC (rev 5050)
> @@ -138,8 +138,8 @@
>
> static void passthrough_down_fill(struct AutopilotMessagePTDown *msg_out)
> {
> -  for (int i = 0; i < SERVOS_NB; i++) {
> -    msg_out->actuators[i] = actuators[i];
> +  for (int i = 0; i < LISA_PWM_NB; i++) {
> +    msg_out->pwm_outputs_usecs[i] = actuators[i];
>   }
> }
>
>
>
>
>
> _______________________________________________
> Paparazzi-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/paparazzi-devel
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]