BÁC nào có file config cái board này dành cho mach3 cho e xin với, vitme e X bước 10, Y bước 10, Z bước 5. Chân thành cảm ơn
trên connection P1 bác dùng 3 chân:
chân số 2 bác cấp xung cho motor quay
chân số 3 bác cấp tín hiệu 1 hoặc 0 cho motor đảo chiều.
chân số 4 bác cấp 5V từ Arduino.
Bác có thể dùng thử code blink led để test motor quay cũng được ạ. Đối với code Blink led thì bác cắm chân số 2 vào chân số 13 của arduino và chân số 4 vào 5V của arduino nha bác.:-)
Minh Sì Gòn: 034.424.6304.
Web: shoplinhkiencnc.com
Mình test chạy rồi, code của anh Tây nhưng chỉ nhanh lắm thì được 1 step/1milisecond => 1 giây được có 1000 steps (2.5 vòng/s) chậm thế, sét xuống dưới 1milisecond thì đơ.
Nguồn 24v-20A mua của tiệm bảng hiệu LED.
Code ông Tây như này: (25miliseconds/step)
Mã:// testing a stepper motor with a Pololu A4988 driver board or equivalent // on an Uno the onboard led will flash with each step // this version uses delay() to manage timing byte directionPin = 9; byte stepPin = 8; int numberOfSteps = 100; byte ledPin = 13; int pulseWidthMicros = 20; // microseconds int millisbetweenSteps = 25; // milliseconds void setup() { Serial.begin(9600); Serial.println("Starting StepperTest"); digitalWrite(ledPin, LOW); delay(2000); pinMode(directionPin, OUTPUT); pinMode(stepPin, OUTPUT); pinMode(ledPin, OUTPUT); digitalWrite(directionPin, HIGH); for(int n = 0; n < numberOfSteps; n++) { digitalWrite(stepPin, HIGH); delayMicroseconds(pulseWidthMicros); // this line is probably unnecessary digitalWrite(stepPin, LOW); delay(millisbetweenSteps); digitalWrite(ledPin, !digitalRead(ledPin)); } delay(3000); digitalWrite(directionPin, LOW); for(int n = 0; n < numberOfSteps; n++) { digitalWrite(stepPin, HIGH); // delayMicroseconds(pulseWidthMicros); // probably not needed digitalWrite(stepPin, LOW); delay(millisbetweenSteps); digitalWrite(ledPin, !digitalRead(ledPin)); } } void loop() { }
Code này chứ nhầm:
Mã:// testing a stepper motor with a Pololu A4988 driver board or equivalent // this version uses millis() to manage timing rather than delay() // and the movement is determined by a pair of momentary push switches // press one and it turns CW, press the other and it turns CCW byte directionPin = 9; byte stepPin = 8; byte buttonCWpin = 10; byte buttonCCWpin = 11; boolean buttonCWpressed = false; boolean buttonCCWpressed = false; byte ledPin = 13; unsigned long curMillis; unsigned long prevStepMillis = 0; unsigned long millisBetweenSteps = 25; // milliseconds void setup() { Serial.begin(9600); Serial.println("Starting Stepper Demo with millis()"); pinMode(directionPin, OUTPUT); pinMode(stepPin, OUTPUT); pinMode(ledPin, OUTPUT); pinMode(buttonCWpin, INPUT_PULLUP); pinMode(buttonCCWpin, INPUT_PULLUP); } void loop() { curMillis = millis(); readButtons(); actOnButtons(); } void readButtons() { buttonCCWpressed = false; buttonCWpressed = false; if (digitalRead(buttonCWpin) == LOW) { buttonCWpressed = true; } if (digitalRead(buttonCCWpin) == LOW) { buttonCCWpressed = true; } } void actOnButtons() { if (buttonCWpressed == true) { digitalWrite(directionPin, LOW); singleStep(); } if (buttonCCWpressed == true) { digitalWrite(directionPin, HIGH); singleStep(); } } void singleStep() { if (curMillis - prevStepMillis >= millisBetweenSteps) { prevStepMillis += millisBetweenSteps; digitalWrite(stepPin, HIGH); digitalWrite(stepPin, LOW); } }