tag 标签: relay

相关博文
  • 热度 1
    2023-11-24 11:06
    432 次阅读|
    0 个评论
    下面是一个简单的ESP8266 RELAY V3的Arduino代码示例: arduino 复制代码 # include const char * ssid = "your_ssid" ; // 输入你的WiFi SSID const char * password = "your_password" ; // 输入你的WiFi密码 // 定义继电器引脚 const int relayPin = 2 ; void setup () { // 初始化串口通信 Serial . begin ( 9600 ); Serial . println ( "ESP8266 Relay Example" ); // 连接到WiFi网络 WiFi . begin (ssid, password); while ( WiFi . status () != WL_CONNECTED) { delay ( 1000 ); Serial . println ( "Connecting to WiFi..." ); } // 打开继电器引脚 pinMode (relayPin, OUTPUT ); digitalWrite (relayPin, LOW ); // 默认关闭继电器 } void loop () { // 打开继电器 digitalWrite (relayPin, HIGH ); delay ( 1000 ); // 继电器打开1秒钟 // 关闭继电器 digitalWrite (relayPin, LOW ); delay ( 1000 ); // 继电器关闭1秒钟 } 在这个示例中,我们使用了ESP8266WiFi库来连接到WiFi网络。你需要将your_ssid和your_password替换为你的WiFi网络的SSID和密码。在setup()函数中,我们初始化了串口通信,并连接到WiFi网络。然后,我们打开了一个名为relayPin的引脚,并将其配置为输出模式。在loop()函数中,我们使用digitalWrite()函数来控制继电器的开关状态,并使用delay()函数来控制继电器的开关时间。
  • 热度 20
    2013-10-31 21:03
    1472 次阅读|
    0 个评论
    A university chemistry department houses a broad range of equipment, ranging from technologically recent equipment to old equipment, older equipment, and finally the "designers-have-been-grave-stoned for twenty years" equipment. One day a call came in from the Mass-Spec Lab: A quadrupole mass spectrometer, made in the UK, was alarming in standby mode but not in operate mode. Fortunately, we had a set of schematics for the instrument, but the folks across the pond draw things a little differently. Fortunately, deciphering the drawings didn't take long using my super secret decoder ring (a.k.a., paper, pencil, and pencil sharpener). The alarm was coming from a relay board that distributed 24Vdc power to three off-board circuits. On this particular machine, power for each circuit goes through a dedicated set of two (one operate and one interlock) SPDT relays rated to 5A. Both relays are energized to pass power in the operate mode and de-energized in standby mode. Any other relay combinations sounds an alarm. The NC contacts on each relay go to alarm logic, where they are XORed to each other. When the "operate" relay is de-energized, 24V (applied to the COM) passes through a 100kΩ to the NO contact, providing 24V low current signal to the second relay's COM. This is needed at the second relay so when it is de-energized there is a "high" logic signal to the alarm logic through the NC contact. A visual inspection while switching "standby" to "operate" showed that all of the relays were toggling. Using a low-power binocular microscope, the relay contacts where inspected. As expected, the NO contacts showed pitting for current switching. The NC contacts appeared clean and pristine, also as expected since they switched very low current. Measurements with an ohmmeter showed some relays having NC contact resistance ranging from half an ohm to tens of ohms on repetitive relay cycling using a bench power supply. One relay randomly measured higher resistance to megaohms. But continued cycling slowly reduced the resistance. After ordering an identical relay and replacing it, the alarm issue went away. But a few months later the problem was back. This time another relay had the resistance issue. We ordered several identical relays. But the real quandary began after we installed one of the new relays. The alarm issue persisted and was traced back to the new relay. Several of these new relays were tested and a few showed the same contact issue. A "good" relay was selected and installed, getting the instrument back in operation. But what was going on?   After some hypothesis, analysis, meditation, perusing of datasheets on different kinds of relays, a headache, shot o'wiskey, dinner, more shots o'whiskey, sleep, hangover, breakfast, I began to formulate a theory. The relay uses silver contact material, which is correct for switching moderate power currents. But the COM-NC circuit is a microamp (small-signal) circuit. Small-signal relay contacts always use gold plating. Why? Because gold doesn't oxidise. Silver is more durable and withstands arcing better than gold, but silver oxidizes. The arcing cuts through this oxidation. Microamp current at 24V does not arc and, therefore, does not clear the oxidation. Over time the oxidation builds up, causing contact resistance problems. Obviously a design goof or oversight by engineers on the big island. (This might be one of the reasons why in 1620 a small group of them left and started a colony called Plymouth.)     So what to do? One solution was to add a load resistor to the NC side to pull more current, thereby causing arcing to clear the oxidation. But this would not work on the second relay due to the 100k resistor. What we needed was a relay with silver on the COM-NO side and gold on the COM-NC side and also fit in place of the original relay. Right! What else? Re-designing the circuit was not an option due to down-time and budget constraints. Hum! What followed almost defies commonsense, but we are academia and the rules do not apply. Take a relay, remove the cover then disassemble (see picture). Go to the junk drawer and get an edge-card connector with gold contacts and remove a contact. Un-curl it. Use a rounded-end punch and piece of hardwood to make two bowl-like dimples. Cut out the dimpled areas forming small pieces for soldering over the NC contacts. File the NC contacts down to make room for the gold contacts. Tin the NC contacts. Using the old-school silicon heat-sink compound and wooden tooth-pick, carefully put heat-sink on the convex side of the dimpled contact. This will keep solder from flowing onto that surface (Ssshhh! This is a secret technique so don't tell anyone.) The heat-sink will also hold the small contact to the toothpick so it can be flipped over. Tin the concave side. Heat the relay contact to melt the tinning, then carefully place the concave side of the gold contact over the relay contact and wait for it to heat. Remove the heat and carefully hold until the solder cools. Repeat process for other relay contact. Clean off heat sink. Reassemble relay but leave the cover off. Use bench power supply to cycle the relay and verify the NC contact arm flexes slightly, bending the NC arm as needed. This insures there is contact pressure. Put on cover and store this "special" relay. Breath deeply, have a cup of coffee, and stretch. Move onto the next project—plastic membrane switch/label eaten off the hot plate... chemists!   About two years later, the instrument failed again, alarming in stand-by. Testing showed one "bad" relay and another following suit. Repeat above process on another relay. We installed these "special" relays and tested. No alarms! Yesss! It has been three months now, and only time will tell if these relays fail. The modification for one takes about an hour of delicate work. A second identical mass-spec has since arrived in the department, improving odds on opportunities for us to mod more relays. But, hey, America's got talent! Richard Bedell, electrical engineer, submitted this article as part of Frankenstein's Fix, a design contest hosted by EE Times (US).
  • 热度 22
    2013-7-17 19:08
    1625 次阅读|
    0 个评论
    In my previous blog , I mentioned that I've been invited to give a guest lecture at the ITT Technical Institute in Alabama, United States. As part of this talk, which is planned for the evening of July 29, I want to give the students some real "hands-on" experience—seeing and touching things like relays and vacuum tubes and so forth. Now, I do have a couple of relays lying around here in my office (who doesn't?), but these little scamps tend to be relatively modern—being presented in transparent plastic packages, for example—which doesn't convey quite the sort of impression I'm hoping to achieve. Thus it was that, on my way into work this morning, I took a detour via that downtown electronics wonderland known as Mock Electronics. If truth be told, I'm happy for any excuse to visit the folks at Mock Electronics to discover any new antique delights with which they invariably tempt me. When I explained what I was planning with regard to my talk and asked if they happened to have any old relays lying around, I certainly wasn't surprised when they whipped out the little beauty you see below.   First of all we have the coil, which is wound around a soft iron core, and which can be energized using the two contacts "C1" and C2" (when I returned to my office, my chum Ivan immediately hooked this little beauty up to his power supply and we discovered that it switches at around 4V and consumes only 20mA; based on this, we assume it was actually intended for 5V operation). Next, we have an iron yoke, which provides a low reluctance path for the magnetic flux. Then we have the armature, which pivots around the left-hand side of the yoke. When no voltage is applied to the coil, a spring pulls the armature such that it is held against contact "A." This means that whatever voltage value is being presented to "input" contact "A" is conducted through the armature to "output" contact "Y." When the coil is energized, it attracts the end of the armature in the upper portion of this image, pulling it to the right. Since the armature pivots around the yoke, this causes the end of the armature in the lower portion of this image to move to the left, thereby disengaging from contact "A" and pressing against contact "B." Now, whatever voltage value is being presented to "input" contact "B" is conducted through the armature to "output" contact "Y." The wonderful thing about the relay in the image above is that it offers such a beautiful combination of simplicity (of function) and sophistication (of implementation). Observe how everything can be quickly and easily adjusted, such as the positions of the contacts and the tension on the spring. Depending on how you wire this up, it could act as a simple isolating buffer, where output "Y" = 0V (logic 0) if the coil is not energized or 5V (logic 1) if the coil is energized; or as an inverter, where output "Y" = 5V (logic 1) if the coil is not energized or 0V (logic 0) if the coil is energized. From this, we could construct AND, OR, NAND, and NOR gates; then XOR and NXOR gates; and then registers and so forth. Yes, of course, you know me so well... now I'm being carried away with dreams of getting several thousand of these little beauties and using them to construct something like a simple 4bit processor, but that's something we can talk about on a future occasion... Let's return to the problem of implementing logic gates and registers using only the type of relay shown in the image above. If you haven't worked with relays before, I bet your knee-jerk reaction is to think of using them in much the same way you might use transistor switches, but—generally speaking—it's not quite that simple. As you will soon discover, constructing logical functions using relays can involve a weird and wonderful mixture of simplicity and complexity; if nothing else, it encourages a lot of "out-of-the-box" thinking. Now, rather than me just waffling on and explaining everything in excruciating, let's have some fun with this. As a starting point, can you come up with a circuit symbol and truth table that clearly and concisely represents the operation of this relay? (Please feel free to change the names of the various contacts I called "A," "B,", "Y," "C1," and "C2" to whatever you like if it better suits your purpose.) Based on this, can you create a circuit diagram for a single buffer and then for three of these buffers connected in series? Next, can you create a circuit diagram for a single inverter and then for three of these inverters connected in series. How about creating a circuit diagram for 2-input AND, NAND, OR and NOR gates (a) in isolation, (b) driving one of your buffer gates, and (c) driving one of your inverter gates? Let's leave things here for the moment. If you rise to this challenge, then we'll move on to consider how we might set about implementing register and memory elements.  
相关资源