Answer the question
In order to leave comments, you need to log in
How to fix stepper motor problems?
CNC on Arduino. The joystick selects the movement along the X, Y axis with simultaneous output to the VGA screen. The operator presses the joystick and the stepper motors move. It is not possible to bring the work of steppers and vga.
I am using a library to display an image on the screen. I wrapped it all in the output() function;
void output() {
VGAX vga;
Serial.println("Start");
boolean button = false;
boolean output = true;
vga.begin();
while (output) {
char stri[10];
static const char str[] PROGMEM = "Move on";
static const char str0[] PROGMEM = "X = ";
static const char str1[] PROGMEM = "Y = ";
static const char str2[] PROGMEM = "Tact = ";
static const char str3[] PROGMEM = "Yoke = ";
double a1 = (analogRead (A1) / 10) - 51;
double a2 = (analogRead (A2) / 10) - 51;
int a3 = analogRead (A5) / 10;
xVa += map(a1, -51, 51, -a3, a3) / 100.0;
yVa += map(a2, -51, 51, -a3, a3) / 100.0;
if ((a1 != 0) || (a2 != 0) || (a3_copi != a3)) {
a3_copi = a3;
vga.clear(BLACK);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str, 10, 0, RED);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str0, 10, 10, RED);
dtostrf(xVa, 3, 2, stri);
vgaPrint(stri, 30, 10, RED, vga);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str1, 10, 20, RED);
dtostrf(yVa, 3, 2, stri);
vgaPrint(stri, 30, 20, RED, vga);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str2, 60, 0, GREEN);
dtostrf(a3, 3, 2, stri);
vgaPrint(stri, 90, 0, GREEN, vga);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str3, 60, 10, GREEN);
dtostrf(a1, 3, 2, stri);
vgaPrint(stri, 90, 10, GREEN, vga);
dtostrf(a2, 3, 2, stri);
vgaPrint(stri, 90, 20, GREEN, vga);
button = true;
} else {
if (button) {
vga.clear(BLACK);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str, 10, 0, RED);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str0, 10, 10, RED);
dtostrf(xVa, 3, 2, stri);
vgaPrint(stri, 30, 10, RED, vga);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str1, 10, 20, RED);
dtostrf(yVa, 3, 2, stri);
vgaPrint(stri, 30, 20, RED, vga);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str2, 60, 0, GREEN);
dtostrf(a3, 3, 2, stri);
vgaPrint(stri, 90, 0, GREEN, vga);
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str3, 60, 10, GREEN);
dtostrf(a1, 3, 2, stri);
vgaPrint(stri, 90, 10, GREEN, vga);
dtostrf(a2, 3, 2, stri);
vgaPrint(stri, 90, 20, GREEN, vga);
vga.delay(100);
dtostrf(0, 3, 2, stri);
vgaPrint(stri, 90, 10, GREEN, vga);
dtostrf(0, 3, 2, stri);
vgaPrint(stri, 90, 20, GREEN, vga);
button = false;
}
}
if (digitalRead(0) == LOW) {
static const char str0[] PROGMEM = "start";
vga.printPROGMEM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str0, 0, 0, GREEN);
delay(5000);
vga.end();
output = false;
}
vga.delay(100);
}
}
void vgaPrint(char * str, byte x, byte y, byte color, VGAX vga) {
vga.printSRAM((byte*)fnt_nanofont_data, FNT_NANOFONT_SYMBOLS_COUNT, FNT_NANOFONT_HEIGHT, 3, 1, str, x, y, color);
}
#include <VGAX.h>
#include "glyph.h"
#define BLACK 0
#define RED 1
#define GREEN 2
#define YELLOW 3
//font generated from BITFONZI - by Sandro Maffiodo
#define FNT_NANOFONT_HEIGHT 6
#define FNT_NANOFONT_SYMBOLS_COUNT 95
//data size=570 bytes
const unsigned char fnt_nanofont_data[FNT_NANOFONT_SYMBOLS_COUNT][1+FNT_NANOFONT_HEIGHT] PROGMEM={
{ 1, 128, 128, 128, 0, 128, 0, }, //glyph '!' code=0
{ 3, 160, 160, 0, 0, 0, 0, }, //glyph '"' code=1
...
{ 3, 96, 192, 0, 0, 0, 0, }, //glyph '~' code=93
{ 4, 48, 64, 224, 64, 240, 0, }, //glyph '£' code=94
};
void servo() {
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
int dl = 5;
for (int i = 0; i < 200; i++) {
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay(dl);
digitalWrite(in1, HIGH);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
delay(dl);
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
delay(dl);
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, HIGH);
delay(dl);
}
}
Answer the question
In order to leave comments, you need to log in
Here you can’t figure it out without a bottle (a good one, such a bottle).
But in general, why is your setup () empty? At a minimum, there should be an initialization of Serial. You also need to transfer the initialization of everything that you have there.
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
VGAX vga;
vga.begin();
perhaps something else missed
ZY As for me, using unipolars is a bad idea. Bipolar people can pick up a bag with any old equipment, drivers cost a penny, and the possibilities and quality of work are much better. You can stir up a really working useful device
Most likely, all controller resources are spent on generating a VGA signal. Therefore, there are no longer enough resources to generate phases for a stepper.
The solution is to use two controllers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question