Servo Motor Control: Unterschied zwischen den Versionen

Aus hyperdramatik
Zur Navigation springen Zur Suche springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(4 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
A classic servor motor is the
Two examples for connecting:
A stronger servo motor is the Dynamixel AX-12A


1) a classic servor motor to Arduino


==Example: Servo Motor Basics with Arduino==
2) a stronger servo motor, the Dynamixel AX-12A, to Arduino
 
 
==Example 1: Servo Motor Basics with Arduino==


https://docs.arduino.cc/learn/electronics/servo-motors
https://docs.arduino.cc/learn/electronics/servo-motors
Zeile 10: Zeile 13:




==Example: Using Dynamixel AX-12A Servo with Arduino==
==Example 2: Using Dynamixel AX-12A Servo with Arduino==


https://www.youtube.com/watch?v=JQSY8jlgW90
https://www.youtube.com/watch?v=JQSY8jlgW90


Using Dynamixel AX-12A Servo with Arduino


Wiring Diagram:
===Wiring Diagram===


AX-12A pin1: GND ---> DC -12V  
AX-12A pin1: GND ---> DC -12V  
Zeile 25: Zeile 27:


*** Connect the two grounds together ***
*** Connect the two grounds together ***
pinout diagram: https://github.com/makertut/ax12-arduino
===Arduino Library===
Download ZIP and install this library in Arduino:


Ax-12A Library https://github.com/jumejume1/AX-12A-servo-library
Ax-12A Library https://github.com/jumejume1/AX-12A-servo-library


https://camo.githubusercontent.com/02e93ce58f9b4fdcdf740bde1467ee4880feee7e7a98059af9716bfeeddd0dc6/68747470733a2f2f312e62702e626c6f6773706f742e636f6d2f2d6d62535a6d41716c7a446b2f576d79746a475a773452492f41414141414141415f2d772f414f63775146743571436b65365066585a744c4e754239584e523276486e685077434c63424741732f733430302f6178313270696e6f75742e706e67
====Code Example====
 
<source lang="js" line start="2" highlight="4-6">
 
/*
* Example showing how to send position commands to AX-12A
*/
 
#include "Arduino.h"
#include "AX12A.h"
 
#define DirectionPin  (10u)
#define BaudRate      (1000000ul)
#define ID        (1u)
 
int initial_pos = 512;
int max = initial_pos + 350;
int min = initial_pos - 350;
 
int pos = initial_pos;
int delta = 1;
 
void setup()
{
  ax12a.begin(BaudRate, DirectionPin, &Serial);
}
 
void loop()
{
  pos = pos + delta;
 
  if (pos > max)
  {
    pos = max;
    delta *= -1;
  }
 
  if (pos < min)
  {
    pos = min;
    delta *= -1;
  }
 
  ax12a.move(ID, pos);
  delay(20);
}
 
</source>

Aktuelle Version vom 24. Mai 2022, 17:23 Uhr

Two examples for connecting:

1) a classic servor motor to Arduino

2) a stronger servo motor, the Dynamixel AX-12A, to Arduino


Example 1: Servo Motor Basics with Arduino

https://docs.arduino.cc/learn/electronics/servo-motors

sweep_bb-2.png


Example 2: Using Dynamixel AX-12A Servo with Arduino

https://www.youtube.com/watch?v=JQSY8jlgW90


Wiring Diagram

AX-12A pin1: GND ---> DC -12V

AX-12A pin2: VDD ---> DC +12V

AX-12A pin3: DATA ---> Tx pin of Arduino

      • Connect the two grounds together ***

pinout diagram: https://github.com/makertut/ax12-arduino


Arduino Library

Download ZIP and install this library in Arduino:

Ax-12A Library https://github.com/jumejume1/AX-12A-servo-library

Code Example

/*
 * Example showing how to send position commands to AX-12A
 */

#include "Arduino.h"
#include "AX12A.h"

#define DirectionPin   (10u)
#define BaudRate      (1000000ul)
#define ID        (1u)

int initial_pos = 512;
int max = initial_pos + 350;
int min = initial_pos - 350;

int pos = initial_pos;
int delta = 1;

void setup()
{
  ax12a.begin(BaudRate, DirectionPin, &Serial);
}

void loop()
{
  pos = pos + delta;

  if (pos > max)
  {
    pos = max;
    delta *= -1;
  }

  if (pos < min)
  {
    pos = min;
    delta *= -1;
  }

  ax12a.move(ID, pos);
  delay(20);
}