Ви не увійшли.
Сторінки 1



Помогите сделать управление шаговым двигателем с помощью энкодера. Поворот энкодера вправо на один шаг - поворот двигателя вправо на один шаг, поворот энкодера влево на один шаг - двигатель влево на один шаг. есть энкодер, шаговый двигатель 23HS8430 3a, драйвер TB6600, ардуино леонардо. я в этом новичок.
Неактивний
Как новичку советую, если задача затруднительна - раздроби её на меньшие и простые, но решаемые. Т.е. поморгай светиком от энкодера ( смотри и разбирай пример ), а затем шаговик таким же макаром. Получится - я знаю!!! Сам сколько раз спотыкался  
 .
Потом смотри примеры выполнения по условию. У тебя железо, результат будет виден сразу.
Неактивний
есть несколько путей.
1. читаем книжки, лазим по форумам, учимся программировать.
   пробуем писать программу.
   если что то не получается - показываем код и задаём вопросы, может быть кто то подскажет)))
   это если интересно и хочется в этом направлении развиваться...
2. формулируем задачу, озвучиваем бюджет и заказываем за денежку.
   а это если не хочется возиться)))
p.s. ждать что кто то просто так будет тратить своё время не стоит...
Остання редакція vvr (2017-02-16 08:47:49)
Неактивний
Есть такой код. не могу залить его в ардуино леонардо. пишет exit status 1
Ошибка компиляции для платы Arduino Leonardo.
/* Include the library */
#include "HCMotor.h"
/* Pins used to drive the motors */
#define DIR_PIN 8 //Connect to drive modules 'direction' input.
#define CLK_PIN 9 //Connect to drive modules 'step' or 'CLK' input.
/* Set the analogue pin the potentiometer will be connected to. */
#define POT_PIN A0
/* Set a dead area at the centre of the pot where it crosses from forward to reverse */
#define DEADZONE 20 
/* The analogue pin will return values between 0 and 1024 so divide this up between 
   forward and reverse */
#define POT_REV_MIN 0
#define POT_REV_MAX (512 - DEADZONE)
#define POT_FWD_MIN (512 + DEADZONE)
#define POT_FWD_MAX 1024
 
/* Create an instance of the library */
HCMotor HCMotor;
void setup() 
{
  //Serial.begin(9600);
  /* Initialise the library */
  HCMotor.Init();
  /* Attach motor 0 to digital pins 8 & 9. The first parameter specifies the 
     motor number, the second is the motor type, and the third and forth are the 
     digital pins that will control the motor */
  HCMotor.attach(0, STEPPER, CLK_PIN, DIR_PIN);
  /* Set the number of steps to continuous so the the motor is always turning whilst 
     not int he dead zone*/
  HCMotor.Steps(0,CONTINUOUS);
}
 
void loop() 
{
  int Speed, Pot;
  /* Read the analogue pin to determine the position of the pot. */
  Pot = analogRead(POT_PIN);
  /* Is the pot in the reverse position ? */
  if (Pot >= POT_REV_MIN && Pot <= POT_REV_MAX)
  {
    HCMotor.Direction(0, REVERSE);
    Speed = map(Pot, POT_REV_MIN, POT_REV_MAX, 10, 1024);
  /* Is the pot in the forward position ? */
  }else if (Pot >= POT_FWD_MIN && Pot <= POT_FWD_MAX)
  {
    HCMotor.Direction(0, FORWARD);
    Speed = map(Pot, POT_FWD_MIN, POT_FWD_MAX, 1024, 10);
  /* Is the pot in the dead zone ? */
  }else
  {
    Speed = 0;
  }
  /* Set the duty cycle of the clock signal in 100uS increments */
  HCMotor.DutyCycle(0, Speed);
}
Неактивний
я не знаю как будет работать с 1.8.1 - у меня она не установлена
чтобы работало с леонардо нужно шаманить библиотеку - для этого нужно серьёзно в программировании разбираться)))
проще купить нано или уну с нужным камнем
Неактивний
есть несколько путей.
1. читаем книжки, лазим по форумам, учимся программировать.
пробуем писать программу.
если что то не получается - показываем код и задаём вопросы, может быть кто то подскажет)))
это если интересно и хочется в этом направлении развиваться...
2. формулируем задачу, озвучиваем бюджет и заказываем за денежку.
а это если не хочется возиться)))p.s. ждать что кто то просто так будет тратить своё время не стоит...
на первый вариант у меня не так уж и много времени для создания этого проекта.
второй вариант интересно цена помощи.
Неактивний
Тёзка. ты не прав!!!! ".....ИЛИ ВАС И....." знания этого языка тебе не помогут. А вот читать и вникать в прочитанное пора бы научиться. Для того чтоб тебе помогли практически нужно чтоб у кого то был в руках твой Леон. И к стати установки у тебя правильно указаны? "Инструменты - Плата- "
 P.S. Пробуй другие версии IDE. У меня их несколько, каждая ведёт себя по своему .
