Giter VIP home page Giter VIP logo

Comments (17)

EmbeddedMan avatar EmbeddedMan commented on June 8, 2024

from easy_driver.

FrankOcean11 avatar FrankOcean11 commented on June 8, 2024

ok thanks that helped although now i noticed that it does not follows some of the serial calls such as "r" for reverse or 1 by it's sign, any ideas why? it will accept s & f as well as 1,2 & 3 but that r

void loop()
{
char c;
if (Serial.available()) {
c = Serial.read();
if (c == 'f') { // forward
sign = 1;
}
if (c == 'r') { // reverse
sign = -1;
}
if (c == 's') { // stop
sign = 0;
}
if (c == '1') { // super slow
spd = 300;
}
if (c == '2') { // medium
spd = 500;
}
if (c == '3') { // fast
spd = 1000;
}
stepper.setSpeed(sign * spd);
}
stepper.runSpeed();
}

from easy_driver.

EmbeddedMan avatar EmbeddedMan commented on June 8, 2024

from easy_driver.

FrankOcean11 avatar FrankOcean11 commented on June 8, 2024

every command it's accepted BUT reverse

from easy_driver.

EmbeddedMan avatar EmbeddedMan commented on June 8, 2024

from easy_driver.

FrankOcean11 avatar FrankOcean11 commented on June 8, 2024

yes i start that sketch at S because i do not want it just running at start right, then ill have to open the serial window to input the command i want F, S or the non working one R as i already have it set at 3 which is 1000 but R just gets ignore, ill even hit S the R and it will spin in the same dir as if i would have hit F instead so it looks like F&R are given out the same val of 1 and never -1 respectfully. but thanks for having a look at it.

from easy_driver.

FrankOcean11 avatar FrankOcean11 commented on June 8, 2024

im not sure but i think the issue might be here

boolean AccelStepper::runSpeed()
{
unsigned long time = millis();

if (time > _lastStepTime + _stepInterval)
{

if (_speed > 0)
{
// Clockwise
_currentPos += 1;
}
else if (_speed < 0)
{
// Anticlockwise
_currentPos -= 1;
}
step(_currentPos & 0x3); // Bottom 2 bits (same as mod 4, but works with + and - numbers)

_lastStepTime = time;
return true;
}
else
return false;
}
or it might be here or both

void AccelStepper::step4(uint8_t step)
{
switch (step)
{
case 0: // 1010
digitalWrite(_pin1, HIGH);
digitalWrite(_pin2, LOW);
digitalWrite(_pin3, HIGH);
digitalWrite(_pin4, LOW);
break;

case 1: // 0110
digitalWrite(_pin1, LOW);
digitalWrite(_pin2, HIGH);
digitalWrite(_pin3, HIGH);
digitalWrite(_pin4, LOW);
break;

case 2: //0101
digitalWrite(_pin1, LOW);
digitalWrite(_pin2, HIGH);
digitalWrite(_pin3, LOW);
digitalWrite(_pin4, HIGH);
break;

case 3: //1001
digitalWrite(_pin1, HIGH);
digitalWrite(_pin2, LOW);
digitalWrite(_pin3, LOW);
digitalWrite(_pin4, HIGH);
break;
}
}

from easy_driver.

EmbeddedMan avatar EmbeddedMan commented on June 8, 2024

from easy_driver.

FrankOcean11 avatar FrankOcean11 commented on June 8, 2024

No it does not spin in reverse

/*
Example 7: Serial command input

Using the exact same hardware setup as Example
1, this sketch illustrates how to use simple
one letter commands from the serial port to
control the direction and speed of the stepper
motor.
https://www.sparkfun.com/products/12779
http://www.schmalzhaus.com/EasyDriver/Examples/EasyDriverExamples.html
Example7 for Brian Schmalz's Easy Driver
We control the direction and speed of a
stepper using the
arduino serial port. Note that (if using
the Serial Monitor)
you will need to press Enter after each
command.
*/
#include <AccelStepper.h>
//#include <SoftwareSerial.h>

AccelStepper stepper(AccelStepper::DRIVER, 2, 3);

int spd = 1000; // The current speed in steps/second
int sign = 0; // Either 1, 0 or -1

void setup()
{
Serial.begin(9600);
stepper.setMaxSpeed(1000);
stepper.setSpeed(0);
}

void loop()
{
char c;
if (Serial.available()) {
c = Serial.read();
if (c == 'f') { // forward
sign = 1;
}
if (c == 'r') { // reverse
sign = -1;
}
if (c == 's') { // stop
sign = 0;
}
if (c == '1') { // super slow
spd = 300;
}
if (c == '2') { // medium
spd = 500;
}
if (c == '3') { // fast
spd = 1000;
}
stepper.setSpeed(sign * spd);
}
stepper.runSpeed();
}

from easy_driver.

EmbeddedMan avatar EmbeddedMan commented on June 8, 2024

from easy_driver.

FrankOcean11 avatar FrankOcean11 commented on June 8, 2024

from easy_driver.

EmbeddedMan avatar EmbeddedMan commented on June 8, 2024

from easy_driver.

FrankOcean11 avatar FrankOcean11 commented on June 8, 2024

Well good thing i buy everything in bulk, i did pull out 2 additional sets "drivers & Steppers" and the issue is in the first Driver i was using to run test on, one of the pins on the ic must of shortened although not visible nor smells but i confirmed this by using that same stepper i been using on a new driver and all your commands worked flawlessly, thanks for your efforts and the update.

from easy_driver.

FrankOcean11 avatar FrankOcean11 commented on June 8, 2024

ok i think im on to something new but im not sure maybe is just my code this time as everything im using it's new, please look at my code and tell me if you see something wrong, because i just hooked the full system connection (HW & SW) and im lacking individual control "meaning both motors are running in the same direction although i only called one" and to top it off i have to enter double digits such as aa or dd / rr or ff to get the command to register.

note i just have 2 simple functions being called in loop in which serial is going to get one of those 2 commands respectfully to run the motors in their respected polarity using char c or e.

#include <AccelStepper.h>
//#include <SoftwareSerial.h>
//FULL2WIRE, DRIVER
AccelStepper Lear(AccelStepper::DRIVER, 2, 3);
AccelStepper Rear(AccelStepper::DRIVER, 4, 5);

int spd = 200;    // The current speed in steps/second
int sign = 0;      // Either 1, 0 or -1

int spd2 = 200;
int sign2 = 0;

void setup()
{
  Serial.begin(9600);
  Lear.setMaxSpeed(1000);
  Lear.setSpeed(0);
  Rear.setMaxSpeed(1000);
  Rear.setSpeed(0);
}

void loop()
{
  earA();
  earB();
}

void earA() {
  char c;
  if (Serial.available()) {
    c = Serial.read();
    if (c == 'f') {  // forward
      sign = 1;
    }
    if (c == 'r') {  // reverse
      sign = -1;
    }
    if (c == 's') {  // stop
      sign = 0;
    }
    if (c == '1') {  // super slow
      spd = 200;
    }
    if (c == '2') {  // medium
      spd = 500;
    }
    if (c == '3') {  // fast
      spd = 1000;
    }
    Lear.setSpeed(sign * spd);
  }
  Lear.runSpeed();
}


void earB() {
  char e;
  if (Serial.available()) {
    e = Serial.read();
    if (e == 'd') {  // forward
      sign = 1;
    }
    if (e == 'a') {  // reverse
      sign = -1;
    }
    if (e == 'x') {  // stop
      sign = 0;
    }
    if (e == '4') {  // super slow
      spd = 200;
    }
    if (e == '5') {  // medium
      spd = 500;
    }
    if (e == '6') {  // fast
      spd = 1000;
    }
    Rear.setSpeed(sign2 * spd2);
  }
  Rear.runSpeed();
}

from easy_driver.

EmbeddedMan avatar EmbeddedMan commented on June 8, 2024

from easy_driver.

FrankOcean11 avatar FrankOcean11 commented on June 8, 2024

no i understand but what if this is a issue where the libraries aren't working with multiple steppers? but if you insist whats your email Brian?

from easy_driver.

EmbeddedMan avatar EmbeddedMan commented on June 8, 2024

from easy_driver.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.