This summer at the dacha, at the end of August, having finally achieved a normal exchange of the device, which will be described below, with an electric meter, I sat on the porch and listened to a conversation between two squirrels, one sitting on a big thuja, and the second on an apple tree. Then my friend called, just returned from a trip to the White Sea. To his question “how are you?” I answered, staying still immersed in the project: “I talked to the counter, I sit here, I listen to the conversation of two squirrels”. A friend paused and said: “Well, of course, I know about squirrels after a liter drunk, but after talking with the counter ???” :)
The article describes a device (hereinafter referred to as “Talker”) designed to take readings from an electric meter and pronounce them in a synthesized voice to a telephone line. In addition to the actual readings of energy consumed, the talker reads the current date, the voltages by phases, the currents by phases, the total consumption and by phases, and displays this data on the built-in TFT display. Also, temperature, humidity, atmospheric pressure and light sensors are connected to the talker.
In fig. 1 shows a photograph of the device. The following nodes are marked with white numbers:
1. RS232 module
2. RJ45 connector for connecting 1Wire sensors
3. RJ45 connector for connecting I2C sensors
4. The zone of formation of the analog speech signal
5. WT588D-U
6. Display based on ILI9341
7. Zone of placement of 2 DAC
8. Blue Pill at STM32F103R8C6
9. Power protection unit
10. DTMF module
11. DC / DC Converter 15 - 5 volts
12. Flat cable 6 wires for connection to the headset connector CCU6225LT
Fig. 1 Appearance Speaking
')
The housing used is G2113 with dimensions 240x120x60mm, with a transparent cover. The photo shows the case without a transparent cover. The photograph of the device with a cover is shown in Fig. 2
Fig. 2 Device in assembled case
The need for this device appeared after the conclusion of an individual contract with MOESK for electricity supply as a result of the lengthy work of our CHT chairman. This action has many consequences. In order to conclude an agreement with MOESK, it is necessary to put a new counter in the metering board on the pole. New counter - hence the new approach to the house. Once a new supply - then why not take three phases and 15 kW for 500 rubles?
As a result, in the old country house a new three-phase input of 15 kW appeared and all the internal wiring in the house was replaced. A new shield appeared, in which, in addition to the standard set of machines and VDT (UZO), four contactors were installed to control the supply of electricity. Three contactors control the activation of heating, the fourth - the power supply to the lighting \ household sockets. When all four contactors are turned off, electricity remains only inside the closed steel shield, all external circuits are de-energized. The contactors are controlled by triac keys with optical isolation S202S02. Triacs are controlled by CCU security controller CCU6225LT Tula company RADS. The controller probably 10 years old, works flawlessly in 24 * 7 mode, controlling electric heating and forming an SMS when the door sensors are triggered. The only problem over the years was the need to change the SIM card. At some point, the device disappeared from the network. Swapping the SIM cards from the phone to the device and vice versa showed that both SIM cards work in the phone, and in CCU6225 only the fresh ones from the phone. Consultation with the provider and the replacement of the SIM card solved the problem completely. It was also necessary to replace the lead backup battery, but 7 years is a good service life for such a battery.
CCU6225 allows you to manage the load independently by SMS, by phone via DTMF, or by a switch in the house. Several switches provided local control of contactors, creating additional convenience and flexibility in controlling equipment at home. The “I am at home” switch allowed us to control, via the CCU6225, the contactor supplying power to the light circuits and home appliances. When you exit it is enough to translate it into the “I left” position and all the appliances in the house will be de-energized. Upon arrival, switch to the “I am at home” position and power will be supplied to all internal circuits. CCU6225 allows you to program the circuit off at the exit from the house and the inclusion of only one (lighting) at the entrance. The point is that when leaving you should turn off the heating, but not the fact that you should turn it on at the entrance.
Also in the panel there are four automatic devices for emergency forced turning on the contactors by direct current supply to the coils parallel to the triac keys. This is done in case of failure of either triacs or CCU6225.
The agreement with MOESK led to the need to submit the evidence of consumed electricity once a month. Those. it is necessary to take a meter reading once a month. This is not a problem in the summer, but in the autumn-winter-spring no one lives there and it’s unreasonable to go to the dacha just for the sake of reading.
The counter Mercury 231 has an infrared port for remote reading of indications, there is a “Configurator” program for communicating with such meters, i.e. The technical ability to read electronically exists. The author of the "Configurator" is a blog and is available by email
Selecting the method of transmission of evidence
For the transfer of evidence there are ready-made industrial solutions (AMR systems) - both software and hardware. But they are quite expensive for a single non-commercial use and require the organization of the communication line. As a rule, some kind of cellular channel is used. Payment for such a channel for today is about 300 rubles a month. Those. for the transfer of 24 testimony (I asked for a two-tariff regime when concluding a contract), you will have to pay 300 p * 12 = 3600 p for the year.
On the one hand, it is a bit. On the other hand - and this money must be earned. The technical redundancy of the Internet channel via cellular communication is also obvious. The house is insured, consider the faces of the criminals, if something happens, it does not make much sense, control 24 * 7 is not needed. For the transfer of evidence, the cheapest form of communication is desirable in order to pay the minimum.
There is such an option - this is the audio channel in the existing CCU6225LT. The incoming call is free, it will take a minute or two to send the testimony by voice. several rubles a month will cost such a data transfer mode. Saving on a couple of orders is serious, despite the absolute values ​​of the sums)
It turns out this scheme: you need to make a controller that will read the readings from the meter through the infrared port and speak them into the telephone line.
Counter placement
The Mercury counter 231 and the infrared adapter are placed in a shield on the pole. From the shield to the Govorilka location, a twisted pair FTP was laid in the house for outdoor placement with a total length of about 35 m. The twisted pair was laid simultaneously with the installation of the new meter and the replacement of the single-phase connection to the house with a three-phase one. The cable consists of 4 standard twisted pairs in a common screen and a black protective sheath. Outer sheath in black is a sign of cable for outdoor use. Black plastic contains additives that increase the resistance of plastic to solar radiation. The infrared adapter is housed in a housing 60 by 40 by 30 mm in size and from the Govorilka looks like a standard RS232 port.
Magnets are glued to the case from the side opposite to the hole for the infrared transceiver. This allowed to attach the module opposite the counter on the inside of the shield door, simply magnifying it to the desired location.
On the back of the cable in the house is mounted a protection device consisting of five 1.5KE18CA type diodes (Protective bidirectional diode, 1500W, 18V, [DO-201]), a standard DB9 plug and a USB connector for powering the infrared adapter. This is certainly not a full lightning protection, but some energy can absorb. On the concept of the talker, a static protection device is designated as a “protection module”.
A standard RS232 connector and a standard USB connector allow, in addition to a talker, to connect a regular laptop and use the Configurator program to, for example, adjust the clock or read meter data to analyze monthly consumption. I used this connection to view the exchange of the program with the counter, write down the commands to the counter and the responses of the counter. From the technical documentation available on the network, it is not always possible to correctly understand which command to issue to the counter and how to correctly decipher the answer. Comparing the memorized screenshots, for example, reading energy or current from the meter and the memorized byte exchange, simply select the command and decode the answers.
In passing, I note that a laptop with a sniffer program is very convenient to watch the exchange of the Speaker and the counter when debugging the sketch, it is enough to connect the RX talker talker and the RX input of the laptop in parallel. I used the Wago electrotechnical fast-clamping clamps for three and five positions to make these connections. A photo of such a terminal is shown in Fig. 3. These terminals have proven extremely convenient for quick installation of twisted pair wires.
Fig. 3 Wago terminal
The choice of element base Speakers
At this design stage, I thought about the basis of the Govorilka - on which element base should the system be made? There are several options:
• Use old computer from availability, remove data and speak programmatically.
• Use something based on Arduino.
The first option is interesting because of the low complexity of the development and the enormous possibilities of expanding the functionality. But since the house is not heated in winter, it is necessary to ensure the operation of the computer even at strongly negative temperatures. And not so much the work itself, as the restart of the company after the cessation of electricity supply. This happens infrequently, but once a month the electricity disappears for a time sufficient for the computer to cool to ambient temperature. Starting the computer at temperatures below +5 degrees Celsius is problematic.
The first serious problem is the start of the hard drive. The manuals indicate the allowable range of +5 degrees. Those. at lower temperatures nothing is guaranteed. Personal experience of operating the server on the balcony also says that the hard drives do not start at low temperatures. The reasons are trivial - thickening of the lubricant in the bearings and insufficient torque of the spindle motor to prevent the pancake pack from moving. This phenomenon for a new, hard-working hard drive is compounded.
The second problem is a sharp change in the parameters of radio electronic elements (ERE) with a drop in temperature. So, we can expect a sharp deterioration in the capacitance of various capacitors in the power supply circuits, which will lead to a noticeable increase in the level of interference on the power supply circuits at low temperatures and possibly to other strange effects, such as instability of work, hang-up, etc., for an autonomously and remotely working computer is unacceptable. Household computers are designed for use in positive temperatures and to put in them ERE with a large temperature range is unnecessarily wasteful.
Obviously, both of these problems can be circumvented by placing the computer in a thermally stabilized housing and, possibly, adding a watchdog timer to restart the hung machine. But this is too expensive a decision. Replacing the usual hard drive on the SSD also does not make sense to consider - it is impractical expensive.
When using Arduino, there are no such problems - there are no disks, the crystal itself is designed to work from -40 to + 105 ° C, and the filter capacitors in the power supply are easily duplicated by elements suitable for operation in an extended temperature range. Watchdog timer is already built.
There is a third problem. Since the expansion of the remote control capabilities is being done, it is reasonable to stop not only on reading the meter readings, but also to install several other sensors - temperature inside and outside the house, humidity, light, atmospheric pressure. All these sensors typically have an I2C or 1Wire type interface, i.e. one way or another, a converter is required of the data received over these interfaces into computer-readable ones. One of the reasonable options is Arduino.
Thus, it turns out that it is reasonable to use Arduino to read the meter and all connected sensors and transmit them by voice over the CCU6225 voice channel.
I could use a standard Arduin Nano on an ATMEL 328p processor, but I had 4 boards on an STM32F103C8T6 processor (Fig. 4) and I decided that it would be interesting to use this more advanced 32-bit processor. STM32F103C8T6 has 64 KB of flash memory for the program and 20 KB of RAM and can work with a clock frequency of 72 MHz. In reality, flash memory more than doubled. The
forum had messages about the successful operation of modules and programs when choosing the option "128 KB of memory."
Fig. 4 The appearance of the board on the processor STM32F103C8T6 (Blue Pill)
STM32F103C8T6 cards come without a bootloader, but the boot loader sewing procedure is simple, after which the board can be programmed using the standard Arduinovsky IDE. The forum
www.stm32duino.com has a detailed description of the actions that must be taken to install the IDE and the bootloader firmware.
The “Blue pill” board with STM32F103C8T6 has hourly quartz (32768 Hz) on board and can store the current time when the backup battery with a voltage of about 3V is connected to the VBATT contact. In my project, this feature is not used, because the time can be read from the counter.
At the time of making a decision on the Govorilka platform, I still didn’t have any real experience with the STM32F103C8T6 processor. Nevertheless, I decided to use this particular processor and did not regret it - it turned out to be no more difficult to work with it than with Atmel328p, and the capacity and resources are much more, the processor is faster. Working with the display turned out to be simpler - level 5 - 3.3 volts are not needed, all sensors are also connected directly. The image on the screen is formed much faster even in the normal exchange mode without using DMA.
In fig. 5 shows the electrical schematic diagram.
Fig. 5 Talker. Electrical schematic diagram
In STM32F103C8T6 there are two I2C hardware controllers and I wanted to spread the different groups of sensors along different channels. So, on one channel I wanted to connect the sensors of external temperature and humidity, and on the second - the rest, located inside the talker housing. In this way, I wanted to increase the reliability and survivability of the system so that in case of collisions with external sensors, only one channel would fail, and everything else would remain in working condition. The first channel started working immediately and without problems (on PB6, PB7 outputs), both in hardware mode with a clock frequency of 400 KHz, and using software exchange. It was not easy to launch the second I2C channel (at the pin PB10, PB11) using the HARDWIRE library, adapted for the Blue Pill. Now I believe that in the HARDWIRE library there are features that manifest themselves when working with the second channel. After a long struggle, the second channel I2C was launched. The situation is paradoxical - if you connect any sensor to the first channel and load a test program, for example, an I2C scanner, everything works right away. Switching the sensor to the second channel and replacing the digit 1 with the digit 2 in the object creation command (HardWire H2Wire (2, I2C_FAST_MODE);) results in the complete inoperability of the system. The board hangs tightly and is brought out of this state only by the Reset button. Detailed studies of the problem with the use of debugging points after each operator and logic analyzer to view the signals generated on the I2C2 bus made it possible to find the place of the hang and eliminate it. For me, the solution to the problem was to specify the exact size of all critical variables used in the I2C2 exchange (int16_t instead of int, etc.). Very carefully assume that the wrong size of variables used to communicate with the HARDWIRE library subroutines results in writing (or reading) invalid memory areas, which in turn gives unpredictable results. Why it manifests itself when using the second channel I2C and does not occur when using the first one - I do not know. Also, this hypothesis does not explain the strangeness with the signals SDA and SCL, one of which, when already loaded, the sketch went to zero and remained there until the reset. How this relates to the declaration of variables and their different sizes - I can’t even imagine.
Sound generation
After analyzing all the desires (aka hotelok), it became clear that there are a lot of phrases for pronunciation (up to a hundred). In the current version used 76 fragments. Use under this small memory Arduino unwise. Searching for an Internet of ways to generate sound gave unexpectedly remarkable results: on the Internet there are WT588D-U modules with 32 megabits of memory, which can memorize up to 220 sound fragments of a total duration of several minutes with the best quality. The modules are equipped with a mini USB connector and can operate in different modes: play the sound on command from the MC, from the buttons. The photo of the module is presented in fig. 10 poses 1. The module has a built-in 13 bit DAC and PWM amplifier for a 0.5 W speaker at 8 ohms. This module only understands the WAV format with a sampling frequency of 6 to 22 kHz. The module supply voltage is 2.8 - 5.5 volts, the interface with the MK is 3.3 volts. If you need to use MK with logic levels of 5 volts - you need to use a converter (suitable from the simplest resistor dividers to the microcircuit).
A software module can be controlled either via a single-wire interface or a three-wire one. Read more
here . A curious feature of the module is the method of generating sound fragments: they can consist of an arbitrary number of sounds and pauses loaded into memory. Pauses do not occupy memory space, i.e. You can load many atomic sounds into memory and construct different fragments from them, combining the same sounds in various ways. To play a specific fragment (or voice, as it is called in the manual), you need to transfer the number of this fragment to the module, wait for the BUSY signal and wait for the BUSY signal to disappear. It is in this sequence - the BUSY signal appears with a rather long delay after receiving the command. The specific type of BUSY signal (low, high, with open collector) is determined during project creation. You can switch these options in the finished project, but you need to recompile the project again before writing to the module. The “Pull high resistor” jackdaw (Fig. 5) controls the “Busy” output type — a full push push pull or open collector. OK mode is useful when connecting a signal LED, and push-pull - when the signal is sent to the control MC. A project is created by a program that can be downloaded, for example,
here (version 1.6 beta) or found on the internet by yourself.
There is version 1.0.
I used version 1.6 beta just because it came into my hands first. I used simplified speaking mode. Thus, the numbers are simply spoken one by one without breaking into hundreds, thousands, the genus and declensions \ cases are not taken into account. For example, the number 397.45 will be spoken as "Three nine seven points four five", and the phrase about the number of detected sensors 18b20 will look like so: "one detected temperature sensors." This method uses the property of significant information redundancy of the Russian language, the uniqueness of perception of information by ear does not decrease, although incorrect cases and inclinations of course cut off hearing. But the simplicity of programming such a mode outweighed the desire to make an academically correct pronunciation. I note that there is no rocket science in programming correct declinations and conjugations, there are a lot of examples where numbers are converted into numbers in words, in all conceivable variants: from skillful tables and macros in Excel to stand-alone C dll, but the complexity of the question is great. Based on these factors, I decided to maximally simplify the actual speaking program at the first stage of work, paying maximum attention to the functioning of the program as a whole and leaving second-order refinements to practice on dark winter evenings :). Free memory in WT588D-U and STM32F103C8T6 is enough for any imaginable delights in the organization of the correct pronunciation. In fig. 5 in the lower right corner, you can see that my entire project took less than 23% of the memory of the WT588D-U module, with a total duration of all fragments of 78 seconds.
Sound files can try to record yourself or generate one of the speech synthesis programs. Having some experience in writing greetings for office telephone exchanges, I chose the second option without hesitation. Experience says that it’s not easy to make a quality sound file on your own - you need a good studio microphone, a room with good sound insulation and a certain amount of practice in pronunciation. Among the Internet projects with a synthesis of the Russian voice, I liked Yvonne most of all.
I prepared a
list of phrases and in a short time I received a set of necessary sounds. There are some flaws: in some phrases, wrong accents, some words are pronounced unusually. For example, the word "ampur" machine speaks like "Ă mper." The intelligibility of the phrases is very good, and I closed my eyes to these shortcomings, although there are certainly ways to fine-tune the speech synthesizers that will allow you to achieve the perfect result. The main objective of the Speaker is to pronounce intelligibly the consumption figures and the output data of the sensors.
I converted the received files to the WAV format as a converter from the AIMP complex. By trial and error, it turned out that the batch converter must explicitly specify all the parameters of the output file, explicitly including all options, otherwise the program to write data to wt588 does not allow importing the file with the message “wrong format”. I didn’t understand it in details, maybe the problem is the absence of any parameter in the file header, which is perceived by the import program as an incorrect format. Naturally, you can use a variety of online converters.
Along the way, it turned out that there is no problem with the Cyrillic file names.
Work with this program has some features. First you need to create a project (Fig. 6).
In the project on the left panel, you need to type sound files. These are the original sounds from which fragments can be constructed. Sound files are required in WAV format with a sampling frequency of 6 to 22 kHz in 2 kHz steps. When importing a file, the program checks these parameters and will not allow importing the file with an invalid sampling rate.
To create a fragment on the right side, select the fragment number (Equation No) and type files from the left panel in the right pane lines. A fragment can include just one sound file from the right panel or consist of many sounds and pauses. In different positions on the right, you can type the same files from the left panel. Those. One copy of the file is stored inside the module and can be used in several fragments. In my project, all the fragments contain only one sound file. To start playback, for example, the fragment number 0xD0, you must send the command 0xD0 to the module.
Fig. 6 Project Screenshot
While the fragment is being played - the BUSY output is pressed to zero (or, on the contrary, to the power supply, an option in the settings). In fig. 7 shows the options for creating a project.
Fig. 7 Project Creation Options
Also in the options of the project, the type of output device - DAC or PWM amplifier is specified. Do not output the DAC to the speaker, you must use an additional amplifier.
I didn’t do an amplifier, but I prepared two projects - one with a DAC, the other with PWM and rearranged the modules in the talker when debugging. In the modules of the next generation, both outputs work simultaneously - i.e. you can attach the speaker and use the output of the DAC. After creating the project and a set of necessary fragments need to compile the project. In fig. 8 shows the result of compiling the project.
Fig. 8 Project Compilation Result
Next, you need to connect the module to the computer and open the module using the “Connect” button (the “Status” indicator turns green), erase the module memory (“Erase”) and save the project (“Download”). You can do this with one “OnekeyDownLoad” button.
Fig. 9 Writing a project to the module
Ready project can be downloaded here .
Microprocessor control of the WT588D-U
A search on the Internet for a ready-made library for managing the WT588 gave rather poor results - there was one acceptable library that works with the module in the 3-wire interface mode. The module can be controlled from the processor either via a single-wire interface or a three-wire one. In reality, you still need to read the state of the BUSY pin and control the CS pin, i.e. totally need 5 conclusions from the MK. The fact that in the Chinese manual is called "single-wire interface" in reality requires three conclusions MK.
In the test scheme, the module earned, but it turned out to be an unpleasant feature — if the system was turned off and on, the module stopped responding to commands. Experimentally, I found out that it is necessary to turn off the power for more than 30 seconds, after which the module is working again. Manipulations with the “reset” output did not help, the module did not respond to it at all. Having found nothing in the internet about this problem, I wrote a letter to the company “Sound Technologies” asking for technical support. To my surprise, I received a completely sane answer. It turned out that the WT588D-U modules had several modifications and earlier versions differed precisely in the behavior I noticed during the fast power-down. The low price of the modules I bought became clear :)
“ ” , , . . ten.
Fig. 10 , 1 – WT588D-U, 2 – WT200302, 3 – WT2003M03
WT588D–U \ . , , .
In the package there were also new modules, more interesting. Thus, the WT200302 module with built-in flash memory (position 10, fig. 10) is two times smaller, works with the MP3 format, and does not require a separate programmer. Significantly increased the maximum number of audio fragments - 3584. It is very easy to program - just connect the module to your computer via USB and record the desired sound files as on a regular USB flash drive. The module is controlled simultaneously by buttons and commands via a single wire. There is no control over the three wires. In the same way as its predecessor, the BUSY output is active while the sound file is being played. In contrast to the previous BUSY module, only low, i.e. when the sound is played, the BUSY signal drops to zero. The module has a curious feature - when connected via USB, it becomes a sound card, i.e.You can listen to your fragments right from the computer.
Another module WT2003M03 (Fig. 10 poses 3) can work with a standard micro flash card with a size from 32 MB to 32 GB. Managed in the same way - by one wire. The module's possibilities are even wider: it supports both WAV and MP3 and can use up to 65,487 fragments.
The package also included modules in a minimalist design and a programmer for them, the photo is shown in Fig. 11. These modules contain the required hardware minimum - one flash memory chip and the control controller wt588. An external controller is required for their programming. They can be used with stringent requirements for cost and size of the device. Details, details of complete sets, possible supply voltages, etc. technical information is abundantly presented here .
Fig. 11
(DIP ), DIN . , . .
. , : , , DIN , .
Technological hint: cleaning the steel needle with holes filled with solder is done like this: the hole heats up and without flux! (this is important) a steel needle is quickly inserted into the hole. The tin hardens with a straw, the needle is taken out - the hole is ready. Solder without flux stick badly to the steel needle, which allows you to re-form the holes in the printed circuit board. If the tin starts to stick - rotate the sufficiently cooled needle in the fingers, a thin layer of fat from the hands will worsen the wettability of the needle surface with solder. If there is a vacuum tin extractor, everything is much simpler :)
After debugging the talker, I started connecting the WT588D-U module via a single-wire interface. In the process of debugging using the logic analyzer, two inaccuracies in the manual were found. The first problem is that after the command has been received, the module sets the BUSY signal after about 34 ms (and not 5, as in the manual). The second is that the RESET pin cannot be left unattached; it must be connected either to the 3.3 V power supply or to the MK output. On the one hand, this is a general rule, on the other hand, this is always explicitly written in manuals.
I didn’t think of it at once and for a long time I couldn’t understand why the system makes a strange wheezing sound instead of normal phrases.
The WT2003M2 and M3 modules differ from WT588 in the size of the control word and the order in which the bits in the word are transmitted. For the WT588, the control word is 8 bits and the low bit must be transmitted first, while the WT2003M2 and M3 have the 16 bit word and the high bit must be transmitted first.
BUSY – WT588 30 ( 5 ), WT2003M2 M3 – 200 . , , , « » + «» + «» + «». , BUSY, .. BUSY .
It was possible to launch the WT2003M2 and M3 boards via a single-wire channel by changing the order of issuing the command bits. According to the manual it is necessary to output the low bit forward. In fact - the big bit ahead. Archives with test programs for modules - here . The test program provides a trigger for the logic analyzer to see what is actually formed at the control output and when the BUSY signal actually appears and disappears.
The WT2003M2 and M3 modules turned out to be quite moody to the parameters of MP3 files. Converted from wav are pronounced slowly. Received from the text-to-speech on-line converter are pronounced with the “swallowing” of the last syllable. Naturally, all files are played normally on the computer. The phenomenon of “swirling” takes place also with the command from the MC and when starting playback with the button. However, these are second-order inaccuracies and you can surely choose mp3 options such that everything will be fine, add silence before and / or after the fragment. The problem is obviously related to the low speed mp3 decoder and can be considered as implementation features: “this is not a bug, this is a feature”.
The last feature of these modules, which should be mentioned, is that the signal from the PWM (that is, directly from the speaker) should not be fed to the input of the cellular module. The result will be terrible. The signal from the DAC after the corresponding filtering circuits should be fed to the input of the cellular module. In my circuit, the signal is additionally attenuated to the level corresponding to the level of a standard microphone, i.e. 20-30 mV. At the DAC output, the signal has a range close to the power level, i.e. 3 volts. I mention this because of this: at first I wanted to make a universal version so that the sound would go both to the cellular module and to the speaker if necessary. I made a circuit for supplying a PWM signal to a speaker or a load resistor through a switch and filtered the same signal to feed a cellular module. A practical test showedthat simple means to filter the PWM signal to an acceptable state does not work, the cellular module gets clogged up on the input and the result is terrible. The reasons are clear - the speaker, being a slow mechanical system, effectively integrates the PWM signal without reacting to higher harmonics. But the signal processing system of the cellular module turned out to be very sensitive to impulse noise. Acceptable sound quality is achieved only when using the DAC output and making the subsequent filter circuit in accordance with the manual. The cellular module is not very sensitive to the signal level, the quality and level of the signal on the cell phone speaker is almost independent of the signal level at the input of the cellular module. When adjusting the level of the resistor R9, it is necessary to take into account the large delay of the cellular path - approximately 200-300 mS in my estimation.In cellular communication, a very effective AGC system, a change in the level of the signal at the input of the cellular module at the volume of the signal at the output of the receiver's cellular phone is not reflected at all. However, adjusting the level with a variable resistor turned out to be useful - despite the excellent work of the AGC system, it is possible to find the signal level at the input of the cellular module where the sound quality at the output (i.e., at the receiver-receiver speaker) is the best. I want to note that the range in which the signal at the output of the entire path is the best is quite small, just a few turns of the multi-turn SP5-3 trimmer resistor.However, adjusting the level with a variable resistor turned out to be useful - despite the excellent work of the AGC system, it is possible to find the signal level at the input of the cellular module where the sound quality at the output (i.e., at the receiver-receiver speaker) is the best. I want to note that the range in which the signal at the output of the entire path is the best is quite small, just a few turns of the multi-turn SP5-3 trimmer resistor.However, adjusting the level with a variable resistor turned out to be useful - despite the excellent work of the AGC system, it is possible to find the signal level at the input of the cellular module where the sound quality at the output (i.e., at the receiver-receiver speaker) is the best. I want to note that the range in which the signal at the output of the entire path is the best is quite small, just a few turns of the multi-turn SP5-3 trimmer resistor.
Since I could not make a universal version of sound, I stopped at the version with a DAC, and for debugging I put the module in PWM mode in the socket. In principle, you can send a signal to the speaker through an additional amplifier, but in practice it turned out to be unnecessary. Everything interesting is displayed on the screen, and you can check the operation of the path just by calling.
RS232 interface
To pair the MK and the RS232 channel, I bought a ready-made board in Chip and Dipe (position 1 in Fig. 1). The name of the board: "RS232 Board, RS232 communication board, based on SP3232, 3-5.5V, ESD protection, hardware flow control." The board is a complete device with a DB9 connector on one side and a connector with terminals on the other side: power supply (from 3 to 5 volts), common, input, output, hardware flow control lines. According to the specification, the board is to a certain extent resistant to static electricity. The board is additionally protected from impulse noise by incoming wires from the meter by absorber diodes placed in an additional external case.
The talker and CCU6225 are mounted in the same housing G2113, housing for REA 240x120x60mm, plastic, with a transparent cover. The basis was the board of double-sided foil fiberglass 0.8 mm thick. On the board, the Dremel milling method has cut out the places for mounting the node connectors. Also on the board are placed rectangular pads for power supply +3.3 and +5 volts to all nodes of the system. Along the perimeter of the power supply areas, SMD filter capacitors with a nominal value of 22 microfarads at 16 volts are soldered off. Between the nodes are connected by wires MGTF 0.12. It is impossible to place all the nodes in the same plane in the selected package, so part of the nodes are placed vertically (power control node and DAC), part over the others (display).
The cable connecting the CCU6225LT audio connector and the signal conversion unit from the D / A output of the WT588D-U is routed under the board through two holes. This solution allowed to some extent protect the audio signal from impulse interference.
Power system
The CCU6225LT module provides power to the talker. In the CCU6225LT there is a current-limited output of +15 volts 900 mA and there are still a couple of unused relays with change-over contacts. Power to the talker can be supplied through normally closed relay contacts. The relay is controlled remotely, which can be used to restart the talker in case of an emergency situation. It is also possible to include a talker for reading only. In this case, the communication session will look like this: a call to the CCU6225LT, switching off the relay (the talker is powered through normally closed contacts), switching to the microphone, listening to data, disconnecting from the microphone, and turning on the power talker to the next talker. I see no practical sense in using such a scenario and mention it only for generality. Switching on both relays gives a galvanic isolation of the CCU6225LT, which can be used during a very strong thunderstorm.
According to calculations, the talker was supposed to consume about 100-150 mA. On the finished device, the measured current was 110 mA. To reduce the voltage from 15 to 5 volts, it is reasonable to use a pulse converter. We strongly did not want to convert a linear stabilizer (15-5) volts * 0.2 A = 2 watts into heat. I chose an inexpensive module (Super mini 3A DC-DC 3V 5V 16V Converter Step Down buck Power Supply Module) based on a step-down converter with a synchronous rectifier (probably based on the MP2307 base), capable (according to the seller's statement) to deliver up to 3 ampere. Reviews of this module on MYSKY show that 3 amps - only in dreams, really, you can count on 1A without overheating, plus it does not have protection against short circuits and overheating. Apparently, a Chinese clone of the microcircuit is used in the module and the excess is thrown out in it, i.e. protection. Despite these drawbacks, the price of the module and its size are extremely attractive.
However, in the absence of overheating protection and a short-circuit, the module fails, i.e. burnout transistor, will give all 15 volts to the output. This is dangerous, too much for MK and sensors. Therefore, I decided to apply protection against overvoltage when the down-converter fails. The protection consists of two independent mechanisms, each of which prevents the voltage of more than 5.6 volts from entering the power supply of the MC.
The first mechanism is made on the half of the LM2903 comparator (OP3-1) and the powerful field switch VT1. It turns on the power to the MK if the supply voltage at the output of the converter is no more than 5.6 volts and turns it off if the voltage is more than 5.6V.
The second mechanism consists of a powerful Soviet-made Zener diode D815A, connected in parallel at the output of the converter and a reusable thermal fuse (MF-F050), connected in series at the input of the converter. In the event of a converter failure and an increase in the output voltage of more than 5.6V, the zener diode will open, current will flow through it, which will lead to heating of the thermal fuse and power supply to the talker. D815A stabilization voltage is 5.6 volts, the permissible current is 1400 mA, which guarantees that the level of 5.6 volts is not exceeded. The permissible current for the Zener diode significantly exceeds the 900mA threshold current from the power supply (CCU6225). The thermal cutout will turn off noticeably earlier than the zener diode will heat up.
The second protection mechanism is one-time and disconnects the voltage irreversibly. To restore normal operation, you will most likely need to replace the pulse converter board. The board is mounted on the connector and if there is a spare one, it is enough to remove the faulty one and insert a new one.
A dual LM2903 with a working range in temperature –40 +125 ° C is used as a comparator. The key transistor is of the type FDS6679AZ, P-channel, -30V, -13A, 9mOhm in the SO8 package. One comparator channel compares the 5.6 volt reference voltage from the zener diode and controls the key. If the voltage at the Zener diode is greater than the voltage at the output of the pulse converter, then the output of the comparator goes to state 0, which opens the power field switch.
The second channel of the comparator is involved in the power failure indication circuit. If the voltage at the output of the protection board is less than 3-x volts, the red HL2 LED turns on indicating the power failure. Green LEDs HL1 and HL3 indicate the presence of +15 and +5 volts.
In CCU6225LT, two free inputs remained, which earlier, before the power supply system in the country house was converted into three phases, were used to read the current and voltage in the network. To measure the current, a Hallway CSLA1CD contactless sensor from Honeywell was used. This sensor provides a voltage proportional to the instantaneous value of the current flowing through the wire on which this sensor is located and can measure both direct and alternating current. In the absence of a flowing current at the output of the sensor there is a half of the supply voltage. Accordingly, when the current is in one direction, the voltage decreases, and in the other direction it increases. With the flow of alternating current, there is a sinusoid at the output, the amplitude of which is proportional to the current strength, shifted by half the supply voltage. To convert the effective value of this sinusoid to a constant voltage, an AD736 chip was used, after which the signal was amplified by an op-amp to obtain a range of 0 +15 V, on which input CCU6225LT was calculated.
The second analog input was used to measure the mains voltage. I once managed to buy a current sensor for 57A, which is rude to control current in the range of amperes (up to 16). But this is not a problem - it is enough to increase the number of turns of the current-carrying wire in the sensor hole and the sensitivity of the sensor will increase in proportion to the number of turns. In other words, two turns will give a sensor at 57/2 = 28.5A, four at 57/4 = 14.25A. The design turned out to be quite successful, it worked stably for many years and had the only drawback - a large zero offset at the output, about 0.5 V. The used OU could not give 0 at the output. Perhaps then I did not know about the existence of the RAIL-TO-RAIL op amp :) With voltage, the solution was simpler - a small transformer with 10-12 volt output and a peak rectifier on germanium D9 diodes gave a fairly accurate voltage meter. The practical use of remote knowledge of current and voltage - control of real consumption, is everything turned off?
When switching to three phases, both of these sensors turned out to be irrelevant. But the meter is a source of fairly complete information about the current state of the power system, it even forms such exotic data as reactive power for each phase. On the Govorilka screen (Fig. 12), I displayed data not only about the current consumption value for each tariff, but also the current values ​​of current, voltage, power for each phase, network frequency, which allowed us to save on switchboard voltmeters and ammeters even by expanding the range of the displayed information compared to devices on the market. To control the total power consumption, it is enough to output a signal proportional to the current power consumption to the CCU6225.
Fig. 12 Display Speakers
For the formation of an analog signal proportional to the current consumed active power and room temperature, I used ready-made DAC modules based on the MCP4725 chip. The modules cost 75 rubles apiece from Ebey and this is probably the cheapest way to get a fairly accurate conversion of a digit to an analog. The modules are controlled via the I2C channel, have the ability to change the address (i.e., two modules can work on the same I2C bus). The DAC module has an output voltage in the range of 0 + 5 volts. The routine to display the value is highlighted in the file. The ability of the Arduino IDE to place individual routines in files in the same directory is used. When opening a project, these files are placed on tabs and compiled as if they were placed in the text of the main module of the program. This is not a library yet, but it is already convenient.
The CCU6225 has an ADC range of 0 +15 volts. You can programmatically set various input voltage conversion factors and turn on the middle point - if the input signal displays a parameter with negative values. For power, it was enough to choose a conversion factor, such that the voltage of 5 volts corresponded to 15 kW of power. But for the temperature this simple solution did not fit. The temperature may be less than zero. I have decided that I will display the temperature in the range of -30 +30 degrees. Those. temperature of -30 degrees will correspond to a voltage of 0 volts at the output of the DAC, and +30 - 5 volts. Unfortunately, the midpoint mode in the CCU6225LT assumes that the midpoint is in the middle of the range — i.e. corresponds to a value of 7.5 volts (= 15/2) and this cannot be changed. Therefore, it is necessary to shift the signal from the DAC so that half of the scale (2.5 volts) corresponds to half the scale of the ADC (7.5 volts). After considering and evaluating different ways of doing this, I chose to use the Rail-to-rail opamp. Requirements for such an op amp: rail-to-rail input and output, power not less than 15 volts, frequency characteristics are not important, minimum price. For these requirements, I found the LMC7101BIM5X / NOPB from Texas Instruments. In CHIPIDIPIP - 40 rubles, I did not find it cheaper.
To convert a range of 0 +5 to a range of 0 +15, a gain of 3 is required (15/5 = 3). For a standard non-inverting inclusion scheme, the gain is determined by the formula Ku = 1 + R1 / R2. I chose the resistor values ​​in the 100 k feedback circuit and 200 k.
There is a simpler way to move the range by 7.5-2.5 = 5 volts - use a 5 volt zener diode connected in series with the output of the DAC. The disadvantage of this method is that the range of change of the signal at the input of the CCU6225LT will remain original, only 5 volts, which threefold reduces the accuracy of the analog signal to digital.
There is another solution to the issue. The ADC range in the CCU6225LT is non-standard: 0 +15 volts are most likely obtained through an input divider, since the standard power supply values ​​of the MK systems are +5 and +3.3 and the same voltages are the maximum for the ADC. Therefore, you can change the values ​​of the resistor divider to obtain the range at the input 0 + 5V. In the simplest case, for this you can close the upper resistor of the proposed divider. But as they say "it was smooth on paper." I received an answer to the request of the manufacturer about the electrical principle circuit that these circuits have been lost because the device has long been discontinued, but it is known that the supply voltage of the system core is +5 volts. Of course you can install to find the desired resistor. But the intuition was against: "You should not climb into a working device and re-solder something there." I listened to the inner voice and went by adjusting to the circumstances.
Connecting external sensors
A number of external sensors are connected to the talker. The temperature is measured by Dallas 18B20 sensors connected via a three-wire circuit. A standard twisted pair is used for the connection. The total length of the loop is approximately 15 m. Programmatically, at each run cycle, the number of connected sensors is determined, the temperature values ​​are read from each detected, and then these data are pronounced. The program announces the number of temperature sensors found and the temperature for each of them. To date, 3 sensors have been used, placed along the far wall evenly along the vertical to monitor the temperature throughout the height of the room. When debugging the talker, I connected 10 sensors in different places of the loop. All 10 were confidently determined.
Three sensors are connected via I2C: BME280, BH1750 and SHT11. BOSH's BME280 sensor provides three parameters — atmospheric pressure, humidity, and indoor temperature. The light sensor BH1750 is connected to the same cable and serves to control the switching of the lighting lamps. The SHT11 sensor is located outdoors in a plastic pipe. The pipe is inserted into the drilled hole in the wooden wall of the house and stands about 1 meter outside the house. The outer end of the pipe is bent down to avoid rain. The sensor in the outer curved end of the pipe provides data on temperature and humidity overboard.
The supply voltage of the sensors is +5 volts, the pull-up resistors R1 and R2 are also connected to +5 volts, since, according to the manual, the inputs PB6, PB7 (I2C) can operate with a voltage of +5 volts.
All these sensors are connected via a single loop. As I wrote earlier, I managed to launch the second I2C channel after installing the Talker in a separate study and therefore at the time of installing and starting the system I had to stop using only one I2C channel. Maybe next summer I will finalize the system.
Conclusion
For today the talker works at my country house. You can listen to the recording of a call to it
here (amr format) or
here (wav format). The sound quality is not high, but the speech is quite legible and its main task is to say the current consumption figures quite confidently. A complete listening cycle takes 1 minute 45 seconds. Payment for these two minutes is a few rubles a month.
At the time of publication of the article (November 30, 2016), the room temperature was -8 ° C, the device was operating normally, in accordance with the task.
Program for Arduino in
this archive .