Loading...
  Show Posts
Pages: [1] 2 3
1  International / Deutsch / Re: Schrittmotoren laufen langsam, sobald zusätzlicher Code hingezufügt wird on: April 14, 2013, 08:51:35 am
Hab grad bemerkt, dass es evtl. an der LiquidCrytal-Library liegen könnte.

Sobald ich folgende Zeilen einfüge, laufen die Schrittmotoren deutlich langsamer:

Code:
  lcd.setCursor(1,0);
  lcd.print("VIDEO");
  lcd.setCursor(1,1);
  lcd.print("TIMELAPSE");
  lcd.setCursor(12,0);
  lcd.print("PANO");

Innerhalb der Library sind auch mehrere delayMicroseconds enthalten.

Gibt es andere LCD-Libraries ohne delay-Funktionen?
2  International / Deutsch / Re: Schrittmotoren laufen langsam, sobald zusätzlicher Code hingezufügt wird on: April 13, 2013, 12:24:25 pm
Alle Delays, die ich benutze, werden nur aufgerufen, wenn ich den JoyStick bewege, oder den Taster drücke. Deshalb habe ich den Aufruf für den Stepper (AccelStepperX.run()smiley-wink zum Testen auch gleich zu Beginn des loop-voids geschrieben.

Da das Problem auch auftritt, wenn ich keine Eingaben mache, also auch kein Delay aufrufe, liegt es nicht an den delays.
3  International / Deutsch / Schrittmotoren laufen langsam, sobald zusätzlicher Code hingezufügt wird on: April 13, 2013, 11:26:30 am
Hallo,

ich baue mir grad einen Controller, mit dem ich 2 Schrittmotoren ansteuern kann. Beide Schrittmotoren sind über Pololu-Controller mit dem Arduino verbunden. Zusätzlich habe ich ein 16x2-LCD-Display und einen Joystick und Taster zur Steuerung.

Als Library für die Schrittmotoren nutze ich den AccelStepper.

Mein Problem ist nun, dass die Schrittmotoren extrem langsam werden, sobald zusätzliche Code dazugefügt wird. Ohne das analogRead und das Switch/Case laufen die Motoren normal/schnell. Mit dem analogRead langsamer und sobald das Switch/Case dazu kommt laufen die in Zeitlupe.

Wie müsste ich das Programm aufbauen, damit die Schrittmotoren nicht vom restlichen Code beeinflusst werden?

Zum Einsatz kommt ein Arduino MEGA 2560.

CODE IST NOCH NICHT VOLLSTÄNDIG:

Code:
#include <LiquidCrystal.h>
#include <AH_Pololu.h>
#include <AccelStepper.h>

LiquidCrystal lcd(29, 27, 22, 24, 26, 28);

//-------------Defintion for AH_Pololu-----------------
AH_Pololu stepperY(200,30,31,51,50,49,48); // Kippen
AH_Pololu stepperX(200,34,35,45,44,43,42); // Drehen

//-------------Defintion for AccelStepper-----------------
AccelStepper AccelStepperY(1, 31, 30); // Kippen
AccelStepper AccelStepperX(1, 35, 34); // Drehen

//-------------Defintion Analoge Eingänge-----------------
const int button0 =  A0;
const int joyX =  A1; // Nullwert = 525
const int joyY =  A2; // Nullwert = 537

//-------------Werte Analoge Eingänge-----------------
int button0_value = 0;
int joyX_value = 0;
int joyY_value = 0;

int progStep = 0; // 0 = Auswahl Modus -- 1 = Auswahl Motion -- 2 = Programmablauf
int modus       = 0; // 0=VIDEO   --  1=TIMELAPSE  --  2=PANO
int motionModus = 0; // 0=SLIDER  --  1=PANOHEAD   --  2=BOTH

int caseVIDEO = 0;
int caseTIMELAPSE = 0;
int casePANO = 0;

int hzX;
int schrittX =0;

int hzY;
int schrittY =0;
void setup()
{
    pinMode (button0, INPUT);
    pinMode (joyX, INPUT);
    pinMode (joyY, INPUT);
  //Serial.begin(115200);
  lcd.begin(16, 2);              // start the library
  AccelStepperX.setMaxSpeed(2000);
  AccelStepperX.setAcceleration(1000);
  AccelStepperX.moveTo(-8000);
}

void loop()
{
    AccelStepperX.run();
   

  //-------------Einlesen der Eingaben-----------------
  joyX_value = analogRead(joyX);
  joyY_value = analogRead(joyY);
  button0_value = analogRead(button0);

  switch(progStep){

    //------Auswahl Modus-------
  case 0:
    AuswahlModus();
    break;
    //------Auswahl Motion-------
  case 1:
    AuswahlMotion();
    break;
    //------Auswahl Programmablauf-------
  case 2:
    switch (modus){
    case 0:
      video();
      break;

    case 1:
      timelapse();
      break;

    case 2:
      pano();
      break;
    }
    break;

  } // switch (progStep)
} // void loop()

Code:
//---------------------------------------------------------------
//-----------------------Auswahl Modus---------------------------
//---------------------------------------------------------------

void AuswahlModus(){
  //-------Auswahl Modus - Anzeige---------
  lcd.setCursor(1,0);
  lcd.print("VIDEO");
  lcd.setCursor(1,1);
  lcd.print("TIMELAPSE");
  lcd.setCursor(12,0);
  lcd.print("PANO");   
  //------Auswahl Modus - Control-Display-----------
  if (modus==0){
    lcd.setCursor(0,0);
    lcd.print(">");
  }
  else if(modus==1){
    lcd.setCursor(0,1);
    lcd.print(">");
  }
  else{
    lcd.setCursor(11,0);
    lcd.print(">");
  }

  //-------Auswahl Modus - Control-Funktion---------------------------------
  if(joyX_value>1000){
    delay(400);

    if(modus==0){
      modus=1;
    }
    else if(modus==1){
      modus=2;
    }
    else{
      modus=0;
    }
    lcd.clear();
  }
  if(button0_value>1000){
    delay(400);
    progStep+=1;
    lcd.clear();
  }
}
//---------------------------------------------------------------
//----------------------Auswahl Motion---------------------------
//---------------------------------------------------------------

void AuswahlMotion(){

  //-------Auswahl Motion - Anzeige---------------------------
  lcd.setCursor(1,0);
  lcd.print("PAN/TILT");
  lcd.setCursor(1,1);
  lcd.print("SLIDER");
  lcd.setCursor(12,0);
  lcd.print("BOTH");   
  //------Auswahl Motion - Control-Display--------------------------------
  if (motionModus==0){
    lcd.setCursor(0,0);
    lcd.print(">");
  }
  else if(motionModus==1){
    lcd.setCursor(0,1);
    lcd.print(">");
  }
  else{
    lcd.setCursor(11,0);
    lcd.print(">");
  }

  //------Auswahl Motion - Control-Funktion--------------
  if(joyX_value==1023){
    delay(400);

    if(motionModus==0){
      motionModus=1;
    }
    else if(motionModus==1){
      motionModus=2;
    }
    else{
      motionModus=0;
    }
    lcd.clear();
  }

  if(button0_value>1000){
    delay(400);
    progStep+=1;
    lcd.clear();
  }
}

Code:
//---------------------------------------------------------------
//---------------------------VIDEO-------------------------------
//---------------------------------------------------------------
void video(){
 
  //-----------Caseweiterschaltung durch Button----------
  if(button0_value>1000){
    delay(400);
    caseVIDEO+=1;
    lcd.clear();
  }
 
  int HzX =4000;

  switch (caseVIDEO){

  case 0:
    lcd.setCursor(6,0);
    lcd.print("MOVE");
    lcd.setCursor(0,1);
    lcd.print("TO STARTPOSITION");
   
stepperX.setSpeedHz(1000);
stepperX.move(-10);
delay(100);
   // stepperX.setSpeedHz(HzX);
   // stepperX.move(16);



 /*      //-----------X----------------------
   if (joyX_value >550 && joyX_value<700)
   {
   schrittX-=8;
   hzX =300;
   }
   if (joyX_value >700 && joyX_value <1020)
   {
   schrittX-=8;
   hzX =1000;
   }
   if (joyX_value >1020)
   {
   schrittX-=8;
   hzX =5000;
   }
   
   if (joyX_value <520 && joyX_value>300)
   {
   schrittX+=8;
   hzX =300;
   }
   if (joyX_value <300 && joyX_value >20)
   {
   schrittX+=8;
   hzX =1000;
   }
   if (joyX_value <20)
   {
   schrittX+=8;
   hzX =5000;
   }
  //-----------------Y----------------------
  if (joyY_value >540 && joyY_value<700)
  {
    schrittY+=8;
    hzY =300;
  }
  if (joyY_value >700 && joyY_value <1020)
  {
    schrittY+=8;
    hzY =1000;
  }
  if (joyY_value >=1020)
  {
    schrittY+=8;
    hzY =5000;
  }

  if (joyY_value <510 && joyY_value>300)
  {
    schrittY-=8;
    hzY =300;
  }
  if (joyY_value <300 && joyY_value >5)
  {
    schrittY-=8;
    hzY =1000;
  }
  if (joyY_value <=5)
  {
    schrittY-=8;
    hzY =5000;
  }
 
  stepperX.setSpeedHz(hzX);   
  stepperX.move(schrittX);
   
  stepperY.setSpeedHz(hzY);
  stepperY.move(schrittY);*/
    break;

  case 1:
    break;

  case 2:
    break;

  case 3:
    break;

  case 4:
    break;
  }
}


//---------------------------------------------------------------
//-------------------------TIMELAPSE-----------------------------
//---------------------------------------------------------------
void timelapse(){
  lcd.setCursor(0,1);
  lcd.print("TIMELAPSE");

}

//---------------------------------------------------------------
//----------------------------PANO-------------------------------
//---------------------------------------------------------------
void pano(){
  lcd.setCursor(0,1);
  lcd.print("PANO");

}

4  International / Deutsch / Saubere und übersichtliche Programmierweise gesucht on: March 31, 2013, 03:19:04 am
Hallo,

momentan bin ich an einem Projekt dran und es wird wohl auf >1000 Zeilen Code hinauslaufen. Bisher habe ich einfach alles in eine Datei und ins void loop() reingeschrieben. Das ist natürlich alles andere als übersichtlich.

Kennt einer von euch eine Seite, die eine saubere und übersichtliche Programmierweise für Arduino-Programme vorschlägt?
5  International / Deutsch / Re: [Schrittmotor] Schritte mit AccelStepper zählen on: March 25, 2013, 05:31:44 am
http://www.airspayce.com/mikem/arduino/AccelStepper/

Und hier der Code, mit dem ich momentan die Stepper per Joystick bewege:

Code:
#include <AccelStepper.h>

AccelStepper Xaxis(1, 5, 4); // pin 2 = step, pin 5 = direction
AccelStepper stepper(1, 9, 8); // pin 2 = step, pin 5 = direction

int schritte = 0;

void setup()

   Xaxis.setMaxSpeed(1000);
   Yaxis.setMaxSpeed(1000);
}

void loop()
{   
  int joyX_value = analogRead(A0);
  int joyY_value = analogRead(A1);
 
  //-------X-Achse--------
  if(joyX_value <100){
  Xaxis.setSpeed(-(1023-joyX_value)*2);
  Xaxis.runSpeed();
  } 
  if(joyX_value <500){
  Xaxis.setSpeed(-(1023-joyX_value)*0.2);
  Xaxis.runSpeed();
  }
  if(joyX_value >520){
  Xaxis.setSpeed(joyX_value*0.2);
  Xaxis.runSpeed();
  }
  if(joyX_value >1000){
  Xaxis.setSpeed(joyX_value*2);
  Xaxis.runSpeed();
  }
 
  //------Y-Achse----------
    if(joyY_value <100){
  Yaxis.setSpeed(-(1023-joyY_value)*2);
  Yaxis.runSpeed();
  } 
  if(joyY_value <500){
  Yaxis.setSpeed(-(1023-joyY_value)*0.2);
  Yaxis.runSpeed();
  }
  if(joyY_value >520){
  Yaxis.setSpeed(joyY_value*0.2);
  Yaxis.runSpeed();
  }
  if(joyY_value >1000){
  Yaxis.setSpeed(joyY_value*2);
  Yaxis.runSpeed();
  }
}
6  International / Deutsch / [Schrittmotor] Schritte mit AccelStepper zählen on: March 24, 2013, 01:31:42 pm
Hallo,

