stepper motor mit potentiometer steuern

Hy habe einen stepper und möchte damit meine drosselklappe vom auto steuern...ich habe einen arduino uno und das adafruit motor shield v2.3

über das sketch kann ich den motor so steuern das der weg den ich brauche in einer annehmbaren geschwindigkeit laufen lassen kann. den poti kann ich mit dem analoginout auslesen. aber ich habe keine ahnung wie ich das mache das das ausgelesene im monitor auch das signal für den motor ist

jemand ne idee

Ja, deine Tastatur ist defekt. Die kann keine Großbuchstaben schreiben.
Und ohne den Sketch können wir nur raten und das geht nicht mehr.

/*
Analog input, analog output, serial output

Reads an analog input pin, maps the result to a range from 0 to 255
and uses the result to set the pulsewidth modulation (PWM) of an output pin.
Also prints the results to the serial monitor.

The circuit:

  • potentiometer connected to analog pin 0.
    Center pin of the potentiometer goes to the analog pin.
    side pins of the potentiometer go to +5V and ground
  • LED connected from digital pin 9 to ground

created 29 Dec. 2008
modified 9 Apr 2012
by Tom Igoe

This example code is in the public domain.

*/

// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to

int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)

void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}

void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);

// print the results to the serial monitor:
Serial.print("sensor = ");
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);

// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(2);
}

Bitte setzen den Sketch in Code-Tags, Schaltfläche "</>" oben links im Editor. Das kannst du auch nachträglich noch ändern.

Das was du gepostet hast ist doch ein Beispielsketch, wo ist denn die Einbindung des Stepper-Motors ?

HotSystems:
Bitte setzen den Sketch in Code-Tags, Schaltfläche "</>" oben links im Editor. Das kannst du auch nachträglich noch ändern.

Das was du gepostet hast ist doch ein Beispielsketch, wo ist denn die Einbindung des Stepper-Motors ?

ja das habe ich versucht kriege es abernicht hin

/*
This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
It won't work with v1.x motor shields! Only for the v2's with built in PWM
control

For use with the Adafruit Motor Shield v2
----> Adafruit Motor/Stepper/Servo Shield for Arduino v2 Kit [v2.3] : ID 1438 : $19.95 : Adafruit Industries, Unique & fun DIY electronics and kits
*/

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);

// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");

AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz

myMotor->setSpeed(140); // 100 rpm
}

void loop() {
Serial.println("Single coil steps");
myMotor->step(60, FORWARD, SINGLE);
myMotor->step(60, BACKWARD, SINGLE);

}

Sketch markiern und die Schaltfläche "</>" verwenden.
Ist doch einfach, oder. Kann aber auch an der Tastatur liegen.

war das richtig wie ich das sketch eingefügt habe

mit diesem sketch versuche ich es schon 4 tage zum laufen zu bringen...immer dieselbe fehler meldung

exit status 1
redefinition of 'void setup()'

hier das sketch

// These constants won't change. They're used to give names
// to the pins used:
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to

int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)

void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}

void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin, outputValue);

// print the results to the serial monitor:
Serial.print("sensor = ");
Serial.print(sensorValue);
Serial.print("\t output = ");
Serial.println(outputValue);

// wait 2 milliseconds before the next loop
// for the analog-to-digital converter to settle
// after the last reading:
delay(2);
}

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);

// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Stepper test!");

AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz

myMotor->setSpeed(140); // 100 rpm
}

void loop() {
Serial.println("Single coil steps");
myMotor->step(60, FORWARD, SINGLE);
myMotor->step(60, BACKWARD, SINGLE);

}

setup() und loop() dürfen nur genau einmal im Sketch existieren.

Zwei Beispiel-Programme zusammenkopieren geht nicht, sie müssen verwoben werden.

agmue:
setup() und loop() dürfen nur genau einmal im Sketch existieren.

Zwei Beispiel-Programme zusammenkopieren geht nicht, sie müssen verwoben werden.

ja aber wie mache ich das

quattrkai:
ja aber wie mache ich das

Wie wäre es denn, wenn du einfach mal liest.

  1. was wir dir schreiben.
  2. Die Grundlagen.

Wie sollen wir dir helfen, wenn du unsere Posts nicht liest.

quattrkai:
ja aber wie mache ich das

Erstmal die zusammengehörigen Bereiche zusammenfassen:

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);

// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);



// These constants won't change.  They're used to give names
// to the pins used:
const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to

int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Stepper test!");

  AFMS.begin();  // create with the default frequency 1.6KHz
  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz

  myMotor->setSpeed(140);  // 100 rpm
}

void loop() {
  Serial.println("Single coil steps");
  myMotor->step(60, FORWARD, SINGLE);
  myMotor->step(60, BACKWARD, SINGLE);

  // read the analog in value:
  sensorValue = analogRead(analogInPin);
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 0, 255);
  // change the analog out value:
  analogWrite(analogOutPin, outputValue);

  // print the results to the serial monitor:
  Serial.print("sensor = ");
  Serial.print(sensorValue);
  Serial.print("\t output = ");
  Serial.println(outputValue);

  // wait 2 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
  delay(2);
}

So ist der Compiler zufrieden. Nun mußt Du noch die gewünschte Funktionalität implemetieren.

natürlich bin ich zufrieden und vielen dank schon im voraus für eure hilfe stellung...ich gestehe ds ich echt keine ahnung habe davon....ich benötige das leider da ich als rollstuhl fahrer mit meinem bmw driften möchte