Остання редакція IgorT12 (2017-02-22 08:20:14)
Неактивний
// EasyDriver connections
#define step_pin 9  // Pin 9 connected to Steps pin on EasyDriver
#define dir_pin 8   // Pin 8 connected to Direction pin
#define SLEEP 12     // Pin 12 connected to SLEEP pin
                    
volatile boolean TurnDetected;  // need volatile for Interrupts
volatile boolean rotationdirection;  // CW or CCW rotation
// Rotary Encoder Module connections
const int PinCLK=2;   // Generating interrupts using CLK signal
const int PinDT=3;    // Reading DT signal
const int PinSW=4;    // Reading Push Button switch
int StepperPosition=0;    // To store Stepper Motor Position
int StepsToTake=4;      // Controls the speed of the Stepper per Rotary click
int direction; // Variable to set Rotation (CW-CCW) of stepper
// Interrupt routine runs if CLK goes from HIGH to LOW
void rotarydetect ()  {
delay(4);  // delay for Debouncing
if (digitalRead(PinCLK))
rotationdirection= digitalRead(PinDT);
else
rotationdirection= !digitalRead(PinDT);
TurnDetected = true;
}
void setup () {
    pinMode(dir_pin, OUTPUT);
   pinMode(step_pin, OUTPUT);
   pinMode(SLEEP, OUTPUT);   
   digitalWrite(SLEEP, HIGH);  // Wake up EasyDriver
   delay(5);  // Wait for EasyDriver wake up
   
 /* Configure type of Steps on EasyDriver:
  //
 // LOW LOW = Full Step //
 // HIGH LOW = Half Step //
 // LOW HIGH = A quarter of Step //
 // HIGH HIGH = An eighth of Step //
 */ 
    
  pinMode(PinCLK,INPUT);  // Set Pin to Input
  pinMode(PinDT,INPUT);  
  pinMode(PinSW,INPUT);
  digitalWrite(PinSW, HIGH); // Pull-Up resistor for switch
  attachInterrupt (0,rotarydetect,FALLING); // interrupt 0 always connected to pin 2 on Arduino UNO
}
void loop () {
  if (!(digitalRead(PinSW))) {   // check if button is pressed
  if (StepperPosition == 0) {  // check if button was already pressed
  } else {
      if (StepperPosition > 0) {  // Stepper was moved CW
        while (StepperPosition != 0){  //  Do until Motor position is back to ZERO
          digitalWrite(dir_pin, HIGH);  // (HIGH = anti-clockwise / LOW = clockwise)
          for (int x = 1; x < StepsToTake; x++) {
              digitalWrite(step_pin, HIGH);
              delay(1);
              digitalWrite(step_pin, LOW);
              delay(1);            
            }
            StepperPosition=StepperPosition-StepsToTake;
        }
      }
      else {
        while (StepperPosition != 0){ 
          digitalWrite(dir_pin, LOW);  // (HIGH = anti-clockwise / LOW = clockwise)
              for (int x = 1; x < StepsToTake; x++) {
              digitalWrite(step_pin, HIGH);
              delay(1);
              digitalWrite(step_pin, LOW);
              delay(1);            
            }
           StepperPosition=StepperPosition+StepsToTake;
        }
      }
      StepperPosition=0; // Reset position to ZERO after moving motor back
    }
  }
// Runs if rotation was detected
  if (TurnDetected)  {
        TurnDetected = false;  // do NOT repeat IF loop until new rotation detected
// Which direction to move Stepper motor
        if (rotationdirection) { // Move motor CCW
            digitalWrite(dir_pin, HIGH);  // (HIGH = anti-clockwise / LOW = clockwise)
            for (int x = 1; x < StepsToTake; x++) {
              digitalWrite(step_pin, HIGH);
              delay(1);
              digitalWrite(step_pin, LOW);
              delay(1);            
            }
            StepperPosition=StepperPosition-StepsToTake;
        }
        if (!rotationdirection) { // Move motor CW
            digitalWrite(dir_pin, LOW);  // (HIGH = anti-clockwise / LOW = clockwise)
            for (int x = 1; x < StepsToTake; x++) {
              digitalWrite(step_pin, HIGH);
              delay(1);
              digitalWrite(step_pin, LOW); 
              delay(1);         
            }
            StepperPosition=StepperPosition+StepsToTake;
        }
  }
}
Неактивний
Сторінки 1