ROBOTIS-GIT / OpenCR

Software for ROS Embedded board (a.k.a. OpenCR). OpenCR means Open-source Control Module for ROS.
Apache License 2.0
383 stars 238 forks source link

Changing PWM Frequency does not seem to work #302

Closed LordSyd closed 2 years ago

LordSyd commented 2 years ago

Hi,

I need to change the PWM frequency the board provides to 5000 Hz for my project. I tried using the code sample provided here: https://github.com/ROBOTIS-GIT/OpenCR/issues/57 This snippet to be precise: `#define PWM_PIN_MAX 6 int pwm_pins[PWM_PIN_MAX] = { 3, 5, 6, 9, 10, 11 }; byte i;

void setup() { for(i = 0; i < PWM_PIN_MAX; i++) { drv_pwm_set_freq(pwm_pins[i], 1000000); // It is constrained to frequencies from 1Hz to 1MHz. drv_pwm_setup(pwm_pins[i]);
} }

void loop() { for(i = 0; i < PWM_PIN_MAX; i++) { drv_pwm_set_duty(pwm_pins[i], 8, 255); //100% duty cycle } delay(100); }`

But this did not work as expected. I measured the voltage using a multimeter and got around 3,3v, which seems odd. I was hoping, as these are Arduino pins, for the upper bound to be 5v, or am I mistaken?

Regards, Daniel

LordSyd commented 2 years ago

Ok, it seems I was mistaken. Sorry about that. After measuring the signal with an oscilloscope, I confirmed the frequency was as intended, but the output voltage at max was only 3.3v, which confused me before.

ROBOTIS-Will commented 2 years ago

Hi @LordSyd

I'm sorry about the delayed response on this issue. The OpenCR is running on ST MCU which runs with 3.3V. Some pins are 5V tolerant, but not able to output a 5V level signal. Hope this information helps.

Thanks!