CNC Update 1 “We Have Motion!”

NOTICE: I CORRECTED ERRORS IN THE CODE AND DESCRIPTION ABOUT MICROSTEPPING AN PULSE DELAY!

Videos at the bottom.

Ok, a lot has happen this week. I started out with a general ideal of how I wanted to accomplish the X and Y axis movements. I was going to go with the sliding table design rather than the Gantry. No real good reason why I have this method in mind it just seems simpler to me. Anyway I go scrounging around through some surplus junk I have picked up from an industrial auction and I came across a couple of pneumatic cylinders with a linear motion mount. This caught my eye right away. The design is quite nice but it only gives me about 10.5″ of travel. This should be fine for my first build and it should be plenty for routing printed circuit boards. Here is a picture of what one of these mounts looks like.

Linear Motion assembly

Today the Stepper motors and EasyDriver boards came in from SparkFun. This is the new version 4.2 driver boards. There isn’t much out there in the ways of tutorials for using this board yet so I hope I can help someone. 

The first order of business was to get some mounting pins soldered onto the driver board so I could plug it into a breadboard for testing. Here is a picture of the module with the pins soldered. 

EasyDriver v4.2 with Pins soldered on

Hint: it’s easier to solder the pins in if you lay the circuit board on the breadboard and stick the pins through the holes into the breadboard then when you have all the pins inserted solder them while its still on the breadboard to hold them straight)

Next I started laying out the jumpers and terminals on the breadboard. I know I could just stick the wires in the breadboard, but I find using these screw terminals work much better. The terminals I have are something like 5 mm pitch so they only pickup every other rail on the breadboard. So it takes a little thought on how to lay the jumpers out.

Jumpers

Terminals

Here is what it looks like when I finished placing all jumpers and terminals.

Completed test board

Wired up

Wired test board

In case you are trying to follow my wiring here, notice the color coding on the stepper motors. On the circuit board there are 4 terminals to hook to the stepper motor. Coil A and Coil B. Coil A terminals are next to each other and Coil B terminals are as well. However due to my use of the 5mm blocks I had to stagger the connections so what you see here  is ABAB, so Blue and Yellow are A coil and Red and Green are B coil.

The wiring of these units is pretty much straight forward. You have a direction Pin, that is held high for one direction and low for the other. A step pin that is pulsed high then low for 1 step. You have 2 other pins that enable micro stepping, ms1 and ms2. Tie them both low if you don’t want to micro step. ( I recommend tying them HIGH until you have tested for successful operation). You have two sources of power, one for the motor and one for the logic. If you are using an external power supply for your motor, which is almost always required, then the board will supply power back to the Arduino through the 5v logic connection. (However I had some issues getting my sketch to upload properly without my normal external supply hooked to the arduino). You have an enable pin that must be held low for the board to operate. The last connection that I used is the Sleep pin. If you tie it low then your motor will not be powered even though the arduino and the easydriver boards are still supplied. This also allows the motor to free wheel. I haven’t used the RST and PFD pins so I can’t speak to them just yet.

Here is the code to get the test running

NOTICE SEVERAL ERRORS WERE CORRECTED SINCE MY ORIGINAL POST!

// Some of this code was scavenged from different places on the Internet but I have changed a few things to get it working.

int dirpin = 8;
int steppin = 9;
int ms2pin = 10;
int enablepin = 11;
int ms1pin = 12;
int sleeppin = 13;
void setup() {
Serial.begin(9600);

pinMode(dirpin, OUTPUT);
pinMode(steppin, OUTPUT);
pinMode(ms2pin, OUTPUT);
pinMode(enablepin, OUTPUT);
pinMode(ms1pin, OUTPUT);
pinMode(sleeppin, OUTPUT);

digitalWrite(enablepin, LOW);    // enable easy driver
digitalWrite(sleeppin, HIGH);    // easy driver operating
digitalWrite(ms1pin, HIGH);    // microstepping disabled
digitalWrite(ms2pin, HIGH);    // microstepping disabled
}
void loop()
{

int i;

digitalWrite(dirpin, LOW);    // Set the direction pin to move forward

delay(1000);                  //Give it some time

Serial.println(“Forward”);    // Print Forward to the terminal window
for (i = 0; i<31000; i++)    // Step Forward 31000 steps
{
digitalWrite(steppin, LOW);   // Start out with step pin low
delayMicroseconds(500);    // Delay controls speed and Torque I originally had these at 100 that was too short
digitalWrite(steppin, HIGH);    // Now switch it high
delayMicroseconds(500);    // Delay controls speed and Torque you need at least a 500 delay
}             //

digitalWrite(dirpin, HIGH);    // Change direction to reverse
delay(100);                     // Give it some time

Serial.println(“Reverse”);     // Print Reverse to terminal window
for (i = 0; i<31000; i++)    // Step in Reverse 31000 steps
{
digitalWrite(steppin, LOW);   //  Start out with step pin low
delayMicroseconds(500);    // Delay controls speed and Torque you need at least a 500 delay  
digitalWrite(steppin, HIGH);    // Now switch it high
delayMicroseconds(500);    // Delay controls speed and Torque you need at least a 500 delay
}            

}

