Stairs.  Entry group.  Materials.  Doors.  Locks.  Design

Stairs. Entry group. Materials. Doors. Locks. Design

» PIC microcontrollers, where can they be useful for a radio amateur? LC meter on a PIC16F628A microcontroller. Diagram and description Types of PIC microcontrollers and their architecture

PIC microcontrollers, where can they be useful for a radio amateur? LC meter on a PIC16F628A microcontroller. Diagram and description Types of PIC microcontrollers and their architecture

Among the many families of microcontrollers from different manufacturers, radio amateurs love two - AVR and PIC. PIC microcontrollers are manufactured by Microchip.

Enthusiasts and hobbyists in the field of electronics often use them both for assembling ready-made projects and for developing their own small automated systems. For example, many built-in volt-ampere meters from China are built on the basis of PIC controllers.

Types of PIC microcontrollers and their architecture

Perhaps the most common microcontrollers among beginners are the junior models, namely the following families:

  • Pic10;
  • Pic12;
  • Pic16.

These microcontrollers are 8-bit, and there are two architectures:

  1. Baseline with 10-bit instructions with 35 assembly instructions.
  2. Mid-range with 14-bit instructions and 35 or 49 assembly language instructions depending on the specific model.

In the developments of radio amateurs, the 16f628 model is very often encountered. The configuration of this pic microcontroller is as follows, it has:

  • built-in clock generator can be set to 4 or 8 MHz;
  • 18 legs – ports, of which 16 can be used for data input/output, 2 are used for power supply;
  • the ability to use a quartz resonator to operate at clock frequencies up to 20 MHz (then 2 more legs are used for it);
  • the letter F in the marking indicates Flash memory with a capacity of 2048 words;
  • Harvard architecture, with 14-bit instructions, 35 in total;
  • machine cycle length is 4 clock cycles (1 action is performed in 4 clock cycles of a quartz resonator or internal oscillator);
  • 224 bytes of RAM;
  • 128 bytes EEPROM;
  • USART – serial port;
  • internal voltage reference;
  • Powered from 3.3 to 5 V.

PIC16 have a low price and fairly developed analog peripherals, which ensures their popularity. At the same time, models can be produced in cases with the number of legs from 18 to 40. This allows you to create more complex systems than is possible in the above example.

There are also more powerful models, for example, 16-bit:

  1. PIC24x
  2. DsPIC30/33F – for digital signal processing.

They are capable of 16 MIPS (million iterations per second), which gives your system very fast performance at 2 push-pull machine cycles, which is achieved by a frequency of 32 MHz. 40 MIPS is achieved at 80 MHz respectively.

The 32-bit PIC32MX microcontrollers have greater performance and memory capacity than 16-bit models, and operate at 80 MHz.

Scope of application of PIC microcontrollers

As already mentioned, the PIC16 family is very popular among radio amateurs. In addition, it is well described in a large amount of literature. In terms of the number of textbooks with the PIC family, at the time of writing, only the AVR family can compete.

Let's look at several circuits using microcontrollers of the PIC family.

Timer for load control on PIC16f628

The simplest automation on PIC microcontrollers is the element of the 8-bit family. Their memory capacity does not allow the creation of complex systems, but is excellent for independently performing a couple of assigned tasks. So this three-channel timer circuit on Pic16f628 will help you control a load of any power. The load power depends only on the installed relay/starter/contactor and the capacity of the electrical network.

The device is configured using a set of 4 buttons SB1-SB4, parameters are displayed on HG1, this is an LCD display with 2 lines of 16 characters. The circuit uses an external 4 MHz quartz resonator, and KV1 is a relay with a 24 V coil power supply, you can use any relay as long as it matches the coil voltage of your power supply. The MK is powered by a 5 V stabilized source.

You can use from 1 to 3 channels to control the load; you just need to duplicate the circuit by adding a relay to the RA3, RA4 pins of the microcontroller.

Alarm clock on MK PIC16f628A

Such watches, according to the developer, turned out to be very accurate, their error is very small - about 30 seconds per year.

With minor modifications you can use any 7-segment indicators. They are powered by a 5V power supply; however, when disconnected from the network, they continue to operate on batteries, which you can see in the upper right corner of the diagram.

Soldering iron power regulator on PIC16f628A

Beginning radio amateurs do not always have the opportunity to buy a soldering station. But they can assemble it themselves. The diagram below shows an adjustable power supply on PIC16f628 for operating a soldering iron. The circuit is based on phase-pulse control. This is, in fact, a modified and modernized analogue of the classic thyristor regulator, but with microcontroller control.

The circuit is quite simple; at the bottom there is an LED display. The main power element is the BT139 thyristor, and the MOC3041 is needed for galvanic isolation of the MK from the network and control of the thyristor using a logical level of 5 V.

How to flash a microcontroller? Where to start studying?

The official programmer for PIC families is PICkit V3, and is the most common. The program code is loaded into the chip using the software that is on the disk; it comes complete with the programmer. The IDE is called MPlab. It is the official development environment from the manufacturer, and by the way, it is free. To study devices there is an excellent book in Russian “Pic-microcontrollers. The Complete Guide" by Sid Katzen. In addition to this book, you will find a huge number of video lessons and text materials that will help you.

The use of PIC microcontrollers is very widespread; many radio amateurs assemble metal detectors and Geiger counters on these microcontrollers.

Model name: PIC16F628A-I/P

Detailed description

Manufacturer: Microchip

Description: 8-bit microcontrollers (MCU) 3.5 KB 224 RAM 16 I/O

Brief contents of the document:
PIC16F627A/628A/648A Data Sheet
Flash-Based, 8-Bit CMOS Microcontrollers with nanoWatt Technology
© 2009 Microchip Technology Inc.
DS40044G
Note the following details of the code protection feature on Microchip devices: Microchip products meet the specification contained in their particular Microchip Data Sheet.

Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions. There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip's Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property. Microchip is willing to work with the customer who is concerned about the integrity of their code. Neither Microchip nor any other semiconductor manufacturer can g

Specifications:

  • Supply Voltage - Max: 5.5 V
  • Supply Voltage - Min: 3 V
  • Mounting type: Through Hole
  • On-chip ADC: no
  • Height: 3.3 mm
  • Length: 22.86 mm
  • Interface: USART
  • Number of I/O lines: 16
  • Number of timers: 3
  • Operating supply voltage: 3 V... 5.5 V
  • Operating temperature range: - 40 C ... + 85 C
  • RAM size: 224 B
  • Data ROM size: 128 B
  • Program memory size: 3.5 KB
  • CPU Series: PIC16
  • Maximum clock frequency: 20 MHz
  • Housing type: PDIP-18
  • Program memory type: Flash
  • Packing: Tube
  • Data bus: 8 bits
  • Width: 6.35mm
  • Core: PIC16
  • RoHS: yes

Spelling options:

PIC16F628AI/P, PIC16F628A I/P

Microprocessor PIC, Core 8bit, 3.5K-Flash 224B-SRAM 128B-EPROM, 20MHz, 3.0V…5.5V, -40°C…85°C PIC (Peripheral Interface Controller) microcontrollers are programmable PROMs, have low power consumption,... .

The clock is built on a PIC16F628A microcontroller, a DS18B20 is used as a sensor, BC212 transistors control the common anodes of a seven-segment indicator, and the circuit also includes several passive elements.

The device is configured using 4 buttons. One increases, the other decreases the value, the third button is used to enter the menu, and also switches menu items. When exiting the menu, the settings are saved to the controller's EEPROM. If the watch freezes for some reason, the reset button can restart it. The watch will continue to operate with the last saved values. The microcontroller is clocked from an external quartz with a frequency of 4 MHz for more accurate timekeeping. PIC16F628 drives the display in multiplex mode. The indicators are controlled by one type of transistor - BC212.

As you know, the frequency accuracy depends on many factors - the quartz resonator, capacitors, the temperature of the microcontroller itself, as well as the quality of the electronic components. In this scheme, the accuracy of the clock can be set using software. We simply need to measure the deviation in seconds over an hour or more, calculate the values ​​using the correction factor formula and enter these values ​​into the controller memory using the menu. If you correctly calculate the correction factor, the clock will be accurate.

Clock setting, menu description:

Ho: Clock setting 0-23
- nn: Set minutes 0-59
- dn: Month setting
- dd: Set the day of the month
- dY: Year setting
- dt: Set the month display format. If 1 - in letters(JA FE ||A AP ||Y JU JL AU SE oc no dE), 2 - in numbers(01 02 03 04 05 06 07 08 09 10 11 12).
- tt: Time display delay. Variable value 2-99s
- td: Date display delay. The variable value is 2-99s. If it is equal to zero, the date is not shown!
- tE: Temperature display delay. The variable value is 2-99s. If it is zero, the temperature is not displayed!
- Sh: Hex value calibration (see below)
- Sl: Hex value calibration (see below)

Examples of setting Sh/Sl calibrations:

Lag of 30 seconds in 24 hours: 30/86400 = 0.000347
1000000 - (1000000 * 0.000347) = 999653 (decimal) = F40E5 (hex)

As a result, we decompose the hexadecimal value 40E5 into Sh=40, SL=E5

Lag of 2 seconds in 1 hour: 2/3600 = 0.000555
1000000 - (1000000 * 0.000555) = 999445 (decimal) = F4015 (HEX)

Sh=40, SL=15

Fast by 15 seconds in 60 days: 15/5184000 = 0.000002
1000000 + (1000000 * 0.000555) = 1000002 (decimal) = F4242 (HEX)

Sh=42, SL=42

The design of a 2-channel thermometer based on PIC16F628A and DS18B20, intended for home use, was of interest to both ordinary radio amateurs and those who have a car.

For use in a car, the design of the thermometer has undergone a number of changes, both circuitry and software. The inscription “Home” has been replaced by “Salon”, and the lower line of the display now displays the voltage of the vehicle’s on-board network. When implementing the function of measuring the voltage of the on-board network, difficulties arose due to the lack of a digital-to-analog converter (ADC) in the used microcontroller. But the microcontroller has a comparator module, which was used to measure the on-board voltage. Using the comparator module, it was possible to measure voltage in the input voltage range from 5.6V to 16V with a measurement resolution of 0.7V. This is the best option for solving the problem without replacing the microcontroller. Knowing the voltage of the on-board network, you can assess the condition of the battery. Immediately when the device is turned on (using the ignition switch or another method), the on-board voltage is measured. If the on-board voltage is less than 10.5 V, the car thermometer-voltmeter will notify with a sound signal (for 1.5 s) and at the same time display the message “Battery - discharged” in the bottom line of the display for about 3...4 s. Next, the current value of the onboard voltage will be displayed in the bottom line. If the voltage value is less than 5.6V, the indicator will display the message "Voltage<6B ", and if more than 16V - " Voltage >16V ".

Description of the scheme:

The microcontroller from Microchip PIC16F628A is used as the control controller D1, which operates in this device from an internal clock generator (4 MHz).

The microcontroller displays information about the measured temperatures and the voltage of the vehicle's on-board network on the LCD indicator E1 from the Nokia3310 mobile phone. This information is transmitted via a serial interface channel of the SPI type. The exchange of information between the microcontroller and the display is one-way; data is transferred only from the microcontroller to the indicator.

Resistors R11...R15, together with the input built-in protective circuits of the indicator, ensure coordination of the levels of control signals supplied to the indicator.

The indicator is powered by a parametric voltage stabilizer, which provides the indicator supply voltage of about +3.3V. The voltage stabilizer is made of zener diode V5, resistor R10 and filter capacitor C8. Power to the stabilizer comes from a stabilized voltage source of +5V. Temperature measurement is carried out by digital temperature sensors U1 and U2 from Maxim DS18B20. These sensors are factory calibrated and allow you to measure ambient temperatures from -55 to +125°C, and in the range -10...+85°C the manufacturer guarantees an absolute measurement error of no worse than ±0.5°C. At the boundaries of the range of measured temperatures, the accuracy deteriorates to ±2°C. The thermometer readings are displayed in the entire range of measured temperatures with a resolution of ±0.1°C.

The exchange of data and commands between microcontroller D1 and temperature sensors U1 and U2 is carried out using a 1-Wire serial interface channel. To simplify the software, the sensors are connected to separate inputs of the microcontroller. In this case, the exchange protocol over the 1-Wire bus is simplified: addressing sensors and their preliminary initialization are not required.

Resistors R4, R6 are load resistors for the 1-Wire interface lines. Resistors R5, R7 perform the function of protecting the internal power supply of the thermometer in the event of a short circuit in the sensor power supply circuits.

Connector X3 is used for in-circuit programming of microcontroller D1. It must be installed when using an SMD microcontroller or when a microcontroller in a DIP package is directly soldered into the board rather than installed into a socket. Connector X3 provides direct connection of the PICKIT2 programmer to the thermometer.

The piezo emitter SP1 provides the output of sound signals notifying that the battery is low.

The internal power supply circuit of a car thermometer is implemented as follows: - from connector X4, the on-board voltage is supplied through diode V1 and resistor R3 to the integrated voltage stabilizer chip U3 of type 7805.

This microcircuit uses the on-board network voltage to generate a stabilized voltage of +5V to power the microcontroller, parametric indicator stabilizer and digital temperature sensors;

Diode V1 prevents the passage of negative voltage pulse noise in the power supply circuit of the thermometer, protects the device in the event of incorrect power supply to the device (power reversal), and together with capacitor C1 prevents the device microcontroller from restarting in the event of voltage dips in the on-board network when the car starter or other energy-intensive consumers are turned on car; - Resistor R3, together with the limiting diode (suppressor) V2, protects the internal circuits of the thermometer from overvoltages arising from the influence of pulse noise.

The unit for generating the analog signal required for measuring the voltage of the on-board network is assembled on a resistive voltage divider R1, R2, a noise suppression filter capacitor C2 (R1, C2), and diodes V3, V4, which together with resistor R1 protect the analog input of the microcontroller from overvoltages.

To increase the accuracy of voltage measurement, it is advisable to use resistors R1 and R2 with 1% accuracy, but since the measurement resolution is very large (0.7V), this condition is not necessary.

The power of resistor R3 must be at least 0.5 W, and the power of steel resistors can be 0.125 W for output and 0.1 W for SMD resistors

A prototype of a car thermometer was assembled on a single-sided printed circuit board:

Attention, the printed circuit board and installation of the prototype are made according to the diagram - Shema_avto_termo_3310_pic16f628.spl, the file of which is presented below. The difference from the diagram presented above is only in the design and positional designations of the elements.

Thermometer on the PIC16F628A and DS18B20 (DS18S20) microcontroller - an article with a detailed description of the memory thermometer circuit and, in addition, a logical continuation of the article I previously published on the Yandex site pichobbi.narod.ru. This thermometer has proven itself quite well, and it was decided to modernize it a little. In this article I will tell you what changes have been made to the scheme and the working program, I will describe the new functions. The article will be useful for beginners. Later I converted the current version of the thermometer into .

The thermometer on the PIC16F628A and DS18B20 (DS18S20) microcontroller can:

  • measure and display temperature in the range:
    -55...-10 and +100...+125 with an accuracy of 1 degree (ds18b20 and ds18s20)
    -in the range -9.9...+99.9 with an accuracy of 0.1 degrees (ds18b20)
    -in the range -9.5...+99.5 with an accuracy of 0.5 degrees (ds18s20);
  • Automatically detect DS18B20 or DS18S20 sensor;
  • Automatically check the sensor for failure;
  • Remember the maximum and minimum measured temperatures.

The thermometer also provides for easy replacement of the 7-segment indicator from OK to an indicator with OA. A gentle procedure for writing to the EEPROM memory of the microcontroller has been organized. A voltmeter that has proven itself well is described in this article -.

The circuit diagram of a digital thermometer on a microcontroller was developed for reliable and long-term use. All the parts used in the circuit are not in short supply. The pattern is easy to follow and perfect for beginners.

The schematic diagram of the thermometer is shown in Figure 1

Figure 1 - Schematic diagram of a thermometer on PIC16F628A + ds18b20/ds18s20

I will not describe the entire circuit diagram of the thermometer, since it is quite simple, I will only dwell on the features.

Used as a microcontroller PIC16F628A from Microchip. This is an inexpensive controller and also not in short supply.

Digital sensors are used to measure temperature DS18B20 or DS18S20 from Maxim. These sensors are inexpensive, small in size, and information about the measured temperature is transmitted digitally. This solution allows you not to worry about the cross-section of the wires, their length, etc. Sensors DS18B20,DS18S20 capable of operating in the temperature range from -55… +125 °C.

The temperature is displayed on a 7-segment 3-digit LED indicator with a common cathode (OK) or with (OA).

To display the maximum and minimum measured temperatures on the indicator, you need the SB1 button. To reset the memory you also need the SB1 button

Using the SA1 button you can quickly switch sensors (street, house).

A jumper is needed to switch the common wire for the LED indicator. IMPORTANT! If the indicator is OK, then we put the jamper in the lower position according to the diagram, and solder the transistors VT1-VT3 with p-n-p conductivity. If the LED indicator is OA, then we move the jamper to the upper position according to the diagram, and solder the transistors VT1-VT3 with n-p-n conductivity.

In Table 1 you can see the entire list of parts and their possible replacement with an analogue.

Table 1 – List of parts for assembling the thermometer
Position designation Name Analogue/replacement
C1, C2 Ceramic capacitor - 0.1 μFx50V -
C3 Electrolytic capacitor - 220μFx10V
DD1 Microcontroller PIC16F628A PIC16F648A
DD2,DD3 Temperature sensor DS18B20 or DS18S20
GB1 Three 1.5V AA batteries
HG1 7-segment LED indicator KEM-5631-ASR (OK) Any other low-power for dynamic indication and suitable for connection.
R1,R3,R14,R15 Resistor 0.125W 5.1 Ohm SMD size 0805
R2,R16 Resistor 0.125W 5.1 kOhm SMD size 0805
R4,R13 Resistor 0.125W 4.7 kOhm SMD size 0805
R17-R19 Resistor 0.125W 4.3 kOhm SMD size 0805
R5-R12 Resistor 0.125W 330 Ohm SMD size 0805
SA1 Any suitable switch
SB1 Tact button
VT1-VT3 Transistor BC556B for indicator with OK/transistor BC546B for indicator with OA KT3107/KT3102
XT1 Terminal block for 3 contacts.

For initial debugging of the digital thermometer, a virtual model built in Proteus was used. In Figure 2 you can see a simplified model in Proteus

Figure 2 – Model of a thermometer on the PIC16F628A microcontroller in Proteus

Figure 3-4 shows the circuit board of the digital thermometer

Figure 3 – Printed circuit board of a thermometer on a PIC16F628A microcontroller (bottom) not to scale.

Figure 4 – Printed circuit board of a thermometer on a PIC16F628A microcontroller (top) not to scale.

The thermometer, assembled working parts, starts working immediately and does not need debugging.

The result of the work is Figures 5-7.

Figure 5 - Appearance of the thermometer

Figure 6 - Appearance of the thermometer

Figure 7 - Appearance of the thermometer

IMPORTANT! In the thermometer firmware not sewn in advertising can be used for your pleasure.

Amendments made to the work program:

1 automatic detection of DS18B20 or DS18S20 sensor;

2. The rewriting time in EEPROM has been reduced (if the condition for rewriting is met) from 5 minutes to 1 minute.

3. The blinking frequency of the dot has been increased;

A more detailed description of the operation of the thermometer can be found in the document, which can be downloaded at the end of this article. If you don’t want to download, then on the website www.pichobbi.narod.ru The operation of the device is also perfectly described.

The finished board fit perfectly into a Chinese alarm clock (Figures 8, 9).

Figure 8 – All the stuffing in a Chinese alarm clock

Figure 9 - All the filling in the Chinese alarm clock

Video - Thermometer operation on PIC16F628A