Thanks Thanks:  0
Needs Pictures Needs Pictures:  0
Picture(s) thanks Picture(s) thanks:  0
Page 4 of 11 FirstFirst 123456789 ... LastLast
Results 46 to 60 of 163
  1. #46
    Join Date
    Nov 2008
    Location
    somewhere
    Posts
    152

    Default

    Hi Ken,

    Can you please give this a try? You will need to add a second pot (on pin A1), which will be your distance set pot.

    What should happen (I think, again, as usual untested) is that when you power it on it'll just sit there doing nothing. Set what speed you want and what distance you want and then press one of the direction buttons (left or right). The motor should accelerate up to speed quickly as it moves to the specified distance, then it should accelerate back down again and stop. Hit the direction button again and it should move the same distance. If you don't want the acceleration feature (probably a waste of time for very small distances, but it may help to eliminate your camera mount shaking as the motor stops) just change line 24 to the same value as the MAX_SPEED value.

    I've also changed everything around so the loop() function is less messy. I've tried to make each function a discrete task, which should make the debugging a little eaiser. the checksetIdle function is a little untidy, but should work.

    Could you also please check the limit function still works (set a distance and hit the direction button, then hit the limit switch before it reaches that distance)?

    Code:
    // Ken's Arduino Controled Camera Slider
    // based on code from Example6 of Brian Schmalz's Easy Driver Example page
    // http://www.schmalzhaus.com/EasyDriver/EasyDriverExamples.html
    //
    // Designed for Arduino UNO
    
    #include <Wire.h>
    #include <Adafruit_MotorShield.h>
    #include <AccelStepper.h>
    
    // Definitions - these make it easier to change what pins we are plugging things into on our arduino, and other control options such as speed
    // First Define the 3 digital input pins for direciton control
    #define LEFT_PIN 2
    #define STOP_PIN 3
    #define RIGHT_PIN 4
    // And the 2 digital inputs to test for limits
    #define LEFT_LIM_PIN 5
    #define RIGHT_LIM_PIN 6
    // and our two analog pot input pin
    #define SPEED_PIN A0
    #define DISTANCE_PIN A1
    // and our MAX SPEED and accelleration
    #define MAX_SPEED 1000
    #define MAX_ACCEL 400                                    // set this to the same as MAX_SPEED if you don't want acceleration
    #define MIN_SPEED 0.1
    // and the minimuum and maximum distance in steps
    #define MAX_DISTANCE 800                // this max distance was selected based on 1 revolution being 200 steps causing a 78mm travel.  comes out at 312mm travel
    #define MIN_DISTANCE 0
    
    // Function forward definitions
    void forwardstep();
    void backwardstep();
    char checkInputs();
    char checksetIdle(char *direction);
    void checksetDistance(char direction,char olddir);
    char checkDTG();
    float calcSpeed(int speedpot,int direction);
    float calcDistance(int destpot);
    
    // Global Variables:
    Adafruit_MotorShield AFMS = Adafruit_MotorShield();
    Adafruit_StepperMotor *motor1=AFMS.getStepper(200,2);
    AccelStepper stepper1(forwardstep,backwardstep);
    
    // initialise any global variables and tell the Arduino what to use the various pins for
    void setup()
    {
        AFMS.begin();
        
        // Tell AccelStepper what the maximum speed should be in steps per second.
        stepper1.setMaxSpeed(MAX_SPEED);
        stepper1.setAcceleration(MAX_ACCEL);
        
        // set up the 3 input button inputs and the limit inputs with pullps
        pinMode(LEFT_PIN, INPUT_PULLUP);
        pinMode(STOP_PIN, INPUT_PULLUP);
        pinMode(RIGHT_PIN, INPUT_PULLUP);
        pinMode(LEFT_LIM_PIN, INPUT_PULLUP);
        pinMode(RIGHT_LIM_PIN, INPUT_PULLUP);
    }
    
    // This is where the main body of the work gets done.  The loop function gets called repeatedly 
    void loop()
    {
        static float current_speed=0.0;                // holds the current motor speed in steps/second
        static int analog_read_counter=1000;                // counts down to 0 to fire analog read
        static char direction=0;                // holds -1, 1 or 0 to control direction
        char enabled;                        // used to keep track of if the motor has been enabled
        static int speed_value;                    // holds the raw analog value of the speed
        char olddir;                        // used to see if the direction has changed
        
        // step 1 - check inputs
        olddir=direction;
        direction=checkInputs();                // get the direction we should be moving in, based on inputs from the dir switches and limits
        checksetDistance(direction,olddir);                // check and set a new distance from the current point, if necessary
            enabled=checksetIdle(&direction);                // check if the motor should be idling or not (note this may set the directuib to 0 if we have reached the specified distance)
        
        // step 2 - run the motor
        if (enabled==1)
        {
            stepper1.run();                    // let the motor step if it needs to before we change the speed
        }
        current_speed=calcSpeed(speed_value,direction);        // calculate what our speed should be based on last pot setting and direciton
        stepper1.setSpeed(current_speed);
        if (enabled==1) {
            stepper1.run();
        }
        
        // step 3 - update analog values, if necessary
        if (analog_read_counter>0)
        {
            analog_read_counter--;
        }
        else
        {
            analog_read_counter=3000;                // change this to a lower number to increase pot response
            speed_value=analogRead(SPEED_PIN);        // get the speed value
                                    // distance value read could go here, but as it isn't updated all that often
                                    // its easier just to do it when necessary
        }
    }
    
    // this function will be called by the AccelStepper every step the motor turns forward
    void forwardstep()
    {
        motor1->onestep(FORWARD, MICROSTEP);
    }
    
    // this function will be called by the AccelStepper every step the motor turns backward
    void backwardstep()
    {
        motor1->onestep(BACKWARD, MICROSTEP);
    }
    
    // this function checks our inputs and returns a number indicating if the motor will turn LEFT (1), RIGHT (-1)
    // or if it should stop (0)
    char checkInputs()
    {
        char direction=0;
        
        if (digitalRead(LEFT_PIN)==0 && digitalRead(LEFT_LIM_PIN)==1)
        {
            direction=1;
        }
        else if (digitalRead(RIGHT_PIN)==0 && digitalRead(RIGHT_LIM_PIN)==1)
        {
            direction=-1;
        }
        else if (digitalRead(LEFT_LIM_PIN)==0 || digitalRead(RIGHT_LIM_PIN)==0 || digitalRead(STOP_PIN)==0)
        {
            direction=0;
        }
        return direction;
    }
    
    // this function checks if our motor should idle or not, based on the direction. it also puts the motor into the idle state
    // returns 1 if the motor is in the idle state
    char checksetIdle(char *direction)
    {
        if (*direction==0)
        {
            motor1->release();
            return 1;
        }
            if (checkDTG()==0)
            {
                    motor1->release();
                    *direction=0;
                    return 1;
            }
        return 0;
    }
    
    // this function reclculates the speed for the motor, based on the last speed potentiometer value and the direction.
    // returns a float indicating what the speed should be
    float calcSpeed(int speedpot,int direction)
    {
        return (direction * ((speedpot/1023.0) * (MAX_SPEED-MIN_SPEED)) + MIN_SPEED);
    }
    
    // this function calculates how far we should move before stopping, based on the last destination potentiometer value
    long calcDistance(int destpot, int direction)
    {
        return (direction * ((destpot/1023.0) * (MAX_DISTANCE-MIN_DISTANCE)) + MIN_DISTANCE);
    }
    
    // this function determines if a new distance to move is necessary, and provides a new distance relative to the current position to the AccelStepper library.
    void checksetDistance(char direction,char olddir)
    {
        int dist_value;                        // holds the raw analog value of the distance
        long distance;                        // holds how far we are going to move
        
        if (direction==0 || olddir==direction)                // we only update the distance if we are about to move (direction is set), and we are changing direction (olddir doesn't equal the new dir)
            return;
            
        dist_value=analogRead(DISTANCE_PIN);            // read the distance pot to figure out how far we have to move
        distance=calcDistance(dist_value,direction);        // calculate the distance
        stepper1.move(distance);                // set the distance to move from the current position
    }
    
    // check the distance to go to determine if we should idle the motor or not.
    char checkDTG()
    {
        if (stepper1.distanceToGo()>0)
        {
          return 1;
        }
        return 0;
    }

  2. # ADS
    Google Adsense Advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many





     
  3. #47
    Join Date
    Nov 2006
    Location
    Heidelberg, Victoria
    Age
    79
    Posts
    2,251

    Default Camera slider update

    Hi foob,

    You have certainly been busy, wow.

    Your amended sketch compiled with that stupid "avrdude:" error, but disappeared when I selected com3 port.

    Now this is a mystery.

    1. Connected up a second pot with one side to GND, the centre to A1 and the other side to 5V. Initially everything was working as it should except that the distance pot had no effect. I checked with a digital probe that it was swinging from 5V to GND, all good
    2. Changed the stepping from "microstep" to "single" and recompiled. This time nothing unless the fwd or rev button was kept depressed. The motor just oscillated and sounded like it was going crook .
    3. Smoked started coming off the Adafruit motor shield, or the Ardunio UNO, not sure which, so quickly pulled the pin.

    I've got spares but am reluctant to try again until I find the cause of the burn out.

    Ken

  4. #48
    Join Date
    Nov 2008
    Location
    somewhere
    Posts
    152

    Default

    wow, guess i screwed something up there. sorry about that...

    I'd be betting the smoke was off the motorshield..

  5. #49
    Join Date
    Nov 2006
    Location
    Heidelberg, Victoria
    Age
    79
    Posts
    2,251

    Default Motor shield blown

    Hi foob,

    Tried connecting my motor to the other set of terminals on the stepper board, no go, it's stuffed I'd say.

    Just assembled a spare Adafruit motor shield I had, reverted back to the last known good sketch where you incorporated the "release" command, and I'm back in business.

    At least the Arduino seams to be ok.

    I have absolutely no idea why the stepper shield burnt out. All I can think of is with three levels of boards, 1. Arduino, 2. Adafruit terminal shield then 3. the Adafruit stepper shield, that a short occurred somewhere between boards.

    Do you have any theories?

    Ken

  6. #50
    Join Date
    Nov 2008
    Location
    somewhere
    Posts
    152

    Default

    sorry, but I've got no idea what went wrong. I'll take a look at the code again tomorrow to see if I can identify what screwed up. Off the top of my head I can take a wild guess that the distance code was telling the stepper to go one way and the speed was telling the stepper to go the other, but I dunno. its a bit hard doing this with out any real idea of the hardware or how the libraries are interacting.

  7. #51
    Join Date
    Nov 2006
    Location
    Heidelberg, Victoria
    Age
    79
    Posts
    2,251

    Default Smoked motor shield

    Hi foob, have you come up with any ideas?
    Ken

  8. #52
    Join Date
    Nov 2008
    Location
    somewhere
    Posts
    152

    Default

    Hi Ken, the checksetIdle function wasn't right, but not in a way that should have caused the motor to burn out.

    Could you please test out the code below for me?

    This should ignore the speed pot completely, but the distance pot should work. I'll put the speed stuff back in once we've got it sorted out.

    Your test procedure should be
    1. connect your distance pot to pin A1. check there is nothing else connected to pin A1 through your shields.
    2. Set your distance pot to 1V output.
    3. press one of the direction buttons. You should get movement in that direction for a distance of about 160mm. If you do not get movement power everything off straight away. Abandon the test at this point and let me know
    4. press the other direction button and you should get movement in that direction for a distance of about 160mm. again, if it doesn't move, power off and tell me (if 3 worked this should).
    5. press the first direction button again, but this time hit the stop button before it gets there. carriage should halt and the motor shouldn't get warm.
    6. press the first direction button again (this time it will try and move to 160mm from where you are now). hit the limit button for this direction and hold it down. carriage should halt and the motor shouldn't get warm. keep holding the limit switch down
    6. press the first direction button again. the carriage should not do anything. motor should stay in the idle state and not get warm. keep holding the limit switch down
    7. press the second direction button, which should allow the carriage to back away from the limit switch 160mm. release the limit switch if it starts the moment.
    8. press the second direction button again (another 160mm in that direction), but hit the limit switch (hold down) before it gets there. carriage should halt and the motor shouldn't get warm.
    9. release the limit switch. carriage should not do anything, motor should stay idle.

    Basically if you get a failure at any point of those tests, power off straight away and let me know. Sorry if I sound paranoid - I want to make sure we don't cook another motor shield.

    Code:
    // Ken's Arduino Controled Camera Slider
    // based on code from Example6 of Brian Schmalz's Easy Driver Example page
    // http://www.schmalzhaus.com/EasyDriver/EasyDriverExamples.html
    //
    // Designed for Arduino UNO
    
    #include <Wire.h>
    #include <Adafruit_MotorShield.h>
    #include <AccelStepper.h>
    
    // Definitions - these make it easier to change what pins we are plugging things into on our arduino, and other control options such as speed
    // First Define the 3 digital input pins for direciton control
    #define LEFT_PIN 2
    #define STOP_PIN 3
    #define RIGHT_PIN 4
    // And the 2 digital inputs to test for limits
    #define LEFT_LIM_PIN 5
    #define RIGHT_LIM_PIN 6
    // and our two analog pot input pin
    #define SPEED_PIN A0
    #define DISTANCE_PIN A1
    // and our MAX SPEED and accelleration
    #define MAX_SPEED 500
    #define MAX_ACCEL 250                                    // set this to the same as MAX_SPEED if you don't want acceleration
    #define MIN_SPEED 0.1
    // and the minimuum and maximum distance in steps
    #define MAX_DISTANCE 800                // this max distance was selected based on 1 revolution being 200 steps causing a 78mm travel.  comes out at 312mm travel
    #define MIN_DISTANCE 0
    
    // Function forward definitions
    void forwardstep();
    void backwardstep();
    char checkInputs();
    char checksetIdle(char *direction);
    void checksetDistance(char direction,char olddir);
    char checkDTG();
    float calcSpeed(int speedpot,int direction);
    float calcDistance(int destpot);
    
    // Global Variables:
    Adafruit_MotorShield AFMS = Adafruit_MotorShield();
    Adafruit_StepperMotor *motor1=AFMS.getStepper(200,2);
    AccelStepper stepper1(forwardstep,backwardstep);
    
    // initialise any global variables and tell the Arduino what to use the various pins for
    void setup()
    {
        AFMS.begin();
        
        // Tell AccelStepper what the maximum speed should be in steps per second.
        stepper1.setMaxSpeed(MAX_SPEED);
        stepper1.setAcceleration(MAX_ACCEL);
        
        // set up the 3 input button inputs and the limit inputs with pullps
        pinMode(LEFT_PIN, INPUT_PULLUP);
        pinMode(STOP_PIN, INPUT_PULLUP);
        pinMode(RIGHT_PIN, INPUT_PULLUP);
        pinMode(LEFT_LIM_PIN, INPUT_PULLUP);
        pinMode(RIGHT_LIM_PIN, INPUT_PULLUP);
    }
    
    // This is where the main body of the work gets done.  The loop function gets called repeatedly 
    void loop()
    {
        static float current_speed=0.0;                // holds the current motor speed in steps/second
        static int analog_read_counter=1000;                // counts down to 0 to fire analog read
        static char direction=0;                // holds -1, 1 or 0 to control direction
        char enabled;                        // used to keep track of if the motor has been enabled
        static int speed_value;                    // holds the raw analog value of the speed
        char olddir;                        // used to see if the direction has changed
        
        // step 1 - check inputs
        olddir=direction;
        direction=checkInputs();                // get the direction we should be moving in, based on inputs from the dir switches and limits
        checksetDistance(direction,olddir);                // check and set a new distance from the current point, if necessary
            enabled=checksetIdle(&direction);                // check if the motor should be idling or not (note this may set the directuib to 0 if we have reached the specified distance)
        
        // step 2 - run the motor
    //    if (enabled==1)
    //    {
    //        stepper1.run();                    // let the motor step if it needs to before we change the speed
    //    }
    //    current_speed=calcSpeed(speed_value,direction);        // calculate what our speed should be based on last pot setting and direciton
    //    stepper1.setSpeed(current_speed);
        if (enabled==1) {
            stepper1.run();
        }
    /*    
        // step 3 - update analog values, if necessary
        if (analog_read_counter>0)
        {
            analog_read_counter--;
        }
        else
        {
            analog_read_counter=3000;                // change this to a lower number to increase pot response
            speed_value=analogRead(SPEED_PIN);        // get the speed value
                                    // distance value read could go here, but as it isn't updated all that often
                                    // its easier just to do it when necessary
        }
    */
    }
    
    // this function will be called by the AccelStepper every step the motor turns forward
    void forwardstep()
    {
            // you can change these to DOUBLE or INTERLEAVE or MICROSTEP!
        motor1->onestep(FORWARD, SINGLE);
    }
    
    // this function will be called by the AccelStepper every step the motor turns backward
    void backwardstep()
    {
          // you can change these to DOUBLE or INTERLEAVE or MICROSTEP!
        motor1->onestep(BACKWARD, SINGLE);
    }
    
    // this function checks our inputs and returns a number indicating if the motor will turn LEFT (1), RIGHT (-1)
    // or if it should stop (0)
    char checkInputs()
    {
        char direction=0;
        
        if (digitalRead(LEFT_PIN)==0 && digitalRead(LEFT_LIM_PIN)==1)
        {
            direction=1;
        }
        else if (digitalRead(RIGHT_PIN)==0 && digitalRead(RIGHT_LIM_PIN)==1)
        {
            direction=-1;
        }
        else if (digitalRead(LEFT_LIM_PIN)==0 || digitalRead(RIGHT_LIM_PIN)==0 || digitalRead(STOP_PIN)==0)
        {
            direction=0;
        }
        return direction;
    }
    
    // this function checks if our motor should idle or not, based on the direction. it also puts the motor into the idle state
    // returns 0 if the motor is in the idle state
    char checksetIdle(char *direction)
    {
            static char lastval=0;
            
        if (*direction==0)
        {
            motor1->release();
                    lastval=0;
                    stepper1.disableOutputs();
            return 0;
        }
            if (checkDTG()==0)
            {
                    motor1->release();
                    *direction=0;
                    lastval=0;
                    stepper1.disableOutputs();
                    return 0;
            }
            if (lastval==0)
            {
                    stepper1.enableOutputs();
                    lastval=1;
            }
        return 1;
    }
    
    // this function reclculates the speed for the motor, based on the last speed potentiometer value and the direction.
    // returns a float indicating what the speed should be
    float calcSpeed(int speedpot,int direction)
    {
        return (direction * ((speedpot/1023.0) * (MAX_SPEED-MIN_SPEED)) + MIN_SPEED);
    }
    
    // this function calculates how far we should move before stopping, based on the last destination potentiometer value
    long calcDistance(int destpot, int direction)
    {
        return (direction * ((destpot/1023.0) * (MAX_DISTANCE-MIN_DISTANCE)) + MIN_DISTANCE);
    }
    
    // this function determines if a new distance to move is necessary, and provides a new distance relative to the current position to the AccelStepper library.
    void checksetDistance(char direction,char olddir)
    {
        int dist_value;                        // holds the raw analog value of the distance
        long distance;                        // holds how far we are going to move
        
        if (direction==0 || olddir==direction)                // we only update the distance if we are about to move (direction is set), and we are changing direction (olddir doesn't equal the new dir)
            return;
            
        dist_value=analogRead(DISTANCE_PIN);            // read the distance pot to figure out how far we have to move
        distance=calcDistance(dist_value,direction);        // calculate the distance
        stepper1.move(distance);                // set the distance to move from the current position
    }
    
    // check the distance to go to determine if we should idle the motor or not.
    char checkDTG()
    {
        if (stepper1.distanceToGo()>0)
        {
          return 1;
        }
        return 0;
    }

  9. #53
    Join Date
    Nov 2006
    Location
    Heidelberg, Victoria
    Age
    79
    Posts
    2,251

    Default Camera slider update

    Hi foobillious,

    Just got your reply. I have all this set up on a mini breadboard, and reckon that's inviting trouble.

    I have a spare Arduino mounted on a plastic plate together with a full length breadboard. I'll carefully transfer all the jumpers etc across, and give your revised code a go.

    I'll also change power supplies to a low current one. Currently using an Arlec battery charger which is probably not ideal.

    Ken

  10. #54
    Join Date
    Nov 2006
    Location
    Heidelberg, Victoria
    Age
    79
    Posts
    2,251

    Default Camera slider update

    Hi foob,

    Sorry for the delay in getting back to you.

    Have reassembled all the components on a new breadboard, and hooked up a 12V, 2A wall plug. This power pack is so light it makes me doubt it has enough grunt.

    OK, your revised sketch compiled ok and runs as per some of the older iterations, ie, push buttons work, limit switches work and the speed pot sort of works. When I say sort of works, it doesn't slow the motor down until it's nearly backed right off.

    1. What's not happening is the distance pot. It is not having any effect on the motor, and I've tried different settings and, waited for half a minute or so.

    I've checked with a multi meter and pin A1 can be varied from 5V to GND. It's currently set on 1V as suggested.

    2. Changing the stepper setting from "single" through to "microstep" does nothing. Feels like the motor is running on "microstep" all the time, it's quite slow. One rev takes about 10 secs.
    This micro stepping also occurs with some older sketches which reinforces my feeling that the plug pack just can't supply the current. Your thoughts?

    My next test will be to revert back to the Arlec battery charger with the risk of blowing something up. I don't have another spare motor shield but there's another on order.

    Ken

  11. #55
    Join Date
    Nov 2006
    Location
    Heidelberg, Victoria
    Age
    79
    Posts
    2,251

    Default Stepper test

    Hi foob,

    I've just run the Adafruit stepper test sketch. The stepper cycles through the various step modes which means the stepper is ok, and the power pack is adequate.

    This is a bit of a mystery.

    Ken

    edit. another mystery. When I load your sketch, I get the error message avrdude: blah blah, and it seems the sketch does not really load. Powering up the board and the previous stepper test sketch runs.
    Is there a way to delete sketches out of the Arduino memory?

    edit2

    The various stepper modes have come good.

  12. #56
    Join Date
    Jun 2010
    Location
    Canberra
    Posts
    769

    Default

    Just had a chance to look at Foob's code. A couple of things to note (assuming I read the code correctly - not guaranteed!) the distance movement thing will only work if you keep the direction button pressed. It'll also only do a new distance if you change directions - i.e. you can't do two 100mm moves in the same direction.

    As for frying driver boards, given the way the Arduino environment is set up, it seems like it should be impossible to smoke an H bridge in a stepper driver - you'd think the board and library would both be designed to make this not happen. That said, I kind of can see how changing step mode without allowing the motor to step to a full-step position might cause problems if the library doesn't ensure that (the use of the stepper1.runSpeed thing in Brian's code makes me think you need to consider this).

    It'd help if you posted a link to the Adafruit stepper test sketch.

  13. #57
    Join Date
    Nov 2006
    Location
    Heidelberg, Victoria
    Age
    79
    Posts
    2,251

    Default Adafruit stepper test sketch

    Hi Rusty,

    So you think there maybe some problems? I've got another problem. How can I get the Arduino onto com port 3?

    foob's sketch doesn't seem to want to compile on ports 1 and 4.

    Code:
     /* 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 
    ---->    http://www.adafruit.com/products/1438
    */
    
    
    
    
    #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(10);  // 10 rpm   
    }
    
    
    void loop() {
      Serial.println("Single coil steps");
      myMotor->step(100, FORWARD, SINGLE); 
      myMotor->step(100, BACKWARD, SINGLE); 
    
    
      Serial.println("Double coil steps");
      myMotor->step(100, FORWARD, DOUBLE); 
      myMotor->step(100, BACKWARD, DOUBLE);
      
      Serial.println("Interleave coil steps");
      myMotor->step(100, FORWARD, INTERLEAVE); 
      myMotor->step(100, BACKWARD, INTERLEAVE); 
      
      Serial.println("Microstep steps");
      myMotor->step(50, FORWARD, MICROSTEP); 
      myMotor->step(50, BACKWARD, MICROSTEP);
    This is ridiculous, the sketch is now compiling, but the motor will only run if the fwd button is kept depressed. Finger off the button, motor stops. The other button does nothing

    Think I need to have a good look in the morning in full sunlight.

    Ken

  14. #58
    Join Date
    Nov 2008
    Location
    somewhere
    Posts
    152

    Default

    The code shouldn't need the button held down. So something isn't right. What version of the code are you running Ken, the updated one I posted or an older version?

    With the revised version of the code the speed pot shouldn't do anything at all. I gave you that new version to establish that the distance stuff was working right before I tried sticking the speed stuff back in.

    The distance pot should purely set how many steps the motor is going to take. So basically if you have that pot set at 5V it should do 800 steps. If you have it set at 1V it should do 160steps (probably about 3/4 of a revolution). At the moment it won't do anything unless the motor is stopped and you then press a direciton button
    (you can keep going in the same direction I think, but the motor needs to stop first). The speed will be fairly slow at this stage - we'll sort that out if we can figure out where your at now. At the moment I'm kind of lost as to what your doing.

    Best give it a fresh start in the morning. stay away from the arlec charger for now, they often don't make good power supplies. I'll be online about 1200AEST tomorrow, everything going to plan (I'm at work, so won't be able to check anything until lunch)

    *edit* btw if your getting compile errors, the arduino software doesn't upload the new code. So we need to sort that out first before we do any tests. Can you post what errors you are getting? in some of those posts you say it compiles, but in others you say it doesn't? Did you ever get a compile and upload of the new code without errors?

  15. #59
    Join Date
    Nov 2006
    Location
    Heidelberg, Victoria
    Age
    79
    Posts
    2,251

    Default Copying code

    RustyArc or foob,

    Is there an easy way of copying code from the screen?

    At present I'm starting at the bottom of a sketch, holding down the mouse button, and scrolling up to highlight the code I want. Press copy, then paste it into an Arduino window.

    I'll wait until morn to check my board connections.

    Ken

  16. #60
    Join Date
    Nov 2008
    Location
    somewhere
    Posts
    152

    Default

    click once at the top, scroll down to the bottom, hold down shift and click again... that'll highlight the lot. Its not much faster, but some people find it easier.

Page 4 of 11 FirstFirst 123456789 ... LastLast

Similar Threads

  1. Limit/home switches
    By warrick in forum CNC Machines
    Replies: 2
    Last Post: 7th July 2012, 08:11 PM
  2. Limit switches
    By Bob Willson in forum CNC Machines
    Replies: 0
    Last Post: 24th August 2011, 12:31 PM
  3. CNC Mill Limit Switches
    By electrosteam in forum METALWORK FORUM
    Replies: 8
    Last Post: 10th September 2010, 07:31 PM
  4. How to Wire Limit switches on Xylotex board.
    By Ch4iS in forum CNC Machines
    Replies: 19
    Last Post: 19th October 2008, 09:58 PM
  5. Xylotex & limit/home switches
    By John H in forum CNC Machines
    Replies: 3
    Last Post: 31st July 2008, 08:08 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •