<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: zhuyue</title>
    <description>The latest articles on DEV Community by zhuyue (@zhangzhuyue).</description>
    <link>https://dev.to/zhangzhuyue</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2223853%2Fb9290cba-0bc2-48ad-b234-9a8e75fe946e.png</url>
      <title>DEV Community: zhuyue</title>
      <link>https://dev.to/zhangzhuyue</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zhangzhuyue"/>
    <language>en</language>
    <item>
      <title>Why the negative voltage with respect to E pole is needed for IGBT driving</title>
      <dc:creator>zhuyue</dc:creator>
      <pubDate>Wed, 06 Nov 2024 14:55:37 +0000</pubDate>
      <link>https://dev.to/zhangzhuyue/why-the-negative-voltage-with-respect-to-e-pole-is-needed-for-igbt-driving-4ba2</link>
      <guid>https://dev.to/zhangzhuyue/why-the-negative-voltage-with-respect-to-e-pole-is-needed-for-igbt-driving-4ba2</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6dp3476zp4z0qslmd4d0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6dp3476zp4z0qslmd4d0.jpg" alt="Image description" width="800" height="1066"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;During the IGBT turn-on process, the voltages at the G and E terminals of the IGBT are represented as: &lt;/p&gt;

&lt;p&gt;$v(t)=A+Be^{-\frac{t}{\tau}}$&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqyungbtyl8vdn95xoaxs.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqyungbtyl8vdn95xoaxs.jpg" alt="Image description" width="800" height="470"&gt;&lt;/a&gt;&lt;br&gt;
Using the three-factor approach, &lt;/p&gt;

&lt;p&gt;$t(0)=A+B=V_L$&lt;/p&gt;

&lt;p&gt;$t(\infty)=A=V_H$&lt;/p&gt;

&lt;p&gt;Therefore, $v(t) = V_H + (V_L - V_H)e^{-\frac{t}{\tau}}$ &lt;/p&gt;

&lt;p&gt;The rise time for charging to the threshold voltage $V_T$ is: &lt;/p&gt;

&lt;p&gt;$t_r=-\tau ln(\frac{V_T-V_H}{V_L-V_H})$&lt;/p&gt;

&lt;p&gt;During the turn-off process of an IGBT, the voltages at the G and E terminals of the IGBT are represented as: &lt;/p&gt;

&lt;p&gt;$v(t)=A+Be^{-\frac{t}{\tau}}$&lt;/p&gt;

&lt;p&gt;Using the three-factor approach, &lt;/p&gt;

&lt;p&gt;$v(0)=A+B=V_H$&lt;/p&gt;

&lt;p&gt;$v(\infty)=A=V_L$&lt;/p&gt;

&lt;p&gt;The result is: $v(t) = V_L + (V_H - V_L)e^{-\frac{t}{\tau}}$ &lt;/p&gt;

&lt;p&gt;The discharge time to $V_T$ is: &lt;/p&gt;

&lt;p&gt;$t_f=-\tau \ln\left(\frac{V_T-V_L}{V_H-V_L}\right)$ &lt;/p&gt;

&lt;p&gt;The power consumption of IGBT includes the loss during conduction and the loss during turn-off; &lt;/p&gt;

&lt;p&gt;Therefore, the total time $t=t_r+t_f$ must be minimized. &lt;/p&gt;

&lt;p&gt;$t=t_r+t_f=-\tau\times ln(\frac{V_T-V_H}{V_L-V_H}\times\frac{V_T-V_L}{V_H-V_L})$&lt;/p&gt;

&lt;p&gt;When $V_T$ and $V_H$ are fixed, choose an appropriate $V_L$ such that t is minimized, i.e.: &lt;/p&gt;

&lt;p&gt;$f(V_L)=ln\left(\frac{V_T-V_H}{V_L-V_H}\times\frac{V_T-V_L}{V_H-V_L}\right)$ attains its maximum; &lt;/p&gt;

&lt;p&gt;Differentiating $f(V_L)$ with respect to $V_L$, we obtain: &lt;/p&gt;

&lt;p&gt;$\frac{f(V_L)}{dV_L}=\frac{2V_T-V_L-V_H}{(V_H-V_L)\times(V_H-V_T)\times(V_T-V_L)}$&lt;/p&gt;

&lt;p&gt;When $V_L=-V_H+2V_T$, $\frac{f(V_L)}{dV_L}=0$ &lt;/p&gt;

&lt;p&gt;When $V_L&amp;lt;-V_H+2V_T$, $\frac{f(V_L)}{dV_L}&amp;gt;0$ &lt;/p&gt;

&lt;p&gt;When $V_L&amp;gt;-V_H+2V_T$, $\frac{f(V_L)}{dV_L}&amp;lt;0$ &lt;/p&gt;

&lt;p&gt;Therefore, when $V_L=2V_T-V_H$, $f(V_L)$ is minimized, meaning that the time required for the IGBT to turn on and off is minimized. &lt;/p&gt;

&lt;p&gt;The IGBT also has the lowest power consumption and the highest efficiency of the power supply. &lt;/p&gt;

&lt;p&gt;In this idealized scenario, the Miller effect and other factors are not taken into account. Adjustments should be made based on the actual waveform obtained through testing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi9zysukwmm99zxh7jeo3.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi9zysukwmm99zxh7jeo3.jpg" alt="Image description" width="800" height="1544"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzqsatcpxgiozlqvcqdxv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzqsatcpxgiozlqvcqdxv.jpg" alt="Image description" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>inverter</category>
    </item>
    <item>
      <title>How to expand the IO number for programmble controller using the self-defined communication protocol</title>
      <dc:creator>zhuyue</dc:creator>
      <pubDate>Tue, 05 Nov 2024 14:52:33 +0000</pubDate>
      <link>https://dev.to/zhangzhuyue/how-to-expand-the-io-number-for-programmble-controller-using-the-self-defined-communication-protocol-4p89</link>
      <guid>https://dev.to/zhangzhuyue/how-to-expand-the-io-number-for-programmble-controller-using-the-self-defined-communication-protocol-4p89</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;Our Wi-Fi IO module customer recently raised a special demand, an AGV integration needs to use 20 digital inputs.&lt;br&gt;
One module only has 12 digital outputs in NPN format, as well as 8 fixed NPN/dry contacts and 6 configurable NPN/PNP/dry contacts, totally 14 digital inputs;&lt;br&gt;
The problem is that, due to cost consideration, the Wi-Fi IO module does not reserve RS485 and other communication interfaces, and even more coincidentally, the output and input interfaces are not connected to the UART port of the microcontroller.&lt;br&gt;
As a senior engineer with rich experience in the field of industrial control and IoT, these problems are obviously not difficult to defeat me.&lt;br&gt;
After a simple analysis, I designed a solution; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd5yaz7ns85fizlfhcsuy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd5yaz7ns85fizlfhcsuy.png" alt="Image description" width="800" height="560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Communication Protocol
&lt;/h2&gt;

&lt;p&gt;In order to achieve data communication between the modules through the input and output ports, I defined a set of communication protocols.&lt;br&gt;
Bit ‘0’ is represented by a high/low level of duration T, bit ‘1’ is represented by a high/low level of duration T, and bit ‘1’ is represented by a high/low level of duration T.&lt;br&gt;
Bit ‘1’ is represented by a high/low level with a duration of 2T.&lt;br&gt;
A byte consists of 8 Bits of data bits, each of which flips the level;&lt;br&gt;
A data frame consists of two bytes of frame header 55FF, one byte of data length, and N bytes of Payload, one byte of CRC checksum, leaving 5T frame interval between frames;&lt;br&gt;
Communication Processing&lt;br&gt;
Use the external interrupt of MCU's IO port to receive data.&lt;br&gt;
At the same time, enable the rising and falling edge interrupts of the IO port, enable a timer for timing, and execute the interrupt procedure when the level change of the IO port occurs, in which the timing value of the current timer is obtained, and the difference between the timing value and the timing value of the last time the interrupt was entered is calculated.&lt;br&gt;
If the difference is &amp;gt;1.5T, it means that the current received data bit is 1, otherwise it is 0. The current received data bit is cached, and when a Byte of data is received, it is sent to the receive ring queue for the main program to parse the data frame;&lt;br&gt;
Use the system's Tick Clock interrupt for sending data, in the Tick Clock interrupt with a period of 250us to determine if there is any data to send, if there is a need to send data, a byte variable is counted, and the bit that is sent is a 1, then when the count value is a 2, the IO port is flipped, otherwise when the count value is a 1, the IO port is flipped;&lt;br&gt;
With the addition of this communication protocol, the whole set of code enables only the Tick clock and external interrupts.&lt;br&gt;
The Tick clock interrupt occurs at 250us, and in this interrupt routine, only some simple time timing and data sending are done, and for the STM32F103 processor with 72MHz selected as the main frequency, the worst case running time is about 5us;&lt;br&gt;
The external interrupts also occur at 250us, and the worst-case running time is also about 5us;&lt;br&gt;
The worst-case interrupt load factor is 10/250 = 4%, according to the Ford SDS requirements, the load factor must be less than 30%;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flqgpeomdqe8efldz03sd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flqgpeomdqe8efldz03sd.jpg" alt="Image description" width="800" height="503"&gt;&lt;/a&gt;&lt;br&gt;
While the main program has no dead wait operation, the worst case cycle time is about 600us, in the software function of the device, the input detection is designed according to the worst 2ms operation cycle, after considering the interrupt influence, the worst case load rate of the processor is 600/0.96/2000=31%;&lt;br&gt;
There is a risk of failure, if the communication input signal contains interfering signals, causing the IO port to generate high frequency signal flip-flops, the MCU will enter external interrupts frequently, the occurrence cycle can be much less than 250us, and the processor will be busy with external interrupt routines, which will lead to other functional abnormalities;&lt;br&gt;
According to Ford's requirements, this situation requires the addition of a low-pass filter in the external signal input circuit, and the change in the signal edge caused by the filter has been analysed by WCCA, and in the worst case the time consumed to rise from 10% to 90%, or to fall from 90% to 10%, is less than 10% of the time of the data bits;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hardware Processing
&lt;/h2&gt;

&lt;p&gt;There are several factors affecting the data waveform, i.e. pulse, throughout the hardware loop:&lt;br&gt;
1) The response time of the Darlington transistor MJD122 used for the output, which, from the specifications, has a rise and fall time of 10us, which has a negligible effect on the data with a minimum pulse width of 250us;&lt;br&gt;
(2) The response time of the optocoupler, from the specification, has a typical value of 4us and a maximum value of 18us;&lt;br&gt;
(4) The charging and discharging time of the input and output parasitic capacitors of the optocoupler, the input capacitance is 150pF at maximum, the input resistance is 3.3kΩ, and the time constant is 0.5nS, which has little effect, but from the curves of the load resistance and the response time, it can be seen that the resistance value of the load resistor has an effect on the rise and fall time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxufysct9yi3d9i5j9jt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdxufysct9yi3d9i5j9jt.jpg" alt="Image description" width="800" height="727"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And according to the module input detection circuit, as shown in the following figure: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuc74717yp1gzj3t5fbe8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuc74717yp1gzj3t5fbe8.jpg" alt="Image description" width="800" height="870"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the NPN input is low, the optocoupler is turned on, and the LED D47 is also turned on. At this time, the load resistance of the optocoupler is approximately R106 and the internal pull-up resistance of the MCU, which is about 3.0K (3.3K//40K), the fall time is about 40us. When the NPN input is high impedance, the optocoupler is turned off, and the LED D47 is also turned off. At this time, the load resistance of the optocoupler is the internal pull-up resistance of the MCU, which is maximum around 50K, the rise time will be more than 100us; &lt;/p&gt;

&lt;p&gt;For a 250 us pulse width of bit 0, a change of more than 125 us will occur, which exceeds the judgment threshold of bit 1 by 375 us, causing it to be misjudged as bit 1, resulting in an error code and causing communication anomalies. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdatdhw4hx0fc0pqd59q8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdatdhw4hx0fc0pqd59q8.jpg" alt="Image description" width="800" height="599"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The optical coupler output waveform when D47 is not short-circuited. &lt;/p&gt;

&lt;p&gt;To solve this problem, I short-circuited D47, so that the load resistance when the optical coupler is turned off becomes 3.0KΩ, and communication resumes to normal. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy7568lladi1dveihr32v.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy7568lladi1dveihr32v.jpg" alt="Image description" width="800" height="599"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Short-circuit the output waveform of the D47 optical coupling. &lt;/p&gt;

&lt;p&gt;At worst, because the response time and load resistance curves are data at ambient temperature, if a 2x safety margin is considered, the rise and fall times can be up to 80 us. The delay of the Darlington transistor is calculated at 20 us, which leads to a pulse variation of 100 us. Additionally, consider a 5 us interrupt response time; &lt;/p&gt;

&lt;p&gt;The pulse width of BIT0 will be increased from a maximum of 250 us to 355 us, leaving a margin of 20 us compared to the judgment threshold value of 375 us, which should ensure reliable reception. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Develop the management system on cloud for simple programmble controller.</title>
      <dc:creator>zhuyue</dc:creator>
      <pubDate>Tue, 29 Oct 2024 11:44:29 +0000</pubDate>
      <link>https://dev.to/zhangzhuyue/develop-the-management-system-on-cloud-for-simple-programmble-controller-1pbe</link>
      <guid>https://dev.to/zhangzhuyue/develop-the-management-system-on-cloud-for-simple-programmble-controller-1pbe</guid>
      <description>&lt;p&gt;These two days, I am modifying the management system of the programmable controller on cloud, which uses VUE as the front-end framework, PHP as the back-end development language, and mysql and redis to store data.&lt;/p&gt;

&lt;p&gt;redis stores real-time data during operation, such as the real-time status of device input and output, while mysql stores configuration data, including user and device data.&lt;/p&gt;

&lt;p&gt;The front-end is forwarded by the Internet of Things gateway on the cloud server through websocket communication, and the remote programmable controller is interconnected.&lt;/p&gt;

&lt;p&gt;Use the wx SDK to obtain the user's authentication information. When the user opens the web page through the WX public account, the WX authentication directly logs in to the system, eliminating the login process.&lt;/p&gt;

&lt;p&gt;When the user opens the web page with the browser, the user can also enter the user name and password to log in;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5p43650inmosrhdyprt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo5p43650inmosrhdyprt.jpg" alt="Image description" width="654" height="588"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu5xjxmg38k3r7g8pmrpn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu5xjxmg38k3r7g8pmrpn.jpg" alt="Image description" width="703" height="928"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vue</category>
      <category>php</category>
    </item>
    <item>
      <title>Why I use ESP8266-07s not ESP8266-01S for simple programmable controller</title>
      <dc:creator>zhuyue</dc:creator>
      <pubDate>Mon, 28 Oct 2024 03:04:24 +0000</pubDate>
      <link>https://dev.to/zhangzhuyue/why-i-use-esp8266-07s-not-esp8266-01s-for-simple-programmable-controller-40bo</link>
      <guid>https://dev.to/zhangzhuyue/why-i-use-esp8266-07s-not-esp8266-01s-for-simple-programmable-controller-40bo</guid>
      <description>&lt;p&gt;&lt;strong&gt;1. Background&lt;/strong&gt;&lt;br&gt;
Because of the concern about the reliability of ESP8266 chipset, learning from the SpaceX rocket redundancy design ideas, ready to use two ESP8266 on the controller to work together to improve reliability.&lt;/p&gt;

&lt;p&gt;Not yet a few months, this is an accident.&lt;/p&gt;

&lt;p&gt;The customer feedback a few months after the installation, the Wi-Fi hotspot of the controller can not be found, and it can't be restored by rebooting.&lt;/p&gt;

&lt;p&gt;And the fault device was sent back for root cause analysis.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Flash content comparison&lt;/strong&gt;&lt;br&gt;
After receiving it, I first connected the serial cable to the Wi-Fi module and monitored the output logo when it was powered on.&lt;/p&gt;

&lt;p&gt;I found that compared with the normal module, the fault product could not fetch the correct firmware from the flash address of address 0x1000, and guessed that the flash data might have been damaged abnormally.&lt;/p&gt;

&lt;p&gt;So, I downloaded the esptool.py tool and read the firmware to the computer through the read_flash command, and I could read the whole flash content normally, and compared it with the downloaded content, and I didn't find any difference.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2i0ajq9bqilcdwf9o056.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2i0ajq9bqilcdwf9o056.png" alt="Image description" width="800" height="476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. EFUSE error analysis&lt;/strong&gt;&lt;br&gt;
I downloaded the firmware with the flash download tool again, but found that it prompted an eFuse detection error.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0kadesva5v2vkzzj4y0q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0kadesva5v2vkzzj4y0q.png" alt="Image description" width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use the serial port debugging  to capture the interaction data of the downloaded firmware and compare it with the download protocol defined by the manufacturer.&lt;/p&gt;

&lt;p&gt;It was found that in addition to synchronization messages, the download tool also reads eFuse data content from the module.&lt;/p&gt;

&lt;p&gt;The normal module (MAC address BC:FF:4D:07:C8:8A) returns the data as:&lt;/p&gt;

&lt;p&gt;c0 01 0a 02 00 00 00 da 8a 00 00 c0&lt;/p&gt;

&lt;p&gt;c0 01 0a 02 00 c8 07 00 02 00 00 c0 /&lt;/p&gt;

&lt;p&gt;c0 01 0a 02 00 00 00 b0 00 31 00 00 00 c0&lt;/p&gt;

&lt;p&gt;c0 01 0a 02 00 4d ff bc 00 00 00 00 c0&lt;/p&gt;

&lt;p&gt;According to the protocol comparison, the corresponding efuse data are:&lt;/p&gt;

&lt;p&gt;00 00 DA 8A, C8 07 00 02, 00 B0 00 31, 4D FF BC 00&lt;/p&gt;

&lt;p&gt;The faulty module (MAC address C4:5B:BE:59:80:34) returns the data as:&lt;/p&gt;

&lt;p&gt;c0 01 0a 02 00 01 01 ef 34 00 00 c0&lt;/p&gt;

&lt;p&gt;c0 01 0a 02 00 80 59 00 02 00 00 c0&lt;/p&gt;

&lt;p&gt;c0 01 0a 02 00 00 00 b0 00 b7 00 00 c0&lt;/p&gt;

&lt;p&gt;c0 01 0a 02 00 be 5b c4 00 00 00 00 c0&lt;/p&gt;

&lt;p&gt;According to the protocol comparison, the corresponding efuse data is:&lt;/p&gt;

&lt;p&gt;01 01 ef 34, 80 59 00 02, 00 b0 00 b7, be 5b c4 00&lt;/p&gt;

&lt;p&gt;According to the eFuse description in the table below, the&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fugefxg5rrpwyc8kdf099.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fugefxg5rrpwyc8kdf099.png" alt="Image description" width="800" height="661"&gt;&lt;/a&gt;&lt;br&gt;
Among them, flag3, the value of normal module is 0 indicates that it is non-ESP8285 chip, while the value of fault module is 1 indicates that it is ESP8285 chip, which is actually ESP8266, resulting in the download tool judging that the eFuse inspection is wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Failure Analysis&lt;/strong&gt;&lt;br&gt;
eFuse is a special piece of storage space in the chip, which is internally connected to each other by fuses.&lt;/p&gt;

&lt;p&gt;When the current flowing through it reaches a certain level, the fuse will be burnt and the value of the bit will change.&lt;/p&gt;

&lt;p&gt;Fuse burning is non-recoverable.&lt;/p&gt;

&lt;p&gt;Therefore, the value of eFuse can only be written once and can only be changed from 0 to 1.&lt;/p&gt;

&lt;p&gt;When writing eFuse, you must be very careful and avoid static electricity and high temperature to prevent the eFuse from being broken.&lt;/p&gt;

&lt;p&gt;According to the above analysis, it should be because of static electricity, high temperature or even space electromagnetic interference, which causes the data of eFuse to be destroyed, and ultimately leads to the program not being able to start normally.&lt;/p&gt;

&lt;p&gt;Next, I am going to replace ESP-01S with ESP-07S.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ESP-07S has the following advantages:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1) External antenna can be connected to increase the range of wireless signal.&lt;/p&gt;

&lt;p&gt;2) Passed CE, FCC certification, electromagnetic compatibility is guaranteed.&lt;/p&gt;

&lt;p&gt;3) With metal shell, it can screen the interference signal.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx5ef68blgujt587rpwk0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx5ef68blgujt587rpwk0.png" alt="Image description" width="648" height="841"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>esp8266</category>
      <category>efuse</category>
    </item>
    <item>
      <title>New Wi-Fi IO module using an advanced Wi-Fi module for AGV integration</title>
      <dc:creator>zhuyue</dc:creator>
      <pubDate>Sat, 26 Oct 2024 13:36:46 +0000</pubDate>
      <link>https://dev.to/zhangzhuyue/new-wi-fi-io-module-using-an-advanced-wi-fi-module-integrating-with-agv-1m5j</link>
      <guid>https://dev.to/zhangzhuyue/new-wi-fi-io-module-using-an-advanced-wi-fi-module-integrating-with-agv-1m5j</guid>
      <description>&lt;p&gt;This is a wireless input/output controller for AGVs, which has recently been updated with a high-performance Wi-Fi module.&lt;br&gt;
The new product has the following function highlights:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Support WPA3 and WPA2 enterprise authentication methods, which can access the wireless network of all factories.&lt;/li&gt;
&lt;li&gt;When selecting WPA2-PSK authentication method, the maximum length of the password supports 64 characters.&lt;/li&gt;
&lt;li&gt;Built-in 2.4G/5G router module with small size saves space in the control box.&lt;/li&gt;
&lt;li&gt;When the computer is connected to the IO controller, it can obtain the IP from the controller through DHCP, and there is no need to manually set the IP of the computer.&lt;/li&gt;
&lt;li&gt;greatly simplify the configuration operation, only need to connect the AP, configuration WAN, LAN/AP, no need for port mapping and other cumbersome operations&lt;/li&gt;
&lt;li&gt;Supports HTTPS/TLS, increasing the security of communication.&lt;/li&gt;
&lt;li&gt;Increase the controller's programmed access rights control to improve security&lt;/li&gt;
&lt;li&gt;Based on the SDK of the Wi-Fi module for secondary development, it realizes the serial port forwarding of multi-channel TCP socket communication, which improves the communication rate of TCP/IP and concurrent performance.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhhcbntfu2c6nuyd8xh10.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhhcbntfu2c6nuyd8xh10.jpg" alt="Image description" width="800" height="552"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fohr7ffd6wf6y9wqfamlp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fohr7ffd6wf6y9wqfamlp.jpg" alt="Image description" width="800" height="712"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqk38t14jwjo8my10i6h6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqk38t14jwjo8my10i6h6.jpg" alt="Image description" width="800" height="749"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>agv</category>
      <category>automation</category>
      <category>wifi</category>
    </item>
    <item>
      <title>Use TL431 to detect battery voltage by the ADC without reference input</title>
      <dc:creator>zhuyue</dc:creator>
      <pubDate>Fri, 25 Oct 2024 13:59:07 +0000</pubDate>
      <link>https://dev.to/zhangzhuyue/use-tl431-to-detect-battery-voltage-by-the-adc-without-reference-input-130o</link>
      <guid>https://dev.to/zhangzhuyue/use-tl431-to-detect-battery-voltage-by-the-adc-without-reference-input-130o</guid>
      <description>&lt;p&gt;A customer has a product that uses a 3.7V lithium battery to power a control circuit that controls actuators such as motors according to certain logic.&lt;/p&gt;

&lt;p&gt;The processor needs to detect the battery voltage in order to stop responding to user inputs and send out an alert signal when the battery is discharged below a certain level.&lt;/p&gt;

&lt;p&gt;Because of cost considerations, the customer chose a very low-cost, simple processor that operates in the 3.0V-5.0V range and has an ADC that does not have a dedicated reference voltage input, but instead uses the power supply as a reference voltage.&lt;/p&gt;

&lt;p&gt;Previously, for the similar products, lithium battery feeds directly to the processor, but when the need to detect battery voltage, if it is done by a fixed voltage divider, when the battery voltage changes, the ADC's reference voltage also follows the change, resulting in the reading of the ADC value is always a fixed value, will not change with the change of the battery voltage; &lt;/p&gt;

&lt;p&gt;The customer's idea is to use a 3.3V LDO, the lithium battery is regulated to 3.3V by the LDO to supply power to the processor, so that the processor's ADC can get a fixed reference voltage.&lt;/p&gt;

&lt;p&gt;I think, there are several problems for this method.&lt;br&gt;
1) Voltage drop, when the load current is above 100mA, the voltage drop between the input and output of the LDO reaches at least 300mV or more, meaning that the input voltage reaches 3.6V or more before the output voltage can be constant at 3.3V, and the Li-Ion battery still has quite a large volume at 3.6V.&lt;/p&gt;

&lt;p&gt;2) Low voltage, with the lithium battery discharge, the voltage continues to drop, when the drop to the LDO can not properly regulate the voltage, the output voltage of the LDO will follow the input voltage changes, resulting in the voltage detection of the ADC value may be a fixed value, thus the battery voltage will be misclassified as a normal high voltage; &lt;/p&gt;

&lt;p&gt;2) Cost, the LDO and peripheral devices need at least 0.5RMB cost, which is a very huge cost for small appliances that are extremely cost sensitive; &lt;/p&gt;

&lt;p&gt;Based on these analyses, I offer another solution using a TL431 as a reference; &lt;/p&gt;

&lt;p&gt;When the processor needs to detect the battery voltage, a high level is output by PA4, which is the supply voltage VDD.&lt;br&gt;
ADC detection through PA5 to get the value AD, for 12-bit ADC detection, the&lt;br&gt;
Calculate to get the supply voltage by the following formula:&lt;/p&gt;

&lt;p&gt;VDD=2.5*4096/AD. &lt;/p&gt;

&lt;p&gt;Because the TL431 can normally regulate the output current as low as 0.5mA or so, in order to achieve 3.0V can still work properly, the resistance value of resistor R26 is selected as&lt;br&gt;
The resistance value of resistor R26 is selected as 1K, And the following formula is calculated:&lt;br&gt;
(VDD-2.5)/R26&amp;gt;0.5mA=&amp;gt;R26&amp;lt;1K. &lt;/p&gt;

&lt;p&gt;When the battery voltage decreases below the point that the TL431 cannot work normally, the input voltage value of PA5 pin is the output voltage value VDD of PA4;&lt;br&gt;
At this time, the AD value detected by PA5 pin is VDD/VDD*4096=4096; &lt;br&gt;
In this case, the programme calculates the power supply voltage value of VDD = 4096 * 2.5/4096 = 2.5V. &lt;/p&gt;

&lt;p&gt;which is completely different from the result obtained by using the LDO scheme.&lt;/p&gt;

&lt;p&gt;From the point of view of DFMEA analysis, the LDO scheme will misjudge the battery voltage as normal at low voltage and perform normal action, which may lead to serious consequences, which is unacceptable.&lt;/p&gt;

&lt;p&gt;It is very important that designing a product should not only focus on the normal function, but also require an in-depth DFEMA analysis to ensure that the abnormal mode will not affect the product with serious abnormality.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fitv0fvr1y5xyruyuukl1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fitv0fvr1y5xyruyuukl1.jpg" alt="Image description" width="780" height="732"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>schmatic</category>
    </item>
    <item>
      <title>Optimize VUE packaing by external importing to reduce the page loading time greatly for ESP8266 programmable controller.</title>
      <dc:creator>zhuyue</dc:creator>
      <pubDate>Fri, 25 Oct 2024 00:35:49 +0000</pubDate>
      <link>https://dev.to/zhangzhuyue/optimize-vue-packaing-by-external-importing-to-reduce-the-page-loading-time-greatly-for-esp8266-programmable-controller-3adb</link>
      <guid>https://dev.to/zhangzhuyue/optimize-vue-packaing-by-external-importing-to-reduce-the-page-loading-time-greatly-for-esp8266-programmable-controller-3adb</guid>
      <description>&lt;p&gt;Import external packets via CDN to optimize the size of js packets of VUE and improve the loading speed of remote device management control system of ESP8266 programmable controller.&lt;br&gt;
In the past few days, I started to modify the programmable controller's cloud management system to integrate into WeChat Public Account for convenient control without APP and to realize the cloud functions such as cloud phone alarm, data logging and analysis.&lt;/p&gt;

&lt;p&gt;Then, after generating a web page through "cnpm run build" and opening the page with a browser, if it is loaded firstly without local cache, it took about 15 seconds to load and display the login or device list page, it's too long to seriously affect the user experience.&lt;br&gt;
Among the files loaded, the file named vendor.xxxx.js has a size of 6 MByte and took about 12 seconds.&lt;/p&gt;

&lt;p&gt;The Webpack packaging tool generates this file by packaging together the components imported by the web page.&lt;/p&gt;

&lt;p&gt;Install the webpack-bundle-analyzer component and configure webpack.base.config.js to&lt;br&gt;
plugins: [&lt;br&gt;
new BundleAnalyzerPlugin&lt;br&gt;
], and&lt;br&gt;
After the building, automatically open the page, It can be found that the element UI in the vendor.js takes up the most space, reaching 6Mbyte.&lt;br&gt;
This is because, when main.js imports element UI, it does so by&lt;br&gt;
import ElementUI from 'element-ui'&lt;br&gt;
which imports the entire element-UI.&lt;/p&gt;

&lt;p&gt;The space occupied by element UI can be reduced by partial import; &lt;br&gt;
For example.&lt;br&gt;
import { MessageBox } from 'element-ui'; &lt;/p&gt;

&lt;p&gt;In addition, instead of packaging the element-UI into vendor.js, it can also load the js and css files from the CDN via script and link tags in index.html. The advantage of doing so is that the browser will download these files from the public CDN servers, so the bandwidth is guaranteed, and it doesn't consume the bandwidth and CPU resources of the cloud server, reduce the investment cost of the cloud server.&lt;/p&gt;

&lt;p&gt;In webpack.base.config.js, add a note about externals.&lt;br&gt;
externals: {&lt;br&gt;
'vue': 'Vue', 'element-ui': {&lt;br&gt;
'element-ui': 'ELEMENT'&lt;br&gt;
}&lt;br&gt;
Remove the vue as well as element UI imports in main.js.&lt;br&gt;
Add loading of js and css files in index.html; &lt;br&gt;
``&lt;br&gt;
After the process, the file size of vendor.js is reduced from 6.8MByte to 2.0MByte; &lt;br&gt;
Without no cache, the page loading time reduced from 15s to 3s, which is perfect.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkmvppzjcqecnsvji5lwr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkmvppzjcqecnsvji5lwr.jpg" alt="Image description" width="800" height="377"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqd1qc6w2l8ufqoz78tlt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqd1qc6w2l8ufqoz78tlt.jpg" alt="Image description" width="800" height="209"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fudkr927jaor9gzcgtrht.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fudkr927jaor9gzcgtrht.jpg" alt="Image description" width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdpttf6wao1ydn5r11b8m.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdpttf6wao1ydn5r11b8m.jpg" alt="Image description" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1sq1ph2khm0b5avse8lb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1sq1ph2khm0b5avse8lb.jpg" alt="Image description" width="800" height="439"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vue</category>
      <category>esp8266</category>
      <category>cloud</category>
    </item>
    <item>
      <title>What's the product cost for 30 samples of ESP8266 based programmable controller.</title>
      <dc:creator>zhuyue</dc:creator>
      <pubDate>Thu, 24 Oct 2024 00:10:56 +0000</pubDate>
      <link>https://dev.to/zhangzhuyue/whats-the-product-cost-for-30-samples-of-esp8266-based-programmable-controller-3dk2</link>
      <guid>https://dev.to/zhangzhuyue/whats-the-product-cost-for-30-samples-of-esp8266-based-programmable-controller-3dk2</guid>
      <description>&lt;p&gt;After adding the RS485 communication circuit, I logged in JLC online system, placed an order for PCBs as well as SMT solder to produce 30 piece samples.&lt;/p&gt;

&lt;p&gt;Total cost for PCB + SMT is 668.51RMB, 22.28 per piece;&lt;br&gt;
Plus 6.60RMB for the ESP8266-07S module, 2RMB for the terminals, 6RMB for the housing, and 3RMB for the relay; &lt;/p&gt;

&lt;p&gt;Total cost is 40RMB; &lt;/p&gt;

&lt;p&gt;if the selling price could be 50RMB excluding freight, I won't lose money.&lt;/p&gt;

&lt;p&gt;Need continue  to investigate how to reduce cost, the current production cost per piece of about 13 RMB, I think the production cost can be reduced    steeply in mass production. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdx9n6t907pbsmz9xw94d.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdx9n6t907pbsmz9xw94d.jpg" alt="Image description" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8f58snzo2tz3gqwxzg8m.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8f58snzo2tz3gqwxzg8m.jpg" alt="Image description" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ful2idh2df8cp1dwcut0c.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ful2idh2df8cp1dwcut0c.jpg" alt="Image description" width="382" height="889"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Add RS485 interface to interact with 3rd party sensor &amp; acuator by MODBUS protocol</title>
      <dc:creator>zhuyue</dc:creator>
      <pubDate>Tue, 22 Oct 2024 15:26:02 +0000</pubDate>
      <link>https://dev.to/zhangzhuyue/add-rs485-interface-to-interact-with-3rd-party-sensor-acuator-by-modbus-protocol-3jl7</link>
      <guid>https://dev.to/zhangzhuyue/add-rs485-interface-to-interact-with-3rd-party-sensor-acuator-by-modbus-protocol-3jl7</guid>
      <description>&lt;p&gt;The software design of ESP8266-based programmable controller as well as testing is nearly completed, including:&lt;br&gt;
Controller software,&lt;br&gt;
The built-in web page,&lt;br&gt;
PC tool developed by delphi to download web pages and firmware,&lt;br&gt;
IOT gateway developed by PHP, &lt;br&gt;
Remote web pages in cloud, &lt;br&gt;
Still need to complete the WX integration, cloud platform management system, third-party APP integration and other functions; &lt;br&gt;
Simultaneously start to update the hardware.&lt;/p&gt;

&lt;p&gt;Considering that MODBUS protocol sensors or actuators via RS485 is also a commonly used function, also data acquisition via RS45 may be required, &lt;br&gt;
If the controller doesn't supprort RS485, it will be a pity.&lt;/p&gt;

&lt;p&gt;Good news is an empty area exists next the output relay; &lt;/p&gt;

&lt;p&gt;Therefore, I added the RS485 communication circuit, in order to avoid surge voltage/current into the communication port to damage the RS485 communication chip, further surges into ESP8266 and damage it, I added two unipolar TVS at the port, And two current-limiting resistor are connected in series, also current-limiting resistors are connected  between the communication chip and the module, to provent the surge.&lt;/p&gt;

&lt;p&gt;In order to be compatible with the 3.3V operating voltage of the ESP8266, the RS485 communication chip is selected the 3.3V operating voltage model.&lt;/p&gt;

&lt;p&gt;ESP8266 may be not realtime enough to  meet the requirements of the MODBUS protocol 3.5 character as a Modbus slave, but as a MODBUS master, it should be no realtime problem.&lt;br&gt;
A few years ago, the design of the circuit has a very cumbersome work, that is, the schematic package and PCB package design, with the electronic component online store, such work has been greatly simplified, the online EDA can provide a schematic package and PCB package, can be imported into the office EDA for direct use.&lt;/p&gt;

&lt;p&gt;The concerning is that for the high voltage surge, even after the TVS clamp, may still be far more than 3.3V, such high voltage into the RS485 communication chip may lead to the chip port and power supply voltage is raised, resulting in damage to the module, need to do a detailed test subsequently; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq54i197e68icu5lgna83.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq54i197e68icu5lgna83.jpg" alt="Image description" width="800" height="968"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcp64w1k0hkfalsqez8l6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcp64w1k0hkfalsqez8l6.jpg" alt="Image description" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn2ow63jdijkqpp5x0dj2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn2ow63jdijkqpp5x0dj2.jpg" alt="Image description" width="482" height="788"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>esp8266</category>
      <category>rs485</category>
      <category>modbus</category>
    </item>
    <item>
      <title>Hardware and PCB design considerations for ESP8266 based programmable controller.</title>
      <dc:creator>zhuyue</dc:creator>
      <pubDate>Tue, 22 Oct 2024 07:18:11 +0000</pubDate>
      <link>https://dev.to/zhangzhuyue/hardware-and-pcb-design-considerations-for-esp8266-based-programmable-controller-5ffo</link>
      <guid>https://dev.to/zhangzhuyue/hardware-and-pcb-design-considerations-for-esp8266-based-programmable-controller-5ffo</guid>
      <description>&lt;p&gt;The development of a simple programmable controller with two potential-free binary inputs and two potential-free binary outputs is completed, I plan to manufacture 50 prototype samples directly from online PCBA service &lt;a href="https://www.jlc.com" rel="noopener noreferrer"&gt;https://www.jlc.com&lt;/a&gt; directly, which is convenient and also low cost.&lt;/p&gt;

&lt;p&gt;There are several considerations in the schematic and PCB design:&lt;br&gt;
(1) output using 10A HonFa relay HF3FF, the coil drive voltage of 5.0V, when driven by a Darlington transistor, the output voltage drop may be about 0.5V, the requirements of the power supply voltage connected to the other end of the coil to 5.5V or more in order to ensure that the relay reliably suction.&lt;br&gt;
Therefore, I chose a DC-DC with adjustable output voltage, and set the output voltage of the DC-DC to 5.5V by choosing a suitable feedback resistor, and then supply power to the ESP8266 through the LDO LM1117-3.3V down to 3.3V;&lt;/p&gt;

&lt;p&gt;(2) Use bidirectional optocoupler for the input isolation , one of the input pin through the current-limiting resistor to the external input terminals, while the other pin through the jump cap to connect to ground or power supply, when connected to ground, support for PNP or dry contact type digital input, when connected to the power supply, support for NPN or dry contact type digital input;&lt;/p&gt;

&lt;p&gt;The current limiting resistor uses a 3.3K resistor, which can provide a current of 3.6mA-7.2mA when the contacts of the external mechanical switch or relay are closed, which can play a role in wetting the current and help to improve the service life of the external switch or relay;&lt;/p&gt;

&lt;p&gt;3) The output needs to support the control of 220V high voltage power, and it is necessary to consider the isolation between high and low voltage, therefore, the relay and the output terminals occupy one side separately, while the power supply and the two inputs occupy the other side;&lt;/p&gt;

