Cov txheej txheem:

Raspberry Pi A1332 Precision Hall - Effect Angle Sensor Java Qhia: 4 Kauj Ruam
Raspberry Pi A1332 Precision Hall - Effect Angle Sensor Java Qhia: 4 Kauj Ruam

Video: Raspberry Pi A1332 Precision Hall - Effect Angle Sensor Java Qhia: 4 Kauj Ruam

Video: Raspberry Pi A1332 Precision Hall - Effect Angle Sensor Java Qhia: 4 Kauj Ruam
Video: Raspberry Pi A1332 Hall Effect Sensor Java Tutorial 2024, Hlis ntuj nqeg
Anonim
Image
Image

A1332 yog 360 ° tsis muaj kev sib cuag siab daws teeb meem programmable sib nqus lub ntsej muag txoj haujlwm sensor. Nws yog tsim los rau cov tshuab siv I2C interface. Nws tau tsim los ntawm Lub Vertical Hall (CVH) thev naus laus zis thiab cov phiaj xwm microprocessor raws lub teeb liab ua haujlwm kuj tseem suav nrog hauv qhov ntsuas no. Nov yog qhov ua piv txwv nrog java code siv Raspberry Pi.

Kauj Ruam 1: Yam Koj Xav Tau..

Yam Koj Xav Tau.. !!
Yam Koj Xav Tau.. !!

1. Raspberry Pi

2. A1332 ib

3. I²C Cable

4. I²C Shield rau Raspberry Pi

5. Ethernet Cable

Kauj Ruam 2: Kev Sib Txuas:

Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas
Kev Sib Txuas

Siv I2C daim thaiv rau raspberry pi thiab maj mam thawb nws hla gpio pins ntawm raspberry pi.

Tom qab ntawd txuas ib qho kawg ntawm I2C cable rau A1332 sensor thiab lwm qhov kawg rau I2C daim ntaub thaiv.

Kuj txuas Ethernet cable rau pi lossis koj tuaj yeem siv WiFi module.

Kev sib txuas tau qhia hauv daim duab saum toj no.

Kauj ruam 3: Code:

Txoj Cai
Txoj Cai

Tus lej java rau A1332 tuaj yeem rub tawm los ntawm peb qhov chaw cia khoom github- Dcube Store

Nov yog qhov txuas rau tib yam:

github.com/DcubeTechVentures/A1332/blob/master/Java/A1332.java

Peb tau siv pi4j tsev qiv ntawv rau java code, cov kauj ruam rau nruab pi4j ntawm raspberry pi tau piav qhia ntawm no:

pi4j.com/install.html

Koj tseem tuaj yeem luam cov cai los ntawm no, nws tau muab raws li hauv qab no:

// Faib nrog daim ntawv tso cai yuav dawb.

// Siv nws txhua txoj hauv kev uas koj xav tau, muaj txiaj ntsig lossis pub dawb, muab nws haum rau hauv daim ntawv tso cai ntawm nws cov haujlwm ua haujlwm.

A1332 ib

// Cov cai no tau tsim los ua haujlwm nrog A1332_I2CS I2C Mini Module

ntshuam com.pi4j.io.i2c. I2CBus;

ntshuam com.pi4j.io.i2c. I2CDevice;

ntshuam com.pi4j.io.i2c. I2CFactory;

ntshuam java.io. IOException;

pej xeem chav A1332

{

pej xeem zoo li qub tsis muaj dab tsi tseem ceeb (Txoj hlua args ) cuam tshuam zam

{

// Tsim I2C npav

I2CBus Bus = I2CFactory.getInstance (I2CBus. BUS_1);

// Tau txais I2C ntaus ntawv, A1332 I2C chaw nyob yog 0x0C (12)

I2CDevice ntaus ntawv = Bus.getDevice (0x0C);

Xov.sleep (500);

// Nyeem 2 bytes ntawm cov ntaub ntawv

// raw_adc msb, raw_adc lsb

byte cov ntaub ntawv = tshiab byte [2];

device.read (cov ntaub ntawv, 0, 2);

// Txheeb xyuas cov ntaub ntawv siv tau

thaum ((data [0] == 0) && (data [1] == 0))

{

device.read (cov ntaub ntawv, 0, 2);

}

// Hloov cov ntaub ntawv mus rau 12-ntsis

int raw_adc = ((cov ntaub ntawv [0] & 0x0F) * 256 + (data [1] & 0xFF));

ob lub kaum = (raw_adc / 4096.0) * 360;

// Cov ntaub ntawv tso tawm rau lub vijtsam

System.out.printf ("Magnetic Angle: %.2f %n", lub kaum ntse ntse);

}

}

Kauj Ruam 4: Cov Ntawv Thov:

A1332 yog qhov zoo tshaj plaws rau kev siv tsheb xav tau kev kub ceev 360 ° ntsuas lub kaum ntse ntse, xws li: hluav taws xob tswj lub zog (EPS), kis tau tus mob, torsion bar, thiab lwm yam kab ke uas xav tau kev ntsuas meej ntawm cov ces kaum. Qhov ntsuas no tau tsim los ua kom tau raws li qhov yuav tsum tau ua ntawm cov tshuab uas suav nrog ntsuas ntawm lub kaum ntse ntse thiab txoj haujlwm tseeb nrog qhov ua tau zoo.

Pom zoo: