BASIC4MCU | 질문게시판 | 스텝모터 힘이 너무 딸립니다.
페이지 정보
작성자 지따따 작성일2019-05-22 16:04 조회4,648회 댓글1건본문
마스터님 답변해주신대로 모터 회전수를 바꿀수 있었습니다.
저희가 제작하려는 의도는 가스를 감지하여 창문을 여닫는 모터이지만
지금 돌아가는 모터로는 창문을 움직이는데 힘이 많이 부족한것같습니다.
코딩 이상때문일까요??
아니면 아두이노 결선 문제일까요?
#include <Stepper.h>
const int TMP36_pin = A1; //온도
const int stepsPerRevolution = 200; //회전수 200/한바퀴
Stepper myStepper(stepsPerRevolution,3,4,6,7);
int ENA=8;
int ENB=5;
int enablePin = 11;
int in1Pin = 10;
int in2Pin = 9;
int ondo1 = 32;
int ondo2 = 30;
int gas1 = 65;
int gas2 = 50;
boolean window = false; //false -> 닫혀있는상태
//true -> 열려있는상태
const int gasPin = A0; // 가스
void setup()
{
myStepper.setSpeed(60);
Serial.begin(9600);
pinMode(enablePin, OUTPUT);
pinMode(in1Pin, OUTPUT);
pinMode(in2Pin, OUTPUT);
pinMode(ENA,OUTPUT); //
pinMode(ENB,OUTPUT);//
pinMode(2, INPUT);
digitalWrite(ENA,HIGH);//
digitalWrite(ENB,HIGH);//
}
void loop()
{
int sensorValue = analogRead(TMP36_pin);
float mVoltage = sensorValue * 5000.0/1024.0;
float temperatureC = (mVoltage - 500) / 10.0;
int value = digitalRead(2);
Serial.print("Now : ");
Serial.print(temperatureC);
Serial.println(" C");
Serial.println();
Serial.print("current gas : ");
Serial.println(analogRead(gasPin));
Serial.println();
Serial.print("Rain : ");
Serial.println(value);
Serial.print("Window : ");
if(window==false) Serial.println("Close");
else if(window==true) Serial.println("Open");
Serial.println("=============================================== ");
Serial.println();
if(window == false && value==1) //창문이 닫혀있고 비가 안오는 상태
{
if(temperatureC<=ondo2 && analogRead(gasPin)>=gas1)
{
sensor_open();
}
else if(temperatureC>=ondo1 && analogRead(gasPin)>=gas1)
{
sensor_open();
}
else if(temperatureC<=ondo2 && analogRead(gasPin)<=gas2)
{
// 동작안함
}
else if(temperatureC>=ondo1 && analogRead(gasPin)<=gas2)
{
sensor_open();
}
}
else if(window == false && value==0) //창문이 닫혀있고 비가 오는 상태
{
if(temperatureC<=ondo2 && analogRead(gasPin)>=gas1)
{
sensor_open();
}
else if(temperatureC>=ondo1 && analogRead(gasPin)>=gas1)
{
sensor_open();
}
else if(temperatureC<=ondo2 && analogRead(gasPin)<=gas2)
{
// 동작안함
}
else if(temperatureC>=ondo1 && analogRead(gasPin)<=gas2)
{
//동작안함
}
else
{
//동작안함
}
}
else if(window == true && value==1) //창문이열려있고 비가 안오는 상태
{
if(temperatureC<=ondo2 && analogRead(gasPin)>=gas1)
{
//동작안함
}
else if(temperatureC>=ondo1 && analogRead(gasPin)>=gas1)
{
//동작안함
}
else if(temperatureC<=ondo2 && analogRead(gasPin)<=gas2)
{
sensor_close();
}
else if(temperatureC>=ondo1 && analogRead(gasPin)<=gas2)
{
//동작안함
}
}
else if(window == true && value==0) //창문이열려있고 비가 오는 상태
{
if(temperatureC<=ondo2 && analogRead(gasPin)>=gas1)
{
//동작안함
}
else if(temperatureC>=ondo1 && analogRead(gasPin)>=gas1)
{
//동작안함
}
else if(temperatureC<=ondo2 && analogRead(gasPin)<=gas2)
{
sensor_close();
}
else if(temperatureC>=ondo1 && analogRead(gasPin)<=gas2)
{
sensor_close();
}
else
{
sensor_close();
}
}
delay(5000);
}
void sensor_open(){
Serial.println("open");
myStepper.step(10*stepsPerRevolution);
Serial.println("stop");
window = true;
Serial.print("Window Status : ");
Serial.println(window);
Serial.println();
}
void sensor_close()
{
Serial.println("Close");
myStepper.step(-10*stepsPerRevolution);
window = false;
Serial.print("Window Status : ");
Serial.println(window);
Serial.println();
}
댓글 1
조회수 4,648master님의 댓글
master 작성일
속도를 조금 느리게 하면 토크가 약간 증가합니다.
모터 전압이 높아야합니다. (모터 정격전압 보다 너무 높으면 과전류 위험이 있기도 하고, 모터와 드라이버에서 심한 발열이 생길 수도 있으며, 고장날 수도 있습니다.)
드라이버 모듈의 전류 능력이 (모터 전류에 비해서) 충분히 커야합니다.
창문의 마찰력이 줄어들 수 있도록 베어링을 사용하는 등의 구조 개선이 가능한지 체크해보시고
근본적으로 부하(창문)를 구동하기에 토크가 부족한 모터라면 모터를 변경하세요