Arduino control for a 3” rotary table

Home Model Engine Machinist Forum

Help Support Home Model Engine Machinist Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
I suspect that there is a mismatch somewhere that is offsetting the screen output or something.

Go back to your ebay listing and study the two links provided. The answer will be somewhere there. One is the library on github and the other is the main page. I can't help you anymore than this. Wait for your new hardware to arrive and start again with the correct library for that code. Any time I have used a LCD it has been dead simple.
 
Loaded the script from post 24 and the curious began - - -
lcd.init();
Ok how to paint this picture - - -
LiquidCrystal keyword is 'init' e.g lcd.init(20,40);
Keyword 'init' doesn't exist in the newliquidcrystal keyword file,
NewLiquidCrystal keyword is 'begin' e.g lcd.begin(20,40);
Both use file name LiquidCrystal_I2C
e.g. LiquidCrystal_I2C lcd(0x3b,20,4); LiquidCrystal Library
LiquidCrystal_I2C lcd(0x3B, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE) NewLiquidCrystal Library

With the LiquidCrystal library installed display doesn't print out correctly as shown on image . . .

DSCF0149_zps6qo5vffz.jpg


Just a few leading letters, nothing more- That library and this display just don't want to cooperate . . .

But it worked before i installed the LiquidCrystal library, worked fine with the NewLiquidCrystal Library, kinda, sorta - gave a compile error lcd.init(20,4) a no go as the keyword is 'begin' rather than 'init' Ok can deal with that.
Changed the lcd lines to suit the library in use, complied and displayed fine

With NewLiquidCrystalDisplay library

DSCF0151_zps9fjs9sby.jpg


Cheap camera bad photos . . Where was I - - Ok so NewLiquidCrystal library works, LiquidCrystal Library doesn't - BUT - having both libraries in the system was a nogo - - - Don't know why it does but arduino used the LiquidCrystal library over the other - If it complies with lcd.init(20x4) in the script its the LiquidCrystal library [uncooperative one]. Complies with lcd.begin(20x4) its the cooperative one . . . So located and deleted the uncooperative library entirely - No longer complies with the 'Tell' code, does compile with the lcd.begin(20,4) code and display works as it should. . .

So having multiple libraries with same calling code as appears to be
LiquidCrystal_I2C lcd(blah blah blah) can be a/source of grief . . .

Sorry for the mud in the water language -
 
All is not lost...removed libraries as per Foozer's suggestion and loaded a sketch that was just for the LCD and now have a functioning display....only kept Wire, Keypad and NewLiquidCrystal, here is the edited sketch I change address to 0x3F and kept everything else.

#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
//LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address //sainsmart lcd2004
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address to units address e.g. 0x27, 0x3f etc
// other backpack changeable i2c address
void setup()
{
lcd.begin(20,4); // initialize the lcd
lcd.home (); // go home
lcd.print("Hello Foozer, Rodw and Bmac");
lcd.setCursor ( 0, 1 ); // go to the next line
lcd.print (" Line Two");
lcd.setCursor ( 0, 2 ); // go to the next line
lcd.print (" Line Three three");
lcd.setCursor ( 0, 3 ); // go to the next line
lcd.print (" Line Fourt five");
}
void loop(){}



I have now tried to incorporate this LCD sketch into Bmac2 sketch...no luck...wont compile...my lack of coding knowledge and started at 3.00 am now 5.00 am, so still have to sort out Keypad function which been trying to do this morning....no luck yet.
Bur happy to report it looks like the LCD is sorted and can be a guideline to get the rest functioning...if only I knew what I was doing.....but I am happy that my knowledge of Arduino has increased substantially thanks to you gents.

Cheers.
 
Also forgot to mention I changed...."lcd.init(20,4); // initialize the lcd"...to..."lcd.begin(20,4); // initialize the lcd"


Cheers.
 
Also forgot to mention I changed...."lcd.init(20,4); // initialize the lcd"...to..."lcd.begin(20,4); // initialize the lcd"


Cheers.

Got the display to work, you're almost home

Don't try to meld the two scripts together, just change/keep the LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); and change the occurrences of lcd.init(20,4) to lcd.begin(20,4); and it should compile - Does here.
 
Time to celebrate...looks like I have a functioning controller...will try later when i connect to stepper motor.
looks like I have all functions, multiple screens...just had to swap keyboard wires around.

Had to alter other instances of LCD init() by deleting all of them bar the first one and change that one to LCDbegin.
here is a copy of the working code for my flavour of LCD.