ich plane grad einen Panoramakopf für meine Kamera.

Es müssen zwei Schrittmotoren mit Pololu-Treiber angesteuert werden.

Geplante Funktion:
1. manuelles Anfahren der Startposition per Joystick (funktioniert bereits).
2. Speichern der Startposition bzw. Setzen der Zähler auf 0.
3. manuelles Anfahren der Endposition per Joystick
4. Speichern der Endposition.

Ich finde die Accelstepper-Library sehr schlecht beschrieben bzw. finde mich überhaupt nicht zurecht.

Was mir nun fehlt, ist die Funktion für Schritt 3, also das Zählen der Schritte. Gibt es da schon was fertiges oder wie kann ich das am besten lösen? Ich möchte also mit dem Joystick die Schrittmotoren bewegen und dabei sollen die Schritte gezählt werden, die zurückgelegt wurden.

7  International / Deutsch / Re: homecontrol4me - Zeitplan einrichten on: January 08, 2013, 03:47:17 pm
Hast du evtl. einen passenden Link? Ich habe nur den Thread gefunden, wo sowas geplant wird, aber noch nicht umgesetzt wurde.

Ab V2(Ende des Jahres) soll wohl die Funktion standardmäßig enthalten sein.
8  Using Arduino / Motors, Mechanics, and Power / Re: Fast stepper library for 6 steppers at same time with controler (Step/Dir) on: January 05, 2013, 11:08:18 am
Hi,
did you find any library which suits your requirements?

