Benutzer-Werkzeuge

Webseiten-Werkzeuge


bauteile:trexdmc

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen gezeigt.

Link zu dieser Vergleichsansicht

Nächste Überarbeitung
Vorhergehende Überarbeitung
bauteile:trexdmc [2014/01/14 14:19]
c.jaedicke angelegt
bauteile:trexdmc [2016/01/21 12:45] (aktuell)
Zeile 1: Zeile 1:
----Motor Treiber TRex DMC---+=====Motor Treiber TRex DMC===== 
 Ein Beispiel-Programm zum Ansteuern des TRex DMC durch die Arduino-Plattform:​ Ein Beispiel-Programm zum Ansteuern des TRex DMC durch die Arduino-Plattform:​
 +
 <code java> <code java>
 /* /*
Zeile 19: Zeile 21:
     ; // wait for serial port to connect. Needed for Leonardo only     ; // wait for serial port to connect. Needed for Leonardo only
   }   }
- 
- 
-  Serial.println("​Goodnight moon!"​);​ 
  
   // set the data rate for the SoftwareSerial port   // set the data rate for the SoftwareSerial port
Zeile 45: Zeile 44:
   mySerial.write(20);​ //​Speedvalue from 0 to 127   mySerial.write(20);​ //​Speedvalue from 0 to 127
 } }
-<​code ​java>+</code> 
 + 
 +// 
 +erweiterter Code: 
 +// 
 +<​code>​ 
 + 
 +/* 
 + The circuit:  
 + ​*connect RX3 Pin 14 to SO on TRex DMC 
 + ​*connect TX3 Pin 15 to SI on TRex DMC 
 +  
 +  
 + */ 
 +  
 +void setup() ​  
 +
 +  // Open serial communications and wait for port to open: 
 +  Serial.begin(57600);​ 
 + 
 +  
 +  // initialize connection to trex 
 +  Serial3.begin(19200);​ 
 +  // further Data-Query Commands: http://​www.pololu.com/​file/​download/​TReX_Commands_v1.2.pdf?​file_id=0J1 
 +   
 +  //Ask the trex module if serial control is enabled 
 +  Serial3.write(0x83);​  
 +  delay(100);​ 
 +  if(Serial3.read() == 1){ 
 +    Serial.println("​Serial is in control!"​);​ 
 +  }else{ 
 +    Serial.println("​Serial ist not in control!"​);​ 
 +  } 
 +  
 +
 +  
 +void loop()  
 +{   
 +  //drive forward: (Motor 1: 0xC2, Motor 2: 0xCA) 
 +   
 +  // Motor 1  
 +  Serial3.write(0xC2);​ //forward motor 1 
 +  Serial3.write(100);​ //​Speedvalue from 0 to 127 
 +  //Motor 2 
 + ​Serial3.write(0xCA);​ //forward motor 2 
 + ​Serial3.write(100);​ //​Speedvalue from 0 to 127 
 +  
 +/*  drive reverse: (Motor 1: 0xC1, Motor 2: 0xC9) 
 +  
 +   // Motor 1  
 +  Serial3.write(0xC1);​ //reverse motor 1 
 +  Serial3.write(100);​ //​Speedvalue from 0 to 127 
 +  //Motor 2 
 + ​Serial3.write(0xC9);​ //reverse motor 2 
 + ​Serial3.write(100);​ //​Speedvalue from 0 to 127  
 +  
 +  
 + drive left:  
 +  
 +   // Motor 1  
 +  Serial3.write(0xC2);​ //forward motor 1 
 +  Serial3.write(100);​ //​Speedvalue from 0 to 127 
 +  //Motor 2 
 + ​Serial3.write(0xCA);​ //forward motor 2 
 + ​Serial3.write(50);​ //​Speedvalue from 0 to 127 
 +  
 + drive right: 
 +  
 +    // Motor 1  
 +  Serial3.write(0xC2);​ //forward motor 1 
 +  Serial3.write(50);​ //​Speedvalue from 0 to 127 
 +  //Motor 2 
 + ​Serial3.write(0xCA);​ //forward motor 2 
 + ​Serial3.write(100);​ //​Speedvalue from 0 to 127 
 + */ 
 +  
 +
 + 
 +</code>
bauteile/trexdmc.1389705588.txt.gz · Zuletzt geändert: 2016/01/21 12:45 (Externe Bearbeitung)