Cov txheej txheem:

Node-RED: RS485 Raspberry Pi Tutorial: 8 Kauj Ruam
Node-RED: RS485 Raspberry Pi Tutorial: 8 Kauj Ruam

Video: Node-RED: RS485 Raspberry Pi Tutorial: 8 Kauj Ruam

Video: Node-RED: RS485 Raspberry Pi Tutorial: 8 Kauj Ruam
Video: RS485 Raspberry pi Node red | Node red rs485 modbus 2024, Hlis ntuj nqeg
Anonim
Node-RED: RS485 Raspberry Pi Tutorial
Node-RED: RS485 Raspberry Pi Tutorial

Cov dej ntws raws qhov pom kev siv cuab yeej Node-RED dhau los ua neeg nyiam ntau dua rau Raspberry Pi cov tsim tawm. Cov lus qhia no yuav qhia koj yuav siv peb li cas cais cais RS422 / RS485 Serial HAT hauv Node-Red kom yooj yim RS485 kev sib txuas lus thiab rau MODBUS daim ntawv thov ib yam nkaus.

Kauj Ruam 1: Cov Cuab Yeej thiab Cov Khoom

Cov Cuab Yeej thiab Cov Khoom
Cov Cuab Yeej thiab Cov Khoom

Cov ntaub ntawv:

  • Raspberry Pi A+, B+, 2B, 3B lossis 4B
  • RS422/RS485 lub kaus mom
  • Daim npav SD

Software:

  • Raspbian Stretch lossis Buster (nrog lub desktop thiab

    pom zoo software)

Kauj Ruam 2: Pub dawb UART hauv Raspbian Stretch lossis Buster

Pub dawb UART hauv Raspbian Stretch lossis Buster
Pub dawb UART hauv Raspbian Stretch lossis Buster

Txoj hauv kev yooj yim tshaj plaws yog siv cov cuab yeej raspi-config hloov UART mus rau GPIO14/15 tus pin. coj cov duab Raspbian tshiab

  1. sudo raspi-teeb tsa
  2. tau txais '5 Kev Xaiv Ua Haujlwm'
  3. tau txais 'P6 Serial'
  4. 'Koj puas xav kom lub plhaub nkag mus kom nkag mus tau ntau dua?' TSIS YOG
  5. 'Koj puas xav kom lub khoos phis tawj serial chaw nres nkoj kom qhib?' YOG
  6. Ua tiav raspi-config
  7. reboot Raspberry Pi

Tam sim no koj tuaj yeem nkag mus rau UART ntawm /dev /serial0

Kauj Ruam 3: DIP Hloov Chaw rau RS485 HAT

DIP Hloov Chaw rau RS485 HAT
DIP Hloov Chaw rau RS485 HAT

Peb RS422/RS485 HAT los nrog 3 DIP hloov tsev txhab nyiaj. Koj yuav tsum teeb cov DIP hloov no rau RS485 raws li qhia hauv daim duab saum toj no.

  • Hloov 1: 1-OFF 2-ON 3-ON 4-OFF
  • Hloov 2: 1-OFF 2-OFF 3-ON 4-ON
  • Hloov 3: 1-OFF lossis ON* 2-OFF 3-OFF 4-OFF

*Nyob ntawm txoj haujlwm ntawm RS422/RS485 HAT hauv kab Modbus koj yuav tsum hloov qhov kev txiav tawm qhov kev tawm tsam ON lossis OFF. Thov hloov tus tiv thaiv mus rau ON txoj haujlwm tsuas yog HAT nyob ntawm ib kawg ntawm txoj kab npav. Hauv txhua qhov xwm txheej hloov pauv qhov kev tawm tsam tawm OFF

Kauj Ruam 4: Pib Node-RED

Pib Node-RED
Pib Node-RED

Pib Node-RED:

Node-RED yog ib feem ntawm Raspbian Stretch thiab Buster (nrog lub desktop thiab pom zoo software). Koj tuaj yeem siv lub node-liab hais kom ua Node-RED hauv lub davhlau ya nyob twg lossis ntawm lub desktop ntawm 'Programming' menu.

Qhib tus editor:

Thaum Node-RED tau ua haujlwm koj tuaj yeem nkag mus rau tus khoos phis tawj hauv browser. Yog tias koj siv browser ntawm Pi desktop, koj tuaj yeem qhib qhov chaw nyob: https:// localhost: 1880.

Kauj Ruam 5: Kev Sib Txuas RS485 yooj yim

Yooj Yim RS485 Kev Sib Txuas Lus
Yooj Yim RS485 Kev Sib Txuas Lus
Yooj Yim RS485 Kev Sib Txuas Lus
Yooj Yim RS485 Kev Sib Txuas Lus

Hauv qhov piv txwv no ntws Raspberry Pi yuav xa cov ntawv 'Nyob Zoo Ntiaj Teb' ntawm RS485 tom qab nias lub pob txhaj tshuaj. Cov dej ntws yuav tau txais cov hlua nkag (txiav tawm los ntawm / d) thiab qhia txoj hlua hauv qhov rais debugging ntawm sab xis.

Kev sib txuas lus yuav ua tiav los ntawm kev siv cov lej hauv thiab tawm ntawm cov node, uas tau teeb tsa ua ntej. Nws yog ib qho tseem ceeb heev los teeb tsa cov khoom ntawm Serial Port rau /dev /serial0 raws li hauv daim duab saum toj no.

Koj tuaj yeem ntsuas qhov ntws nrog lub PC txuas nrog (ntawm USB rau RS485 adapter) thiab cov phiaj xwm yooj yim.

Kauj Ruam 6: MODBUS - Kev teeb tsa 1

MODBUS - Kev teeb tsa 1
MODBUS - Kev teeb tsa 1

Hauv cov theem hauv qab no kuv xav qhia koj yuav ua li cas siv qhov yooj yim Modbus RTU kev sib txuas lus hauv Node-RED.

Ua ntej peb yuav tsum teeb tsa Modbus ntxiv node-red-contrib-modbus ntawm tus thawj tswj hwm palette lossis ntawm bash los ntawm kev nkag mus:

npm nruab node-red-contrib-modbus

Tam sim no koj tuaj yeem import qhov ntws.

Kauj Ruam 7: Modbus Configuration 2

Modbus Kho 2
Modbus Kho 2
Modbus Kho 2
Modbus Kho 2
Modbus Kho 2
Modbus Kho 2

Tom qab ntshuam cov dej ntws peb tuaj yeem saib hauv kev teeb tsa ntawm 'Modebus sau' thiab 'Modbus nyeem' nodes. Nws yog qhov tsis tseem ceeb los teeb tsa 'Server' cov cuab yeej rau dev/serial0 thiab teeb tsa nws raws li qhia hauv cov duab saum toj no.

Kauj ruam 8: Modbus Test

Modbus Xeem
Modbus Xeem

Rau qhov kev sim kuv tau txuas nrog Arduino nrog RS485 Shield li Modbus qhev (koj tuaj yeem tshawb xyuas qhov qhia no kom paub ntau ntxiv).

Modbus Nyeem ntawv yuav pov npav Chav 1 tag nrho 2s thiab nyeem 8 cov npe ntawm tus qhev. Koj tuaj yeem pom qhov tshwm sim hauv qhov xwm txheej ntawm Modbus Cov Lus Teb. Ntawm 2 lub tshuab txhaj tshuaj koj tuaj yeem teeb tus lej 6 ntawm tus qhev rau 0 lossis 255.

Pom zoo: