Step motora her saniye için belirli adım attırmak.

Katılım
2 Ocak 2019
Mesajlar
13
Puanları
1
Yaş
39
Bir saat için kullanacağım bir kod var elimde.Fakat minimum 2 saniyede bir adım atabiliyor.2 saniyede 200 ve üzeri adım atabiliyor.Ben 1 saniyede 20 adım atmasını istiyorum.Koda süre olarak 1 yazdığımda motor dönmüyor.Motor :Nema 17 sürücü drv8825 , RTC: ds3231 ,arduino uno.
Yardımcı olabilecek varsa sevinirim.
 
Çok hakim değilim ama, adım ile tur sayısını karıştırmıyorsundur umarım.
Geçen dönem okulda bir proje yapmıştım, 18 derecelik adım sayısına sahip bir step motor kullanmıştım.
1 turu 1 saniyede attığı için de :
#include <Stepper.h> //Step motora ait komutları kullanabilmek için kütüphanesini ekliyoruz.
const int stepsPerRevolution = 20; // demiştim, böylelikle 1 tur için 20 adım atıyordu step motorum(360/18)

Yine iki farklı motor kapısı kullanmıştım ve dönmesi için de bir stepcounter algoritması kurmuştum :

for(int stepperCounter=0; stepperCounter<2; stepperCounter++) //2 times turning.
{
stepperA.step(-stepsPerRevolution); //Section A oppening.
isSectionAOpen = true;
stepperB.step(-stepsPerRevolution); //Section B opening.
isSectionBOpen = true;

// yani, alakalı mı bilmem ama kafanda bir fikir oluşması için paylaşayım dedim.
 
Çok hakim değilim ama, adım ile tur sayısını karıştırmıyorsundur umarım.
Geçen dönem okulda bir proje yapmıştım, 18 derecelik adım sayısına sahip bir step motor kullanmıştım.
1 turu 1 saniyede attığı için de :
#include <Stepper.h> //Step motora ait komutları kullanabilmek için kütüphanesini ekliyoruz.
const int stepsPerRevolution = 20; // demiştim, böylelikle 1 tur için 20 adım atıyordu step motorum(360/18)

Yine iki farklı motor kapısı kullanmıştım ve dönmesi için de bir stepcounter algoritması kurmuştum :

for(int stepperCounter=0; stepperCounter<2; stepperCounter++) //2 times turning.
{
stepperA.step(-stepsPerRevolution); //Section A oppening.
isSectionAOpen = true;
stepperB.step(-stepsPerRevolution); //Section B opening.
isSectionBOpen = true;

// yani, alakalı mı bilmem ama kafanda bir fikir oluşması için paylaşayım dedim.
Teşekkür ederim cevap için. Aslında istediğim motor her saniye içinde 20 adımı atacak.Bir turunu 10 saniyede tamamlayacak.Motor mili dakikada 6 tur yapmış olacak.Elimdeki kod çok hassas bir şekilde çalışıyor fakat minimum 2 saniyelik periyot ayarlayabiliyorum.2 saniyede 40 tur atıyor.

#include <Wire.h>
#include "Sodaq_DS3231.h"

/*
This code keeps time and update the stepper motor STEPS_PER_CYCLE every CYCLE_INTERVAL
*/

// number of steps to advance the stepper motor
const int stepsPerCycle = 40;

// cycle interval in seconds.
const int cycleInterval = 2;

// The number of steps in one full motor rotation
const int stepsInFullRound = 800;

// how fast the stepper motor turns in revolutions per second
const double stepperRevPerSec = 0.1;

const int cycleInterval =1 yapınca motor çalışmıyor.
.....devamını eklemedim.
Kodu kullanacağım saat bu.
 

Ekli dosyalar

  • Screenshot_20200725_201935_com.huawei.himovie.overseas.jpg
    Screenshot_20200725_201935_com.huawei.himovie.overseas.jpg
    222.9 KB · Görüntüleme: 11
Son düzenleme:
Hocam ben de sadece bir ders aldım bu konuda, dediğim gibi hakim değilim ; ama algoritması anlamında çıkardıklarımı söyleyeyim :

Toplam 10 saniyede, 200 adım ve bir tur istiyorsunuz. 200 adım da bir tur demek motorun 1.8 derecelik stepe sahip olması anlamına geliyor. yine delay() metodunu kullandığınızı varsayıyorum.

Step motorun dönmesi için de bir çeşit koşulla boolean mantığı kullanılmalı bence.


Yine internette gördüğüm bir step motor tur ve hız süresi ayarlama algoritma örneğini aşağıya bırakıyorum, dikkat ederseniz burada da delay ve ivme mantığıyla ayarlıyor step motor dönüşünü.

#include <AccelStepper.h>
// Define a stepper and the pins it will use
AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
void setup()
{
stepper.setMaxSpeed(200.0);
stepper.setAcceleration(100.0);
}
void loop()
{
stepper.runToNewPosition(0);
delay(1000);
stepper.runToNewPosition(200);
delay(1000);
stepper.runToNewPosition(200);
delay(1000);
stepper.runToNewPosition(200);
}
 

Forum istatistikleri

Konular
128,123
Mesajlar
915,188
Kullanıcılar
449,829
Son üye
mehmetoner

Yeni konular

Geri
Üst