Cov txheej txheem:

Mus txog 3 RS485 Busses ntawm Ib Arduino: 5 Kauj Ruam
Mus txog 3 RS485 Busses ntawm Ib Arduino: 5 Kauj Ruam

Video: Mus txog 3 RS485 Busses ntawm Ib Arduino: 5 Kauj Ruam

Video: Mus txog 3 RS485 Busses ntawm Ib Arduino: 5 Kauj Ruam
Video: Programowanie ARM (STM32, CooCox, Wgrywanie kodu) #1 2024, Hlis ntuj nqeg
Anonim
Txog 3 RS485 Busses ntawm Ib Arduino
Txog 3 RS485 Busses ntawm Ib Arduino
Txog 3 RS485 Busses ntawm Ib Arduino
Txog 3 RS485 Busses ntawm Ib Arduino

Hauv cov lus qhia no kuv yuav qhia yuav ua li cas txuas mus rau 3 kev ywj pheej RS485 cov tsheb npav mus rau ib qho Arduino. Qhov no tuaj yeem muaj txiaj ntsig yog tias koj xav tsim lub qhov rooj ntawm cov npav no lossis yog tias koj xav tswj cov cuab yeej hauv cov npav no (tsis tas yuav txuas lub tsheb npav nws tus kheej). Lwm daim ntawv thov yog kev sib txuas ntawm RS422 cov cuab yeej (piv txwv li kev tswj lub cev muaj zog) thiab RS485 cov cuab yeej (piv txwv li lub ntsuas pa) rau tib Arduino.

Nyob rau txhua qhov xwm txheej koj yuav xav tau daim thaiv RS485 nrog kev sib cais sib cais kom tshem tawm cov teeb meem hauv av thiab tiv thaiv Arduino.

Kauj Ruam 1: Cov Cuab Yeej & Cov Khoom

Image
Image

Kho vajtse:

  • Arduino UNO (lossis lwm lub koos pij tawj siv computer nrog Arduino Shield qhov nyob)
  • Arduino RS42 / RS485 Shield nrog kev sib cais sib cais

Software:

Arduino IDE Cov

Kauj Ruam 2: DIP Hloov & Jumper Teeb rau BUS 1

DIP Hloov & Jumper Teeb rau BUS 2
DIP Hloov & Jumper Teeb rau BUS 2

Jumper:

  • UART RX rau txoj haujlwm 0
  • UART TX to position 1
  • Voltage rau txoj hauj lwm 5V

DIP Hloov:

  • S1 = OFF - ON - ON - OFF
  • S2 = OFF - OFF - ON - ON
  • S3 = ON - OFF - OFF - OFF

Kauj Ruam 3: DIP Hloov & Jumper Teeb rau BUS 2

Jumper:

  • UART RX rau txoj haujlwm 2
  • UART TX to position 3
  • Voltage rau txoj hauj lwm 5V

DIP Hloov:

  • S1 = OFF - ON -ON - OFF
  • S2 = OFF - OFF - ON - ON
  • S3 = ON - OFF - OFF - OFF

Kauj Ruam 4: DIP Hloov & Jumper Teeb rau BUS 3

DIP Hloov & Jumper Teeb rau BUS 3
DIP Hloov & Jumper Teeb rau BUS 3

Jumper:

  • UART RX rau txoj haujlwm 4
  • UART TX to position 5
  • Voltage rau txoj hauj lwm 5V

DIP Hloov:

  • S1 = OFF - ON - ON - OFF
  • S2 = OFF - OFF - ON - ON
  • S3 = ON - OFF - OFF - OFF

Kauj Ruam 5: Kev Sib Koom Software

Daim thaiv rau tsheb npav 1 yuav siv kho vajtse UART ntawm tus lej 0 thiab 1 ntawm Arduino. Ob qho lwm qhov kev tiv thaiv yuav siv software UARTs.

#suav nrog

SoftwareSerial RS485_BUS2 (2, 3);

SoftwareSerial RS485_BUS3 (4, 5);

void teeb tsa ()

{

….

// init serial chaw nres nkoj rau npav 1

Serial.begin (9600);

// init serial chaw nres nkoj rau npav 2

RS485_BUS2.begin (9600);

// init serial chaw nres nkoj rau npav 3

RS485_BUS3.begin (9600);

….

Cov ntaub ntawv xa tawm ntawm cov software UARTs no raug txwv los ntawm kev suav lub zog ntawm Arduino. Yog lawm yog tias koj yuav siv ARM raws li Arduino lossis STM32 pawg thawj coj no yuav tsis muaj teeb meem tiag tiag, tab sis rau UNO nws tau pom zoo kom siv tsuas yog ob daim thaiv tib lub sijhawm thiab rau daim thaiv thib ob tsis ntau dua li 9600 Baud raws li cov ntaub ntawv tus nqi.

Pom zoo: