How to quit escape room

    The article is partly a warning of assumptions, not excluding that the developer can feel all their disadvantages, partly - an attempt to explain - what the customer wants from you, partly - work on the mistakes or recognition of the “fool”. Caution: DotA jargon ahead, “I am not a geek!”, As well as skillful presentation without the help of mats. Continuing to read, you risk forming an opinion that the author is an absolutely repulsed animal, not knowing pity, fear and mercy ©. Just take it for granted that everyone has the right to be imperfect, and everything will be fine with us. Please and thank you.

    Work was carried out on the automatic escape room, the details of which, as is customary, will be omitted. This work lasted for more than a year, and initially there were really tangible flaws in view of the banal lack of experience, but then everything turned into a non-optimal management. Customers (they were called, say, Goodwin and Urfin) were mainly engaged in the cosmetic component of the project, were engaged from and to, after we focused on the actual logic and implementation, because the doors and objects were ready, and it was necessary to make they moved. Time began to press, and at some stage we slept 5 hours a day.

    Of course, it is necessary to blur the details in order to maintain secrecy, but I’m too specific to remember something and fail, because I have stopped all work on it more than 5 months ago. The piece of work turned out to be enough to afford every day with a blunt knife to open a tin can with some saury, and the tea bags were so compact that the cesspool was happy to see me once every two weeks. My room turned into a ventilation shaft in which Rebecca lived from the film “Aliens.” Or "Alien 2", as anyone familiar. If someone does not remember, then here's a screen with a bunch of garbage:

    Rebecca the Newt

    The events that triggered the trigger; there was no such thing that forced me to write “gg” to chat and to pour, as such was not. I was just visited by a clear and clear thought: I need a long rest. The transmitter on my cell phone went into airplane mode for 4 months. These same 4 months in the statistics of requests for face, contact, forums, in which my cookie-data could appear in any way, are marked by such a long hole. No one, through any channel, could not get in touch with me. I was just thrilled to sit in the room, eat stew and roll in the dothan. I know the foul business, but I had time to at least achieve perfection somewhere.

    Summarizing the whole project, I can immediately name its main mistake - the lack of a systematic approach. I know that a special interface board was used in Space One, which provides peripheral interaction with TCP / IP. I did not have such boards, only a handful of Arduino, which in the end was needed for some absolutely simple things. We have tried to reduce everything possible to the management of a simple 0 or 1, but to the gut, as they say microcontrollers. This reduced the load on the central server, collected on the Mega2560, in order to receive and issue information on the web with the least delay. The logic of the quest was rewritten from Wiring to JavaScript, but this led to brakes, because JS runs on a non-RTOS system, as a result, the logic was then copied to its own format (xml, which was guided by the Java application) although it is generally naive to believe that this gave something, since it is still being executed in the Windows environment. In general, this work often reworked something that seemed to have been debugged, where some shoals suddenly crawled out, and the original article was written about this exactly; but now it is that the implementation of logic implements the application in Java, more precisely, about the causes and prerequisites of this.

    Why Java and not JS? I have no idea, he was written by another person, apparently this tool is more familiar to him. Having received a message from the Whatsapp group about my non-appearance to clarify the details, this man sent Picard a frame to the group, leaning his hand to his head, but he would know that at that moment I absolutely did not care - I think I could understand. And we will try to figure out how it happened. Nowadays, the possible barking at each other is not so annoying, “they are inadequate, do not obey regulations, do not comply with standards and operating rules, deduce equipment to unacceptable regimes, question my qualifications with every phrase,” “it is inadequate, incompetent, to complete the project is not maybe the timing is ripped off, constant alterations, some kind of samopal is not like everyone else's, ”etc., etc.

    Pobazlali and that's enough. Goodwin and Urfin are still ghouls, but the last thing that would have occurred to me was to deliberately spoil their business. I will not get the benefits, and harm out of spite, just like that - not for the common good. So why then worsen the world? I think that the priority of the task of cheating me and arranging anti-advertising is not particularly high, so that no one will ever turn to me. Hardly even such a task has been set. Experience is a stern teacher, and you need to find the strength to go on. And the most important thing is to use this experience. Part of this experience, at least the one that I can remember - I dare to hope, I will tell you, dear reader.

    We rarely covered each other with foul language, but still the mood was so-so. In order not to go mad, I had to use in my work the most difficult of all that I could manage - guides VJLink and stream Karina. Yes, yes, I remind you: I'm not a geek, I'm just an animal. Of course, I am aware of the fact that these two are clinical imbeciles: do not think that one of them is a spiritual teacher for me; itpedia is much more suitable for this role. But we were somehow distracted from the quest, the thoughts on the way to which boiled down approximately to “yes, to nag him again, as long as it can, when it ends.” In general, the lack of enthusiasm on any project is reflected in the worst way. Who needs to sweat when Slark in your team is 0-7? So it is here: if every task, every implemented solution meets you with a glitch on a glitch, all hope melts. Sit back and I will share some thoughts on how to prevent this. Also, I would like to see more of these techniques in the comments. Any experience is subjective, but it is a large amount of precedents that allows them to generalize and analyze. Study. I made a lot of mistakes, but still not all of the possible ones. Probably, one of the readers came across something different, but in general similar. Share your experience, all will be grateful to you.

    My rules


    • All sensors must be indicated.
    • All comparators must have a hysteresis.
    • All twists must be soldered.
    • All power wires should be thick.
    • All signal wires must be shielded.
    • All wires with voltages higher than 40 V must have better insulation than just a dull pair. 220 twisted pair or noodles - moveton.
    • All outlets must have an open collector / open drain.
    • All inputs must receive signals through the current loop / optocouplers.
    • All devices performing asynchronous reception-transmission must have a reset pulse shaper and a watchdog timer to be ready to receive at any time.
    • All switching devices must have spark-proof circuits. Relay especially, stuck together contacts is not fun.
    • Every mechanic is heavier than a kilogram like gearbox. People who put the engine right on the brick, without a gearbox - know: the hand of Satan will overtake anyone. Just be damned: 3
    • All inductive loads must have a counter-parallel diode to suppress the self-induced EMF. If the current can go both ways (opening / closing locks from the autoactuator, motor, etc.), a 0.1 μF capacitor is used instead of a diode.
    • Resistors, transistors and optocouplers are not superfluous.
    • Resistors innature are not superfluous, especially where the ISP connector.
    • The ISP connector must be such that it cannot be inserted upside down.
    • Batteries do not like a deep discharge. No matter what, any.
    • Used batteries - especially.
    • Quartz stabilization is good and positive, like that of Sergei Simonov. Moot the 555 in time-critical applications - evil and negative.
    • Cable is always better than radio.

    Motion sensors, range finders, reed switches and sensors are not presence sensors.


    Although it is written in the description of the product HC-SR501, but - no. It does NOT detect presence. It determines the disturbances in the interference pattern that the sensor sees through the Fresnel lens. The presence of a person in a certain zone is determined by the interruption of the infrared beam, and it is narrowly focused, and even with reservations. Originally intended to use the ultrasonic rangefinder. Unfortunately for the range finder, the walls of the room were made of foam, painted with a primer. The reflections were monstrous, in addition at the opposite end, there was a second range finder around the corner (yes, reader, we were unable to use the flag system and prohibit the simultaneous operation of both sensors, but still). In general, the readings of these sensors turned out to be close to the truth only by amusing chance, well, or due to "greenhouse" conditions,

    The infrared range finder, unfortunately, had no time to buy or test (although to whom it was told, at such and such a time). Therefore, infrared receivers in one wall and LEDs in another were immured along the edges of the room. To make them visible there was no joke, since it would destroy the atmosphere, and that is why obstacle sensors, such yellow, with a variable resistor at the back, were not used - they worked perfectly, but the front was such a red light from the LED which is like IR, but not fully - shorter than 808 nm. Maybe 780. In general, they can be seen as the lights in the cameras. In addition, there was not enough distance, normally they determined people only within 45 cm. Therefore, I had to make my own.

    VS1838 (by the way, a universal thing, they are still needed) and TSAL6200, inserted into tubes of plastic dowels, took part in this. It did not work. In robokraft (sorry, do not consider advertising) IR-phototransistors with two outputs are sold, they look like a transparent LED, cost 15 rubles or something, their resistance to lighting with a stable unmodulated light of 780-1000 nm sharply decreases, and it was necessary to use their. But for the year they have not bought. But I had a bunch of VS1838, torn from Chinese household fixtures for utility rooms, who do not know - this is such a small, less sensitive, cheaper analogue of TSOP1738. As we all know, the 1738 contains a demodulator, a filter, and AGC. Therefore, they can not shine unmodulated light, for the sensor it will be just the background light. Generally, it was easy to transfer the pulse bursts of the required frequency to the LEDs, you just need to use direct output to the port (for digitalWrite () is too slow for such things), and delayMicroseconds (27). 27 μs is somewhere around a half-period of 38 kHz, the carrier allocated by the sensor. However, it is impossible to simply take and shine at 38 kHz, such an AGC signal counts as noise, so I had to divide 38 kHz into bursts so that the signal would not be cut off. Strangely enough, the parasitic illumination of neighboring sensors (there were six of them altogether, the distance between them was about 35 cm) was not observed, there were particular dips in brightness, leading to an underestimated sensitivity of some individual sensors — too, but nonetheless. Not. Ra. Bo. Ta Lo. you just have to use direct output to the port (for digitalWrite () is too slow for such things), and delayMicroseconds (27). 27 μs is somewhere around a half-period of 38 kHz, the carrier allocated by the sensor. However, it is impossible to simply take and shine at 38 kHz, such an AGC signal counts as noise, so I had to divide 38 kHz into bursts so that the signal would not be cut off. Strangely enough, the parasitic illumination of neighboring sensors (there were six of them altogether, the distance between them was about 35 cm) was not observed, there were particular dips in brightness, leading to an underestimated sensitivity of some individual sensors — too, but nonetheless. Not. Ra. Bo. Ta Lo. you just have to use direct output to the port (for digitalWrite () is too slow for such things), and delayMicroseconds (27). 27 μs is somewhere around a half-period of 38 kHz, the carrier allocated by the sensor. However, it is impossible to simply take and shine at 38 kHz, such an AGC signal counts as noise, so I had to divide 38 kHz into bursts so that the signal would not be cut off. Strangely enough, the parasitic illumination of neighboring sensors (there were six of them altogether, the distance between them was about 35 cm) was not observed, there were particular dips in brightness, leading to an underestimated sensitivity of some individual sensors — too, but nonetheless. Not. Ra. Bo. Ta Lo. so I had to divide 38 kHz into bursts so that the signal was not cut off. Strangely enough, the parasitic illumination of neighboring sensors (there were six of them altogether, the distance between them was about 35 cm) was not observed, there were particular dips in brightness, leading to an underestimated sensitivity of some individual sensors — too, but nonetheless. Not. Ra. Bo. Ta Lo. so I had to divide 38 kHz into bursts so that the signal was not cut off. Strangely enough, the parasitic illumination of neighboring sensors (there were six of them altogether, the distance between them was about 35 cm) was not observed, there were particular dips in brightness, leading to an underestimated sensitivity of some individual sensors — too, but nonetheless. Not. Ra. Bo. Ta Lo.

    We could be confused by this topic, discuss the non-optimality of the program (for why, then, the diagnostic program, in which a separate sensor was chosen as a defining, worked from and to, ideally?), But this is beyond the scope of the topic. Let me just say that I rarely make mistakes. If I twist the six signal wires in one bundle - I know: the output from them is an open collector, in a bundle they do n’twill not affect each other. I know that each sensor has its own 0.1 μF capacitor in parallel with the power supply, that each LED has its own, separate resistor, and that several LEDs are connected in parallel to one resistor only terminated. So we will not dwell on this, it was necessary to use phototransistors and apply a direct current to the LEDs. Everything. Also, each in the tube to avoid parasitic flare. It could work, just at a certain stage the necessary decision was not made.

    RFId is not eternal, i'm not infinite


    The RFId receiver has its very small reading zone. For good receivers, it is about 7 cm. For those that are worse - 4 cm. The coil can be rewound (the main thing to consider is that the resonant frequency does not go too far from 125 kHz), but then again - not to any size. However, its diameter can be increased 2-2.5 times. The action involved three autonomous, which could be anywhere in the subject, which had to be identified. The size of two of these items was close to the dimensions of the ATX power supply unit, respectively, the coil diameter was tens of centimeters, so the RFId variant had to be abandoned.

    Here again, the IR channel helped, only not with such powerful LEDs, but weaker (on the contrary, it was necessary for the signal to be received only in close proximity to the receivers). In one of the objects there are immured 11 light-emitting diodes, shining from all possible angles, because the object is round. The other has a wooden handle, so there are only three LEDs, since it is not necessary to shine in the direction of the handle, it still sticks up, where there is no receiver. The third item is quite small, and in his case it might even be possible to pay attention again to the RFId, but the dimensions were still incomparable with the reading zone.

    All items are powered by 18650 batteries with capacity from 2000 to 3400 mAh. Where there is 2000, there used. The principle with IR is simple - we wait a long period of time (seconds), give a square signal of 38 kHz a little longer than a millisecond so that the receiver triggers and gives a clear zero at the output. Repeat to taste. Initially, two 555x timers were engaged in this, of course, time was creeping unclear where, of course, they forgot to turn it off, but the timer always wants to eat, and it’s not necessary for him that 20 mA, of course, two used banks really didn’t like it.

    The objects had to be opened (yes, the silicone extremities of the zombies, the F1 grenade made of cast iron without a single seam, think it out for yourself), although it didn’t take much of that time. Well, for a week they were taken in total. The timers were replaced with atmega8, the IRRemote code didn’t fit there (although funny, after a while I managed to compile a sketch for sending, and the compiler showed no errors with the selected atmega8 - maybe I already had a new version of the library). Why 8? Well, cheap, plus the 328 was not available. The program simply gave out a burst of pulses with the necessary pause, and after 7000 seconds fell asleep, translating all outputs into a high-impedance state and turning off everything that is possible to reduce the current consumption to dozens of microamps. It works and the problem is solved.

    On the receiving side, three sensors trigger three conditions. Upon arrival of the pulse, the counter is started and the time stamp (millis) is saved. If the next impulse came to the same sensor and the counter reached n1 - the first item, n2 - the second and so on. If n is large enough and there is no signal, apparently the signal was random and the counter will be reset. I do not think that this is some kind of mega super algorithm, but it solves some problems:

    1. To attach a lot (that is, more than one) IR receiver to one controller is not a task for noobs. Yes, even on mega2560. Yes, there is a multi-fork fork IRRemote. Single sensors and a self-made condition system are simpler.
    2. There were misunderstandings with writing the IRRemote code in atmega8. Yes, it was possible to write a RAW packet, form an array of it, and then again produce low-level functions and microsecond delays, but something was too lazy.
    3. The sensors have long wires, you never know. Long is more than two meters.

    The DC-05 connector (arduine's power connector) allows you to reset the counting time - if you insert a connector into it, two of the three contacts open, cutting off the power. The third item has no connector (it is too authentic for this), but the reset didn’t cause any problems either - the battery charges from TP4056, it has a CH pin, a zero on which indicates the charging process - it is connected to the Reset. TP4056 receives the energy wirelessly through a coil - we put it on the charging cradle - it's like inserting a connector, everything is reset. They took it off - the dumping will not be pulled to the ground, you can count the impulses. We counted - we will sleep, deeply and for a long time; To disable the battery, you must forget to charge this thing for a year. And then, it is collapsible. These items were the most successful solution, which came out almost immediately, albeit with some dances.

    Yikes Invalid device signature. Double check connections and try again or use -F to ignore ...


    The most vile mistake of all my practice. You have no idea what's wrong. These are the situations that occurred to me:

    1. The order of wires MOSI (D11), MISO (D12), SCK (D13) is reversed.
    2. Instead of 22 pF capacitors, something else is soldered near quartz. Once, instead of one of them, there was a 1k resistor. Soldered inscription down.
    3. All six wires must be intact. Always drag the tester (the connector is such a connector), always call up from the connector right up to the controller's feet (nobody canceled the defects on the board). Or even from the feet of the master controller (in the programmer) to the feet of the slave.
    4. Suppose the board is powered from 12 through 7805. The minuses of the programmer and 7805 must be connected. Yes, all 6 wires are contacted, but once again check it is useful.
    5. Invalid controller selected.
    6. The correct controller is selected, but its signature is still different. Here is what I have written for mega328 in hardware \ tools \ avr \ etc \ avrdude.conf:

      #    signature		= 0x1e 0x95 0x0f;  #tqfp32#    signature		= 0x1e 0x95 0x14;  #dip28

      With what we work, then uncomment.
    7. Fuses are installed on external quartz (more than 8 MHz), which is actually absent. There always have a scarf with a quartz and two capacitors and three wires. And also, always provide on the board pads going to XTAL1 and XTAL2. Even if it will be exactly 8 MHz, from the batteries. Even if "just a flash once, you can't forget it there." As much as possible.
    8. Pure f███ing magic? Another, exactly the same board collected again, worked.

    The plausibility of light


    Do not use tricolor tape for flame effects. The flame contains in some proportions yellow light, red light. Everything. Try to use the combination of R + G to achieve yellow - the flame will be green. You will try to increase the brightness by adding “white” blue - there will be a flame of blue, blue or violet-peach, if yellow is enough. It is not necessary to use cold colors as components of primary colors, in general, there should not be any physically green and blue LEDs in this tape. None of the words at all. This decision is the most unfortunate decision. Most likely, the tape in the lamps Goodwin and Urfin still decide to change. There are enough channels there, this is also controlled by the samopal at atmega8, in fact the Pro mini board, which also has three power transistors for PWM-compatible outputs. Two yellow tapes and one red will be the one. All three are random. It is a pity that a tolerant RNG circuit on a noise diode was not caught, although pseudo-random atmega8 opuses look tolerable. But not with green in the ribbon.

    Stroboscope


    Lightning is a noble phenomenon, in any case for inducing atmospheric pressure, but it is not as demanding as it seems. It is simpler to switch a square of 1x1 m pasted over with a tape (80 meters, 96 amperes at 12 volts, almost 1.2 kW), than to burn one 10 kV flash lamp with a pulse at a current in milliamperes. Why? Because the broadband interference. The stroboscope at the time of the flash of gray lights wherever possible, a clear band will be seen on the entire spectrum. Flash. How to remove it is not clear. The strobe, enabled through a power filter, safely hangs both the W5100 and the arduin. The only successful experiment on this topic was done with a battery. Ways to untie the strobe from the main network - two.

    Method one:

    1. Turn on the stroboscope to charge the working capacitor. Two relays, it will be necessary to cut off both power wires from the outlet.
    2. Disable.
    3. We energize the igniting winding, by radio or through an optocoupler.

    Method two:

    1. We remake the power of the strobe to low voltage so that it does not connect to the outlet at all.
    2. We energize the igniting winding, by radio or through an optocoupler.

    Storoboskop must be carefully shielded. It is generally useful to solder a box of foiled material around the igniting transformer, just in case. And it is not a fact that something will not hang again. Meanwhile, powerful field workers work quite normally at frequencies up to 100 kHz, turn on 80 meters of tape for 100 μs - do n ... uh, like two fingers about ..., well, in general, I will not find a suitable expression, the main thing is to stock up capacitors, so that the BP does not swear. And the interference will be low-frequency, and this is much easier to filter. Chokes, electrolytes, well, in general, you know. I understand that this is not an example more expensive than a flash lamp, but it is easier to work.

    Dimmers 220


    Maybe the creators did not come across this, and maybe they did only one channel, and somehow they forgot to mention on the Web that the voltage from one phase regulator can flow to the second if they are nearby. It is treated with a surge protector. In the microwaves such iron, on the body is written EMI Filter.

    Charge air sensor


    The sensor is simple, it is a movable curtain of tinned foiled fiberglass, the movement of which is limited to a fishing eraser. Why not a rubber band for money? - fishing is more durable. The air enters through a tube with a diameter of about 2 cm. Probably, an impeller with an encoder / magnets + Hall sensors, a pressure sensor, etc. would have entered here, but this was not available (lol, a year has passed, so far I have burned off this otmazy about the presence), well, I wanted to make the sensor as oak as possible so that long wires could go to it. Little pleasant, you know, in the lesson “dragging SPI or i2c for 7 meters from the arduin, 7 (seven) meters, Karl”.

    I consider the sensor, in general, successful, but it has a flaw. This drawback lies in the special temporal (that is, that is) signal profile, ADSR-envelope, so to speak. There are a number of options for how exactly the air will flow into the sensor, how to blow it. You can blow long, you can briefly, often / rarely and so on. Therefore, we need precise time frames that limit sensor drawdowns to those and only those cases when zero comes from it, for some time, and after this time, zero should become one, again, not less than some time. It seems like a couple of conditions, but in fact it turned out to be difficult to choose these frames, and the difference in some 100 ms diametrically changed the logic of the sensor response. Of course, there was no oscilloscope to take the necessary readings during the model blow, and then adjust the system of conditions to them. Anyway, the tuning was reduced to two or three weeks of work and there were no special tricks there. Even the wires are not torn.

    Speaking of wires


    This, for the most part, is copper-clad aluminum twisted pair STP, with a foil screen. Previously, there was a copper UTP pair, but almost all of it was replaced with shielded. First of all, it is not clear what the incursions of the sensors, leading earlier to false alarms, have stopped, and secondly - so much calmer. True bimetal, but oh well. The stupidity is the number of times the technician who works with the project before me allowed it - he spent with his UTP a pair of everything. Including the wires of the lamps, which were originally 220. Then they put there lamps with a long thread, gnawing a negligible current, and this, in principle, in general, if you do not care about security, was permissible. But the light of Goodwin's lamps with Urfin did not suit us and we replaced them with tape, submitting 12 instead of 220. Since the lamps had already been installed, there was an E27 cartridge, and we just made a pair of handkerchiefs on mega8, to which such sockets were soldered with energy saving lamps. It seems to be all the way through, but one polarity in one cartridge turned out to be one polarity, and another polarity in another wall, and it was fun to change a failed 7805 when the lamps were mixed up. Since then, they have burned the inscriptions on them with a soldering iron. Then Urfin and Goodwin wanted to control these lamps, and it was fascinating and entertaining to explain to them, exactly what way and what possibilities to control how many channels they have, by two wires, two of which are power wires. They somehow drooped, but did not argue, this is a plus for them in karma. We will return to this aspect, but for now let's continue with the wires.

    Many interesting solutions are connected with them, because everything was built and connected at the same time, I understand that everything is for the painter Petit, who should not smoke and stupid, waiting for Vasya, a mason, but purely hypothetically it was possible to foresee a few more questions. The technical assignment as such was born in the course of work, but we will write it off for noob and lack of experience. The consequences are as follows: 8 meters of tape, for a moment, almost 10 amps, powered by oneveins UTP pair. To the credit of this core, it can withstand such a current (spoiler: not all) and not even warm, but only due to modulation, as well as real, monolithic copper, without any bimetal. However, if the modulation stops and there is one unit at the gate, the fieldmaster will not care. After an hour of such a regime, the insulation will melt, and the guys from the Magic Country of Oz will have fun picking out the wire, for it is embedded in the floor. Well, they did not know that in the future they would decide to stick so many tapes there, well, it does not happen to anyone. Of course, everything will have to be pulled out from the force of 70 centimeters, but nevertheless ...

    Part of the wires was then not needed at all. Part of the wires - coaxial TV cable for cameras (of course, not IP) and microphones. When they decided to drag the DVR a little, it turned out that the cables of the cameras and microphones should be expanded. Then it turned out that the cables that try to push the corrugation by force, usually break in place of soldering. Some of the twisted pairs were divorced before me, and then Dr. Emmett Brown decided that it would be great to make minuses a blue and a brown pair in one cable, and a blue one and a green one in the other. I was used to unwinding the pairs and making all the white wires a minus, and all the colored ones as a plus. Well, you must admit that it is more difficult to confuse the polarity. Find out later this polarity from the dangling, bitten off cables - it was just a song! Especially when a pair of ohms motor is connected at that end, and it is impossible to distinguish short-circuit from non-short-circuit by resistance ... In general, a month later, it was possible to pass an oral test on the resistances of all cables present in the system, as well as diagrams of which colors are connected inside the twists together. It was not even written in the tables, it is hammered into the subcortex, as they are being driven in by the soldiers and then in the middle of the night they ask for the serial number of the machine gun.

    Sound subsystem


    WTV-020SD16P did not enter. Not any TF card reads, there are no clear signs of what works at all, examples of distinct results do not give. An alternative option was the samopal at atmega328 with the TMRpcm library. Not satisfied with the amplitude of the signal, trying to reduce the resistor at the PWM output, reduced-reduced, 328 take and bark. Changed, connected to such an amplifier, to such an amplifier, in general - quietly, they say. Not satisfied. Even one of these men voiced a bright light thought to sequentially connect one amplifier (Chinese speaker), and to its output, where there are two wires to a speaker, is a second amplifier, and it was a titanic task: to bring to his bright mind a simple message that says "Man, you just burn the entrance." On dark nights, nightmares torment me and I wake up in a cold, sticky sweat with just one thought: what if he didn’t believe me? Schmutka yumora, I do not care.

    There are 6 sound sources in total, of which one is a woofer and in one of the rooms is stereo sound, so we can conditionally call it 4 zones from which the sound comes. The first three simply represent different channels 5.1 and are voiced from a computer; the last channel did not have enough woofers. There is a computer, one small speaker and one large speaker separated into different 2.0 channels (stereo).

    When you start your computer, Firefox is launched on it, in it is a page, in a page is an infinite loop with an AJAX request for a PHP script served by a server on the same computer. On request for PHP from the outside, he writes a number to the file, on AJAX request from the page - he says a digit, if the digit is different from the previous one - AJAX, more precisely, howler.js, plays a sound. Where - depends on the sound, in some sounds in the right channel there is complete silence, they are for one speaker, in other sounds there is silence in the left channel, they are for another speaker.

    The computer is old and forgets something that allows you to wake him up over the WOL, in a few hours. That is, if you turn it off, and even from the phone, even from another computer to send the WOL packet for the foreseeable time, the computer will start. A day goes by and he no longer does this. Therefore, we had to drag two wires to his power button.

    The rest of the sound remained secret for me, before it was also played from HTML using howler.js, then the new person adapted the VLC player library to his Java application, now I don’t know. I understand the comments in the spirit of “server with howler - a crutch solution, where is the mp3 shield?”, I explain right away - by that time I hadn’t visited the idea to buy, besides, “we have 5 players on WTV020, here are flash drives”. It turned out to be a working solution, and I do not consider it to be worse than the mp3 shield.

    Command Subsystem


    Now it consists of two central processors to which sensors / actuators are connected via long wires. Long - it means more than two meters. If the performer is via IRFZ48N, either a relay board, or a more powerful relay (60A) if the motor, or the phase controller on the triac + moc3021 / 3051. If the sensor is through an optocoupler, so that the ground of the sensors is untied from the ground of the Arduino. The length of the wires - up to 20 m, either way it is either current loops or stranded wires for powerful loads. Why not dissolve DMX / RS-485 for them right away, for me it's a mystery. But there is something that is. Previously, they were controlled remotely by a network of transceivers nRF24L01 +. The transceiver protocol included a device code, an operation code, and another damn grandmother, and there were not even collisions, but he worked so-so in conjunction with the loop serving Ethernet. Requests come often, because Urfin and Goodwin want to see on the operator’s computer a state, preferably in real time, so first in the HTML interface, and then in the Java service, an infinite loop was placed, continuously polling the state, from both controllers . Naturally, in those 150 milliseconds that the controller was engaged in the network, he was not up to the transceivers.

    There are two ways to make this subsystem better.
    First, you can stop the poll-cycle, and send the state only by changing the sensor readings. This will require a transmitter capable of giving a signal to a computer (for example, serial Wi-Fi ESP8266, sending a request for PHP).
    Secondly, you can divide the system into separate devices, each of which will be able to directly communicate with the computer, but this will require a network interface on all devices, from sensors to motors. For example, for several devices geographically concentrated near a door, and yet, they will need more than 2. In general, make a TCP / IP peripheral board from the quest about Space Odyssey. Such a board is the best solution possible.

    Process orientation


    This theory does not belong to me, I do not insist on anything. And in thoughts there is no questioning of the business qualities of Goodwin and Urfin, but a number of decisions they made as specifically indicated the intention to delay the delivery of the project as far as possible. This concerns mainly the implementation. The most epic, it is perhaps a direct instruction to make all connections to the arduine mechanical, those are the steel pins 40x2.54 in plastic. Why this was done when soldering to the board is more reliable, incomprehensible. I remind you that the twisted pair was soldered. Which is generally hard and can jump out of the connector. Which you do not solder to the pin on the pinhole, otherwise it will fall off, soldering acid is obligatory. Which then in the place of soldering should be closed with shrinking, you never know what.

    Previously, everything, or almost all devices were located together with connectors and optocouplers on the cross-board. It was the largest board ever made by me, its size is 305x405 mm. Unfortunately, the foil was Chinese, and therefore the foil layer was only 18 microns, and to tin her was just a hell of a business. Because of the enormous size, any modifications required to lift it completely, because there were more than 40 connectors in total, each with at least three wires, and disconnecting them all to remove - it’s better to bite your head off right away. It was wildly inconvenient to solder anything there, since the board was abovesoldering iron. In addition, despite all the adjusted wiring, errors were still made in the connectors. Minus a month, and this cross-board was ultimately refused, although it was more convenient to connect performers with sensors to it. This is the second most unsuccessful decision; the first were and remain green LEDs in a ribbon imitating the light of a flame.

    If we knew right away, it was more logical to place all the logic in the immediate vicinity of the router / computer, and to pull only the wires to the end devices, which was not worth trying to provide for controllers in the field - it would be possible to finish the work much earlier. However, we had no experience, and most likely a focus on the process — something logically following from this. I do not share this view, and I think that all the tried-and-true options were positive in one way or another, since they revealed many unsuccessful decisions. If I continue to break into the escape room - our experience will be useful to someone from those who read this article.

    On the one hand, I don’t have any right to talk about this topic at all: our enemy throne is broken without me. But I was specifically strained by some of their decisions, which run counter to common sense and cost minimization. If you hired me to make some decisions - do not argue and doubt. If I say that the signal from the speaker of one amplifier cannot be fed to the input of another, it means that I have a reason. If I say that the RFId reading zone is insufficient, it means I had time to check, I don’t say anything from the ceiling.

    The man on whom my job was dumped


    In the eighth month, another character joined our project, whom we will call the Tin Woodman. He had some industrial sensors at his disposal, and some of the devices underwent changes both in design and in logic. By that time I was already beginning to give thoroughly, and his intervention, in general, was required by me. Something clearly working did not work, the same 6 infrared perimeters that perform the function of a presence sensor. With him, unlike Urfin and Goodwin, at least one could have conversations, for he distinguished the bolt from the resistance, the same two sometimes urged me to pull out all my teeth, one by one, without anesthesia. The Tinman immediately proposed several fixes that could affect reliability, but few of these gave results. However, most recently, they were the ones who raised the question of using the IRRemote code in objects. That is this thingit was already fully debugged, and still something happened there. Uorfin climbed to disassemble one of them and made a short circuit, had to change the transistor. Although, this is exactly the moment in which it would not be necessary to climb once again.

    The unique development of the Tinman is an angle sensor, it was needed for, say, a steering wheel with pedals. In order to determine where it is being turned, the KY040 encoder with a controller stood there, the alpha version even had Schmitt triggers and a counter from the PighiXXX circuit that suppressed bounce and transformed it is not clear that phase-shifted into step / dir signals. But he didn’t manage to do any sane work, then he began to make mistakes, then he crumbled, and so it was decided to replace it with a disk with a hole, and two photo interrupters consisting of an ancient Soviet photodiode FD265 with a comparator, and white LEDs. When the disk was rotated, the hole appeared under the LEDs, a zero was obtained on the comparators, the order in which the zeros came from two comparators made it possible to estimate the direction and approximately the position. Not that the encoder, but does not require interrupts, so it can be connected by long wires. Long is more than two meters. Well, let's be honest - optocouplers are easily installed to the KY040, a counter-parallel diode, 0.1 microfarad ceramics, and we get a normal encoder, which can be connected at least a hundred meters away. Especially since they are scattered in bulk in a bag. But the sediment remained, I no longer wanted to be contacted, and the code was already rewritten and worked more precisely.

    The glitches that arose later were most likely related to a line fault, with some ghostly signals that were induced, but in the end it worked. His only drawback was that he worked slowly, and at high speeds he could miss something (remember, the polling cycle was still there, in the central controller, which also served HTTP requests from the control panel). The survey cycle, with some other sensors, was moved to pro mini, which gave information to the main controller via Serial0. How fascinating it was to wonder why it did not work on Serial1! But nevertheless, it is not about this. The angle sensor had some mechanical defects, and the Tinman replaced it with a complex of something that determines movement in general (motor? Encoder? But what difference does it make?), And two Hall sensors, finding out exactly where the movement takes place. So a new version, the third version of the code defining the number of revolutions, was born.

    In addition to reworking some sensors, he deals with the remaining hardware adaptation of the project. I do not ascribe to him any special merits, but the gold for the creep will go to the one whose strike is the last. The project will be completed by this person, but I will get the bastards of the bastards, who have killed a thick pile on people who need my help. On the one hand, my act is disgusting, and I admit it. On the other hand, certain conditions were granted to me - when these conditions stopped being arranged for me, my godlike person ceased to be in these conditions. Everything. And disgusting, not disgusting - I somehow indifferent. I express my gratitude to the Tin Woodman - he took up what I have no strength left for.

    Bug work


    The first and main step towards transparent and gambleless control is the board from Space Odyssey. This thing is necessary , it allows you to solve a bunch of problems at once:

    1. If the contractor does not have powerful consumers, the entire device (the board itself and, say, a couple of meters of tape connected to the board) can be powered by PoE.
    2. You will not have collisions in traffic. You will not have systematically repeated requests at all, which means that there is a tenfold lower probability of setting up a network, miss the answer or anything else. All management can be made completely asynchronous - something needed from the executor - they sent a request - it was executed. Everything, it is not necessary to repeat the request.
    3. You will have access to information about the artist in general. Sensors? Yes, even a dozen, we catch through a multiplexer / shift register and see each , on what and how much. Engine? You can not only turn on, but also make sure that it really turned on, with a current sensor.

    A typical example of "how not to" - do an imitation of the flame on the eighth mega, cheaply, elementary - what is there to provide? random () and only. As if not so.
    I assure you, arguing in this way, you will find yourself in the exact same situation. Then you will need to change the color of the flame, then smoothly extinguish / ignite, then the devil with horns, but there are no control wires, from the word altogether. And you can't hang the radio, because SPI is busy. Or something else. And as you like - so spin, but give birth to a decision.

    Therefore, the most important thing is to provide direct access of performers to the computer and vice versa. Maybe through Modbus. Maybe DMX. But the more familiar the interface, the less hemorrhoids will be in the future. The most native is TCP / IP. I advise you not to abuse ESP8266, even if you really want. There is an opportunity to lay a cable - use a cable.

    Next, we return to the rules. Sensors are working from and to, so that the current state is evaluated by one glance, so that everything works clearly and unambiguously. If the sensor is discrete (zero or one), it should not show a level in the middle. Twists are lost or not done at all, splitting everything up on boards / boards. We do not save on wires. Polarity is not confused. We know for sure: if you forget something, turn it on incorrectly, only a fool can break it - yes, exactly, such a fool will be found. Turn on, forget, break. Therefore, protection, protection and tons of protection.

    Even you should consider yourself a fool. Previously, I was satisfied with the usual arduin ISP connector, but one day the day came when the MOSI / D12 port died in my programmer. The programmer, of course, I have another, but the other connector is single row. And there are seven wires in it, not six. First, plus, then empty, then minus and all the rest. To the contrary it was impossible to stick it at all. You say - where are the resistors 100-300 ohms for each of these wires? And it would work with the standard one, and nothing would burn upside down. That's right, and now I also have resistors. But the connector is symmetrical, I will not do it ever again.

    One more thing - current sensors. They are cheap, this is one powerful low-impedance resistor, one trimming resistor and half LM393. But it will be seen that the door has already opened, but the engine pulling it is still on, and its windings do not like it. I recommend to put them on everything that you can turn on remotely. LEDs / ribbon is not necessary, but if there are really many LEDs, it is desirable. A pile of tape loads the power supply as well as the engines.

    If you do not need to make an additional timer from watchdog, use it for its intended purpose. So that any dangling device in a maximum of 4 seconds is no longer dangling. By the way, nothing , absolutely noInformation defining the mode of the quest (inaccessibility of opening the doors, closure / openness of locks, etc., sensor immunity) should not be stored in RAM. It is necessary to proceed from the assumption that everything can hang at absolutely every moment. This should in no way distort / violate the logic of tasks and decisions; it is only possible to impose responsibility on the state of the system on one device — the operator’s computer — so that it always has a complete picture of the states before our eyes.

    If you collect samopal, then here is the main thing:

    Each case must have a ceramic capacitor of 0.1 microfarad. Each shift register, each comparator. Especiallyat the microcontroller. Also, such a capacitor, plus the uF electrolyte so 100 should be soldered to nRF24L01 +, ESP8266, ENC28J60. Directly on the pins of the board, or on the wires in close proximity to the board. Land on a free board area is not superfluous. Toner is cheap, and weed faster. Plus, hypothetically, something shields on the board. Quartz is necessary everywhere. Without quartz, an arduin can be made at atmega8, provided that it does not count the intervals more accurately than hundreds of microseconds. Atmega8 is cheaper than Attiny85 / 2313.

    If there is a choice between LiIon and NiMH batteries, lithium is easier to charge: the boards on TP4056 can be taken and daubed, as Banana used to say, but special controllers for nickel are still not visible.

    If there are performers in the system who do not tolerate long-term start-ups (locks, solenoids, heaters, perhaps some powerful engines, engines with a final stroke of thrust that can accidentally break / tear something), it will additionally make for them a long-term protection. For example, if a car lock actuator is permanently turned on, the motor winding will generate heat, the engine will heat up and melt the gearbox, as it is plastic. We all know that a second is enough for him to open / close. Just doing a second pulse shaper, all we need is 555 and a bunch of strapping. Or RC-chain with a CMOS trigger.

    Loader - as a rule - evil. Write via ISP, or at least change the standard to optiboot.

    Arduino SUDDEN is capable of being a MIDI device. If you need sound in a computer, it would be better for it to appear in a VST player or instrument, and not in a browser from under Javascript. This is so if the local sound is not possible / not satisfied. VST plows and hosts are now full of hell, including free ones.

    Psychological aspect


    The smartest contractors in our world are whores. We can and should take an example from them: they clearly and clearly tell the client what he can do and what they will avoid in any way. My mistake was to participate in a project not in a specific position, but in several - this led to unnecessary responsibility and non-optimal spending of time. For example, two weeks were devoted to one thing, which in its essence was simply a button / switch / pair of contacts. Although you could just open your mouth and say: "As you like, do it, I need one wire to close with another when acting on this thing." And I am responsible for the program and for which of these wires will be the ground and which digital input.

    Four weeks was devoted to the settings in the color of the glow of the tape, and the result is far from ideal. And this is impossible to control. You could just make a radio / wire, and bring the full color to the computer, or at least some coefficients. Or brutally, to provide an area in the EEPROM, which can be corrected by external pribluda with the screen 1602 and the button, because it would not be difficult to make such a pribluda.

    For three weeks they caught a joint in the mechanics of the doors, although my chelik clicked on it, a couple of rollers broke off. Well it is, nothing special. Let's call this complaint ordinary whining.

    And te te and te pe. These people tried to move a 100-pound load with a 40-watt engine. Sorokavattny, Karl. These people systematically asked me the question, why not to do so, absolutely not delving into the subtleties of the option syak. Yes, some of their decisions were sensible. But some made me fiercely burn and wonder - why bark myself after buying a dog?

    In general, in this aspect, only two principles can be distinguished:

    1. Know your qualifications and insist on it. Do you think that air can be pumped by a compressor? Let them not climb with their aquarium pomp.
    2. Mark the rules. Only with an elastic band, only in a classical pose, well, you understand, I hope. Sorry for the vulgarity, but there are no other metaphors to pick up.

    On this, I think, I have stated enough information. Think, remember, share experiences. My was not the best, but it is valuable, and it will be easier for the rest, the more experience we give in the comments. So go ahead.

    FYI: the article is devoid of illustrations, since I see no reason to draw two ISP connectors, one is standard, the other is mine, and it is correct / wrong to sign. All the solutions described above easily googling, but if you need one, write in the comments. Editing options are available, and all illustrations of interest can be added.

    Also popular now: