LK-Servo: Unterschied zwischen den Versionen

Aus Linkerkit.de

Wechseln zu: Navigation, Suche
(Codebeispiel Arduino)
(Codebeispiel Arduino)
 
Zeile 13: Zeile 13:
 
</div>
 
</div>
 
==Codebeispiel Arduino==
 
==Codebeispiel Arduino==
<pre class="brush:cpp">#include  
+
<pre class="brush:cpp">#include <SoftwareSerial.h>
 
SoftwareSerial mySerial(3, 2);
 
SoftwareSerial mySerial(3, 2);
 
   
 
   
Zeile 27: Zeile 27:
 
{
 
{
 
   //cammand : S + PWM + Duty_H + Duty_L + E
 
   //cammand : S + PWM + Duty_H + Duty_L + E
   for(i=100;i<450;i++)   {
+
   for(i=100;i<450;i++)
 +
  {
 
     //PWM 1
 
     //PWM 1
 
     mySerial.print('S');  //Start
 
     mySerial.print('S');  //Start
     mySerial.print(char(1)); //PWM Kanal auswahl
+
     mySerial.print(char(1)); //PWM channel selection
 
     mySerial.print(char(i/0xFF)); //Duty HIGH
 
     mySerial.print(char(i/0xFF)); //Duty HIGH
 
     mySerial.print(char(i%0xFF)); //Duty LOW
 
     mySerial.print(char(i%0xFF)); //Duty LOW

Aktuelle Version vom 16. November 2016, 18:12 Uhr

Bild

LK-Servo.jpg

Technische Daten / Kurzbeschreibung

Linker Kit Platine mit einem Servo Modul. Die Kommunikation läuft über eine TTL UART serielle Schnittstelle.

Spezifikation

Anzahl an Channels: 8
Frequenz: 50Hz (ca. 20ms)
Präzision: 5us
Optionaler Eingang für externe Stromversorgung 6-15V
Kommunikationsinterface: UART (ein Formfaktor vom Linker kit)

Codebeispiel Arduino

#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 2);
 
void setup()
{
  mySerial.begin(9600);
  delay(100);
}
 
unsigned int i;
 
void loop()
{
   //cammand : S + PWM + Duty_H + Duty_L + E
   for(i=100;i<450;i++)
   {
     //PWM 1
     mySerial.print('S');   //Start
     mySerial.print(char(1)); //PWM channel selection
     mySerial.print(char(i/0xFF)); //Duty HIGH
     mySerial.print(char(i%0xFF)); //Duty LOW
     mySerial.print('E'); //End
 
     //PWM 2
     mySerial.print('S');
     mySerial.print(char(2));
     mySerial.print(char(i/0xFF));
     mySerial.print(char(i%0xFF));
     mySerial.print('E');
     delay(5);
   }
 
    for(i=450;i>100;i--)
   {
     mySerial.print('S');
     mySerial.print(char(1));
     mySerial.print(char(i/0xFF));
     mySerial.print(char(i%0xFF));
     mySerial.print('E');
     mySerial.print('S');
     mySerial.print(char(2));
     mySerial.print(char(i/0xFF));
     mySerial.print(char(i%0xFF));
     mySerial.print('E');
     delay(5);
   }
}

Codebeispiel Raspberry

 

Downloads

Infos:
Deutsch: 001359111-an-01-de-SERVOMODUL_FUER_ARDUINO.pdf