Cov txheej txheem:

RS485 Ntawm Arduino thiab Raspberry Pi: 7 Kauj Ruam
RS485 Ntawm Arduino thiab Raspberry Pi: 7 Kauj Ruam

Video: RS485 Ntawm Arduino thiab Raspberry Pi: 7 Kauj Ruam

Video: RS485 Ntawm Arduino thiab Raspberry Pi: 7 Kauj Ruam
Video: Austin Mahone - Mmm Yeah ft. Pitbull 2024, Kaum ib hlis
Anonim
RS485 Ntawm Arduino thiab Raspberry Pi
RS485 Ntawm Arduino thiab Raspberry Pi

Rau tsev kawm ntawv kuv yuav tsum ua ib qhov project. Kuv xaiv los ua tus tswj tsev cog khoom ntse tswj tau los ntawm raspberry pi. Cov ntsuas yuav raug siv los ntawm arduino uno. Thaum lub hlis uas ua raws kuv yuav tshaj tawm qhov kev ua ntawm cov phiaj xwm no ib qib zuj zus ntawm cov lus qhia kom koj ib yam tuaj yeem ua tau. RS485 zoo meej rau qhov no. RS485 txhawb kev nrawm txog 10 Mbit/s thiab 1200 meter nrug. Nyob ntawm qhov ntev cable koj xav tau kom txo qhov nrawm koj tab tom xa. Saib ntawm lub rooj no kom paub qhov ceev tshaj plaws ntawm qhov nrug. Txhawm rau nyeem thiab teeb tsa tus nqi ntawm tus qhev RS485 Kuv yuav siv cov lus nab.

Kauj ruam 1: Xav tau

Qhov:

  • Raspberry PI (Kuv siv 3B+)
  • MAX485 module
  • USB rau RS485 interface
  • qee cov xov hlau jumper
  • arduino ib

Kauj Ruam 2: Txhim Kho Qhov Xav Tau Software Rau Hauv Raspbian

Kuv yuav tsis tham txog yuav ua li cas teeb tsa raspbian rau koj li raspberry. Twb muaj qee cov lus qhia piav qhia qhov no. Kuv yuav piav qhia yuav ua li cas teeb tsa cov software xav tau.

Thawj zaug hloov kho koj cov raspberry:

apt hloov tshiab

Tom qab ntawd nruab pip:

apt-tau nruab python3-pip

Nyem sau rau Yog

Tom qab ntawd teeb tsa minimalmodbus:

pip3 nruab -U minimalmodbus

Kauj Ruam 3: Txuas Arduino

Txuas lub Arduino
Txuas lub Arduino

Hauv cov duab saum toj no koj tuaj yeem pom yuav ua li cas xaim lub arduino mus rau RS485 interface. Qhov thib ob RS485 sawv cev rau USB rau RS485 adapter.

Kauj Ruam 4: Coding Arduino

Ua ntej ntshuam lub tsev qiv ntawv no los ntawm kev kos duab, siv lub tsev qiv ntawv thiab ntxiv zip qiv ntawv. Qhov no yog txoj cai rau tus qhev ntawm arduino uas ua rau nws muaj peev xwm tswj tau onboard coj ntawm tus pin 13 ntawm arduino.

Kauj Ruam 5: Programming RS485 ntawm Raspberry

Tam sim no peb tab tom mus rau tus lej raspberry pi ua tus tswv.

  • Qhib lub davhlau ya nyob twg ntawm koj tus raspberry pi.
  • Tsim cov ntawv tshiab modbus.py

koj modbus.py

  • ntaus kuv rau ntxig
  • muab tshuaj txhuam rau hauv qhov chaws hauv daim ntawv
  • nias tus yuam sij khiav tawm
  • laj: wq
  • nias tus yuam sij nkag

Kauj Ruam 6: Xeem Tsab Ntawv

Xeem Tsab Ntawv
Xeem Tsab Ntawv

Ntaus hauv qhov hais kom ua:

sej3 modbus.py

Tam sim no muab rau 1 lossis 0 thiab koj yuav pom cov coj ntawm arduino mus thiab tawm.

Kauj Ruam 7: Xaus

Nov yog thawj kauj ruam txhawm rau ua kom kuv tus tswj tsev cog khoom tiav. Ntawm RS485 Kuv tuaj yeem qhib kuv li qub thiab nyeem qhov ntsuas qhov ntsuas. Kuv vam tias koj txaus siab rau cov lus qhia no.

Rau cov neeg uas hais lus Dutch koj tuaj yeem ua raws kuv qhov haujlwm nyob qhov ntawd. Thaum qhov project tiav kuv yuav ua tus qhia ntxiv ntawm kuv qhov project tiav

Pom zoo: