Aprendizaje GRBL (3)

Aprendizaje GRBL

control_de_coolant.c / .h

Este archivo es relativamente simple: por el nombre, controla el enfriamiento, pero el enfriamiento es particularmente extraño en GRBL. De hecho, el enfriamiento se escuchará más en la impresión 3D, porque es probable que el cabezal del extrusor se dañe si todavía está a una temperatura alta cuando no está extruyendo. Pero el CNC es diferente, no se calienta, es de tipo láser.
Simplemente mire el código fuente:

void coolant_init()
{
    
    
  COOLANT_FLOOD_DDR |= (1 << COOLANT_FLOOD_BIT);
  #ifdef ENABLE_M7
    COOLANT_MIST_DDR |= (1 << COOLANT_MIST_BIT);
  #endif
  coolant_stop();
}


void coolant_stop()
{
    
    
  COOLANT_FLOOD_PORT &= ~(1 << COOLANT_FLOOD_BIT);
  #ifdef ENABLE_M7
    COOLANT_MIST_PORT &= ~(1 << COOLANT_MIST_BIT);
  #endif
}


void coolant_set_state(uint8_t mode)
{
    
    
  if (mode == COOLANT_FLOOD_ENABLE) {
    
    
    COOLANT_FLOOD_PORT |= (1 << COOLANT_FLOOD_BIT);

  #ifdef ENABLE_M7  
    } else if (mode == COOLANT_MIST_ENABLE) {
    
    
      COOLANT_MIST_PORT |= (1 << COOLANT_MIST_BIT);
  #endif

  } else {
    
    
    coolant_stop();
  }
}


void coolant_run(uint8_t mode)
{
    
    
  if (sys.state == STATE_CHECK_MODE) {
    
     return; }
  protocol_buffer_synchronize(); // Ensure coolant turns on when specified in program.  
  coolant_set_state(mode);
}

Estas funciones básicamente controlan los niveles alto y bajo de GPIO para controlar si está habilitado.
usar

coolant_set_state

Puede cambiar el estado.

El archivo de encabezado solo tiene la declaración de la función

#ifndef coolant_control_h
#define coolant_control_h 


void coolant_init();
void coolant_stop();
void coolant_set_state(uint8_t mode);
void coolant_run(uint8_t mode);

#endif

cpu_map.h

Este archivo se selecciona básicamente de acuerdo con diferentes tableros, puede mirar directamente el código fuente:

#ifndef cpu_map_h
#define cpu_map_h


#ifdef CPU_MAP_ATMEGA328P // (Arduino Uno) Officially supported by Grbl.
  #include "cpu_map/cpu_map_atmega328p.h"
#endif

#ifdef CPU_MAP_ATMEGA2560 // (Arduino Mega 2560) Working @EliteEng
  #include "cpu_map/cpu_map_atmega2560.h"
#endif

/* 
#ifdef CPU_MAP_CUSTOM_PROC
  // For a custom pin map or different processor, copy and edit one of the available cpu
  // map files and modify it to your needs. Make sure the defined name is also changed in
  // the config.h file.
#endif
*/

#endif

Elija diferentes tableros para incluir diferentes archivos de encabezado.

defaults.h

Este nombre de archivo, seguido de una macro al frente:

#define DEFAULTS_GENERIC

Es relacionado. De hecho, este archivo se utiliza para seleccionar diferentes tipos de máquinas e incluir diferentes archivos de encabezado para su procesamiento. Puede ver la siguiente imagen:
Inserte la descripción de la imagen aquí
En términos generales, si no hay cambios en la etapa inicial, seleccionaré directamente el tipo de máquina predeterminado por defecto. Pero los productos son diferentes, CNC tendrá diferentes tipos de aplicaciones para diferentes escenarios, diferentes estructuras o utilizará diferentes motores. En este momento, este archivo es particularmente importante, porque es muy conveniente para los usuarios modificar directamente los modelos, o incluso agregar nuevos modelos por sí mismos.

eeprom.c / .h

Esto debería ser extremadamente simple, a juzgar por el nombre del archivo, usted sabe que es la realización de eeprom. Antes de realizar la migración, ¿no debería quedar claro qué tipo de interfaces necesita esta eeprom?

Aquí puedes personalizar el nombre de la EEPROM, claro que no importa

#ifndef EEPE
		#define EEPE  EEWE  //!< EEPROM program/write enable.
		#define EEMPE EEMWE //!< EEPROM master program/write enable.
#endif

Aquí realmente depende del tipo de eeprom

/* These two are unfortunately not defined in the device include files. */
#define EEPM1 5 //!< EEPROM Programming Mode Bit 1.
#define EEPM0 4 //!< EEPROM Programming Mode Bit 0.

Aquí necesita implementar una función para leer un byte y una función para escribir

unsigned char eeprom_get_char( unsigned int addr )
void eeprom_put_char( unsigned int addr, unsigned char new_value )

Aquí es necesario realizar la verificación de EEPROM

void memcpy_to_eeprom_with_checksum(unsigned int destination, char *source, unsigned int size) 

int memcpy_from_eeprom_with_checksum(char *destination, unsigned int source, unsigned int size) 

Así es, ¿parece sencillo? Por supuesto, esto se debe a que la velocidad actual del chip no es lo suficientemente rápida, si desea que la EEPROM sea más rápida. ¿O necesitas almacenar más cosas? ¿Debería cambiarse la forma de leer y escribir y la forma de verificación?

Supongo que te gusta

Origin blog.csdn.net/qq_42312125/article/details/112914705
Recomendado
Clasificación