I would like to sincerely thank all of those that posted their suggestions and help...cheers.

/*
4x4 matrix keypad amd a 20 x 4 LCD.
Edit StepsPerRotation & TableRatio(# of turns for 360 degrees)in line 29
M542 driver
5/2/2015
*/

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};

byte rowPINS[ROWS] = {11,10,9,8};
byte colPINS[COLS] = {7,6,5,4};

Keypad kpd = Keypad(makeKeymap(keys),rowPINS,colPINS, ROWS, COLS);
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);// set the LCD address to 0x20 for a 16 chars and 4 line display
// SCL - 21, SDA - 20, VCC - +5, Gnd - Gnd
//setup vars
const int stp = 2; // connect pin 2 to step
const int dir = 3; // connect pin 3 to dir
const int StepsPerRotation = 400; // Set Steps per rotation of stepper NOTE the driver is set to Half step
const int TableRatio = 36; // ratio of rotary table
const int Multiplier = (StepsPerRotation * TableRatio)/360; // 200*90=18000/360 = 50
const int stepdelay = 1;
float Degrees = 0; // Degrees from Serial input
float ToMove = 0; // Steps to move
float bob = 0;
int cho = 0;

void setup()
{
lcd.begin(20,4); // initialize the lcd
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);

// Print welcome message to the LCD.
lcd.backlight();
lcd.print("Rotary Table Control");
lcd.setCursor(4,2);
lcd.print(" ");
lcd.setCursor(3,3);
lcd.print("updated 2016");
delay(2000);

cho = 0;
char key = kpd.getKey();
lcd.print("Enter Selection:");
lcd.setCursor(0,1);
lcd.print("Degrees = A");
lcd.setCursor(0,2);
lcd.print("Divisions = B");
lcd.setCursor(0,3);
lcd.print("JOG = C");
while(cho == 0)
{
key = kpd.getKey();
switch (key)
{
case NO_KEY:
break;
case 'A':
Degrees=getdegrees();
lcd.clear();
cho = 1;
break;
case 'B':
Degrees=getdivisions();
cho=2;
break;
case 'C':
Degrees=getjog();
lcd.clear();
cho=3;
break;
} // end case
} // end while cho=0
} // end setup

void loop() // MAIN LOOP
{
lcd.clear();
char key = kpd.getKey();
bob = 0;
lcd.setCursor(7,0);lcd.print("Total: ");lcd.print(bob,2); // total steps
lcd.setCursor(0,3);lcd.print("FOR=A REV=B X=C");
while(key != 'C') // C will return to start menu
{
lcd.setCursor(0,0);lcd.print(abs(Degrees),2);lcd.print((char)223);
key = kpd.getKey();
if(key == 'A') // FORWARD
{
bob = bob + Degrees;
ToMove = (Degrees*Multiplier);
digitalWrite(dir, LOW);
printadvance();
}
if(key=='B') // REVERSE
{
bob = bob - Degrees;
ToMove = (Degrees*Multiplier);
digitalWrite(dir, HIGH); // pin 13
printadvance();
}
} // end while not C loop

setup();
} // end main VOID


float getjog()
{
float Degrees = 0;
float num = 0.00;
char key = kpd.getKey();
lcd.clear();
lcd.setCursor(6,0);lcd.print("Jogging");
lcd.setCursor(0,1);lcd.print("A=1 B=10 C=100 Steps");
lcd.setCursor(0,2);lcd.print("Enter Degrees:");lcd.setCursor(0,3);lcd.print("OK = # ");lcd.print((char)60);lcd.print((char)45);lcd.print(" D");

while(key != '#')
{
switch (key)
{
case NO_KEY:
break;
case 'A':
Degrees = 1;
lcd.setCursor(14,2);lcd.print(Degrees);
break;
case 'B':
Degrees = 10;
lcd.setCursor(14,2);lcd.print(Degrees);
break;
case 'C':
Degrees = 100;
lcd.setCursor(14,2);lcd.print(Degrees);
break;
case 'D':
num=0.00;
lcd.setCursor(14,2);lcd.print(" ");
lcd.setCursor(14,2);
break;
}
key = kpd.getKey();
}
return Degrees;
}


