Ssr arduino pwm

Твердотельные реле SSR: руководство по использованию

Используйте твердотельные реле для управления мощной нагрузкой с помощью Arduino, Raspberry Pi и других микроконтроллеров.

Релейные модули помогут коммутировать ТЭН в DIY-электрочайнике, включать/отключать освещение или рулить однофазным электрическим двигателем.

Список моделей

Модель Количество каналов Управляющее напряжение Коммутируемое напряжение Коммутируемый ток
SSR-1 D4810 1 3–32 В DC 24–480 В AC 10 А
SSR-1 D4825 1 3–32 В DC 24–480 В AC 25 А
SSR-1 D4840 1 3–32 В DC 24–480 В AC 40 А

Общие сведения

Твердотельное реле SSR (англ. Solid State Relay) — это электронный рубильник, который коммутирует силовое напряжение с помощью слаботочного. Это даёт возможность внешним контроллерам, например Arduino или Raspberry Pi, управлять мощными бытовыми приборами. При этом электрическая связь между управляющей электроникой и коммутируемой нагрузкой отсутствует — никакие помехи не повлияют на работу девайса.

  • Если на управляющих контактах присутствует напряжение, то между силовыми контактами есть электрическая связь.
  • Если на управляющих контактах нет напряжения, то между силовыми контактами электрической связи нет.

В отличии от механических реле, в твердотельных реле нет катушки управления и подвижной контактной группы. Вместо силовых контактов внутри модуля расположена печатная плата с полупроводниковыми компонентами. Благодаря этому, в момент коммутации на контактах реле не возникает искра или электрическая дуга, а это позволяет устанавливать реле во взрывоопасных помещениях. Также твердотельные релейные модули обладают большим ресурсом работы, высоким быстродействием и совершенно бесшумной работой.

Твердотельные реле семейства SSR-1 DA — это однофазные полупроводниковые реле с контролем управления перехода тока через ноль (Zero Cross Circuit). При подаче управляющего сигнала, блок управления реле производит коммутацию выходных контактов, только когда фаза синусоидального напряжения питающей сети переходит через ноль. Это позволяет уменьшить начальный бросок тока, снизить уровень создаваемых электромагнитных помех и увеличить срок службы коммутируемых устройств.

Примеры работы

Рассмотрим несколько примеров работы с твердотельным реле.

Простой коммутатор

Работать с реле можно даже без микроконтроллера. Соберём макет системы освещения, где маленький тумблер сможет рулить бытовой лампочкой на 220 В.

Что понадобится

Схема устройства

Результат работы

При переключении состояния маленького тумблера → управляющие напряжение поступает на управляющие контакты реле → происходит коммутация выходных контактов реле → бытовая лампочка включается или выключается.

Пример работы с Arduino

Автоматизируем процесс, вместо ручного управления заставим реле коммутировать контакты по заданному алгоритму. На роль контроллера для работы с твердотельным реле рассмотрим платформу Arduino Uno.

Что понадобится

Схема устройства

Программная настройка

Исходный код

Результат работы

После прошивки Arduino, бытовая лампочка будет менять своё состояние каждую секунду.

Элементы платы

Силовые контакты

Силовые контакты используются для подключения нагрузки в разрыв цепи.

Контакт Функция Подключение
1 Клемма подключения нагрузки или силового питания. Подключите к нагрузке или силовому питанию.
2 Клемма подключения нагрузки или силового питания. Подключите к нагрузке или силовому питанию.

Управляющие контакты

Управляющие контакты используются для подключения управляющего напряжения.

Контакт Функция Подключение
3 Клемма подключения управляющего напряжения (+). Подключите к плюсу управляющего напряжения.
4 Клемма подключения управляющего напряжения (−). Подключите к минусу управляющего напряжения или земле.

Индикаторный светодиод

Красный индикаторный светодиод подскажет текущее состояние реле:

  • Горит: на управляющих контактах присутствует напряжение → силовые контакты реле замкнуты.
  • Не горит: на управляющих контактах отсутствует напряжение → силовые контакты реле разомкнуты.

Источник

LabVIEW Interface for Arduino Discussions

Arduino PWM for SSR

Arduino PWM for SSR

‎12-11-2011 10:13 PM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report to a Moderator

I’m fairly new to labview so please bear with me:)