I´am also searching for a library with the requirements above.
9  International / Deutsch / homecontrol4me - Zeitplan einrichten on: January 05, 2013, 07:18:22 am
Hallo,
ich benutze HC4M:
http://www.homecontrol4.me/de/

um meine Lampen, PC etc. per Androidphone zu steuern.

Nun würde ich gern einen Zeitplan einrichten, sodass die Lampen zu einer bestimmten Uhrzeit ein- und ausgeschaltet werden. Eine DS1307 RTC ist bereits vorhanden.

Mein größtes Problem ist nun, wie ich in der Weboberfläche die entsprechenden Buttons hinzufüge und mit der RTC so verknüpfe, dass entsprechend geschaltet wird.

Ich habe mir zwar schon die Codes angeschaut, blick jedoch überhaupt nicht durch, welcher Teil für was ist. Im HC4M-Forum gibt es leider auch keine Lösung für meine gewünschte Funktion.

Hat sich jmd. schon mal mit der Thematik beschäftigt?
10  International / Deutsch / Re: AH_Pololu - on: January 04, 2013, 10:11:41 am
Ok, ich habe vor bis zu 5 Schrittmotoren gleichzeitig anzusteuern.

Welche Library eignet sich da am besten?

Ich hatte mir AccelStepper angeschaut, blick da jedoch überhaupt nicht durch.
Ziel  ist eine Steuerung für Timlapse-Aufnahmen, also Bewegung-->Pause-->Bewegung.

Da ich "Kurven fahren" möchte, brauche ich für jede Bewegung eine andere Anzahl an Schritten. Diese Schritte sind in einer txt-Datei gespeichert und sollen bei jedem Durchlauf ausgelesen und durchgeführt werden.

Die Library soll einfach nur eine konstante Geschwindigkeit liefern und mir die Möglichkeit bieten eine bestimmte Anzahl von Schritten zu fahren. Bei AccelStepper habe ich das irgendwie nicht hinbekommen, die Beschreibung auf deren Seite ist ziemlich unverständlich für Anfänger, auch mit dem Beispielen konnte ich mein Ziel nicht erreichen,
11  International / Deutsch / Pololu A4988 - mehrere Stepper ohne Delay ansteuern on: January 04, 2013, 05:46:47 am
Hallo,

ich benutze den Pololu A4988 und habe folgende Library gefunden:
http://arduino.alhin.de/index.php?n=48

Für mich ist es nicht ganz ersichtlich, ob die Library den Code an irgendeiner Stelle block/pausiert, oder ob alles gleichzeitig ausgeführt wird.

Zumindest habe ich kein delay() in der Library gefunden.

