Recent Posts

Pages: [1] 2 3 ... 10
1
Project Guidance / Steppers Not Moving At Same Sp...
Last post by Josdc - Today at 10:39 am
Hello Experts,

I have a code for moving the stepper motors of a 3d printer. In one part of the code, I can chose to move one stepper motor by pressing a button. In other part of the code (homing), the same stepper needs to be moved, and I used the same function. The problem is, the speeds are not the same: the "homing" speed is way, way slower.

I am using an Arduino Mega with LCD Keypad Shield. Here is the part of the code that the stepper goes "fast":

Code: [Select]
void menuItem1() { // Function executes when you select the 2nd item from main menu
  int activeButton = 0;

  lcd.clear();
  lcd.setCursor(1, 0);
  lcd.print("Move X Axis");

  while (activeButton == 0) {
    int button;
    readKey = analogRead(0);
    if (readKey < 790) {
      delayMicroseconds(1000);
      readKey = analogRead(0);
    }
    button = evaluateButton(readKey);
    switch (button) {
      case 0:  // When button returns as 0
        break;
      case 1:  // When button returns as 1
        lcd.clear();
        lcd.print("Press Up or Down");
        lcd.setCursor(0, 1);
        break;
      case 2:  // When button returns as 2
        valXUp = digitalRead(LimitSwitchXUp); // read sensor
        if (valXUp == HIGH) {
          MoveAxisUp (Xdir, Xstep);
        }
        break;
      case 3:  // When button returns as 3
        valXDown = digitalRead(LimitSwitchXDown); // read sensor
        if (valXDown == HIGH) {
          MoveAxisDown (Xdir, Xstep);
          break;
        }
        break;
      case 4:  // This case will execute if the "back" button is pressed
        button = 0;
        activeButton = 1;
        break;
    }
  }
}


In this case, the X axis will move with this MoveAxisDown function. Here's the function for you guys to see (for up and down):

Code: [Select]
void MoveAxisUp(int Direction, int Step) {
  digitalWrite(Direction, HIGH);          // Xdir = X Direction
  digitalWrite(Step, HIGH);        // Setting Steps
  delayMicroseconds(200);          // Delay between Steps
  digitalWrite(Step, LOW);
  delayMicroseconds(200);          // The nut will go up on its own axis
}

void MoveAxisDown(int Direction, int Step) {
  digitalWrite(Direction, LOW);          // Xdir = X Direction
  digitalWrite(Step, HIGH);        // Setting Steps
  delayMicroseconds(200);          // Delay between Steps
  digitalWrite(Step, LOW);
  delayMicroseconds(200);          // The nut will go DOWN on its own axis
}


Now, here's the part of the code where the stepper go very slow:

Code: [Select]
void menuItem5() { // Function executes when you select the 5th item from main menu
  int activeButton = 0;

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Press Up To");
  lcd.setCursor(0, 1);
  lcd.print("Start Homing");

  while (activeButton == 0) {
    int button;
    float savedLT;
    readKey = analogRead(0);
    if (readKey < 790) {
      delay(100);
      readKey = analogRead(0);
    }
    button = evaluateButton(readKey);
    switch (button) {
      case 2:
        valXUp = digitalRead(LimitSwitchXUp); // Reading sensor values
        valXDown = digitalRead(LimitSwitchXDown);

        valZ1Up = digitalRead(LimitSwitchZ1Up);
        valZ1Down = digitalRead(LimitSwitchZ1Down);

        //Serial.println("ValUP: ");
        valZ2Up = digitalRead(LimitSwitchZ2Up);
        //Serial.println(valZ2Up);
        valZ2Down = digitalRead(LimitSwitchZ2Down);
        //Serial.println(valZ2Down);

        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Moving Z2");
        delay(1000);

        flagZ2 = 0;
        while (flagZ2 == 0) {
          valZ2Down = digitalRead(LimitSwitchZ2Down);
          Serial.println(valZ2Down);
          Serial.print("Z2 - Down");
          if (valZ2Down == LOW) {
            valZ2Down = digitalRead(LimitSwitchZ2Down);
            if (valZ2Down == LOW) {
              valZ2Down = digitalRead(LimitSwitchZ2Down);
              if (valZ2Down == LOW) {
                flagZ2 = 1;
              }
            }
          }
          MoveAxisUp (Z2dir, Z2step);
        }

        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Moving Z1");
        delay(1000);

        flagZ1 = 0;
        while (flagZ1 == 0) {
          valZ1Down = digitalRead(LimitSwitchZ1Down);
          Serial.println(valZ1Down);
          Serial.print("Z1 - Down");
          if (valZ1Down == LOW) {
            valZ1Down = digitalRead(LimitSwitchZ1Down);
            if (valZ1Down == LOW) {
              valZ1Down = digitalRead(LimitSwitchZ1Down);
              if (valZ1Down == LOW) {
                valZ1Down = digitalRead(LimitSwitchZ1Down);
                flagZ1 = 1;
              }
            }
          }
          MoveAxisUp (Z1dir, Z1step);
        }

        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Moving X");
        delay(1000);

        flagX = 0;
        while (flagX == 0) {
          valXUp = digitalRead(LimitSwitchXUp);
          Serial.println(valXUp);
          Serial.print("X - Up");
          if (valXUp == LOW) {
            valXUp = digitalRead(LimitSwitchXUp);
            if (valXUp == LOW) {
              valXUp = digitalRead(LimitSwitchXUp);
              if (valXUp == LOW) {
                flagX = 1;
              }
            }
          }
          MoveAxisUp (Xdir, Xstep);
        }

        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Moving Z2");
        delay(1000);

        flagZ22 = 0;
        while (flagZ22 == 0) {
          valZ2Up = digitalRead(LimitSwitchZ2Up);
          Serial.print("Z2 - Up");
          Serial.println(valZ2Up);
          if (valZ2Up == LOW) {
            valZ2Up  = digitalRead(LimitSwitchZ2Up);
            Serial.print("Z2 - Up");
            Serial.println("Ciclo 1");
            if (valZ2Up == LOW) {
              valZ2Up = digitalRead(LimitSwitchZ2Up);
              Serial.println("Ciclo 2");
              delayMicroseconds(1000);
              if (valZ2Up == LOW) {
                Serial.println("Ciclo 3");
                valZ2Up = digitalRead(LimitSwitchZ2Up);
                if (valZ2Up == LOW ) {
                Serial.println("Ciclo 4");
                flagZ22 = 1;                  
                }
              }
            }
          }
          MoveAxisDown (Z2dir, Z2step);
        }

        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Homing Completed");
        break;

      case 4:  // This case will execute if the "back" button is pressed
        button = 0;
        activeButton = 1;
        break;
    }
  }
}