I am trying to create a PWM signal from the Using LIFA with a frequency of 1 Hz and adjustable duty cyle. The reasoning behind the 1 Hz frequency is because the digital output pin on the Arduino will control a solid state relay, and I do not want to overwork the relay as they heat up quickly. I have seen posts on this forum asking about adjusting the frequency, however I have not been able to come across anything regarding a frequency as low as one Hz.

Is this something that I can imliment in my labview block diagram or will it need to be coded into my .pde file.

any insight would be greatly appreciated..

Re: Arduino PWM for SSR

‎12-11-2011 11:21 PM

  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report to a Moderator

The two main PWM modes for Arduino are «Fast PWM» and «Phase-correct PWM». With Phase-correct PWM, you can get down to frequencies as low as 30Hz. This is calculated by frequency = (clock frequency)/(N*512, where N is the prescale factor (1, 8, 64, 256, 1024) and the clock frequency is 16MHz. You can see this post for information on how to change to PWM frequency. Also, there is a great document on the Arduino website which explains the difference between the different PWM modes. It looks like this will be the easiest way for you to implement a slower frequency.

However, if you need the 1Hz frequency, it looks like it might be possible to attain a frequency lower than 30Hz with the Arduino using this library, however this has not been implemented into LIFA yet. Also, the ATMega328 documentation provides some information about another mode called the Clear Timer on Compare Match (CTC) Mode, where you may be able to using the OCR0A register to attain a lower frequency. I haven’t tried this myself, but it might be a possibility. You can find information about this mode on page 101 of the ATMega328 manual.

Источник

Arduino PID Temperature Control

Advanced Process Control Technology for little cost.

Being a devoted nerd, I’ve long been fascinated by Proportional Integral Derivative (PID) process control. So, when a local farmer asked me to automate a vegetable canning process, I took it as a challenge to physically realize a PID temperature control device. Of course, many fine industrial process controllers already exist (say, from Omega), but I strived to learn their secrets and do it smaller and cheaper. The Arduino product family provides inexpensive hardware for the home builder. Plus, the Arduino integrated development environment (IDE) is easy to install and remarkably easy to use. For these reasons, I decided to build an Arduino PID temperature control unit.

The farmer’s canning application required executing a specific time vs. temperature profile to process the vegetables properly. The thermal control system is composed of the PID controller, solid-state relay (SSR), and 1,500W hotplate. Refer to Figure 1.

FIGURE 1.Thermal application block diagram.

The Arduino controller that I eventually made stores a number of time vs. temperature profiles (Figure 2). Once programmed on a PC (in the normal Arduino IDE way), the unit can be taken out to the process shed for stand-alone operation.

FIGURE 2. Example temperature profile.

Hardware

This PID controller device consists of three sub-units: an Arduino Uno R3; MAX6675 thermocouple temperature sensor; and1602 LCD keypad display. Assembly is simply a matter of observing the correct orientation and fitting the sub-units together. Soldering the MAX6675 module is optional for initial testing (Figure 3).

FIGURE 3. Simplified circuit diagram.

Analog pins A1-A5 were enabled for digital function to provide temperature sensor power and communication. Fortunately, this leaves digital pins 3 and 11 (both on 16-bit TIMER2) available to use for Pulse Width Modulation (PWM) outputs: pin 11 to heat (plus +); pin 3 to cool (minus -). Two optional LEDs provide a visual indication of PID variable outputs. An Arduino Nano and breadboard were used for actual SSR bench testing purposes.

1602 LCD Keypad Display Shield

This is a popular Arduino shield that integrates a 16-character by two-line LCD display with five navigation buttons and one reset button. This hardware is supported in the standard Arduino IDE library. Simply #include in your sketch.

MAX6675 Temperature Sensor Module

This temperature sensor module incorporates the MAXIM 6675ISA eight-pin integrated circuit soldered to a PCB (printed circuit board) substrate. The five-pin electrical interface consists of two power pins and three data I/O pins. Specifications are:

  • 3.0-5.5V supply voltage
  • K-type thermocouple only
  • 0–1024°C temperature range
  • 12-bit resolution (0.25°C)

250K conversions per second max

  • SPI compatible interface
  • Install the Arduino MAX6675 library for both Fahrenheit and Celsius temperature measurements. The module’s five interface pins fit neatly into the A1-A5 holes on the LCD keypad display shield.

    PID_v1R Library

    This sketch modifies the excellent PID_v1 library from Brett Beauregard ( [email protected] ). This new library is contained in the software zip file in the downloads for this article. Simply copy the PID_v1R folder to your Arduino library folder and enable in menu >Sketch>Include Library.

    Software Sketch

    Like fancy commercial controllers, I wanted to enter every parameter and control every function using the five navigation buttons on the LCD keypad display shield, but that is beyond this project’s scope (i.e., beyond my capability). So, the easiest way to experiment is to USB-connect the Arduino Uno and open the sketch in the Arduino IDE.

    I still wanted to employ some keypad functionality to make the device portable for remote operation. Basic keypad functionality was programmed to allow the user to select pre-defined temperature profiles and begin processing.

    After power-up/reset, the display prompts you to scroll up/down through a list of stored temperature profiles. Each profile is defined for up to five temperature and time points. Once you select a profile, the Arduino unit will execute the time and temperature sequence, then return to the last menu. The temperature profile data structure is:

    typedef struct < // 5 steps in temperature profile
    char *desc; // description 16 char max.
    double Kp, Ki, Kd; // PID parameters
    double T1, T2, T3, T4, T5; // T temperature
    unsigned long t1, t2, t3, t4, t5; // t time [integer minutes]
    > profile;

    The sketch as written provides memory for six profiles. Five profiles are intended for sequenced operation and one special profile named “Default” for static continuous operation for a duration of up to 50 days (see millis() counter). Of course, the user can and must edit profile variables to create their own custom functionality and temperature control sequences.

    Also notice that PID constants Kp, Ki, Kd can be tailored in each profile for use in multiple applications. Refer to Figure 4.

    FIGURE 4. LCD display for PID in progress.

    During operation, the LCD display shows a PID sequence in progress; t is total elapsed time in minutes; I and D are PID Integral and Differential terms; PV is Process Value, i.e., current temperature in degrees Fahrenheit. In the lower right, a PID error is indicated by the letter E.

    Sketch features are as follows:

    • A temperature alarm is programmed to terminate execution immediately if min/max temperature limits are exceeded.
    • If either min/max PID output limit is reached, an error “E” is momentarily displayed on the LCD display. While not fatal, this should be a clue that some thermal variable may need adjusting.
    • The Arduino serial monitor tool displays PID steps in progress.
    • Commenting one line of code switches between PID simulation and live operation.

    About PID

    PID process control theory was developed in the early 20th century. It is well researched and commonly applied in modern industry today. PID mathematics can be complicated, but (within limits) PID can compensate for thermal resistance and thermal capacitance in systems to yield precise temperature control. PID behavior is defined by three K constants: Kp (proportional), Ki (integral), and Kd (derivative). In general, these K constants and PID output can range widely for a variety of applications.

    Ideal PID temperature control assumes both a heating and cooling source (with the same linear thermal forcing gain). This can be difficult to achieve in practice due to different heat/cool technologies. There are many ways to go wrong. Even when operating correctly, wild oscillations in temperature are possible. However, with careful attention, PID control can be adapted to many applications.

    Many commercial PID controllers claim to autotune the Kp, Ki, Kd coefficients to achieve optimal performance. I suspect these methods are often empirical and apply only to a narrow set of conditions. PID mathematics is very complicated. Fortunately, there are practical manual methods and online simulations to aid in setting these important PID parameters.

    For this controller, the PID proportional output uses PWM on two digital output pins. PWM is easily enabled in the Arduino environment and provides accurate eight-bit modulation. Often, PWM is used to create a (time-averaged) variable DC voltage, but here the digital signal duty cycle modulates the SSR AC power cycle. One pin outputs the plus (+) and a second pin is the minus (-) PID output. PWM resolution for this microcontroller is eight bits (0-255 values) for each pin.

    Practical Application

    Because PWM output ranges 0-255, this also constrains the PID output function to this range (actually -255 to +255 for dual ± outputs). Therefore, PID constants Kp, Ki, Kd must be chosen carefully to never exceed these limits during operation. Using constrained K constant values may limit PID performance in terms of max temperature excursion and settling time.

    Nevertheless, with proper K constant selection, full range (0-1024°C) temperature sensor operation should be possible for a wide variety of thermal loads.

    Consider the special case of a heat-only application; say, perhaps a small SMT solder oven. In reality, there is no cooling function, so if the PID output

    A simple rule of thumb [3] for the maximum sample period is to take the ramp time and divide by 10. In this example, it took roughly two seconds to heat from 20 to 120 degrees. So, the maximum sample period is 2 sec/10 = 0.2 seconds. Indeed, the blue dots show good PID control at this sampling period: 0.2 sec.

    For most practical applications, under-sampling should not be a problem. Using this PWM strategy, the device is capable of a 0.267 sec sample period minimum; suitable for a three second ramp time.

    SSR and PWM Problem

    Solid-state relays are capable of switching on/off heavy AC loads. Common low cost SSRs are rated for up to 480 VAC at 40A. Yikes! Several SSR types exist, but all AC power SSRs use a TRIAC thyristor element.

    Here, the power is not actually switched until the load current falls below a specified holding current (typically

    For 60 Hz AC power, the maximum delay is 1/2 cycle or 8.33 ms. Considering that our PWM duty cycle ranges from 0-255, a single bit of resolution at 8.33 ms would imply a full range PWM switching period of 256 * 8.33 ms = 2.133 sec. By selecting a PWM switching frequency, the control resolution is determined because SSR power switching only responds to higher order bits. Take a look at Figure 7.

    binary bits control range Period [ms] Freq. [Hz>
    8 256 2133.33 0.46875
    7 128 1066.67 0.9375
    6 64 533.33 1.875
    5 32 266.67 3.75
    4 16 133.33 7.5
    3 8 66.67 15
    2 4 33.33 30
    1 2 16.67 60

    FIGURE 7. PWM switching frequency and resolution.

    Because the ATmega328P master clock operates at 16 MHz and the maximum TIMER2 divisor is 1024, the minimum PWM sampling frequency is

    30 Hz, yielding four levels of resolution control. However, if we further divide the ATmega328P master clock frequency by 8, then the PWM frequency is 3.75 Hz and five-bit (32 level) resolution is achieved.

    Considering many practical applications, a sampling rate of

    4 Hz with five-bit resolution was an acceptable trade-off. Implementing both TIMER2 pre-scalar 1024 divisor and master clock divisor 8 is required to reach a PWM frequency of 16 MHz/(1024*256*8*2) = 3.83 Hz. The master clock was divided in software with the clock_prescale_set(clock_div_8); function which, of course, has a similar effect on the delay(); millis() instructions. Delay values must be divided proportionally.

    The Arduino standard PID_v1 library was also edited for the same reason and a modified PID_v1R library is included in the zip archive at the article link.

    Testing

    To debug and validate this design, an Arduino Nano and breadboard were used with two LEDs, an SSR, and a 60W incandescent light bulb (Figure 8). It was easy to see the LEDs flash at a slow rate (PWM cycle time) and the LED brightness change (PWM duty cycle).

    FIGURE 8. Arduino Nano test circuit.

    The definitive test was switching a 120V resistive load (60W light bulb). To my joy, flashing and variable intensity was observed. This was the extent of bench testing before deployment.

    Discussion

    This was a satisfying project because I learned a lot about PID and made a practical PID temperature control device. The Arduino IDE and libraries made programming and testing a breeze.

    A few quick points:

    • Online cost of hardware is very cheap ($20) and can be assembled by almost anyone in just seconds.
    • ATmega328P microcontroller performance provides for both rapid sampling (4 Hz) and five-bit PWM SSR switching. Along with a wide temperature range (0-1024°C), this unit is ready for a variety of applications.
    • Keypad selection of temperature profiles enables the user to operate stand-alone at the remote process site.
    • Only 30% of program memory and 60% dynamic memory are used, leaving plenty of space for user enhancements.

    Some practical applications might include vegetable canning, rice cooker, slow cooker, alcohol fermentation, or an SMT solder oven. Someday, I’m going to turn the PID problem around and make a device that senses meat temperature and indicates the remaining cooking time. The Thanksgiving turkey will be cooked perfectly every time. NV

    Resources

    All components (Arduino Uno R3, 1602 LCD keypad display, MAX6675 module and thermocouple, SSR) are easily purchased online.

    Источник

    Adblock
    detector