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

Can't drive LRA motor #3

Open
ghost opened this issue Aug 17, 2024 · 1 comment
Open

Can't drive LRA motor #3

ghost opened this issue Aug 17, 2024 · 1 comment

Comments

@ghost
Copy link

ghost commented Aug 17, 2024

I am using Tinycircuits AST1013 LRA driver wireling with ESPWROOM32 and the LRA motor used in the AST1013 is VG0832013D, whose resonant frequency is 235 Hz. The LEDC library used in your code has updated and I made some changes accordingly.

`#include <Wire.h>
#include "Adafruit_DRV2605.h"

const int Motor_PWM_Pins = 16;
const uint32_t Default_PWM_Frequency = 235;
Adafruit_DRV2605 drv;

void SetMotorVoltage(uint8_t Fraction = 0x89)
{
drv.writeRegister8(0x16, Fraction);
drv.writeRegister8(0x17, Fraction);
}

void SetFreq(uint32_t Freq = Default_PWM_Frequency)
{
//DRV2605 Input PWM Frequency: 10-250kHz
assert (Freq <= 1950); //DRV2605 cannot support > 250kHz PWM signals
assert (Freq != 0); //DRV2605 cannot support < 10Hz PWM signals
Freq *= 128;
ledcAttachChannel(16, Freq, 8, 0);
ledcWrite(16, 255);

}

void setup()
{
Serial.begin(115200);
Wire.begin();

/Setup DRV2605/
drv.begin();
drv.useLRA();
drv.setMode(DRV2605_MODE_PWMANALOG);

//LRA_OPEN_LOOP
drv.writeRegister8(DRV2605_REG_CONTROL3, drv.readRegister8(DRV2605_REG_CONTROL3) | 0x01);
/Setup DRV2605/

SetFreq(Default_PWM_Frequency);
}

void loop()
{
while (Serial.available())
{
int Frequency = Serial.parseInt();
uint8_t Power = Serial.parseInt();
SetFreq(Frequency);
SetMotorVoltage(Power);

while (Serial.available())
  Serial.read();  //Read redundant data in buffer

}
}
`

But it is not working. I don't know what issues I am facing. I have read the datasheet of DRV2605L and I understood the theory but I am rookie for MCUs. Can you please guide me?
WhatsApp Image 2024-08-17 at 12 20 23_f96357fa
WhatsApp Image 2024-08-17 at 12 20 23_4581a047

Thank you.

@mntr31
Copy link

mntr31 commented Aug 28, 2024

Can someone please guide me through this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant