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'm not a geek!”, As well as skilful 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 the form of a banal lack of experience, but then everything turned into a non-optimal management. The customers (they were called, say, Goodwin and Urfin) were mainly involved in the cosmetic component of the project, were engaged from and to, after we focused on the actual logic and implementation, since 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 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, here is a screen with a bunch of garbage:
The events that triggered the trigger; Something that forced me to write in the chat "gg" and 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 guided the Java application), although it’s generally naive to believe that it gave something, since it is still running 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 precisely about this; but now it’s about the fact that the implementation of logic implements the Java application, more precisely, about the reasons and prerequisites for this.
Why Java and not JS? I have no idea, another person wrote it, apparently this tool is more familiar to him. Having received a message from the Whatsapp group about my absence to clarify the details, this person 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 the instructions, do not comply with the standards and operating rules, take the 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.
Pobed and enough. Goodwin and Urfin are still ghouls, but the last thing that would have occurred to me was to deliberately spoil their affairs. 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 any such task at all. 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 crazy, I had to use in my work the most difficult of everything that could be explored - VJLink guides and Karina's streams. 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 saw him again, well, how much is possible, 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 else, 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 capacitor of 0.1 microfarad will be 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. To roil 555 in time-critical applications is 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 determine 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 area is determined by the interruption of the infrared beam, with a narrow focus, 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. 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, or due to “greenhouse” conditions, when the radiators were directed not to the working room but somewhere to the side, where there was a wooden table in the background, a soft rag or something that is not glossy, effectively absorbing.
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, the infrared receivers in one wall and the LEDs in another were immured along the edges of the room. To make them visible there was no joke, since this 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 completely - 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 is sharply reduced when illuminated with a stable unmodulated light of 780-1000 nm, 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, it is impossible to shine in them with unmodulated light, for the sensor it will be just a background light. In general, it was easy to transfer the pulse bursts to the LEDs of the required frequency, all you need is 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 is considered 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, special brightness dips, 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 goes beyond the topic. Let me just say that I rarely make mistakes. If I twist six signal wires in one bundle - I know: the output from them is an open collector, in the bundle they will 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, meaning not endless
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 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, but not with such powerful LEDs, but weaker (on the contrary, it was necessary for the signal to be received only in the immediate vicinity of the receivers). In one of the objects there are immured 11 light-emitting diodes, shining at 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 is 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 doing this, naturally the time creeped out unclear where, naturally they forgot to turn it off, and 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 zombie, 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 desired pause, and after 7000 seconds fell asleep, switching all outputs to 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 one, 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:
- 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.
- There were misunderstandings with writing the IRRemote code at 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.
- 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 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 from all my practice. You have no idea what's wrong. These are the situations that occurred to me:
- The order of wires MOSI (D11), MISO (D12), SCK (D13) is reversed.
- 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.
- 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 of the roads on the board). Or even from the feet of the master controller (in the programmer) to the feet of the slave.
- Suppose the board is powered from 12 through 7805. The cons of the programmer and 7805 must be connected. Yes, all 6 wires are contacted, but once again check it is useful.
- Invalid controller selected.
- 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
What we work with, we will uncomment it. - 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 just forget it." As much as possible.
- Pure f███ing magic? Another, exactly the same board, collected again, worked.
The credibility of the light
Do not use tricolor tape for flame effects. The flame contains in some proportions yellow light, red light. Everything. Try to use to achieve the yellow combination of R + G - the flame will be green. You will try to increase the brightness by adding “white” blue - there will be a blue, blue or violet-peach flame, if yellow is enough. It is not necessary to use cold colors as components of primary colors, in general, there should not be physically green and blue LEDs in this tape. None of the words at all. This decision - the most unfortunate taken. Most likely, the tape in the fixtures 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 most. 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 a single 10 kV flash lamp with a pulse at a current in milliamperes. Why? Because the interference is broadband. The stroboscope at the time of the flash of gray lights wherever possible, on the whole spectrum, there will be a clear band. Flash. How to remove it is not clear. The strobe, turned on through the surge protector, 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:
- Turn on the stroboscope to charge the working capacitor. Two relays, it will be necessary to cut off both power wires from the outlet.
- Disable.
- We energize the igniting winding, by radio or through an optocoupler.
Method two:
- We remake the power of the strobe to low voltage so that it does not connect to the outlet at all.
- 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 again something will not hang on you. 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 the right 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 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, to be successful, but it has a flaw. This drawback lies in the special temporal (ie, temporal) profile of the signal, the 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 reality it turned out to be difficult to pick up 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 was not clear what the incursions of the sensors, leading earlier to false alarms, 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 couple of
everything . Including the wires of the lamps, which were originally 220. Then they put there lamps with a long thread, gnawing an insignificant 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 how and how many channels they could control the two wires, two of which are power wires. They somehow drooped, but did not argue, this is their plus 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 of this are: 8 meters of tape, this is for a moment, almost 10 amps, powered by a
single core 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 wire 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 force the shove into the corrugation, 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 with a plus. Well, you must admit that it is more difficult to confuse the polarity. Find out then this polarity from the dangling, bitten off cables - it was just a song! Especially when a motor with a pair of Ohms is connected at that end, and it is impossible to distinguish short-circuits from non-short-circuits by resistance ... In general, a month later it was possible to take an oral test on the resistances of all cables present in the system, as well as the diagrams of which colors are connected inside strands together. It was not even written in the tables, it is hammered into the subcortex, as soldiers are driven in 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? Schyutka 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, so you 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 to PHP from the outside, he writes a number to the file; on AJAX requests 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, two wires had to be dragged 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”. This 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 / performers 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 a 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 had a device code, an operation code, and another damn grandmother, and there were not even collisions, but he worked so-so together 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 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, it is possible to 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 my thoughts there is no questioning of the business qualities of Goodwin and Urfin, but a number of the 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 the 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 tyap-lyap, 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 fool it 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, 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
above the soldering 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 arrange 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 - you could finish the work much earlier. However, we had no experience and most likely a focus on the process - something logical that follows from this. I do not share this view, and I think that all the tried-and-true options were in one way or another plus, because 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 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 obviously working did not work, the same 6 infrared perimeters, which function as 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. , , . , , , IRRemote.
, - . , . , , .
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 to 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 comparator, the order in which the zeros came from two comparators allowed us to estimate the direction and approximately the position. Not that the encoder, but does not require interrupts,so you can connect over 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 a normal encoder is obtained, which can be connected at least a hundred meters away. Especially since they were 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 malfunction in the line, 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 more sensors, was relocated 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.
, . - , , — . , , , , . — , . , — , . . , — - . — , .
— .
, :
- , ( , , ) PoE.
- . , , - . — - — — . , .
- . ? , / , . ? , , .
« » — , , — ? random() . .
, , . , /, , , . , SPI . -. — ,
.
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.
, . , , . ( ), . , /. . . : - , , — , , . , , . , .
. ISP-, , MOSI/D12. , , , — . , . , , . . — 100-300 ? , . , . .
— . , , LM393. , , - , . , . / , — . , .
watchdog , . 4 . ,
,
, ( , / . ., )
. , , . / , — , .
, :
0.1 . , .
. , , 100 nRF24L01+, ESP8266, ENC28J60. , . — . , . , - . . atmega8, . Atmega8 Attiny85/2313.
LiIon NiMH — : TP4056 , , .
, (, , , , , - /), . , , , , . , / . , — 555 . RC- -.
— — . ISP, - optiboot.
Arduino SUDDEN is capable of being a MIDI device. If you need sound in a computer, then it would be better for it to appear in a VST player or tool, 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 up to the devil, including free ones.
Psychological aspect
— . : — , . , — . , , , // . : « , ». , , .
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:
- 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 pump.
- 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.
, , . , , . , , , . .
FYI: , . . ISP , — , — , /. , , , , . , .