float getdivisions()
{
float Degrees = 0;
float num = 0.00;
char key = kpd.getKey();
lcd.clear();
lcd.setCursor(0,1);lcd.print("Enter Division:");lcd.setCursor(0,3);lcd.print("OK = # ");lcd.print((char)60);lcd.print((char)45);lcd.print(" D");
lcd.setCursor(16,1);

while(key != '#')
{
switch (key)
{
case NO_KEY:
break;

case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
num = num * 10 + (key - '0');
lcd.print(key);
break;

case 'D':
num=0.00;
lcd.setCursor(16,1);lcd.print(" ");
lcd.setCursor(16,1);
break;
}
Degrees = 360/num;
key = kpd.getKey();
}
return Degrees; //num;
}


float getdegrees()
{
//int key = 0;
float num = 0.00;
float decimal = 0.00;
float decnum = 0.00;
int counter = 0;
lcd.clear();
//lcd.init();
char key = kpd.getKey();
lcd.setCursor(0,1);lcd.print("Enter Degrees:");lcd.setCursor(0,3);lcd.print("OK = # ");lcd.print((char)60);lcd.print((char)45);lcd.print(" D");
lcd.setCursor(15,1);
bool decOffset = false;

while(key != '#')
{
switch (key)
{
case NO_KEY:
break;

case '.':
if(!decOffset)
{
decOffset = true;
}
lcd.print(key);
break;

case 'D':
num=0.00;
lcd.setCursor(15,1);lcd.print(" ");
lcd.setCursor(15,1);
break;

case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
if(!decOffset)
{
num = num * 10 + (key - '0');
lcd.print(key);
}
else if((decOffset) && (counter <= 1))
{
num = num * 10 + (key - '0');
lcd.print(key);
counter++;
}
break;
} //end case
decnum = num / pow(10, counter);
key = kpd.getKey();
} //end while not #
return decnum;
} // end getdegrees

void printadvance() // print function
{
lcd.setCursor(6,1);lcd.print("Moving");
lcd.setCursor(4,2);lcd.print("Steps ");lcd.print(ToMove,0);
lcd.setCursor(13,0);lcd.print(bob,2);
rotation(ToMove,0);
lcd.setCursor(6,1);lcd.print(" ");
}

void rotation(float tm, int d)
{
for(int i = 0; i < tm; i++)
{
digitalWrite(stp, HIGH);
delay(stepdelay);
digitalWrite(stp, LOW);
delay(stepdelay);
}
}

void software_Reset() // Restarts program from beginning but does not reset the peripherals and registers
{
asm volatile (" jmp 0");
}
 
Just a reminder for anyone using this code is to change table ratio...in my case it is 90 to 1.
And of course this is a code slightly modified but based on the code submitted by Bmac 2...thanks.
 
Well ..spent most of the day reading up about stepper drivers etc and tried wiring in different configurations to run the motor I have.
I swapped out the driver for a higher capacity than a M542 driver...just to see if it was a faulty M542...doesn't seem to be as both drivers not rotating motor.
I altered the code from pin 2 and pin 3 to pin13 Dir and pin 12 Pul....at the moment wiring is pin13 to PUL+...pin 12 to Dir+.... ground to PUL- ,Dir - and Enable -.
I must be close to getting this thing running.
Any ideas... my connections or something with the code ?.....I notice on the code there is .const int stp = 12;.further down the code there is pinMode(stp, OUTPUT);Do I need to change this ?


Cheers.
 
Well ..spent most of the day reading up about stepper drivers etc and tried wiring in different configurations to run the motor I have.
I swapped out the driver for a higher capacity than a M542 driver...just to see if it was a faulty M542...doesn't seem to be as both drivers not rotating motor.
I altered the code from pin 2 and pin 3 to pin13 Dir and pin 12 Pul....at the moment wiring is pin13 to PUL+...pin 12 to Dir+.... ground to PUL- ,Dir - and Enable -.
I must be close to getting this thing running.
Any ideas... my connections or something with the code ?.....I notice on the code there is .const int stp = 12;.further down the code there is pinMode(stp, OUTPUT);Do I need to change this ?


Cheers.


More info needed - Uno or Mega? what type stepper motor? what driver? driver shield? Driver shields generally are pin specific with [grumble grumble] no consistent standard . . . So knowing the type of driver is knowing which pins the code should call . . .
 
Try disconnecting the enable wires to the stepper driver totally. In my experience, it is a stepper disable signal and the manual says it should not normally be connected.

Been caught myself!
 
Tried both Uno and Mega...currently Mega Connected, Nema 23 425 oz/in , Sutia M542 driver - 48 volt in, A+-red, A- Blue, B+ - green, B- black, Pul- bridged to Dir - bridged to Gnd
Pul+ to Pin 12, Dir+ to Pin13.....no Enable connection.

