Low-code Example – Digital Input

Low-code Example – Digital Input

[QEC教程]

For the full tutorial, see 範例:QEC 上的低程式碼數位輸入/輸出.

Digital Input

With 86EVA and ArduBlock, using the EtherCAT digital input module to receive external signals and print them out through Serial Port.

硬體說明

  • QEC-M-01
  • QEC-R11D0F: EtherCAT 16數位輸出通道從站模組
  • 其他: 開關

Circuit

與Digital Output相同,請先將QEC-M上的EtherCAT Out網路與QEC-R11DF0的EtherCAT In網路連接。 此範例將外接一個按鈕,使用QEC-R11DF0的Pin8 作為接收信號腳位:

  1. Vp電源連結外部按鈕
  2. 外部按鈕接到QEC-R11DF0的Pin8+
  3. QEC-R11DF0的Pin8-接回Vp電源的GND

如圖所示。

rn_image_picker_lib_temp_228850c5-c615-466d-a50b-ec309e6c6616

Step 1: 86EVA, EtherCAT Configuration

Go to the 86Duino Coding IDE, open the 86EVA tool, and configure EtherCAT.

1-DIQ-eva(en)-2-3

Step 2: Set up the Virtual Arduino Pin and generate the code

In the screen of the Digital Input slave device, QECR11DF0D, set DI08 as Virtual Pin D0 as the pin selection for the subsequent ArduBlock.

1-DIQ-eva(en)-2-4

After completion, the 86EVA code can be generated.

1-DIQ-eva(en)-2-5

Step 3: ArduBlock setup

Open ArduBlock.

1-DIQ-eva(en)-2-6

We need to print out the signal of Digital Read through the Serial Port, so we drag the serial print block of the Communication class into the program’s main loop.

1-DIQ-eva(en)-2-7

Let the EtherCAT digital pin block from the EtherCAT – Pins class into the main loop and set the pin to D0.

1-DIQ-eva(en)-2-8

However, the original Serial Print’s message block cannot be directly combined with the EtherCAT digital pin block. So, it must be converted from Boolean to String via the glue block, and then it can be printed via Serial Port.

1-DIQ-eva(en)-2-9

In this example, in order to prevent the Digital Input signal from being continuously output in the Serial Port, you can create two variables as the basis for reading the signal change and then print out the signal through the Serial Port after judging whether the received signal is different between the two times by if-else in the main program. In this way, you can use the 86EVA with ArduBlock to receive external digital signals using the EtherCAT digital input module and print them out via Serial Port.

1-DIQ-eva(en)-2-10

Generate the code and upload it.

1-DIQ-eva(en)-2-11

學習更多

你可以在下方找到更多關於QEC基礎應用的信息 EtherCAT應用.
You can also explore 程式語法參考 or 函式庫參考 for a more detailed collection of 86Duino IDE programming.

發表評論

上部へスクロール