OK, now time for a couple of videos. Note the wire ties holding the stepper motor on, I couldn’t find any m3.5 screws today so I just used the wire ties for now.

CNC 040 6.5 Meg

CNC 044 5.5 Meg

I am not impressed with the torque of these small steppers I will most likely need to size up but more testing is required. This was because I had my pulse width too narrow. After increasing the delays to 500, I have plenty of torque!

I was the happy recipient of some really cool parts today (Thanks Brian). I now have some 20mm rails and 2 20mm ball screws. These will be the DADDY project after I flush all of the software and driver issues out with this junior unit. (insert smile).

I guess that’s enough for today. More to come…

54 Responses to “CNC Update 1 “We Have Motion!””

  1. admin says:

    Sorry for the code mistakes in the original post, I hope it didn’t cause anyone trouble.

  2. Duncan says:

    Sometimes its the small things. I’m building a rig and was having weird issues with motor torque. I put it down to microstepping, but in looking through your sample code I had my delay after I swapped my steppin low to high not in between. Moved it two lines and my problems are solved, thanks for the inadvertent help it saved me some hair pulling.

  3. admin says:

    Duncan,
    I am really pleased this was helpful to you in some way. Are using the EasyDriver stepper driver or something else?

  4. Hi, good day.. Your post is extremely striking. I never believed that it was feasible to do something like that until after I looked over your page. You undeniably offered an excellent understanding on how this kind of whole process functions. Ill make sure to return for more info. Keep writing!

  5. Duncan says:

    Hey Mark, I’m using two easy drivers to power my Pan and Tilt of a motion control camera rig. My new battle is with microstep resolution and battling the resonance that pops up when taking small discreet steps. I’m going to experiment with a library that microsteps with ramping in the pulse delay to try to ease the vibration. As it stands now it seems like taking a half step is more reliable position wise than going four 1/8 step microsteps. My other thought is to swap my 1.8 degree motors for 0.9 deg ones. I have one I picked up on ebay and it works well and I figure the extra resolution cant hurt, plus it gives me more steps to ramp up and down on each move. On a side note I’ve been seeing 6v 1.2amp motors and am wondering how they compare to my 12v 0.4amp motors. I’m not sure which would have more torque and which would last longer on my 8 x AA battery pack.

  6. admin says:

    Hey Duncan,
    I have noticed that micro stepping with small steppers produces very little torque. I am not sure your problem isn’t more of a torque related issue than a resolution. However you potentially could get enough resolution with the .09 deg motor to not need to micro step. As far as the 12v versus the 6V, if you are going to use the easydriver it will current limit the 6v motor so I am not sure how much difference it would make but I would be interested in your results. Thanks for commenting and good luck.

  7. Ken Eads says:

    I have the Arduino Duemilanove and EasyDriver 4.2. I am looking for code to move the stepper in only one direction with 40 steps per revolution. It seems very simple but I am having problems. Thanks for anyones help.

  8. admin says:

    Hi Ken,
    I am not sure I understand your question. Do you have a stepper motor that only has 40 steps per revolution? If so that would be a 9 degree stepper motor and I haven’t seen one like that. Here is the way it works. A stepper motor has a rating of degrees per step, such as .9. If you want to turn the stepper one revolution, 360 degrees, then you must send 400 full step pulses to the driver board. Every full step pulse you send to the driver board will advance the motor .9 degrees. I hope this helps. If not then maybe you can give me a little more information and I will see what I can do.

  9. Ken Eads says:

    Sorry for the confusion. My stepper is 1.8 degrees per step and I am trying to get it to step 40 times per 360 degrees or 9 degrees each time it moves. It only needs to move in one direction. Actually, what I want is the motor to move 9 degrees, switch off, then switch on, and then move another 9 degrees. I would like to controll the movement with a microswitch so that each time I trip the microswitch the motor advances 9 degrees. Hopefully, this will clear-up the confusion. Thanks again.

  10. admin says:

    Ken,
    I think I understand now. Try this code. It compiles without error but I didn’t run it to check it.

    // Some of this code was scavanged from different places on the internet but I have changed a few things to get it working.

    int dirpin = 8;
    int steppin = 9;
    int ms2pin = 10;
    int enablepin = 11;
    int ms1pin = 12;
    int sleeppin = 13;
    int MicroSwPin = 2; // the number of the pushbutton pin
    int lastMSState = LOW; // the previous reading from the input pin
    long lastDebounceTime = 0; // the last time the output pin was toggled
    long debounceDelay = 50; // the debounce time; increase if the output flickers

    void setup() {
    Serial.begin(9600);

    pinMode(MicroSwPin, INPUT);
    pinMode(dirpin, OUTPUT);
    pinMode(steppin, OUTPUT);
    pinMode(ms2pin, OUTPUT);
    pinMode(enablepin, OUTPUT);
    pinMode(ms1pin, OUTPUT);
    pinMode(sleeppin, OUTPUT);

    digitalWrite(enablepin, LOW); // enable easy driver
    digitalWrite(sleeppin, HIGH); // easy driver operating
    digitalWrite(ms1pin, HIGH); // microstepping disabled
    digitalWrite(ms2pin, HIGH); // microstepping disabled
    }

    void loop()
    {
    // read the state of the switch into a local variable:
    int reading = digitalRead(MicroSwPin);

    // check to see if you just pressed the button
    // (i.e. the input went from LOW to HIGH), and you’ve waited
    // long enough since the last press to ignore any noise:

    // If the switch changed, due to noise or pressing:
    if (reading != lastMSState) {
    // reset the debouncing timer
    lastDebounceTime = millis();
    }

    if ((millis() – lastDebounceTime) > debounceDelay)
    {
    int i;

    digitalWrite(dirpin, LOW); // Set the direction pin to move forward

    delay(1000); //Give it some time

    Serial.println(“Forward”); // Print Running to the terminal window
    for (i = 0; i<5; i++) // Step Forward 5 steps
    {
    digitalWrite(steppin, LOW); // Start out with step pin low
    delayMicroseconds(500); // Delay controls speed
    digitalWrite(steppin, HIGH); // Now switch it high
    delayMicroseconds(500); // Delay controls speed
    } //
    }

    }

  11. Ken Eads says:

    Thank you so much for the code. I will have to wait until the weekend after I return home to rewire the breadboard and upload the code. I will let you know the results next week. Have a great one and thanks for your help.

  12. admin says:

    No problem, I hope it works for you. If not give me a shout we will work it out.

  13. Ken Eads says:

    I cut and pasted the code and rewired my breadboard to account for all of the pins. However, when I tried to compile and upload the code I received the following error code: error: stray ‘\’ in program In function ‘void setup()’:
    In function ‘void loop()’:

    I looked for the problem but could not figure it out. Thanks for your help

  14. gnu_B says:

    Helpful code…

    Had to change the quote marks from this…

    “ and ”

    to this…

    ” and ”

    on lines 33 & 45 to make it compile on my PC.

    -Thanx

  15. admin says:

    Yep, I was able to duplicate the error from pasting the code. Here is a link to the pde file.

  16. Ken Eads says:

    Thanks to gnu_B and admin. I will give it a shot and hopefully, get this thing running.

  17. gnu_B says:

    After the previously mentioned quote mark change from the example given above, and adding proto-board jumpers to ms2pin = 10, enablepin = 11, ms1pin = 12, and sleeppin = 13, the code ran perfectly on a Vexta PX244-04AA stepper motor.

    I have a nice bench power supply and was able to vary the voltage. On my particular motor which is rated to 24v, optimum running was at about 17v-20v.

    I also tried micro-stepping enabled (ms1pin = LOW, ms2pin = LOW). Not only was speed reduced, but motor torque was considerably reduced, and smooth operation was very touchy to changes in voltage, with unexpected behavior at voltage much over or much under 17v.

    Thanks for the code, it really put some ‘wind in my sails’.

    Regards,

    gnu_B

  18. admin says:

    That is really great! Glad that I helped in some way. Thanks for the testing feedback, that is pretty good info.

  19. Ken E says:

    I’m back. Glad to hear that gnu-B got everything running great. the code compiled and uploaded fine. I have a Sparkfun stepper for testing and a NEMA 23 for the application. I am powering the board with my USB. Could this be causing the motor to spep continuosly but very unsteady and not very accurately? It isn’t waiting for any signals from the microswitches.

    Thanks,

  20. Ken E says:

    I also notice that when I turn the power off to the ED board and then turn it back it on, the motor almost always takes a step backwards before starting its stepping in the opposite and right direction. Maybe there is a clue there somewhere.
    Thanks,

  21. Ken E says:

    I also put 12 V power to Arduino but it did not make a difference.

    Thanks,

  22. admin says:

    Ken,
    I am traveling on business and don’t have much time but real quickly, you said you put 12v on the Arduino. You need to put the 12v on the ED board. If you are powering the ED board from the Arduino then that is your problem.

  23. Ken E says:

    I have always had 12 V on the ED to drive the motor but I have now added the 12 V to the Arduino.
    Thanks,

  24. Ken E says:

    In looking over gnu_B’s comments I note that I must be doing something wrong in the wiring as he is up and running. In review, I am unsure how to wire the microswitch (int MicroSwPin = 2; // the number of the pushbutton pin). solving the wiring may solve everthing.

    Thanks.

  25. gnu_B says:

    Enclosed is code for a micro stepping demo, based on Mark’s code.

    Please note that I had to reverse the HIGH and LOW states to the MS1 and MS2 terminals, otherwise results were opposite of what should have happened.

    I made the pulse loops 200 steps each so you can clearly see that 200 full steps does equal 360 degrees, and that enabling MS1 only, results in 180 degrees, and enabling MS2 only results in 90 degrees, and enabling MS1 and MS2 results in 45 degrees, as would be expected.

    I have video of the stepper running the code and in the background is the printout running on the screen.

    Best Regards,

    -gnu_B

    BEGIN CODE…

    // This is a microstep demo is based on code from Mark
    // Original code came from here

    int dirpin = 8;
    int steppin = 9;
    int ms2pin = 10;
    int enablepin = 11;
    int ms1pin = 12;
    int sleeppin = 13;
    void setup() {
    Serial.begin(9600);

    pinMode(dirpin, OUTPUT);
    pinMode(steppin, OUTPUT);
    pinMode(ms2pin, OUTPUT);
    pinMode(enablepin, OUTPUT);
    pinMode(ms1pin, OUTPUT);
    pinMode(sleeppin, OUTPUT);

    digitalWrite(enablepin, LOW); // enable easy driver
    digitalWrite(sleeppin, HIGH); // easy driver operating
    digitalWrite(ms1pin, LOW); // microstepping disabled
    digitalWrite(ms2pin, LOW); // microstepping disabled
    }
    void loop()
    {
    Serial.println(“”);
    Serial.println(“* * * START CYCLE HERE * * *”); // Print start of cycle

    digitalWrite(ms1pin, LOW); // MS1 disabled
    digitalWrite(ms2pin, LOW); // MS2 disabled
    Serial.println(“* Full Step* “);

    delay(500); //Give it some time

    int i;

    digitalWrite(dirpin, LOW); // Set the direction pin to move forward

    delay(1000); //Give it some time

    Serial.println(“Forward – Full Step”); // Print Forward to the terminal window
    for (i = 0; i<200; i++) // Step Forward 200 steps
    {
    digitalWrite(steppin, LOW); // Start out with step pin low
    delayMicroseconds(1000); // Delay controls speed and Torque I originally had these at 100 that was too short
    digitalWrite(steppin, HIGH); // Now switch it high
    delayMicroseconds(1000); // Delay controls speed and Torque you need at least a 500 delay
    } //

    digitalWrite(dirpin, HIGH); // Change direction to reverse

    delay(500); //Give it some time

    Serial.println("Reverse – Full Step"); // Print Reverse to terminal window
    for (i = 0; i<200; i++) // Step in Reverse 200 steps
    {
    digitalWrite(steppin, LOW); // Start out with step pin low
    delayMicroseconds(1000); // Delay controls speed and Torque you need at least a 500 delay
    digitalWrite(steppin, HIGH); // Now switch it high
    delayMicroseconds(1000); // Delay controls speed and Torque you need at least a 500 delay
    }

    digitalWrite(ms1pin, HIGH); // MS1 enabled
    digitalWrite(ms2pin, LOW); // MS2 disabled
    Serial.println("* half step *");

    digitalWrite(dirpin, LOW); // Set the direction pin to move forward

    delay(500); //Give it some time

    Serial.println("Forward – MS1"); // Print Forward to the terminal window
    for (i = 0; i<200; i++) // Step Forward 200 steps
    {
    digitalWrite(steppin, LOW); // Start out with step pin low
    delayMicroseconds(1000); // Delay controls speed and Torque I originally had these at 100 that was too short
    digitalWrite(steppin, HIGH); // Now switch it high
    delayMicroseconds(1000); // Delay controls speed and Torque you need at least a 1000 delay
    } //

    digitalWrite(dirpin, HIGH); // Change direction to reverse

    delay(500); //Give it some time

    Serial.println("Reverse – MS1"); // Print Reverse to terminal window
    for (i = 0; i<200; i++) // Step in Reverse 200 steps
    {
    digitalWrite(steppin, LOW); // Start out with step pin low
    delayMicroseconds(1000); // Delay controls speed and Torque you need at least a 1000 delay
    digitalWrite(steppin, HIGH); // Now switch it high
    delayMicroseconds(1000); // Delay controls speed and Torque you need at least a 500 delay
    }

    digitalWrite(ms1pin, LOW); // MS1 disabled
    digitalWrite(ms2pin, HIGH); // MS2 enabled
    Serial.println("* quarter step *");

    digitalWrite(dirpin, LOW); // Set the direction pin to move forward

    delay(500); //Give it some time

    Serial.println("Forward – MS2"); // Print Forward to the terminal window
    for (i = 0; i<200; i++) // Step Forward 200 steps
    {
    digitalWrite(steppin, LOW); // Start out with step pin low
    delayMicroseconds(1000); // Delay controls speed and Torque I originally had these at 100 that was too short
    digitalWrite(steppin, HIGH); // Now switch it high
    delayMicroseconds(1000); // Delay controls speed and Torque you need at least a 1000 delay
    } //

    digitalWrite(dirpin, HIGH); // Change direction to reverse

    delay(500); //Give it some time

    Serial.println("Reverse – MS2"); // Print Reverse to terminal window
    for (i = 0; i<200; i++) // Step in Reverse 200 steps
    {
    digitalWrite(steppin, LOW); // Start out with step pin low
    delayMicroseconds(1000); // Delay controls speed and Torque you need at least a 1000 delay
    digitalWrite(steppin, HIGH); // Now switch it high
    delayMicroseconds(1000); // Delay controls speed and Torque you need at least a 500 delay
    }

    digitalWrite(ms1pin, HIGH); // MS1 enabled
    digitalWrite(ms2pin, HIGH); // MS2 enabled
    Serial.println("* eighth step *");

    digitalWrite(dirpin, LOW); // Set the direction pin to move forward

    delay(500); //Give it some time

    Serial.println("Forward – MS1 + MS2"); // Print Forward to the terminal window
    for (i = 0; i<200; i++) // Step Forward 200 steps
    {
    digitalWrite(steppin, LOW); // Start out with step pin low
    delayMicroseconds(1000); // Delay controls speed and Torque I originally had these at 100 that was too short
    digitalWrite(steppin, HIGH); // Now switch it high
    delayMicroseconds(1000); // Delay controls speed and Torque you need at least a 1000 delay
    } //

    digitalWrite(dirpin, HIGH); // Change direction to reverse

    delay(500); //Give it some time

    Serial.println("Reverse – MS1 + MS2"); // Print Reverse to terminal window
    for (i = 0; i<200; i++) // Step in Reverse 200 steps
    {
    digitalWrite(steppin, LOW); // Start out with step pin low
    delayMicroseconds(1000); // Delay controls speed and Torque you need at least a 1000 delay
    digitalWrite(steppin, HIGH); // Now switch it high
    delayMicroseconds(1000); // Delay controls speed and Torque you need at least a 500 delay
    }

    }

    …END CODE

  26. admin says:

    Thanks gnu_b, I actually noticed those MS1 and MS2 were backwards when I first did this and forgot to change it in the code. If you will register with the site, I will give you rights to upload your images if you would like.

  27. admin says:

    You need to follow the directions on the the official Arduino web site for the wiring. I don’t have the link right now but are you using a pull up or pull down resistor?

  28. Ken E says:

    Thanks gnu_b and admin. This has turned into quite a large project from what I had envisioned as being so simple. I will cut and paste and upload the code tomorrow and maybe not till the weekend as I am traveling the rest of the week. You ask about the resistor but I have not done anything to the ED except solder all of the pins. I have done nothing to the Arduino. So in answer to your question, no resistor has been added. I think I am way out of my skill set with this project as I didn’t know I needed a resistor. I am still unsure as to how and where to wire the micro switch, so I will follow-up with Arduino on that. Again thanks for your help on this simple project. Hopefully, when I get the monster up and running I can show you some video or pics. It is still some weeks away.

    Signed,

    Lost-but thankful for your help and indulgence.

    Regards,
    Ken

  29. Ken E says:

    I decided to cut and paste tonight but could not compile due to the following code: error: stray ‘\’ in program In function ‘void setup()’:
    In function ‘void loop()’:
    At global scope:
    I tried changing the quote marks and directed by gnu_b the other night but even though they changed on screen I still contiued to get the same error codes until I clicked on and copied the PDE file that admin sent. I do not understand the reason for that. I will look got those quote marks again in this copy and see if I can get them to change and then compile.

    Thanks,

    Ken

  30. Ken E says:

    I was able to get the program compiled by exporting to Word and using the Times New Roman font. I then copied from Word to the sketch and the compile errors then showed me exactly what I needed to change by highlighting them in yellow. I believe all of the problems were caused by the font change from the blog to sketch. Thanks again for your help. I am closer but not there yet. I need to go now.
    Regards,
    Ken

  31. admin says:

    Here is the link to the debounce switch setup

  32. gnu_B says:

    Ken E,

    Yes, you are correct, the Blog software is changing characters in the code that is pasted in, and worse, it doesn’t seem to be very consistent. Some of the quote characters were changed, but not all, and a semi-colon was deleted. This kind of stuff can be very frustrating, especially is you really are a ‘newbie’.

    So, I took my stepper demo code, tested it, then zipped it and then un-zipped it and tested it again to make sure it compiled correctly. It passed the test.

    If there is some way that I can post that zipped file on this blog, or some way I can email that file to you, I will.

    You need to have something you can count on…

    Regards,

    -gnu_B

  33. Ken E says:

    gnu_B,

    Thanks for the reply and yes I truly am a newbie. Admin can give you my email if he does that sort of thing. I would love to have your zipped file. I am going to try modify your code but I first need to study the switch wiring that admin sent and get that working first. I think admin was going to let you post your video as well.

    Thanks again.

    Ken

  34. Ken E says:

    admin,

    Thanks for the link and I am going to try to figure the switch out tonight. I appreciate your help and input. I also give you permission to give gnu_b my email address. I am also looking forward to his video so I can confirm that my stepper is doing exactly as his is doing. Thanks again.

    Regards,
    Ken

  35. gnu_B says:

    Ken,

    I sent you the Microstep Stepper Motor Demo code, and some tips that you may have overlooked.

    If you don’t have a “pin map” for your Arduino, you’ll need to locate one.

    Best of luck!

    Regards,

    -gnu_B

  36. Ken E says:

    Admin,

    Thanks for sending along my email to gnu_B. We have already communicated and he has been a great help.

    Regards,
    Ken

  37. admin says:

    No problem, Glad to be of assistance, and thanks to gnu for helping.

  38. Ken E says:

    I am back with the switch wired but now I cannot get the Arduino to upload the sketch. I may have blown the board. I am getting the following error code:

    avrdude: stk500_getsync(): not in sync: resp=0×00
    avrdude: stk500_disable(): protocol error, expect=0×14, resp=0×51

    Has anyone seen this code before. Arduino trouble shooting didn’t talk about the various codes. The green light is on but the other led’s only flicker occasionally.

    Thanks,
    Ken

  39. admin says:

    The only thing that comes to mind really quickly is, make sure you have it set for the correct board, under tools – board-
    Also if you are not using an external power supply to power the board you might try that.

  40. Ken E says:

    Admin,

    Thanks for the tips. I did check the board under tools and that is ok. I will try the separate power supply.

    Thanks,
    Ken

  41. Ken E says:

    I googled the problem and did all the checks that were recommended and decided to order a couple of new Atmega328 chips. I hope that will fix the problems.

    Ken

  42. Ken E says:

    I received the Atmega 328 chip today, installed and the Arduino is back to uploading and working great. I loaded both gnu-B’s and admins sketches. I beleive gnu-B’s worked as he had outlined but I need to check it more carefully. Admin the program steps but it takes about 80 or so step to get one RPM. The switch seems to work in only one position. I have a 10k ohm resistor in place. I tried a 330 ohm resistor and that did not seem to work at all. The motor seems to step in about 5 degree increments and will only stop as long as I hold the switch down. If I don’t hold the switch down it just continues to step. It appears that it considers the switch always on unless I depress it. Switching terminals caused it not to operate at all. I am closer than ever. I did switch MS1 and MS2 to low as recommended. Now I am lost again.

    Regards,
    Ken

  43. admin says:

    Ken,
    I am not ignoring you, I am working VERY long days right now and when I get home I am just shot. I can’t even think about what you are saying right now. Give me a day or two and I will get back with you.
    Thanks,
    Mark

  44. Ken E says:

    Mark,
    Absolutely no problem. Do your job and get your rest.
    Best regards,
    Ken

  45. admin says:

    Ken,
    When you say you switched the terminals on the switch and it wouldn’t operate at all, Exactly what did you switch? You should have 3 terminals on your switch. NO, NC, and COM. Normally open, Normally Closed and Common, respectively. Which one ties to the input pin of the arduino now?

  46. Ken E says:

    Admin,
    There are 3 terminals on my switch. I have the common to the ground and resistor and then on to pin 2 on the Arduino. When I put the NC to the 5v the light comes on the Arduino only when I press the switch. When I put the 5v to the NO the Arduino is always on and the Stepper just wiggles the tinest bit when I push the switch but doesn’t step and when I release the button it stops and moves reverse just a wiggle. Nothing happens when the switch is not pushed.
    Thanks,
    Ken

  47. admin says:

    The resistor should tie from either the ground or the 5v directly to the arduino pin. This is called a pull up or pull down resistor depending on how you connect it. Then the switch common should also tie to the arduino pin.
    If you connected the resistor to the 5v+, then the NO pin should tie to GND.
    If you connected the resistor to the GND, then the NO pin should tie to 5V+
    What this does is tie the pin to the arduino either High or low depending on how you hook the resistor, then when you push the switch and close the contact, it will have a lower resistance than the resistor of course, and toggle the input to the other state. I will try to diagram it out below.

    ………………………………………5V
    ………………………………………|resistor
    ……………………Arduino Pin +
    ………………………………………\ NO Switch
    ………………………………………|GND

  48. Ken E says:

    Here is the map I used for the connections. I have the 5V connected the NO on the switch. I have the common connected to the GND, then resistor, then on to pin 2 of the Arduino.

    http://webzone.k3.mah.se/projects/arduino-workshop/projects/arduino_meets_processing/instructions/switch.html
    Thanks,
    Ken

  49. admin says:

    Try swaping the GND and 5V wires going to the resistor and the switch. In other words the resistor would now go to the 5V and the switch would go to GND. Let me know what the result is.

  50. Ken E says:

    It works now when I put the resistor in the 5V pin and then run down to the breadboard with the other end. Then I ran a wire to the NO on the switch and then one to pin 2 on the Arduino. GND I ran down to the board and on to the common of the switch. It is working. I tried reversing and putting the resistor directly in the GND but really no change. The ED seems to get hot faster and the stepper isn’t moving the 5 steps. It takes about 16 switch pushes to go 90 degrees, so it looks like it is moving about 5.6 degrees per switch push. the Arduino is running cool in Idle when both the Green LED and the upper small white LED is lit. I think we are there is we can get the stepping right.
    Ken

Leave a Reply