Skip to content

Commit

Permalink
Remove voltage probes, add output cooling probes, control light/diode…
Browse files Browse the repository at this point in the history
…s using a MOSFET + refactoring
  • Loading branch information
Lyrkan committed Oct 13, 2023
1 parent f72d78b commit 56e2301
Show file tree
Hide file tree
Showing 27 changed files with 419 additions and 603 deletions.
54 changes: 27 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,19 @@

What it **CAN** do:

- Monitor coolant flow and temperature (using a "YF-B4"-type sensor and a thermistor)
- Monitor input/output coolant flow and temperature (using "YF-B4"-type sensors and thermistors)
- Monitor lids opening (using two microswitches)
- Monitor 3 separate voltages (< 50V, they have to share the same ground as the control board)
- Monitor for fire (using an LM393 IR flame sensor module)
- Control a 6 channels relays board for:
- CO2 laser activation (the main switch on an vanilla K40, not the "fire" button)
- Control a 3 channels relays board for:
- CO2 laser activation (the main switch/interlock on an vanilla K40, not the "fire" button)
- Air-assist activation
- Cooling activation
- Lights activation
- Positioning laser diodes activation
- Alarm activation
- Control 12V lights
- Control 5V laser diodes
- Control a motorized bed (based on [this design](https://civade.com/post/2020/08/23/D%c3%a9coupe-laser-CO2-K40-:-R%c3%a9alisation-d-un-lit-motoris%c3%a9), but it should work with other ones as long as the stepper can be controled using a DRV8825 driver)
- Expose sensors/state data through an API **(unstable)**

What it **CANNOT** do:
What it **CANNOT** do yet:

- Move the laser head
- Trigger the CO2 laser
Expand All @@ -50,25 +48,27 @@ For the control panel:
- 1x NodeMCU-32 (38 pins)
- 1x ILI9488 3.95" LCD screen
- 1x DRV8825 stepper driver
- 2x 10kΩ 1/4W resistor
- 3x 27kΩ 1/4W resistors
- 3x 470kΩ 1/4W resistors
- 1x L7805CV 5V regulator
- 2x IRLML6244 N-channel MOSFETs
- 2x 1N4007 diodes
- 5x 10kΩ 1/4W R1206 SMD resistors
- 2x 220Ω 1/4W R1206 SMD resistors
- 1x 0.1uF electrolytic capacitor
- 1x 100uF electrolytic capacitor
- 3x 0.1uF ceramic capacitors
- 2x 2P PCB terminal blocks (5mm pitch)
- some 2.54mm pin headers / XH connectors
- 1x 2P PCB terminal blocks (5mm pitch)
- some 2.54mm pin headers / XH connectors / jumpers

Other things you may need:

- 1x motorized bed with a NEMA17 stepper and a limit switch
- 1x 6 channel relay board
- 1x 3 channel relay board
- 1x air compressor for air assist
- 1x YF-B4 flow sensor with a thermistor (preferably one with a 50kΩ resistance at 25°C and B=3950K)
- 2x YF-B4 flow sensor with a thermistor (preferably one with a 50kΩ resistance at 25°C and B=3950K)
- 1x LM393 IR flame sensor module
- 2x micro switches
- 1x (or 2x depending on your needs) 5V laser diodes
- 1x 12V blinking light
- 1x 12V LED light (for the enclosure)
- 1x 12V blinking light (for the alarm)

## Building the firmware

Expand Down Expand Up @@ -143,14 +143,15 @@ GET http://<YOUR_PANEL_IP>/api/sensors
```json
{
"sensors": {
"voltages": {
"v1": 4.900000095,
"v2": 12.10000038,
"v3": 18
},
"cooling": {
"flow": 5.619999886,
"temp": 18.89999962
"flow": {
"input": 5.619999886,
"output": 5.60124556
},
"temp": {
"input": 18.89999962,
"output": 21.3
}
},
"lids": {
"front": "opened",
Expand All @@ -172,15 +173,14 @@ GET http://<YOUR_PANEL_IP>/api/alerts
```json
{
"alerts": {
"voltages": true,
"cooling": false,
"lids": true,
"flame_sensor": false
}
}
```

### Relays activation state
### Relays/MOSFETs activation state

```
GET http://<YOUR_PANEL_IP>/api/relays
Expand All @@ -189,7 +189,7 @@ GET http://<YOUR_PANEL_IP>/api/relays
```json
{
"relays": {
"laser": false,
"interlock": false,
"air_assist": true,
"cooling": true,
"alarm": false,
Expand Down
Binary file modified gerber/Gerber_K40-Control-Panel.zip
Binary file not shown.
Binary file modified images/pcb-3d.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/screenshot-controls.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/screenshot-status.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions include/K40/alerts.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#ifndef K40_ALERTS_H
#define K40_ALERTS_H

enum AlertType {
typedef enum {
ALERT_TYPE_VOLTAGE = 0x01,
ALERT_TYPE_COOLING = 0x02,
ALERT_TYPE_LIDS = 0x04,
ALERT_TYPE_FLAME_SENSOR = 0x08,
};
} AlertType;

void alerts_toggle_alert(AlertType type, bool enable);
uint8_t alerts_get_current_alerts();
Expand Down
31 changes: 14 additions & 17 deletions include/K40/bed.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,49 @@
#define BED_IDLE_UPDATE_INTERVAL 500
#define BED_RUNNING_UPDATE_INTERVAL 100

enum BedDirection {
typedef enum {
BED_DIR_DOWN = -1,
BED_DIR_UNKNOWN = 0,
BED_DIR_UP = 1
};
} BedDirection;

enum BedStepperPin {
typedef enum {
PIN_BED_STEP = 16,
PIN_BED_DIR = 17,
PIN_BED_LIMIT = 27
};
} BedStepperPin;

enum BedState {
typedef enum {
BED_STATE_IDLE,
BED_STATE_GOING_UP,
BED_STATE_GOING_DOWN,
BED_STATE_HOMING,
};
} BedState;

enum BedCommandType {
typedef enum {
BED_COMMAND_MOVE_ABSOLUTE,
BED_COMMAND_MOVE_RELATIVE,
BED_COMMAND_HOME,
BED_COMMAND_STOP,
BED_COMMAND_SET_CURRENT_POSITION_AS_ORIGIN,
};
} BedCommandType;

typedef struct BedCommand BedCommand;
struct BedCommand {
typedef struct {
BedCommandType type;
int32_t value_nm;
};
} BedCommand;

typedef struct BedPosition BedPosition;
struct BedPosition {
typedef struct {
bool is_set;
int32_t position_nm;
};
} BedPosition;

typedef struct BedStatus BedStatus;
struct BedStatus {
typedef struct {
BedState state;
BedPosition target;
BedPosition current;
BedPosition origin;
};
} BedStatus;

void bed_init();
BedState bed_update();
Expand Down
24 changes: 14 additions & 10 deletions include/K40/cooling.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,22 @@

#define COOLING_FLOW_UPDATE_INTERVAL 500 // ms

enum CoolingPin {
PIN_COOLING_THERMISTOR = 33,
PIN_COOLING_FLOW = 25
};
typedef enum {
PIN_COOLING_THERMISTOR_IN = 39,
PIN_COOLING_FLOW_IN = 25,
PIN_COOLING_THERMISTOR_OUT = 36,
PIN_COOLING_FLOW_OUT = 33
} CoolingPin;

typedef struct CoolingValues CoolingValues;
struct CoolingValues {
float_t flow;
float_t temperature;
};
typedef struct {
float_t input_flow;
float_t input_temperature;
float_t output_flow;
float_t output_temperature;
} CoolingValues;

void IRAM_ATTR cooling_flow_probe_interrupt();
void IRAM_ATTR cooling_flow_input_probe_interrupt();
void IRAM_ATTR cooling_flow_output_probe_interrupt();
void cooling_update_status(esp_adc_cal_characteristics_t *adc_chars);

#endif
6 changes: 3 additions & 3 deletions include/K40/flame_sensor.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef K40_FLAME_SENSOR_H
#define K40_FLAME_SENSOR_H

enum FlameSensorPin {
PIN_FLAME_SENSOR = 5
};
typedef enum {
PIN_FLAME_SENSOR = 22
} FlameSensorPin;

void flame_sensor_update_status();

Expand Down
9 changes: 4 additions & 5 deletions include/K40/lids.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#ifndef K40_LIDS_H
#define K40_LIDS_H

enum LidPin {
typedef enum {
PIN_LID_STATUS_FRONT = 35,
PIN_LID_STATUS_BACK = 32
};
} LidPin;

typedef struct LidsStates LidsStates;
struct LidsStates {
typedef struct {
bool front_opened;
bool back_opened;
};
} LidsStates;

void lids_update_status();

Expand Down
29 changes: 15 additions & 14 deletions include/K40/relays.h
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
#ifndef K40_RELAYS_H
#define K40_RELAYS_H

#define RELAY_PIN_STATE_ENABLED LOW
#define RELAY_PIN_STATE_DISABLED HIGH
typedef enum {
RELAY_STATE_ENABLED,
RELAY_STATE_DISABLED
} RelayState;

enum RelayPin {
PIN_RELAY_LASER = 14,
PIN_RELAY_AIR_ASSIST = 12,
PIN_RELAY_COOLING = 13,
PIN_RELAY_ALARM = 4,
PIN_RELAY_LIGHTS = 0,
PIN_RELAY_BEAM_PREVIEW = 26
};
typedef enum {
RELAY_PIN_INTERLOCK = 12,
RELAY_PIN_AIR_ASSIST = 14,
RELAY_PIN_ALARM = 4,
RELAY_PIN_LIGHTS = 13,
RELAY_PIN_BEAM_PREVIEW = 26
} RelayPin;

typedef struct RelaysCommand RelaysCommand;
struct RelaysCommand {
typedef struct {
RelayPin pin;
bool enable;
};
RelayState state;
} RelaysCommand;

void relays_init();
bool relays_is_enabled(RelayPin pin);
void relays_update();

#endif
25 changes: 0 additions & 25 deletions include/K40/voltage_probes.h

This file was deleted.

4 changes: 2 additions & 2 deletions include/UI/screens/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

#define STATUS_SYSTEM_UPDATE_INTERVAL 500

enum StatusUpdateType {
typedef enum {
STATUS_UPDATE_PROBE_VOLTAGE = 0x01,
STATUS_UPDATE_PROBE_COOLING = 0x02,
STATUS_UPDATE_PROBE_LIDS = 0x04,
STATUS_UPDATE_PROBE_FLAME_SENSOR = 0x08,
};
} StatusUpdateType;

extern lv_obj_t *ui_status_screen;

Expand Down
1 change: 0 additions & 1 deletion include/queues.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ extern QueueHandle_t bed_command_queue;
extern QueueHandle_t cooling_current_status_queue;
extern QueueHandle_t flame_sensor_current_status_queue;
extern QueueHandle_t lids_current_status_queue;
extern QueueHandle_t voltage_current_status_queue;

extern QueueHandle_t relays_command_queue;

Expand Down

0 comments on commit 56e2301

Please sign in to comment.