Making My Arduino produce 1-2ms pulses

Hello Everyone,

I have this K243 motor controller http://secure.oatleyelectronics.com/files/K243notes.pdf and it says that it can be controlled by 1-2mS (Radio Control) INPUT...,but I want it to be controlled by my Arduino..

Can my arduino mimic the pulses of a radio control? Through servo codes?

Note: send a 1 - 2ms pulse every 20ms. If it gets a 1.5ms pulse, it will not move. Anything from 1.5 - 2ms will cause it to move in a direction. And opposite for 1.5 - 1ms.

I used this code: http://www.jbprojects.net/projects/wifirobot/car_arduino.c since my setup is a Wifi controlled car, I can succesfully control my arduino through my router :slight_smile:

I need something to start with... for motor control. 1-2ms

Help

Thanks! :cry:

This is a most standard request you have. Please search a little bit in this Forum and in the Playground: the Keywords are: RC, PPM, servo.
You will find 20 very instructive articles and 200 interesting discussions...

Erac,

Did you try using the Arduino servo example sketche (knob.pde) to see if that works with your motor contoller?

Once you get that working then you can modify the sketch to use microseconds instead of degrees

#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
 
int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin 
 
void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
} 
 
void loop() 
{ 
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) 
  val = map(val, 0, 1023, 1000, 2000);     // scale it to use it with the servo (value between 1ms and 2ms) 
  myservo.writeMicroseconds(val);                  // sets the servo position according to the scaled value 
  delay(15);                           // waits for the servo to get there 
}

Hi mem,

I haven't tried the sketche (knob.pde), do I need to? Can't I just send pulses and see what happens?

Somebody recommended: analog write command i have had success ,

as i said use a 50% signal, then centre the motor[turn the VR1 & VR2 are only to adjustment the 1-2mS (Radio Control) input if used] , now u can control the speed

ie if u use a 25% signal the motor will go at half speed one way, and if u use 75% signal it will go at half speed the other way

and 50% should be centre..

Will this work? I'm pretty mixed up sorry...

Somebody recommended: analog write command i have had success

Right up to the point the magic smoke escapes.

R/C PPM around 50Hz (20ms frame) with 1 to 2 ms pulses.

Arduino PWM from analogWrite, around 490Hz.

Not recommended.

There was a technical discussion in this thread on way it's a bad idea to use analogWrite with hobby servos: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1249178408.

The Arduino servo library is designed to produce pulses between 1ms and 2ms. The sketch I posted above is based on the knob example and lets you set the pulse width using a variable resistor but you can change the code to write any valid value. The writeMicroseconds function accepts values in microseconds so you would use a value of 1000 for 1ms up to 2000 for 2ms.

Thanks!

I will apply PPM instead of PWM :slight_smile:

Thanks Guys! The servo codes worked.

But my problem is how to brake the motor because placing it on reverse while going forward is not advisable for my motor controller..

Any ideas how?

Thanks

But my problem is how to brake the motor

Turn the power off and short the motor terminals.

Hello,

I know this would work if done physically, but my setup is controlled by my ARDUINO microcontroller..

Is there a way to simmulate the shorting of the terminals through servo coding?

Thanks

Is there a way to simmulate the shorting of the terminals through servo coding?

No.

If you need extra control then you will have to wire in the extra electronics to do it. Flywheel breaking is what this is called and is mentioned in this article - http://www.thebox.myzen.co.uk/Workshop/Motors_1.html

Although that is referring to motors you could treat the whole servo as if it were a motor for the breaking part.

But my problem is how to brake the motor

The motor controller has no braking function. And when you put to neutral the motor is floatting.

placing it on reverse while going forward is not advisable for my motor controller.

Why? It is just EMF vs back-EMF. Of course you should not go from all forward to all backward. But if you slow down the motor and then put a little reverse I think this will brake the motor.

Thanks Guys! I think I'll apply the code above and see what happens.