I have checked everything numerous times, I have looked at code and to me it looks ok...nothing jumps out at me...but really I haven't a clue,tho I wonder why Cons Int is used and others seem to use Pinmode....just an observation trying to get this sorted.



LCD and Keypad working great.

/*
4x4 matrix keypad amd a 20 x 4 LCD.
Edit StepsPerRotation & TableRatio(# of turns for 360 degrees)in line 29
M542 driver
5/2/2015
*/

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};

byte rowPINS[ROWS] = {11,10,9,8};
byte colPINS[COLS] = {7,6,5,4};

Keypad kpd = Keypad(makeKeymap(keys),rowPINS,colPINS, ROWS, COLS);
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);// set the LCD address to 0x3F for a 20 chars and 4 line display
// SCL - 21, SDA - 20, VCC - +5, Gnd - Gnd
//setup vars
const int stp = 12; // connect pin 12 to step
const int dir = 13; // connect pin 13 to dir
const int StepsPerRotation = 400; // Set Steps per rotation of stepper NOTE the driver is set to Half step
const int TableRatio = 90; // ratio of rotary table
const int Multiplier = (StepsPerRotation * TableRatio)/360; // 200*90=18000/360 = 50
const int stepdelay = 1;
float Degrees = 0; // Degrees from Serial input
float ToMove = 0; // Steps to move
float bob = 0;
int cho = 0;

void setup()
{
lcd.begin(20,4); // initialize the lcd
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);

// Print welcome message to the LCD.
lcd.backlight();
lcd.print("Rotary Table Control");
lcd.setCursor(4,2);
lcd.print(" ");
lcd.setCursor(3,3);
lcd.print("updated 2016");
delay(2000);

cho = 0;
char key = kpd.getKey();
lcd.print("Enter Selection:");
lcd.setCursor(0,1);
lcd.print("Degrees = A");
lcd.setCursor(0,2);
lcd.print("Divisions = B");
lcd.setCursor(0,3);
lcd.print("JOG = C");
while(cho == 0)
{
key = kpd.getKey();
switch (key)
{
case NO_KEY:
break;
case 'A':
Degrees=getdegrees();
lcd.clear();
cho = 1;
break;
case 'B':
Degrees=getdivisions();
cho=2;
break;
case 'C':
Degrees=getjog();
lcd.clear();
cho=3;
break;
} // end case
} // end while cho=0
} // end setup