In this part, I'm homing the system. the "val something" variable is a limit switch that I use to prevent the axis from coliding. I need to check if it's low 3 times because of the noise.


Here is the full code if you need it: EDIT: I can't add the full code because the forum only allows 9000 characters.


Any comments?

Thank you Experts,

Josdc
2
Don't use the Arduino 3.3v source to power the nrf24L01, it doesn't provide a enough juice for it.
3
Deutsch / Erkennen an welchem Anschluss ...
Last post by multi - Today at 10:36 am
Hallo,

ich möchte mir etwas bauen, an dem ich mehrere DS18B20 Temperatursensoren anschließen kann. Dies soll so realisiert sein, dass auf der Platine 4 Buchsen sind und ich an jeder einen Temperatursensor anschließen kann.
Der Arduino soll dann die Werte auslesen und an mehreren 7-Segmentanzeigen anzeigen.

Jetzt ist mein Problem, dass der Sensor an Buchse 1 immer an der Anzeige 1 (Buchse2->Anzeige2...) dargestellt werden soll. Ich weiß jedoch im Vorhinein nicht, welcher Sensor wo angeschlossen wird.

Wie ist sowas am besten realisierbar?

Meine Ideen bis jetzt:
1. Vor jeder Buchse einen Transistor, damit ich die einzelnen Sensoren abschalten kann und dann im setup einen nach dem anderen zuschalte und mir dann merke wo der neue angeschlossen ist.

2. Man darf immer nur einen Sensor nach dem anderen anschließen und der bekommt dann einfach die nächste freie Anzeige (nicht wirklich eine Lösung und außerdem müsste man bei jeder Stromunterbrechung alle Sensoren neu einstecken)
4
Project Guidance / Re: Using interrupt for RPM bu...
Last post by Robin2 - Today at 10:35 am
You need to post your program so we can see what you can see.

And I strongly recommend that you change your user name to something other than your email address unless you enjoy being flooded with spam.

...R
5
Programming Questions / Re: Fixing Auduino
Last post by pert - Today at 10:34 am
Please post a link to where you downloaded the DS1307RTC library from, or if you installed it via Library Manager (Sketch > Include Library > Manage Libraries) state the full name. Please always use the chain links icon on the toolbar to make links you post to the forum clickable.
6
Website and Forum / Re: Ethernet Module having pro...
Last post by Juraj - Today at 10:32 am
this is not the right forum board for this question
7
Your problem is not clear bro.
Are you trying to control 4 relays with an arduino using the SIM800L GSM module? or what are you trying to achieve?
8
Website and Forum / Re: Ethernet Module having pro...
Last post by pert - Today at 10:30 am
The EtherCard library is written for use with the ENC28J60 Ethernet controller. The Ethernet library is written for use with the W5100 Ethernet controller and can not be used with the ENC28J60. If you want a library written for ENC28J60 with the same API as the Ethernet library I recommend:
https://github.com/ntruchsess/arduino_uip/tree/Arduino_1.5.x
There is also a fork of it that has more recent development but I haven't used that one:
https://github.com/UIPEthernet/UIPEthernet
9
Project Guidance / Re: Wireless Communication bet...
Last post by Robin2 - Today at 10:30 am
Will a wemos d1 mini solve my problem?
and Where can I see your tutorials?
In the link at the bottom of Reply #2

...R
10
Ok, been reading the tutorial on state change, but do I insert the code for it in loop or the interrupt routine?
Thanks, Greg.
Pages: [1] 2 3 ... 10