Skip to content

Commit

Permalink
Merge branch 'release/v1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey12malyshev committed Jan 27, 2024
2 parents 2688590 + 8eb31c2 commit 42f7d74
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 41 deletions.
20 changes: 7 additions & 13 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
Проект паяльной станции на микроконтроллере Atmega8a из хлама

За основу взят готовый проект. Проведен рефакторинг (привел типы данных и функции к классическому Си), добавлен режим индикации NO_SOLDER при отсутсвии или неисправности паяльника, добавлен heartbeet-светодиод.

The project of a soldering station on the Atmega8a microcontroller from the trash

Refactoring was carried out (brought data types and functions to classical C), NO_SOLDER indication mode was added when a soldering iron is missing or entered, a Heartbeat LED was added.

## Инструментарий
## Toolkit
*PlatformIO* + *VS Code*

Настройка: https://randomnerdtutorials.com/vs-code-platformio-ide-esp32-esp8266-arduino/
## Прошивка ПО
USBISP(USBASP) + Khazama AVR Programmer
Configuring the development environment: https://randomnerdtutorials.com/vs-code-platformio-ide-esp32-esp8266-arduino/
## Program firmware
USBISP(USBASP) HW programmer + Khazama AVR SW Programmer

## Hardware
- МК Atmega8a 16MHz, 1KB RAM, 8KB Flash
- ОУ LM358
- Индикатор BA56-12SRWA
- Indicator BA56-12SRWA

<img src= "https://github.com/sergey12malyshev/Solder_Station/blob/develop/image/work.jpg" width=30% height=30%> <img src= "https://github.com/sergey12malyshev/Solder_Station/blob/develop/image/noSolder.jpg" width=30% height=30%>
<img src= "https://github.com/sergey12malyshev/Solder_Station/blob/develop/image/hard.jpg" width=40% height=40%>

## Полезная информация
Исходник: https://www.allaboutcircuits.com/projects/do-it-yourself-soldering-station-with-an-atmega8/

Перевод статьи: https://radioprog.ru/post/193
## Useful information
The original project: https://www.allaboutcircuits.com/projects/do-it-yourself-soldering-station-with-an-atmega8/


Binary file added image/SolderingStationSchematic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 28 additions & 28 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
/*
* Доработанный проект паяльной станции из хлама
* A modified design of a junk soldering station
* https://github.com/sergey12malyshev/Solder_Station
* Origin: https://www.allaboutcircuits.com/projects/do-it-yourself-soldering-station-with-an-atmega8/
* Version: 1.1.0
*/
#include <Arduino.h>
#include <PID_v1.h>

#define COMMON_CATHODE false // Установить в true для общего катода
#define COMMON_CATHODE false // Set to true for a common cathode indicator

enum Modes {WORK, NO_SOLDER};
Modes mode = WORK;

static int16_t digit_common_pins[] = {A3, A4, A5}; // Общие выводы для тройного 7-сегментного светодиодного индикатора
static int16_t digit_common_pins[] = {A3, A4, A5}; // General conclusions for the triple 7-segment LED indicator
static int16_t max_digits = 3;
static int16_t current_digit = max_digits - 1;

static uint32_t updaterate = 500; // Изменяет, как часто обновляется индикатор. Не ниже 500
static uint32_t updaterate = 500; // Changes how often the indicator is updated. Not less than 500
static uint32_t lastupdate;

static int16_t temperature = 0;

/* Определяет агрессивные и консервативные параметры настройки ПИД-регулятора */
/* Defines aggressive and conservative settings of the PID controller */
double aggKp = 4, aggKi = 0.2, aggKd = 1;
double consKp = 1, consKi = 0.05, consKd = 0.25;

double Setpoint, Input, Output;

PID myPID(&Input, &Output, &Setpoint, consKp, consKi, consKd, DIRECT); // Задать ссылки и начальные параметры настройки
PID myPID(&Input, &Output, &Setpoint, consKp, consKi, consKd, DIRECT); // Set links and initial settings

static void show(int16_t value, Modes workMode);

static void convertThermocoupleData(void)
{
const uint16_t measured = 303; // Измеренное значение при калибровке (Уже подстроил под свою конструкцию)
Input = analogRead(0); // Прочитать температуру
Input = map(Input, 0, measured, 25, 350); // Преобразовать 10-битное число в градусы Цельсия
const uint16_t measured = 303; // The measured value during calibration (Already adjusted to its design)
Input = analogRead(0); // Read the temperature
Input = map(Input, 0, measured, 25, 350); // Convert a 10-bit number to degrees Celsius
}