Da ich u.a. ein LCD-Display benutze, muss der Code so sein, dass es nicht blockt.
12  Using Arduino / Programming Questions / Re: SplinesMaster Library - How the add additional graphes? on: December 30, 2012, 12:25:57 pm
I dont want 6 dimensions, I need 5 2D graphes.
It should look like the graph in the picture
13  Using Arduino / Programming Questions / Re: SplinesMaster Library - How the add additional graphes? on: December 30, 2012, 08:22:35 am
Calculating the values and storing it to the SD works fine, but I´ve only tried with one graph, as in the catmull-example. Now I want to calculate 4 other graphes at the same time.

Here is the original example:

Code:
  float x[7] = {-1,0,1,2,3,4, 5};
  float y[7] = { 0,0,8,5,2,10,10};
  tempCurve.setPoints(x,y,7);
  tempCurve.setDegree( Catmull );
 
  for( float i = 0; i <= 4; i+= .1 ) {
    float temp = tempCurve.value(i);
    Serial.print(i);
    for(float j=0; j<= temp; j += .2) {
      Serial.print( "*" );
    }
    Serial.print( "   " );
    Serial.println(temp);
  }

The function in the for-loop only calculates the values for x and y.

Now I want to have a working code which looks like this:

Code:

float u[7] = {-1,0,1,2,3,4, 5};
float v[7] = { 0,0,8,5,2,10,10};
float w[7] = { 0,0,8,5,2,10,10};
float x[7] = {-1,0,1,2,3,4, 5};
float y[7] = { 0,0,8,5,2,10,10};
float z[7] = { 0,0,8,5,2,10,10};
  tempCurve.setPoints(u,v,w,x,y,z,7);
  tempCurve.setDegree( Catmull );
 
  for( float i = 0; i <= 4; i+= .1 ) {
    float temp = tempCurve.value(i);
    Serial.print(i);
    Serial.print( "   " );
    Serial.println(temp);

And temp should output the values for u,v,w,y and z. Now my problem ist, that I don´t know which parts of the  main code I have to modify to add additional graphes.
14  Using Arduino / Programming Questions / SplinesMaster Library - How the add additional graphes? on: December 30, 2012, 03:59:53 am
Hi,
I am using the SplinesMaster Library to control stepper motors:
https://github.com/kerinin/arduino-splines

It works fine with one motor, but now i want to use up to five motors. To get better performance from the arduino, I want to calculate the values in advance, save them in a txt-file on a SD-card and read them when its necessary.

It should look like this:

X U V W Y Z
-------------
0 0 0 0 0 0
1 2 3 4 5 6
2 4 8 10 12 16
3 1 2 2 3 4
...
1200 1000 500 200 800 300

U,V,W,Y and Z depend on X, which is the current position from the stepper.

Now I need your help:

What is the easiest way to add additional graphes(U,V,W and Z) and save them as mentioned above?

I want to use 9 points (incl. the both Catmull points at the ends).
15  International / Deutsch / in txt-Datei schreiben und lesen on: December 28, 2012, 08:23:26 am
Hallo,
ich plane grad ein Projekt, bei dem ich bis zu 5 Schrittmotoren verwende. Da ich Wegpunkte abfahren möchte, benutze ich zusätzlich die Arduino Splines-Library (https://github.com/kerinin/arduino-splines).

Da jeder Punkt von der Splines-Library berechnet werden muss, ist diese ziemlich rechenintensiv. Vor allem, wenn alle 5 Schrittmotoren verwende.

Ich kann mir nicht vorstellen, dass die Berechnung von einem Arduino Uno / Mega 2560 so schnell stattfindet, dass ich annährend Echtzeit bekomme.

Nun hab ich die Idee, die ganzen Punkte in folgendem Format vorher berechnen zu lassen, in einer txt-Datei zu speichern und später einfach abzurufen:

Code:
X U V W Y Z
-------------
0 0 0 0 0 0
1 2 3 4 5 6
2 4 8 10 12 16
3 1 2 2 3 4
...
1200 1000 500 200 800 300

Wie rechenintensiv ist es für den Arduino aus einer solchen Datei die Werte auszulesen?
Ich schätz mal um ein SD-Karten Modul komme ich nicht herum, oder? Eine Beispieldatei hatte ca. 50 KB.
Pages: [1] 2 3