&lt;p&gt;4) Using a housing sold in the market, after measuring the dimensions with calipers, draw the sketch of housing by autocad, import the autocad file to protel, set the imported lines to the keepout layer as the border of the PCB.&lt;/p&gt;

&lt;p&gt;5) As the controller can be mounted into the control cabinet, it is not suitable to use PCB on-board antenna or ceramic antenna, in addition, the size of the housing is very limited, therefore, the external PCB antenna with IPEX interface is used and sticked to the housing. The SMA antenna terminal is also reserved next to the input terminal, which can be transferred to the SMA holder through the IPEX wiring, so that the user can use the external antenna to connect to the terminal.&lt;/p&gt;

&lt;p&gt;6) A push button is reserved for users to restore the factory settings when they forget the Wi-Fi password, otherwise the device may turn into a brick once the password is forgotten.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Folm416zdr63ze57e6u15.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Folm416zdr63ze57e6u15.jpg" alt="Image description" width="800" height="517"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>hardware</category>
      <category>esp8266</category>
      <category>pcb</category>
    </item>
    <item>
      <title>Why I don't dynamically allocate RAM memory for ESP8266 based simple programmable controller</title>
      <dc:creator>zhuyue</dc:creator>
      <pubDate>Tue, 22 Oct 2024 05:03:56 +0000</pubDate>
      <link>https://dev.to/zhangzhuyue/why-i-dont-dynamically-allocate-ram-memory-for-esp8266-based-simple-programmable-controller-2d3l</link>
      <guid>https://dev.to/zhangzhuyue/why-i-dont-dynamically-allocate-ram-memory-for-esp8266-based-simple-programmable-controller-2d3l</guid>
      <description>&lt;p&gt;Using ESP8266 to design the controller for script programming, I think the RAM space of ESP8266 is only 96kB, if the program occupies the memory through dynamic memory allocation, it will affect the execution efficiency and reliability of the program.&lt;/p&gt;

&lt;p&gt;The controller has many functions and complex code, it is difficult to control the allocation and release of memory, also difficult to ensure that there will not be a failure to allocate memory, at this time, the exception handling and waiting for the memory free will become complex, and will inevitably affect the efficiency of the program execution, finally affects the efficiency of the controller, timing and logic.&lt;/p&gt;

&lt;p&gt;Therefore, when I designed the code, I allocated a fixed amount of memory to several important functional modules, including the cache for sending and receiving data from the TCP server and client, the cache for parsing the HTTP protocol, and the write cache for rewriting the script program in flash.&lt;/p&gt;

&lt;p&gt;This allocation, 96kByte is stretched to the limit, after the development of all the functions, only about 7kByte heap size left.&lt;/p&gt;

&lt;p&gt;In many places, time must be sacrificed for RAM space.&lt;br&gt;
For example, when designing the remote firmware upgrade function, encountered the problem of reading and writing flash memory requires 4-byte alignment, not only read and write the address and length of the data need to be 4-byte alignment, and memory constraints can't be fixed by just allocating enough memory to move the data to achieve 4-byte memory, can only be directly in the upper level of the data passed down to the data memory operation, and the data memory address is not 4-byte aligned, passed directly to the function spi_flash_read/spi_flash_write operation, then it will throw the data alignment exception with error code 9 and reboot.&lt;/p&gt;

&lt;p&gt;In the end, I can only add additional codes to achieve 4-byte alignment of the address and data length, and read and write by a word (4 bytes) as a unit one by one, and read and write from the upper level  in units of bytes.&lt;/p&gt;

&lt;p&gt;Actual test, it does affect the read and write speed of flash, resulting in a longer time to upgrade the firmware.&lt;/p&gt;

&lt;p&gt;However, the upgrade is an infrequently used function, a little longer time is acceptable, stability is still the most important.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmx2s01phsrvi01c74d7g.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmx2s01phsrvi01c74d7g.jpg" alt="Image description" width="800" height="517"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>esp8266</category>
    </item>
    <item>
      <title>RAM and flash usage for ESP8266 based simple programmable controller.</title>
      <dc:creator>zhuyue</dc:creator>
      <pubDate>Tue, 22 Oct 2024 03:02:06 +0000</pubDate>
      <link>https://dev.to/zhangzhuyue/ram-and-flash-usage-for-esp8266-based-simple-programmable-controller-5197</link>
      <guid>https://dev.to/zhangzhuyue/ram-and-flash-usage-for-esp8266-based-simple-programmable-controller-5197</guid>
      <description>&lt;p&gt;For the programmable controller based on ESP8266, built-in web page Chinese programming, two digital inputs and two relay outputs, the codes are complete now start to the further optimization as well as reliability testing.&lt;/p&gt;

&lt;p&gt;After running the application, the ESP8266 still has about 6K of RAM space left.&lt;br&gt;
Flash space is used as follows:&lt;br&gt;
512kByte is used to store web pages;&lt;br&gt;
256kByte for storing Chinese programs written by users through web pages;&lt;br&gt;
4kByte for storing user configuration data;&lt;br&gt;
4kByte for backing up user configuration data;&lt;br&gt;
4kByte for storing bootloader programs;&lt;br&gt;
1MByte for storing application programs;&lt;br&gt;
1MByte for firmware upgrade;&lt;br&gt;
A total of 2.7MByte of space is required.&lt;br&gt;
The Flash space size of ESP8266-07S is 4MByte, and there is still a lot of Flash space left;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2cpll12spu3fb1atn6h4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2cpll12spu3fb1atn6h4.jpg" alt="Image description" width="800" height="426"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>esp8266</category>
    </item>
  </channel>
</rss>