void loop() // MAIN LOOP
{
lcd.clear();
char key = kpd.getKey();
bob = 0;
lcd.setCursor(7,0);lcd.print("Total: ");lcd.print(bob,2); // total steps
lcd.setCursor(0,3);lcd.print("FOR=A REV=B X=C");
while(key != 'C') // C will return to start menu
{
lcd.setCursor(0,0);lcd.print(abs(Degrees),2);lcd.print((char)223);
key = kpd.getKey();
if(key == 'A') // FORWARD
{
void setup()
{
lcd.begin(20,4); // initialize the lcd
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);


float getjog()
{
float Degrees = 0;
float num = 0.00;
char key = kpd.getKey();
lcd.clear();
lcd.setCursor(6,0);lcd.print("Jogging");
lcd.setCursor(0,1);lcd.print("A=1 B=10 C=100 Steps");
lcd.setCursor(0,2);lcd.print("Enter Degrees:");lcd.setCursor(0,3);lcd.print("OK = # ");lcd.print((char)60);lcd.print((char)45);lcd.print(" D");

while(key != '#')
{
switch (key)
{
case NO_KEY:
break;
case 'A':
Degrees = 1;
lcd.setCursor(14,2);lcd.print(Degrees);
break;
case 'B':
Degrees = 10;
lcd.setCursor(14,2);lcd.print(Degrees);
break;
case 'C':
Degrees = 100;
lcd.setCursor(14,2);lcd.print(Degrees);
break;
case 'D':
num=0.00;
lcd.setCursor(14,2);lcd.print(" ");
lcd.setCursor(14,2);
break;
}
key = kpd.getKey();
}
return Degrees;
}


float getdivisions()
{
float Degrees = 0;
float num = 0.00;
char key = kpd.getKey();
lcd.clear();
lcd.setCursor(0,1);lcd.print("Enter Division:");lcd.setCursor(0,3);lcd.print("OK = # ");lcd.print((char)60);lcd.print((char)45);lcd.print(" D");
lcd.setCursor(16,1);

while(key != '#')
{
switch (key)
{
case NO_KEY:
break;

case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
num = num * 10 + (key - '0');
lcd.print(key);
break;

case 'D':
num=0.00;
lcd.setCursor(16,1);lcd.print(" ");
lcd.setCursor(16,1);
break;
}
Degrees = 360/num;
key = kpd.getKey();
}
return Degrees; //num;
}


float getdegrees()
{
//int key = 0;
float num = 0.00;
float decimal = 0.00;
float decnum = 0.00;
int counter = 0;
lcd.clear();
//lcd.init();
char key = kpd.getKey();
lcd.setCursor(0,1);lcd.print("Enter Degrees:");lcd.setCursor(0,3);lcd.print("OK = # ");lcd.print((char)60);lcd.print((char)45);lcd.print(" D");
lcd.setCursor(15,1);
bool decOffset = false;

while(key != '#')
{
switch (key)
{
case NO_KEY:
break;

case '.':
if(!decOffset)
{
decOffset = true;
}
lcd.print(key);
break;

case 'D':
num=0.00;
lcd.setCursor(15,1);lcd.print(" ");
lcd.setCursor(15,1);
break;

case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
if(!decOffset)
{
num = num * 10 + (key - '0');
lcd.print(key);
}
else if((decOffset) && (counter <= 1))
{
num = num * 10 + (key - '0');
lcd.print(key);
counter++;
}
break;
} //end case
decnum = num / pow(10, counter);
key = kpd.getKey();
} //end while not #
return decnum;
} // end getdegrees

void printadvance() // print function
{
lcd.setCursor(6,1);lcd.print("Moving");
lcd.setCursor(4,2);lcd.print("Steps ");lcd.print(ToMove,0);
lcd.setCursor(13,0);lcd.print(bob,2);
rotation(ToMove,0);
lcd.setCursor(6,1);lcd.print(" ");
}

void rotation(float tm, int d)
{
for(int i = 0; i < tm; i++)
{
digitalWrite(stp, HIGH);
delay(stepdelay);
digitalWrite(stp, LOW);
delay(stepdelay);
}
}

void software_Reset() // Restarts program from beginning but does not reset the peripherals and registers
{
asm volatile (" jmp 0");
}


Cheers
 
Whoops meant to say....wonder why "Const int" is used whilst I have observed "Define "as being used in other sketches..
See I have no Idea

Cheers.
 
Similar driver - en-, dir-, pul- all to GND

dir+ to arduino pin
pul+ to arduino pin

en+ enable, pulled low to have driver process step, direction commands, pulled high to to have driver process step, direction commands. Don't really see an enable command in the code, could be the driver used is fixed enabled.

what free pins are available? can add an enable command
top of script where defines and other int rest add
int Enable = youropenpin; // Stepper Enable Pin
this pin connected to the en+ of the driver

in setup add pinMode(Enable, OUTPUT);
digitalWrite(Enable, LOW); enable driver command processing . .

I think that's right, can stumble through arduino


powered on stepper should resist being turned by hand
a digitalWrite(Enable,HIGH); should disable driver from processing commands and stepper should turn freely by hand . . .
 
I have -en, dir-, pul- all to gnd

here is my pin layout...12 and 13 PWM, 22 Digital

// SCL - 21, SDA - 20, VCC - +5, Gnd - Gnd
//setup vars
const int stp = 12; // connect pin 12 to step
const int dir = 13; // connect pin 13 to dir
const int en = 22; // Stepper Enable Pin 22 this pin connected to the en+ of the driver
const int StepsPerRotation = 400; // Set Steps per rotation of stepper NOTE the driver is set to Half step
const int TableRatio = 90; // ratio of rotary table
const int Multiplier = (StepsPerRotation * TableRatio)/360; // 200*90=18000/360 = 50
const int stepdelay = 1;
float Degrees = 0; // Degrees from Serial input
float ToMove = 0; // Steps to move
float bob = 0;
int cho = 0;

void setup()
{
lcd.begin(20,4); // initialize the lcd
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);
pinMode(en, OUTPUT);
digitalWrite(en, LOW);


no turning of motor yet...locked up hard.

Cheers.
 
Whoops meant to say....wonder why "Const int" is used whilst I have observed "Define "as being used in other sketches..
See I have no Idea

Cheers.

#define (or anything starting with #) is a precompiler directive. The generate no code.

So
#define step 12
simply means to replace the word step with the value 12 before compiling any code like a global search and replace before compiling.

A const on the other hand is actually a variable that is stored in memory somewhere but the differnence between const int step = 12; and int step2 = 13;
is that the const directive tells the compiler that this value will never change so the compiler is free to optimise generated code, possibly overlaying the variable on top of another const with the same value or leaving out some other variable management code.

The other one you see in your code is a volatile variable. This tells the compiler that this variable can be changed by another piece of code without notice so make no optimising assumptions about its value. Typically a volatile variable is used for interprocess communications. eg between an interrupt routine and the main loop.

Anyway, back to your problem. Having the stepper locked up is not a bad thing. It says the drive is powered up so it just needs a step and direction signal to move. Do me one favour, and it may not do anything if the stepper is holding firm. Just unplug the enable connector from the DM542 and see if that changes anything. I don't think it will if you have holding torque.

I suspect the problem is that the stepdelay is too short. You have set it to 1 so that means the pulses are only 1 millisecond long if you look in the rotation() procedure. If you look in your stepper driver manual you will see some minimum step pulse times (probably in microseconds). So the LinuxCNC guys say not to go under 3500 microseconds and you are running at 1000 microseconds. I can run the DM542 at 1500 microseconds with dedicated step generation hardware. I don't think you would want to go under 10 but I would try changing the step delay to say 100 or higher before reducing it by trial and error until it stops moving and then move back to a safe value. Make sure you watch it closely, I was disheartened when after months of work , I thought nothing was moving until I saw the faintest of movement due to a miscalibrated axis.
 
Just to clarify, delay(x) stops for x milliseconds. There are 1000 milliseconds in a second but there are 1000000 microseconds in a second. So 1 millisecond = 1000 microseconds. You will sometimes see people using usec for microseconds.
 
Hi Rod,
Unpluged the enable connector....still has strong cogging.
Increased delay to 150...no movement at all.
Must be getting close to this running.....i put a DMM on the pins and there is no voltage showing on the meter...on Pul+, Dir+, and EN+...would have thought something would have shown...in the manual it shows VCC on PUL+, DIR+, EN+.....and controller wired to PUL-,DIR-,EN-....this is the firast time I have seen a circuit Diagram like this...all the other diagrams Ive seen are the way I have it now


Cheers
 
Hi Rod,
Unpluged the enable connector....still has strong cogging.
Increased delay to 150...no movement at all.
Must be getting close to this running.....i put a DMM on the pins and there is no voltage showing on the meter...on Pul+, Dir+, and EN+...would have thought something would have shown...in the manual it shows VCC on PUL+, DIR+, EN+.....and controller wired to PUL-,DIR-,EN-....this is the firast time I have seen a circuit Diagram like this...all the other diagrams Ive seen are the way I have it now


Cheers

A parallel port breakout board is active low so it is wired that way. Maybe try it that way but I never had to do that with an Arduino and I am not doing it that way with my Mesa 7i76e ethernet controller with LinuxCNC.
 
Swapped connections around....no cogging now....definate motor clicking sound when Mega reset is pressed.

not sure where I go from here.


Cheers

Screenshot at 2017-03-08 22-12-01.png
 
Swapped connections around....no cogging now....definate motor clicking sound when Mega reset is pressed.
Cheers

Good news is you haven't gone insane - YET - -
Questions to myself -
Pin 13 IIRC that pin runs the on-board LED ? Member reading something, somewhere, sometime ago about using that pin for other than the built in LED could be iffy - - So on that side I only consider pins 2-12 as generally usable.
[0,1 are interrupts] that's Rods realm . .
Wired as common anode [+] ? Like to keep a common GND between components so use common cathode [-]

Stepping? Begin with setting the current switch to whatever the stepper calls for 3.5, 4 amp, whatever the data sheet says. Set the steps to FULL for now.

Does the motor run? What the minimum code required to get it to turn?
// using my little cigar box test platform - Pin numbers will vary dependant upon hardware used
void setup()
{
// put your setup code here, to run once:
pinMode(A2,OUTPUT); // set pins to Outputs - change pin numbers to suit hardware
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
digitalWrite(A2,LOW); // enable stepper
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(3,LOW); // Direction, Set to HIGH for opposite direction
digitalWrite(2,LOW);
delayMicroseconds(2000); // slow, change number up-down to adj speed
digitalWrite(2,HIGH);
delayMicroseconds(2000);
}

Is enable pin set as an OUTPUT?
lcd.begin(20,4); // initialize the lcd
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);

Did I forget to mention that, to add
pinMode(enable, OUTPUT);
 

Latest posts

Back
Top