Hi,
I have NEMA Hybrid Stepper motor, I am using a M542T driver to drive the stepper motor with Arduino Uno. I have LCD displaying the count of the rotation. I programmed the to achieve 1600 steps delivering 100 RPM. So for every 1600 step it will count and display the count on a LCD. The PWM on off time i calculated as 365 micro second for the stepper. The code execution time for LCD is 24 milli seconds. So after every 1600 steps the motor stops for a few millisecond and the starts. So the rotation is not smooth at all.
If there is a way for me to overcome the problem please help me.
Thanks in advance.
My Sketch:
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
// Assign human-readable names to some common 16-bit color values:
#define  BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF
#define BLUE 0x3498DB
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
//Variable Initialization
int i = 0;
int a = 0;
int b=0;
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Serial.println(F("TFT LCD test"));
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  pinMode(10, OUTPUT); // Step Pin
  pinMode(11, OUTPUT) ; // Dir Pin
  digitalWrite(10, LOW);
  digitalWrite(11, LOW);
  tft.setRotation(1);
  tft.fillScreen(BLACK);
  unsigned long start = micros();
  tft.setCursor(90, 0);
  tft.setTextColor(BLUE);
  tft.setTextSize(4);
  tft.println("SENTIAL");
  tft.println();
  tft.setTextColor(GREEN);
  tft.setTextSize(3);
  tft.println("Operation Mode: 3");
  tft.println();
  tft.println();
  tft.setTextColor(RED);
  tft.setTextSize(3);
  tft.print("Rate:");
}
void loop() {
  // put your main code here, to run repeatedly:
  
  i = i + 1;
  digitalWrite(10, HIGH);
  delayMicroseconds(375);  
  digitalWrite(10, LOW);
if(i<1600)
{
  delayMicroseconds(375);
}
  if (i == 1600)
  {
    b=displayRate(b);
  }
}
int displayRate(int a)
{
  a = a + 1;
  tft.fillCircle(126, 136, 40, BLACK);
  tft.setCursor(96, 134);
  tft.print(a);
  i = 0;
  return a;
}
			
			
									
						
										
						