3D scanner (4) - Carcasă controller

Descriere proiect:
În acest pas al proiectului am creat o carcasă pentru controller, motor și bluetooth. Se văd în imaginile de mai jos cam cum a ieșit, dar părerea mea este că această carcasă este suficient de compactă pentru a o folosi în continuare.
Documentatie proiect:
- Am învățat câteva tehnici de proiectare de pe site-ul tinkercad.com, site de proiectare pentru începători.
Componente:
- Plastic PLA incolor
- Imprimanta 3D
- Smartphone cu bluetooth
- Applicatie Android - Arduino Bluetooth controller v1.3

Schema electronică/sistem:

Cod de test:

#include "SoftwareSerial.h"
#include "BasicStepperDriver.h"
#include "StepperDriver.h" 
#include "AccelStepper.h"
#include "A4988.h"
#define MS1 6
#define MS2 7
#define MS3 8
#define ENABLE 5
// Motor steps per revolution. Most steppers are 200 steps or 1.8 degrees/step
#define MOTOR_STEPS 200
#define RPM 360
// Acceleration and deceleration values are always in FULL steps / s^2
#define MOTOR_ACCEL 2000
#define MOTOR_DECEL 1000
// Since microstepping is set externally, make sure this matches the selected mode
// If it doesn't, the motor will move at a different RPM than chosen
// 1=full step, 2=half step etc.
#define MICROSTEPS 8

// All the wires needed for full functionality
#define DIR 3
#define STEP 4

//Global Variables
String command = ""; // Stores response of the HC-06 Bluetooth device
// defines pins numbers
const int stepPin = STEP; 
const int dirPin = DIR; 
char _btRxData; //Most recent received byte from BT Shield
String _btRxBuff=""; //Local buffer for received data
int speedmot=RPM;
short microsteps=1;
// 2-wire basic config, microstepping is hardwired on the driver
A4988 stepper(MOTOR_STEPS, DIR, STEP, ENABLE, MS1, MS2, MS3);

void setup() {
  Serial.begin(57600);
  BluetoothInit();
  stepper.begin(RPM, MICROSTEPS);
  stepper.enable();
   /*
     * Set LINEAR_SPEED (accelerated) profile.
     */
    stepper.setSpeedProfile(stepper.LINEAR_SPEED, MOTOR_ACCEL, MOTOR_DECEL);
        Serial.println("START");
    /*
     * Using non-blocking mode to print out the step intervals.
     * We could have just as easily replace everything below this line with 
     * stepper.rotate(360);
     */
     stepper.startRotate(360);
}

void loop() {
        static int step = 0;
    unsigned wait_time = stepper.nextAction();
  //If new byte of data to receive from BT Shield
  if(Serial1.available())
  {
     _btRxData = Serial1.read(); //Read it
     _btRxBuff += _btRxData;   //Add it to buffer
     Serial.print(_btRxData);  //Debug: Send to PC Console 

      if(_btRxData == '1')              // Checks whether value of data is equal to 1
         digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
      else if(_btRxData == '0')         //  Checks whether value of data is equal to 0
         digitalWrite(dirPin, LOW);    //If value is 0 then LED turns OFF
      
      if(_btRxData == '2')              // Checks whether value of data is equal to 1
      {
        speedmot +=1; // Enables the motor to move in a particular direction
        Serial.println(speedmot);  //Debug: Send to PC Console
         stepper.enable(); 
      }
      else if(_btRxData == '3')         //  Checks whether value of data is equal to 0
      {
         speedmot -=1;   //If value is 0 then LED turns OFF
          Serial.println(speedmot);  //Debug: Send to PC Console 
           stepper.enable();
      }
      if(_btRxData == 'x')              // Checks whether value of data is equal to 1
      {
         speedmot = 0; // Enables the motor to move in a particular direction
         microsteps=1;
          Serial.println(speedmot);  //Debug: Send to PC Console 
            stepper.disable();
        Serial.println("END");
      }
      if(_btRxData == 'b')              // Checks whether value of data is equal to 1
      {
         speedmot = 1; // Enables the motor to move in a particular direction
          Serial.println(speedmot);  //Debug: Send to PC Console 
           stepper.enable();
      }
      if(_btRxData == 'c')              // Checks whether value of data is equal to 1
      {
         speedmot = 90; // Enables the motor to move in a particular direction
          Serial.println(speedmot);  //Debug: Send to PC Console 
           stepper.enable();
      }
      if(_btRxData == 'p')              // Checks whether value of data is equal to 1
      {
         speedmot = 180; // Enables the motor to move in a particular direction
          Serial.println(speedmot);  //Debug: Send to PC Console 
           stepper.enable();
      }
      if(_btRxData == 't')              // Checks whether value of data is equal to 1
      {
         speedmot = 360; // Enables the motor to move in a particular direction
          Serial.println(speedmot);  //Debug: Send to PC Console 
           stepper.enable();
      }
     if(_btRxData == 's')  
     {
      microsteps++;
      stepper.setMicrostep(microsteps);
      Serial.println(microsteps);  //Debug: Send to PC Console 
     }
  }

    /*
     * Moving motor one full revolution using the degree notation
     */
stepper.rotate(speedmot);

}

void BluetoothInit()
{  
  Serial1.begin(57900);
  Serial1.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
  Serial1.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave"
  Serial1.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
  Serial1.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
  delay(2000); // This delay is required.
  Serial1.print("\r\n+LOSSRECONN=0\r\n");
  delay(2000);
  Serial1.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable 
  delay(2000); // This delay is required.
  Serial1.flush();
}
Urmează pasul următor, care cuprinde tijele pentru conectarea mecanică cu senzorul și un panou alb în spatele obiectului.
Weekend plăcut tuturor!

Etichete

Afișați mai multe

Arhiva

Afișați mai multe