static double convertReostatData(void)
{
double newSetpoint = analogRead(1); // Прочитать установленное значение потенциометром
newSetpoint = map(newSetpoint, 0, 1023, 150, 350); // и преобразовать его в градусы Цельсия (минимум 150, максимум 350)
double newSetpoint = analogRead(1); // Read the set value by the potentiometer
newSetpoint = map(newSetpoint, 0, 1023, 150, 350); // and convert it to degrees Celsius (minimum 150, maximum 350)
return newSetpoint;
}

Expand All @@ -57,35 +57,35 @@ static inline void disablePWM(void)

static void regulator(void)
{
double gap = abs(Setpoint - Input); // Расстояние от установленного значения
double gap = abs(Setpoint - Input); // Distance from the set value

if (gap < 10.0)
{ // мы близко к установленному значению, используем консервативные параметры настройки
myPID.SetTunings(consKp, consKi, consKd);
{ // we are close to the set value, using conservative settings
myPID.SetTunings(consKp, consKi, consKd);
}
else
{
// мы далеко от установленного значения, используем агрессивные параметры настройки
// we are far from the set value, we use aggressive settings
myPID.SetTunings(aggKp, aggKi, aggKd);
}
myPID.Compute();
analogWrite(11, Output); // Уcтановить PWM
analogWrite(11, Output); // Install PWM
}

int main(void)
{
init();
//initVariant();

DDRD = B11111111; // Установить выводы ATMEGA порта D с 0 по 7 как выходы
DDRB |= (1UL << PINB5); // Установим pb5 на выход
DDRD = B11111111; // Set the ATMEGA pins of port D from 0 to 7 as outputs
DDRB |= (1UL << PINB5); // Let's set pb5 to the output

for (int16_t y = 0; y < max_digits; y++)
{
pinMode(digit_common_pins[y], OUTPUT);
}

myPID.SetOutputLimits(0, 220); // Устанавливаем ограничение мощности максимум на 85% (220/255)
myPID.SetOutputLimits(0, 220); // Setting the power limit to a maximum of 85% (220/255)
myPID.SetMode(AUTOMATIC);
lastupdate = millis();
Setpoint = 0;
Expand All @@ -94,7 +94,7 @@ int main(void)
{
convertThermocoupleData();

if (millis() - lastupdate > updaterate) /* Обновить температуру жала */
if (millis() - lastupdate > updaterate) /* Update the sting temperature */
{
lastupdate = millis();
temperature = Input;
Expand All @@ -104,22 +104,22 @@ int main(void)
double newSetpoint = convertReostatData();
double change = abs(newSetpoint - Setpoint);

if (change > 3) /* Отобразить установленное значение, если было изменение */
if (change > 3) /* Display the set value if there was a change */
{
Setpoint = newSetpoint;
temperature = newSetpoint;
lastupdate = millis();
}

/* Автомат состояний */
/* State machine */
if (temperature <= 380)
{
regulator();
show(temperature, WORK);
}
else
{
show(temperature, NO_SOLDER); // Отобразим аварию (перегрев или отсутсвие паяльника)
show(temperature, NO_SOLDER); // We will display an accident (overheating or lack of soldering iron)
disablePWM();
}

Expand All @@ -133,28 +133,28 @@ static void show(int16_t value, Modes workMode)
B00111111, B00000110, B01011011, B01001111, B01100110, B01101101, B01111101, B00000111, B01111111, B01101111,\
B01000000 /*- no soldering-iron symbol*/
};
const uint8_t noSolderingIronSymbol = 10u;// ---
const uint8_t noSolderingIronSymbol = 10u; // ---
int16_t digits_array[] = {0};
bool empty_most_significant = true;

for (int16_t z = max_digits - 1; z >= 0; z--) // Цикл по всем цифрам
for (int16_t z = max_digits - 1; z >= 0; z--) // Cycle through all digits
{
if (workMode == WORK)
{
digits_array[z] = value / pow(10, z); // Теперь берем каждую цифру из числа
digits_array[z] = value / pow(10, z); // Now we take each digit from the number
}
else if(workMode == NO_SOLDER)
{
digits_array[z] = noSolderingIronSymbol;
}

if (digits_array[z] != 0 )
empty_most_significant = false; // Не отображать впереди стоящие нули
empty_most_significant = false; // Do not display the leading zeros

value = value - digits_array[z] * pow(10, z);
if (z == current_digit)
{
if (!empty_most_significant || z == 0) // Проверить, что это у нас не ведущий ноль, и отобразить текущую цифру
if (!empty_most_significant || z == 0) // Check that this is not a leading zero, and display the current digit
{
#if (!COMMON_CATHODE)
PORTD = ~digits[digits_array[z]];
Expand Down

0 comments on commit 42f7d74

Please sign in to comment.