Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG? enable_active_high logic inverted #12

Open
rambros3d opened this issue Sep 17, 2024 · 0 comments
Open

BUG? enable_active_high logic inverted #12

rambros3d opened this issue Sep 17, 2024 · 0 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@rambros3d
Copy link

rambros3d commented Sep 17, 2024

MCU: Esp32-S3
Driver IC: DRV8212

Here's the modified code from the open loop example.

#include <Arduino.h>
#include "SimpleFOC.h"
#include "SimpleDCMotor.h"

#define enPin 11
#define pwm1pin 14
#define pwm2pin 15
DCDriver2PWM driver = DCDriver2PWM(pwm1pin, pwm2pin, enPin);

void setup() {
  driver.voltage_power_supply = 10.0f;
  driver.voltage_limit = 10.0f;
  // init driver
  driver.init();
  // this enables the driver
  driver.enable();
}
void loop() {
  driver.setPwm(5.0f);
  delay(1000);
}

I think this is reversed since drivers like these are usually enabled when the sleep pin is HIGH
image

All the drivers have this in their init() function:
digitalWrite(pinEN, enable_active_high ? LOW : HIGH);
If this is infact the issue, then this fixes the issue
digitalWrite(pinEN, enable_active_high ? HIGH : LOW);

If it is an issue with just the open loop example: calling enable function after init() would fix this
driver.enable();

My use case is pretty simple, I just want to drive Brushed motors with mcpwm using arduino compatible code.
I'm have created this issue since I'm not sure if it is a library bug or just a bug with the open loop example.

Anyway thanks again @runger1101001, This seems to be the only arduino compatible library that supports the mcpwm

@runger1101001 runger1101001 self-assigned this Sep 19, 2024
@runger1101001 runger1101001 added bug Something isn't working documentation Improvements or additions to documentation labels Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants