Grog please Help with servo controller


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
AdolphSmith's picture

I have Used a ATMEGA328 +

I have Used a ATMEGA328 + DUAL Motor Controller ( https://www.robotics.org.za/index.php?route=product/product&product_id=2...) as driver for my DC Servo motor. 

Inside also a Rotary Encoder ( https://www.robotics.org.za/index.php?route=product/search&search=rotary... ) . 

So the small ATMEGA328 Board need a small program inside that read my rotary encoder and turn the motor to the position he recieve from the Ardiuno Mega pin 8 . So when ArdiunoMeg give command like to a servo he must respond same way as servo.

Can you do this. Or do i understood it wrong what is possable.

Thank you

Adolph

 

Adolph

 

GroG's picture

Ahoy Adolph, I would have

Ahoy Adolph,

I would have answered you sooner, but I'm in Germany working.  Lots of work work... long days here and jet lag make me want to sleep when I'm done with the day.

But I think this is a great project you are working on !

The first thing which came to mind .. 

I think its impressive you want to make this "behave" like a servo, but I think your trying TO HARD !  Bit-Banging an RC signal would be ineffecient and prone to errors.

I would prefer to support it from MRL as a real DC Motor with a single channel encoder. 

Which means you should not need the additional Mega to be connected to it.  I believe you can directly connect an FTDI cable to it.  So you'd run MRLComm.ino on the motor controller directly.  

There are only 2 pieces which would need to be added.

  1. MRLComm.ino needs to support a DC Motor with a single encoder such that MRL can send the motor to moveTo(170)  and MRLComm.ino would start the DC motor at a specified and appropriate PWM speed.  Count the nnumber of pulses from the encoder, and stop (possibly ramp down) the motor at the appropriate 170 pulse.
  2. Motor and Servo need a common interface in MRL-land .. So that you can use any of the Python scripts currently written for a Servo to work on your new "Motor-Servo" 

Does this sound desirable to you?

AdolphSmith's picture

Thank you. I will tri to

Thank you. I will tri to program Baby ardiuno if i do not succeed i will do this. Thank you.

 

AdolphSmith's picture

Grog please i must realy tri.

Grog please i must realy tri. Any small program that i can tri load in the Baby Arunutang please. It have like the picture shows buildt in motor driver and have everything. I know you can do this please

 

GroG's picture

Do you have a FDTI cable - so

Do you have a FDTI cable - so you can program the Orangutang ?

Can you post a picture of your current setup?

AdolphSmith's picture

(No subject)

AdolphSmith's picture

Grog i hope this is what you

Grog i hope this is what you ask

GroG's picture

Perfect Adolph ! Ok - They

Perfect Adolph !

Ok - They have a library, we do not want it - but I need to find out details about the H-Bridge.

Clever product tiny Arduino + Dual H-Bridge - theoretically, you should be able to drive Massive Adolph Servos from this board.  I see it uses pwm for speed control which is what I would expect - what I don't see at the moment is if its a :

  • Evil Dirty H-Bridge - where direction and speed are controlled on the same line but 2 pins - and it has a evil shoot-through state  .. or
  • Happy Good H-Bridge - where direction pin is seperate from the speed pin

I'm hoping for the latter - but haven't found the answer yet.

GroG's picture

Found it

Found it !

https://github.com/pololu/libpololu-avr/blob/master/src/OrangutanMotors/OrangutanMotors.cpp

Now I have to understand it :)

GroG's picture

Good news its a Happy Good

Good news its a Happy Good H-Bridge !!!

So it looks like a simple pwm pin for speed & direction is on another pin...

We need to find out exactly what pins your current motor is hooked up to - what are they?

The next step would be to make a very small sketch which drives the motor WITHOUT Pololu's Motor library.

Have you driven this motor with Pololu's Motor library yet?

What experiments have you done so far Adolph?

AdolphSmith's picture

At this stage i am bad. I

At this stage i am bad. I hooked everything up but can not find any skettch that i can use with motor and rotary encoder/ So i am realy stuck . Have every thing but no test without test script(Library) Mi connections is exactly as my first drawing in this blog . 

http://myrobotlab.org/sites/default/files/users/user884images/Servo%20Mi...

 

wvantoorn's picture

Adolph, did you try uploading

Adolph, did you try uploading a sketch to use the baby board without encoder? The encoder can be added easely, if you test with the scripts from the polulu site, you can test speed, direction and so, and after grog gets back i think he can build a simple sketch with an encoder in it to use as dc motor/servo  with poti.

GroG's picture

Small simple steps will win

Small simple steps will win the Race !

Step 1

Cause and effect - upload a simple blink program, does it work ?
Unplug everything from the Atmega 328 if you need too except the FDTI cable.
This is the first check. If it worky - you say "WORKY !"  and we move on to Step 2 - if it no worky - we find out why..

AdolphSmith's picture

Sory Grog what i ment was

Sory Grog what i ment was that blink leds working but other things not like motors.I have tested with blink led yes. Worky. Now for something in scrip that let motors run. Because all the scrips available need pot to get motors running. I do not use pot .

 

GroG's picture

I looked at some of the

I looked at some of the documentation & the libraries code.

I "think" PWM power is controlled by pin 6.  If that is correct a simple analog write should change the motors speed.

Try this 


#file : home/GroG/servoMotor.c edit raw
#include 
#include 
#include 
 
 
/*
 * OrangutanMotorExample for the 3pi robot, Orangutan LV-168, Orangutan SV-xx8,
 *   and Baby Orangutan B
 *
 * This example uses the OrangutanMotors library to drive
 * motors in response to the position of user trimmer potentiometer
 * and blinks the red user LED at a rate determined by the trimmer
 * potentiometer position.  It uses the OrangutanAnalog library to measure
 * the trimpot position, and it uses the OrangutanLEDs library to provide
 * limited feedback with the red user LED.
 *
 * http://www.pololu.com/docs/0J17/5.e
 * http://www.pololu.com
 * http://forum.pololu.com
 */
 
OrangutanAnalog analog;
OrangutanLEDs leds;
OrangutanMotors motors;
 
void setup()               // run once, when the sketch starts
{
 
}
 
void loop()                // run over and over again
{
  //                  M1   M2
  //motors.setSpeeds(128, 128);
  
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(14, OUTPUT);
  pinMode(15, OUTPUT);
  pinMode(16, OUTPUT);

  // PIN MAPPINGS M1 POWER PD5 == Pin 12
  analogWrite(1, 128);
  digitalWrite(1, 0);
  delay(1000);
  analogWrite(2, 128);
  digitalWrite(2, 0);
  delay(1000);
  analogWrite(3, 128);
  digitalWrite(3, 0);
  delay(1000);
  analogWrite(4, 128);
  digitalWrite(4, 0);
  delay(1000);
  analogWrite(5, 128);
  digitalWrite(5, 0);
  delay(1000);
  analogWrite(6, 128);
  digitalWrite(6, 0);
  delay(1000);
  analogWrite(7, 128);
  digitalWrite(7, 0);
  delay(1000);
  analogWrite(8, 128);
  digitalWrite(8, 0);
  delay(1000);
  analogWrite(9, 128);
  digitalWrite(9, 0);
  delay(1000);
  analogWrite(10, 128);
  digitalWrite(10, 0);
  delay(1000);
  analogWrite(11, 128);
  digitalWrite(11, 0);
  delay(1000);
  analogWrite(12, 128);
  digitalWrite(12, 0);
  delay(1000);
  analogWrite(13, 128);
  digitalWrite(13, 0);
  delay(1000);
  analogWrite(14, 128);
  digitalWrite(14, 0);
  delay(1000);
  analogWrite(15, 128);
  digitalWrite(15, 0);
  delay(1000);
  analogWrite(16, 128);
  digitalWrite(16, 0);
  delay(1000);
   
  leds.red(HIGH);       // turn red LED on
  delay(128);
 
  leds.red(LOW);       // turn red LED off
  delay(128);
}

If that works we can start thinking about the feedback of the encoder.  I hope your still interested in doing this ! 

 

AdolphSmith's picture

Yes i must get this working

Yes i must get this working thank you

AdolphSmith's picture

// F_CPU tells util/delay.h

// F_CPU tells util/delay.h our clock frequency
//#define F_CPU 8000000UL // Orangutan frequency (8MHz)
#define F_CPU 20000000UL // Baby Orangutan frequency (20MHz)
#include <avr/io.h>
#include <util/delay.h>
 
void delayms( uint16_t millis ) {
while ( millis ) {
_delay_ms( 1 );
millis--;
}
}
 
int main( void ) {
DDRD |= 1 << DDD1; // set LED pin PD1 to output
while ( 1 ) {
PORTD &= ~( 1 << PORTD1 ); // LED off
delayms( 900 ); // delay 900 ms
PORTD |= 1 << PORTD1; // LED on
delayms( 100 ); // delay 100 ms
}
return 0;
}
 
AdolphSmith's picture

This is message what i get of new script

Arduino: 1.6.3 (Windows 7), Board: "Pololu Orangutan or 3pi robot w/ ATmega328P"
 
sketch_apr26e.ino:1:27: fatal error: orangutanleds.h: No such file or directory
 
compilation terminated.
 
Error compiling.
 
  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
 
AdolphSmith's picture

This is working

#include <OrangutanLEDs.h>
#include <OrangutanAnalog.h>
#include <OrangutanMotors.h>
 
/*
 * OrangutanMotorExample for the 3pi robot, Orangutan LV-168, Orangutan SV-xx8,
 *   and Baby Orangutan B
 *
 * This example uses the OrangutanMotors library to drive
 * motors in response to the position of user trimmer potentiometer
 * and blinks the red user LED at a rate determined by the trimmer
 * potentiometer position.  It uses the OrangutanAnalog library to measure
 * the trimpot position, and it uses the OrangutanLEDs library to provide
 * limited feedback with the red user LED.
 *
 * http://www.pololu.com/docs/0J17/5.e
 * http://www.pololu.com
 * http://forum.pololu.com
 */
  
OrangutanAnalog analog;
OrangutanLEDs leds;
OrangutanMotors motors;
  
void setup()               // run once, when the sketch starts
{
  
}
  
void loop()                // run over and over again
{
  //                  M1   M2
  motors.setSpeeds(128, 128);
   
  pinMode(1, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  pinMode(14, OUTPUT);
  pinMode(15, OUTPUT);
  pinMode(16, OUTPUT);
 
  // PIN MAPPINGS M1 POWER PD5 == Pin 12
  analogWrite(1, 128);
  digitalWrite(40, 0);
  delay(1000);
  analogWrite(48, 128);
  digitalWrite(2, 0);
  delay(1000);
  analogWrite(55, 128);
  digitalWrite(3, 0);
  delay(1000);
  analogWrite(65, 128);
  digitalWrite(4, 0);
  delay(1000);
  analogWrite(45, 128);
  digitalWrite(5, 0);
  delay(1000);
  analogWrite(66, 128);
  digitalWrite(6, 0);
  delay(1000);
  analogWrite(77, 128);
  digitalWrite(7, 0);
  delay(1000);
  analogWrite(88, 128);
  digitalWrite(8, 0);
  delay(1000);
  analogWrite(59, 128);
  digitalWrite(9, 0);
  delay(1000);
  analogWrite(120, 128);
  digitalWrite(10, 0);
  delay(1000);
  analogWrite(111, 128);
  digitalWrite(11, 0);
  delay(1000);
  analogWrite(88, 128);
  digitalWrite(12, 0);
  delay(1000);
  analogWrite(93, 128);
  digitalWrite(13, 0);
  delay(1000);
  analogWrite(74, 128);
  digitalWrite(14, 0);
  delay(1000);
  analogWrite(85, 128);
  digitalWrite(15, 0);
  delay(1000);
  analogWrite(56, 128);
  digitalWrite(16, 0);
  delay(1000);
    
  leds.red(HIGH);       // turn red LED on
  delay(128);
  
  leds.red(LOW);       // turn red LED off
  delay(128);
}
 
AdolphSmith's picture

Motors need power and under

Motors need power and under 40 it dont start

GroG's picture

So when you comment

So when you comment out 

//motors.setSpeeds(128, 128);

it doesn't work ?

That's the goal Adolph, not to use the motors.setSpeed and still be able to move the motors .. :)

AdolphSmith's picture

If you

If you do //motors.setSpeeds(128, 128);

nothing turn
 
AdolphSmith's picture

(No subject)