an dem Anderen bin ichn noch dran, habe aber ein Schaltplan für das Modul gefunden
- - - Aktualisiert - - -
so, jetzt habe ich folgendes gemacht:
von dieser webseite:
mit dieser einstellung:
diesenJumpers:
ENA Removed
ENB Removed
PWM1 Installed - wahrscheinlich durch die Verbindung ENA - Arduino3
PWM2 Installed - ENB verbunden mit Arduino6
On the header:
GND ==> GND on Arduino
5V ==> N/C (5V Logic power is available from on-board regulator)
ENB ==> Arduino 6
ENA ==> Arduino 3
IN1 ==> Arduino 2
IN2 ==> Arduino 4
IN3 ==> Arduino 7
IN4 ==> Arduino 8
Power Terminal Block:
5V ==> N/C
GND ==> Ground on Motor Power Supply
VCC ==> +12V (for 12 volt motor)
OUT1 Terminal Block:
Pin1 ==> Motor 1 +
Pin2 ==> Motor 1 -
OUT2 Terminal Block:
Pin1 ==> Motor 2 +
Pin2 ==> Motor 2 -Motor RH dreht ca. 5sec, stoppt und dreht 5sec in andere RichtungCode:/* L298N Test Code hacker.instanet.net Tim Laren timl@instanet.com This example code is in the public domain. */ #define OUT1PIN1 2 // H-bridge OUT1.1 #define OUT1PIN2 4 // H-bridge OUT1.2 #define ENABLE1 3 // H-bridge Ena 1 #define OUT2PIN1 7 // H-bridge OUT2.1 #define OUT2PIN2 8 // H-bridge OUT2.2 #define ENABLE2 6 // H-bridge Ena 2 void setup() { // setup motor pins pinMode(OUT1PIN1, OUTPUT); pinMode(OUT1PIN2, OUTPUT); pinMode(ENABLE1, OUTPUT); digitalWrite(ENABLE1, HIGH); // set the enables to high } void loop() { digitalWrite(OUT1PIN1, LOW); // set leg 1 of the H-bridge low digitalWrite(OUT1PIN2, HIGH); // set leg 2 of the H-bridge high delay(5000); digitalWrite(OUT1PIN1, HIGH); // set leg 1 of the H-bridge high digitalWrite(OUT1PIN2, LOW); // set leg 2 of the H-bridge low delay(5000); }
jetzt werde ich versuchen das für zwei Motoren zu erweitern...
edit:
zunächstmal geht auch Beschleunigung - mit diesemCode:/* L298N Test Code w/ Speed Control hacker.instanet.net Tim Laren timl@instanet.com This example code is in the public domain. */ #define OUT1PIN1 2 // H-bridge OUT1.1 #define OUT1PIN2 4 // H-bridge OUT1.2 #define ENABLE1 3 // H-bridge Ena 1 #define OUT2PIN1 7 // H-bridge OUT2.1 #define OUT2PIN2 8 // H-bridge OUT2.2 #define ENABLE2 6 // H-bridge Ena 2 void setup() { // setup Motor 1 pins pinMode(OUT1PIN1, OUTPUT); pinMode(OUT1PIN2, OUTPUT); // setup Motor 2 pins pinMode(OUT2PIN1, OUTPUT); pinMode(OUT2PIN2, OUTPUT); } void loop() { digitalWrite(OUT1PIN1, LOW); // set leg 1 of the H-bridge low digitalWrite(OUT1PIN2, HIGH); // set leg 2 of the H-bridge high Ramp(ENABLE1,0,255,1,10); Ramp(ENABLE1,255,0,-1,10); digitalWrite(OUT1PIN1, HIGH); // set leg 1 of the H-bridge high digitalWrite(OUT1PIN2, LOW); // set leg 2 of the H-bridge low Ramp(ENABLE1,0,255,1,10); Ramp(ENABLE1,255,0,-1,10); } void Ramp(int Motor, int Start, int End, int Inc, int Del) { /* Ramps from PWM of Start to End adding Inc each time delay of Del MS each time thru the loop */ for(int i=Start;i<End;i = i + Inc) { analogWrite(Motor, i); // Motor 1 Speed delay(Del); } }






Zitieren
Lesezeichen