kann ich das nach lesen irgendwo welche Funktionalität ich implemetieren muss...ganz ehrlich ich habe keine ahnung

super agmue das sketch läuft....habe es mir malangesehen und verstanden was gemeint war mit nur einmal setup() und loop()

allerdings steht der motor

void loop() {
Serial.println("Single coil steps");
myMotor->step(60, FORWARD, SINGLE);
myMotor->step(60, BACKWARD, SINGLE);

ja immer noch auf so das er von alleine 60 schritte vorwörts und dann 60 schritte rückwärts fährt....wie geht das das der motor das ausgelesene nun auch fährt...
habe es mir auch mal im serielen monitor angesehen jetzt kann ich die werte sehen....nur sind sie noch nicht verknüpft mit dem motor

Jetzt sind die Teile formal verknüft, nun muß noch die inhaltliche Verbindung erfolgen. Versuche mal (ungetestet):

  myMotor->step(outputValue, FORWARD, SINGLE);
  myMotor->step(outputValue, BACKWARD, SINGLE);

Damit sollten sich die Schritte beeinflussen lassen.

agmue:
Jetzt sind die Teile formal verknüft, nun muß noch die inhaltliche Verbindung erfolgen. Versuche mal (ungetestet):

  myMotor->step(outputValue, FORWARD, SINGLE);

myMotor->step(outputValue, BACKWARD, SINGLE);




Damit sollten sich die Schritte beeinflussen lassen.

hy das habe ich gestern schon gemacht...hat funktioniert....supi vielen vielen dank das funktioniert....

leider fährt der stepper motor dann aber sagen wir mal z.b. 50 schritte vorwärts und dann rückwärts....da er ja das output ausliest und dann denn wert erst vorwärts und dann rückwärts fährt....

leider bekomme ich im moment das hier

Der Sketch verwendet 4978 Bytes (15%) des Programmspeicherplatzes. Das Maximum sind 32256 Bytes.
Globale Variablen verwenden 568 Bytes (27%) des dynamischen Speichers, 1480 Bytes für lokale Variablen verbleiben. Das Maximum sind 2048 Bytes.
avrdude: verification error, first mismatch at byte 0x0000
0xff != 0x0c
avrdude: verification error; content mismatch
avrdude: verification error; content mismatch

habe die arduino software schon neu instaliert...hat aber nix gebracht....

quattrkai:
leider fährt der stepper motor dann aber sagen wir mal z.b. 50 schritte vorwärts und dann rückwärts....da er ja das output ausliest und dann denn wert erst vorwärts und dann rückwärts fährt....

Der Motor macht das, was Du programmiert hast. Ist doch schon mal ein Schritt in die richtige Richtung, also Schulterklopfen und freuen!

Poti und Drosselklappe hört sich wie ein Handgas an, richtig? Da wäre ein Servo möglicherweise besser geeignet denn ein Schrittmotor. Hast Du Dich bewußt für einen Schrittmotor entschieden? Wenn ja, geht das natürlich auch: Proportional zur Potistellung den Schrittmotor bewegen. Oder hast Du eine andere Vorstellung?

Wenn Du mir versicherst, Du bist volljährig und hälst Dich an die in Deinem Land gültigen Gesetze, besonders die Straßenverkehrsordnung und die Straßenverkehrszulassungsordnung, mache ich bei diesem Thema weiter.

Ein Stepper ist hier nicht der optimale Ansatz. Nimm lieber einen Servo. So eine Lösung habe ich an einem 1200er Käfermotor mit Vergaser seit Jahren am Laufen

avrdude: verification error, first mismatch at byte 0x0000
0xff != 0x0c

Wenn du Pech hast, ist dein Bootloader geschrottet und du müsstest einen neuen BL drüberbügeln.
Vorher mal das USB-Kabel vom Board ziehen und neu aufstecken, so dass Windows (ich gehe davon aus, dass du Windows xyz nutzt?) es neu erkennen kann. Manchmal (aber auch nur manchmal) hilft das bei diesem Fehler; leider deutet diese Fehlermeldung aber auf einen korrupten Bootloader hin.

agmue:
Der Motor macht das, was Du programmiert hast. Ist doch schon mal ein Schritt in die richtige Richtung, also Schulterklopfen und freuen!

Poti und Drosselklappe hört sich wie ein Handgas an, richtig? Da wäre ein Servo möglicherweise besser geeignet denn ein Schrittmotor. Hast Du Dich bewußt für einen Schrittmotor entschieden? Wenn ja, geht das natürlich auch: Proportional zur Potistellung den Schrittmotor bewegen. Oder hast Du eine andere Vorstellung?

Wenn Du mir versicherst, Du bist volljährig und hälst Dich an die in Deinem Land gültigen Gesetze, besonders die Straßenverkehrsordnung und die Straßenverkehrszulassungsordnung, mache ich bei diesem Thema weiter.

hy...natürlich bin ich volljährig ich bin 40 jahre und querschnittsgelähmt also rollstuhlfahrer....ich habe zwar ein handgas und eine bremse i meinem alltags auto aber zum driften ist das echter käse....

ich habe mich für einen schrittmotor entschieden weil ich dachte das wäre ideal dafür....deine programierung hat ja auch funktioniert.... aber der motor hat ja immer den wert des potis genommen und ist dann erst vorwärts und dann den wert des potis rückwärts gefahren

kann man das nicht machen das zum beispiel der wert des potis z.B. 33 beim stepper motor die Position 0 ist und dann z.B. der wert vom poti 500 vollgas ist

wäre echt geil wenn du mir da weiter helfen kannst agmue