PLC 跟傳統語言不一樣的地方,由於每一個 statement 都必須有執行條件,因此 FOR 迴圈裡面的每一個 statement 前面放了 LD X1 指令,以便用按鍵來觀察計算結果。
使用價格較便宜的 FX3U-485-BD 發送 modbus 封包至遠端繼電器 (9600, E81, modbus addr#1), 使用 Function 5 控制燈泡, 這是查閱 MITSUBISHI_FX3U-Users-Manual-Data-Communications-Networking (JY997D16901C), Non-Protocol Communication (RS/RS2 Instruction) 的範例改的, 就不多解釋了
操作影片:
階梯圖:
計時器 T 在循環控制的基本迴圈 design pattern
觀念上, 傳統的 Timer, 通電前 B 接點導通, 通電後開始計時, 計時終了換成 A 接點導通
本例中, X0 為啟動按鈕, X1 為停止按鈕, 使用 M0 進行自鎖, 要控制 8 個 Y 輸出, 用到 T0 ~ T7 共 8 個計時器, 依 T0 ~ T7 順序啟動, 等於傳統配電盤上串接在一起, 且 T7 的 B 接點用來串接在整個電路之前, 當 T7 計時終了, B 接點斷開, 瞬間切斷整個計時迴路, T7 本身也斷電, 因此 T7 B 接點又馬上重新接上, 使得 T0 從頭開始計時.
操作影片:
階梯圖:
index.html
answer.html
WebFig進入點: IP>FireWall>NAT頁面
Chain: dstnt
Protocol: 6(tcp)
Dst. Port: AAAA-BBBB
Dst.Address type: local
Action: dst-nat
To Address: 192.168.88.NNN
To Port:AAAA-BBBB
Today some guy in the Facebook proposed an interesting problem about how to use the RFID and the SD in ESP32s . Both peripheral devices used the SPI connections. The point is they need it's own CS (chip select) pin to enable the SPI (MOSI/MISO/CLK) bus. Only one of them can be enabled in the same time because the enabled device will occupy the SPI bus.
Uusing the original SD ReadWrite code of the arduino example, we could find it's failed even if the CSs are defined well. To see what happened, I checked the compiler messages, as the following:
Use library SPI、verison 1.0,in folder:C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SPI
Use library SD、version 1.0.5,in follder:C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\SD
Use library FS、version 1.0,in folder:C:\Users\user\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\FS
From the view point of the software architecture, the SD layer is stacked above the FS which is stacked on the SPI hearware driver. The above messages showed that ESP32 SD library was applied, which caused the original SD ReadWrite code to be failed.
To solve the problem, some library definition are to be modified as the follows.
Visual Studio 環境可使用的方法:
sprintf(szTemp, "%I64d", i.QuadPart); // or
sprintf(szTemp, "%lld", i.QuadPart);
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import cv2
import numpy as np
pic = 'pic/b2.jpg'
img=cv2.imread(pic,cv2.IMREAD_COLOR)
hsv=cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
lower_coffee = np.array([0,0,0])
upper_coffee = np.array([60,255,180])
mask = cv2.inRange(hsv, lower_coffee,
upper_coffee)
kernel1 =
cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(13,13))
kernel2 =
cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(15,15))
#mask = cv2.morphologyEx(mask,
cv2.MORPH_CLOSE, kernel)
mask = cv2.dilate(mask ,kernel1)
mask = cv2.erode(mask, kernel2)
out = cv2.bitwise_and(img, img, mask=
mask)
cv2.imshow("img",img)
cv2.imshow('mask',mask)
cv2.imshow("out",out)
cv2.waitKey(0)
cv2.destroyAllWindows()
|