Tom, thanks for replying. Yes, I have PWM working, but the motor is on a gearbox and modulation is causing the whole thing to be jittery, noisy, not smooth. And it needs to rotate both ways. The same motor is quiet under a constant voltage.
I don't have specs for this motor. It's unbranded 12v cheap motor with a gearbox. The motor is whisper quiet when applied partial voltage from an analog power source.
There's no need to determine position, it's time based. I need to be able to fake acceleration, deceleration and direction in code. And be able to respond to a current spike - decelerate quickly, not just shut off. The whole thing need to be smooth.
I can use relays as long as they are not making clicking sound.
HAve you tried different pwm frequencies? At high f's the motor may act a bit like a speaker, and at low f's will vibrate. You should be able to find a frequency range where it is quiet. PWM is def the way to go for motor speed control unless you can measure the current, speed or position and use feedback as motor torque drops dramatically with applied voltage.
Also I dont believe your driver board supports variable voltage control
I think you're asking for something contradictory: speed control based on current. Current feedback is typically used to control torque not speed. That aside, it's going to have to be custom built: as you've probably found, the "hobbyist-friendly" off the shelf boards have current limiting, not current feedback control. So you need something that can read the current load and use that as a feedback element to vary ... what? The voltage/duty cycle input? That will result in torque control, not speed control.
FWIW, the lowest-cost computer-controllable motor drives that use current feedback that I can think of are made by amc (Advanced Motion Controls). They offer Modbus RTU or Modbus TCP (and maybe USB) interfaces. I did a project with one of them about 2 years ago and I may be able to find a part number if you're interested, but ISTR that a single axis will be around $500 and you'll need an appropriate motor. However, it will cost much less than having someone capable design a controller for you.
I am basically looking for a spike in current usage for a given speed - a stall or a near stall. And it can be a second delayed. I understand that making a motor move faster will require more current and reading current load will give different values depending on the speed. But I can compare current reading with an approximate normal reading inside Arduino code, I will have to have a set of values, specific to the motor. Any reading above these expected values (interpolated) is a stall. Will this not work?
Speed.
I think my problem is the code. It has delay(...) and it could be causing the jitter. I don't have the correct PWM code. I think I need to go back to code and remove the delay lines, and figure out how to up the frequency above the audible range. Thank you for pointing me in the right direction!
Hi,
Have you written a simple and nasty PWM code, using to Arduino's PWM commands.
For just ONE motor.
Nothing flash just make the motors run, see if you then have noise.
And I mean a REALLY simple code...
Nothing else in it, just motor run code.
Thanks.. Tom..
PS, Look at the data for your Nano 33 and see what pins have what default PWM frequency.