Objective:
My objective was to use this library to control SG90-TowerPro servo motors using a PCA9685.
Problem:
When analysing the voltage on the pwm cable of the servo, I find fixed 0.033V where I should find a changing value orbiting around 0.3V.
Context:
Using a single SG90-TowerPro servo motor connected to the port 0 of the PCA9685. Using CubeMX and CubeIDE to code. No compiling error and everything seem to work according to the debugger. Coding on an STM32F303K8 nucleo board. Having the files correctly imported. Servo documentation: https://cdn.datasheetspdf.com/pdf-down/S/G/9/SG90-TowerPro.pdf
Relevant parts of the code:
Rewrote the hal importing part of pca9685.h in order to import the correct hal as follows:
Replaced
#if (defined STM32L011xx) || (defined STM32L021xx) || \
(defined STM32L031xx) || (defined STM32L041xx) || \
(defined STM32L051xx) || (defined STM32L052xx) || (defined STM32L053xx) || \
(defined STM32L061xx) || (defined STM32L062xx) || (defined STM32L063xx) || \
(defined STM32L071xx) || (defined STM32L072xx) || (defined STM32L073xx) || \
(defined STM32L081xx) || (defined STM32L082xx) || (defined STM32L083xx)
#include "stm32l0xx_hal.h"
#elif defined (STM32L412xx) || defined (STM32L422xx) || \
defined (STM32L431xx) || (defined STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx) || \
defined (STM32L451xx) || defined (STM32L452xx) || defined (STM32L462xx) || \
defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \
defined (STM32L496xx) || defined (STM32L4A6xx) || \
defined (STM32L4R5xx) || defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)
#include "stm32l4xx_hal.h"
#else
#error Platform not implemented
#endif
with
#include "stm32f3xx_hal.h"
Main code:
Initialization:
#include "pca9685.h"
#define SERVO_COUNT 1
uint8_t ActiveServo;
pca9685_handle_t handle = {
.i2c_handle = &hi2c1,
.device_address = PCA9865_I2C_DEFAULT_DEVICE_ADDRESS,
.inverted = false
};
pca9685_init(&handle);
pca9685_set_pwm_frequency(&handle, 50.0f);
HAL_Delay(2000);
Loop
pca9685_set_channel_duty_cycle(&handle, 1, 0.09f, false);
HAL_Delay(1000);
pca9685_set_channel_duty_cycle(&handle, 1, 0.06f, false);
HAL_Delay(1000);
According to the documentation, it should be on between 1 and 2 ms on a 20 ms pwm period (wich is 5 to 10% equivalent to 0.05 to 0.1) working at 50 hertz.
Debugging tried:
Made it work with an arduino nano
Made it (kinda) work with another library (just some vibrations problems to fix)
Watched very carefully the sleeping status of the PCA (did not sleep at all)
All of this had led me to think maybe the problem was not on my part but I certainly can be wrong as you seem far more knowledgeable than me.
Hoping for this issue to be helping,
Objective:
My objective was to use this library to control SG90-TowerPro servo motors using a PCA9685.
Problem:
When analysing the voltage on the pwm cable of the servo, I find fixed 0.033V where I should find a changing value orbiting around 0.3V.
Context:
Using a single SG90-TowerPro servo motor connected to the port 0 of the PCA9685. Using CubeMX and CubeIDE to code. No compiling error and everything seem to work according to the debugger. Coding on an STM32F303K8 nucleo board. Having the files correctly imported. Servo documentation: https://cdn.datasheetspdf.com/pdf-down/S/G/9/SG90-TowerPro.pdf
Relevant parts of the code:
Rewrote the hal importing part of pca9685.h in order to import the correct hal as follows:
Replaced
with
#include "stm32f3xx_hal.h"Main code:
Initialization:
Loop
According to the documentation, it should be on between 1 and 2 ms on a 20 ms pwm period (wich is 5 to 10% equivalent to 0.05 to 0.1) working at 50 hertz.
Debugging tried:
Made it work with an arduino nano
Made it (kinda) work with another library (just some vibrations problems to fix)
Watched very carefully the sleeping status of the PCA (did not sleep at all)
All of this had led me to think maybe the problem was not on my part but I certainly can be wrong as you seem far more knowledgeable than me.
Hoping for this issue to be helping,