Замена серво двигателя на эл. магнит

artclonic
Offline
Зарегистрирован: 13.01.2015
ifndef CONFIGURE_H
#define CONFIGURE_H
//------------------------------------------------------------------------------
// Makelangelo - supports raprapdiscount RUMBA controller
// dan@marginallycelver.com 2013-12-26
// RUMBA should be treated like a MEGA 2560 Arduino.
//------------------------------------------------------------------------------
// Copyright at end of file.  Please see
// http://www.github.com/MarginallyClever/Makelangelo for more information.

//------------------------------------------------------------------------------
// CONSTANTS
//------------------------------------------------------------------------------
//#define VERBOSE           (1)  // add to get a lot more serial output.
#define HAS_SD  // comment this out if there is no SD card
#define HAS_LCD  // comment this out if there is no SMART LCD controller
//#define USE_LIMIT_SWITCH  (1)  // Comment out this line to disable findHome and limit switches



// servo angles for pen control
#define PEN_UP_ANGLE         (80)
#define PEN_DOWN_ANGLE       (10)  // Some steppers don't like 0 degrees
#define PEN_DELAY            (250)  // in ms

// for serial comms
#define BAUD                 (57600)  // How fast is the Arduino talking?
#define MAX_BUF              (64)  // What is the longest message Arduino can store?


#define MICROSTEPS           (16.0)  // microstepping on this microcontroller
#define STEPS_PER_TURN       (200 * MICROSTEPS)  // default number of steps per turn * microsteps
#define MAX_FEEDRATE         (40000.0)  // depends on timer interrupt & hardware
#define MIN_FEEDRATE         (1500)
#define DEFAULT_FEEDRATE     (7000.0)
#define DEFAULT_ACCELERATION (8)

#define STEP_DELAY           (150)  // delay between steps, in microseconds, when doing fixed tasks like homing

#define NUM_AXIES            (6)  // x,y,z
#define NUM_TOOLS            (6)
#define MAX_SEGMENTS         (32)  // number of line segments to buffer ahead

// for arc directions
#define ARC_CW               (1)
#define ARC_CCW              (-1)
#define MM_PER_SEGMENT       (10)  // Arcs are split into many line segments.  How long are the segments?


#ifdef HAS_LCD
#define HAS_SD
#endif

// SD card settings
#define SDPOWER            -1
#define SDSS               53
#define SDCARDDETECT       49
// Smart controller settings
#define BEEPER             44
#define LCD_PINS_RS        19 
#define LCD_PINS_ENABLE    42
#define LCD_PINS_D4        18
#define LCD_PINS_D5        38 
#define LCD_PINS_D6        41
#define LCD_PINS_D7        40
#define LCD_HEIGHT         4
#define LCD_WIDTH          20
// Encoder rotation values
#define BTN_EN1            13
#define BTN_EN2            12
#define BTN_ENC            43
#define BLEN_C             2
#define BLEN_B             1
#define BLEN_A             0
#define encrot0            0
#define encrot1            2
#define encrot2            3
#define encrot3            1

#define NUM_SERVOS         (1)
#define SERVO0_PIN         (11)
#define SERVO1_PIN         (4)


//#define MOTHERBOARD 1 // RUMBA
#define MOTHERBOARD 2 // RAMPS

#if MOTHERBOARD == 1
#define MOTOR_0_DIR_PIN    (16)
#define MOTOR_0_STEP_PIN   (17)
#define MOTOR_0_ENABLE_PIN (48)

#define MOTOR_1_DIR_PIN    (46)
#define MOTOR_1_STEP_PIN   (48)
#define MOTOR_1_ENABLE_PIN (62)
#endif

#if MOTHERBOARD == 2
#define MOTOR_0_DIR_PIN    (60)
#define MOTOR_0_STEP_PIN   (61)
#define MOTOR_0_ENABLE_PIN (56)

#define MOTOR_1_DIR_PIN    (46)
#define MOTOR_1_STEP_PIN   (48)
#define MOTOR_1_ENABLE_PIN (62)
#endif


//------------------------------------------------------------------------------
// EEPROM MEMORY MAP
//------------------------------------------------------------------------------
#define EEPROM_VERSION   4                         // Increment EEPROM_VERSION when adding new variables
#define ADDR_VERSION     0                         // address of the version number (one byte)
#define ADDR_UUID        (ADDR_VERSION+1)          // address of the UUID (long - 4 bytes)
#define ADDR_SPOOL_DIA1  (ADDR_UUID+4)             // address of the spool diameter (float - 4 bytes)
#define ADDR_SPOOL_DIA2  (ADDR_SPOOL_DIA1+4)       // address of the spool diameter (float - 4 bytes)


//------------------------------------------------------------------------------
// TIMERS
//------------------------------------------------------------------------------
// for timer interrupt control
#define CLOCK_FREQ            (16000000L)
#define MAX_COUNTER           (65536L)
#define TIMER_PRESCALER_COUNT (5)
// time passed with no instruction?  Make sure PC knows we are waiting.
#define TIMEOUT_OK            (1000)

// optimize code, please
#define FORCE_INLINE         __attribute__((always_inline)) inline


#ifndef CRITICAL_SECTION_START
  #define CRITICAL_SECTION_START  unsigned char _sreg = SREG;  cli();
  #define CRITICAL_SECTION_END    SREG = _sreg;
#endif //CRITICAL_SECTION_START


//------------------------------------------------------------------------------
// STRUCTS
//------------------------------------------------------------------------------
// for line()
typedef struct {
  long step_count;
  long delta;  // number of steps to move
  long absdelta;
  int dir;
  float delta_normalized;
} Axis;


typedef struct {
  int step_pin;
  int dir_pin;
  int enable_pin;
  int limit_switch_pin;
  int limit_switch_state;
  int reel_in;
  int reel_out;
} Motor;


typedef struct {
  Axis a[NUM_AXIES];
  int steps_total;
  int steps_taken;
  int accel_until;
  int decel_after;
  float feed_rate_max;
  float feed_rate_start;
  float feed_rate_start_max;
  float feed_rate_end;
  char nominal_length_flag;
  char recalculate_flag;
  char busy;
} Segment;



//------------------------------------------------------------------------------
// METHODS
//------------------------------------------------------------------------------

extern Segment line_segments[MAX_SEGMENTS];
extern Segment *working_seg;
extern volatile int current_segment;
extern volatile int last_segment;
extern float acceleration;


//------------------------------------------------------------------------------
// GLOBALS
//------------------------------------------------------------------------------
extern Motor motors[NUM_AXIES];


#endif // CONFIGURE_H

Добрый день. Построил "рисовалку" состоящую из двух шаговых двигателей и сервопривода для подъема/опускания карандаша. Ардуино мега + рампс. (Полный комплект от 3 Д принтера).

Есть софт стандартный Микланджело называется от туда и прошивка. Хотелось бы внести в нее изменения..

В моей конструкции хочу заменить серву на эл. магнит.

Рисовалка работает на G кодах ЧПУ... X Y Z

Серва опускалась при изменении Z. А я хочу конструктивно изменить опускания карандаша - заменив привод на эл. магнит. Т.е. (к примеру)  команда G01 Z10   - включит,  команда G01 Z0 - выключит.

Эл. магнит желательно запитать от "стола горячего" (это на примере 3Д принтера)

Подскажите как это реализовать. Привел код Configure.h

 

 

artclonic
Offline
Зарегистрирован: 13.01.2015

Вот мож по следующему пути пойти:

M106 - код включает (замыкает) пины горячего стола

M107 - код выключает (размыкает) пины горячего стола

Пробывал с прошивкой Марлин (на 3 Д принтерах используется) Там все работает по кодам... Только вот кинематика несколько иная. А в Микеланджело кинематика нужная - но серва предусмотрена.

Может можно прям блоком с прошивки Марлина скопировать? функцию вкл/выкл "горячего стола"?

А может легче использовать пины сервы? На вкл и выкл... эл. магнит 6 в...