controlling 4 motors independant by PWM

Got an Arduno Uno, with a pixy cam and 4 motors. I need to control 4 motors independent by PWM, in such a way that i can sent for example

Motor 1; 4000 pulses (2000Hz pulses) Motor 2; 2000 pulses ( 200Hz pulses) Motor 3; till some sensor reacts (motor requires a 2000Hz signal Motor 4; till some sensor reacts (motor requires a 200hz signal)

The problem i face with this is, that these motors need to be enabled add a random time. So often one of the motors is allready running then i need for example motor 1 to do 4000 pulses.

I was thinking of using the Tone command for this, ea tone(pin, frequency, duration) However that works for one pin at a time.

But this must be possible i believe since reprap printers can control 2 motors too to xontrol x y of the printing head. So what is the trick behind it ?.

Hi,

What are your motors? spec/data please. They must need a driver for them as the UNO cannot provide the current they need.

Tom.... :)

I know they need a driver, but i focus on the programming part fist

Hi,

TomGeorge: What are your motors? spec/data please.

Please, if you have no motors and no driver how do you know?

PGT: The problem i face with this is, that these motors need to be enabled add a random time.

Can you post a photograph of the motor please. Tom........ :)

I know they need a driver, but i focus on the programming part fist

I agree, the PWM code doesn't really depend on the type/size of motor being driven. The code might depend on the specifics of the motor driver being used.

Definitely take a look at the AccelStepper library - you'll need acceleration to get to 2000 steps/second without stalling/miss-stepping and you can declare multiple instances - just call all the run() methods in loop().

If you are counting pulses then you are probably going to need stepper motors and PWM doesn't apply to steppers. DC motors work with PWM and then you don't/can't count pulses.