PCF8574: About I2C I / O Expander ya Arduino

Kufotokozera: PCF8574 TI CHIP

Mwamvadi za Kufotokozera: IC PCF8574, chip chomwe chimatha kugulidwa padera kapena kukhazikitsidwa kale modula ngati ena ambiri Zida zamagetsi kuti muthe kusakanikirana ndi bolodi lanu la Arduino. Poterepa, ndiwowonjezera zolowetsa ndi zotuluka za Basi ya I2C.

Mutha kuganiza kuti Arduino ili nayo kale Integrated I2C basi, ndipo ndi zoona. Koma PCF8574 itha kuthandiza kupititsa basiyo kupitirira malire a board yanu yachitukuko, yomwe ingakhale yothandiza kwambiri kwa ena opanga omwe amafunikira zoposa zomwe Arduino amapereka.

Kodi basi ya I2C ndi yotani?

Arduino UNO millis ntchito

Dzinalo I2C limachokera Dongosolo Losakanikirana kapena masekeli ophatikizika. Mtundu wake wa 1.0 udapangidwa mu 1992 ndi Philips. Kenako 2.1 yachiwiri ibwera mu 2000 ndipo lero yakhala yofanana (pa 100 kbit / s, ngakhale imalola mpaka 3.4 Mbit / s maximum) pomwe patent imatha mu 2006 ndipo itha kugwiritsidwa ntchito momasuka.

Pakadali pano imagwiritsidwa ntchito kwambiri pamsika kulankhulana, ndipo amakondweretsedwanso kwambiri ndi omwe amapanga mapulojekiti awo olumikizira ma microcontroller osiyanasiyana ndi zotumphukira zophatikizidwa mu IC imodzi.

El I2C ndi basi kulumikizana kodziwika bwino. Imagwiritsa ntchito njira yolumikizirana yolumikizana yokhala ndi njira ziwiri zokha (pali gawo lachitatu, koma limalumikizidwa ku reference kapena GND), imadziwikanso kuti TWI (Two Wire Interface):

  • Imodzi yanthawi (SCL).
  • Zina za data (SDA).
Zonsezi ndizotseguka zotseguka za CMOS ndipo zimafunikira kukana. Komanso, ngati chipangizo chimodzi chikutumiza 0 ndi china 1, pakhoza kukhala mavuto, ndichifukwa chake mzerewo umangokhala 1 (mulingo wapamwamba) ndipo zida nthawi zonse zimafalitsa 0 (otsika).

Izi zikutanthauza kuti mbuye ndi kapolo amatumiza deta pa chingwe chofanana kapena njanji, yomwe imayang'aniridwa ndi yoyamba yomwe imatulutsa chizindikirocho. Chida chilichonse cholumikizidwa ndi basi ya I2C chikhala ndi adilesi yapadera yomwe angatumizidwe, kuti athe kuwongolera operekera. Koma sikoyenera kuti aphunzitsi azikhala ofanana nthawi zonse (aphunzitsi ambiri), nthawi zonse ndiomwe amayambitsa kusamutsako.

Monga ndinafotokozera kale m'nkhaniyi Kutulutsa I2C Ndatchulapo kale, bolodi lirilonse limalumikizana ndi I2C m'malo osiyanasiyana. Ndichinthu chomwe muyenera kukumbukira kuti muzitha kuchigwiritsa ntchito bwino pamtundu uliwonse wa mbale:

  • Arduino UNO: SDA ili mu A4 ndi SCK mu A5
  • Arduino Nano: chimodzimodzi ndi zam'mbuyomu.
  • Arduino Mini ovomereza: chimodzimodzi.
  • Arduino Mega: SDA ili pa pini 20 ndipo SCK pa 21.
  • Zambiri zam mbale.

Mukudziwa kale kuti mutha kugwiritsa ntchito I2C pazithunzi zanu mosavuta, popeza Laibulale ya Wire.h ndi ntchito zosiyanasiyana polumikizana motere:

  • yamba (): yambani laibulale ya Wire ndikunena ngati ili mbuye kapena kapolo
  • pemphoKuchokera (): yogwiritsidwa ntchito ndi mbuye kufunsa zambiri kuchokera kwa kapoloyo.
  • yambani Kutumiza (): yambitsani kapolo.
  • Mapeto Kutumiza (): kufalitsa kumapeto.
  • lembani ()- Lembani deta kuchokera kwa kapolo poyankha pempho lochokera kwa mbuye kapena mutha kuyika pamzere kutumiza kwa ambuye
  • kupezeka (): abwezera kuchuluka kwa mabayiti kuti awerenge.
  • werengani (): werengani mawu ofalitsidwa kuchokera kwa kapolo kupita kwa mbuye kapena mosemphanitsa.
  • Landirani ()Imayitanitsa ntchito pomwe kapolo amalandila kuchokera kwa mbuye.
  • onRequest ()Amayitanitsa ntchito pomwe kapolo amafunsira deta kuchokera kwa mbuye.

Para zambiri za Arduino mapulogalamu ndi ntchito zomwe mungathe kutsitsa Phunziro la PDF.

Kodi PCF8574 ndi chiyani?

Gawo la PCF8574

PCF8574 ndi Zolowetsa ndi zotulutsa zama basi za I2C (I / O) zokulitsa. Itha kupangidwa ndi opanga osiyanasiyana, kuphatikiza pakupezeka mu ma IC ndi ma module. Mulimonsemo, ndizotheka kulumikiza ndi bolodi lanu la Arduino ndikukhala ndi mphamvu zowongolera zida zambiri kuposa zomwe mavabodi amavomereza.

El Kufotokozera: PCF8574 Ndizosavuta, chifukwa zimangophatikiza Mapaini a 8 quasi-directional (P0-P7 pomwe tchipisi tolumikizirana talumikizidwa), ndipo mbali inayo muli ndi SDA ndi SCL zomwe muyenera kulumikizana ndi board ya Arduino, komanso VCC ndi GND kuti mulimbikitsenso gawoli. Ndipo musaiwale zikhomo zitatu zolankhulira A0, A1, A2 kuti musankhe zida zomwe kulumikizaku kulunjika ...

Kufotokozera: PCF8574

Zawo mawonekedwe ena kuti mudziwe:

  • Kulumikizana kwake, kukhala kotseguka kotseguka, kungakhale amagwiritsira ntchito zonse monga zolowetsa ndi zotuluka.
  • La pachimake pano Ndi 25mA ikakhala ngati yotulutsa (kumira, pomwe pano ikuyenda kupita ku PCF8574) ndi 300 µA (gwero, lomwe likuyenda kuchokera ku PCF8574)
  • La nkhawa magetsi ndi 2.5 ndi 6v. Kugwiritsa ntchito poyimira kumakhala kotsika kwambiri, 10 onlyA yokha.
  • Zotsatira zonse ndi latches, kusunga boma popanda kufunika kwa zochitika zakunja. Muyenera kuchitapo kanthu mukafuna kusintha boma.
  • Mutha kupeza 8 mayendedwe otheka, Ndiye kuti, mpaka pazida 8 zolumikizirana kapena kugwiritsa ntchito ma module 8 kuti mukulitse mpaka zida 64. Ma adilesi (zikhomo A0, A1, A2) adzakhala:
    • 000: adilesi 0x20
    • 001: adilesi 0x21
    • 010: adilesi 0x22
    • 011: adilesi 0x23
    • 100: adilesi 0x24
    • 101: adilesi 0x25
    • 110: adilesi 0x26
    • 111: adilesi 0x27
  • Kuvomereza kusokoneza (INT) ndi mzere wapadera kuti mupeze deta popanda kuwunika pafupipafupi.

Kuphatikiza ndi Arduino

Chithunzi chojambula cha Arduino IDE

Kulumikizana ndi Arduino ndikosavuta, muyenera kungolumikiza Vcc ndi pini ya 5v ya board ya Arduino, ndi GND ndi GND ya Arduino. Mbali inayi, zikhomo za PCF8574 SDA ndi SCL module zitha kukhala kulumikiza ndi zikhomo 14 (A5 SCL) ndi 15 (A4 SDA). Pokhapokha zitayamba kugwira ntchito, mwachidziwikire mutha kugwiritsa ntchito Px kulumikiza zida zomwe mukufuna kulumikizana ...

Ndiye zikadasowa kuyamba ndi chitsanzo sewero ku Arduino IDE. Mutha kuzichita popanda kugwiritsa ntchito laibulale yowonjezera monga ...

#include <Wire.h>
 
const int address = 0x38;
 
void setup()
{
   Wire.begin();
   Serial.begin(9600);
}
 
void loop()
{
   for (short channel = 0; channel < 8; channel++)
   {
      // Escribir dato en cada uno de los 8 canales
      Wire.beginTransmission(address);
      Wire.write(~(1 << channel));
      Wire.endTransmission();
      
      // Lee dato del canal
      delay(500);
   }
}

Monga zolowetsera:

#include <Wire.h>
 
const int address = 0x38;
 
void setup()
{
   Wire.begin();
   Serial.begin(9600);
}
 
void loop()
{
   short channel = 1;
   byte value = 0;
 
   // Leer el dato del canal
   Wire.requestFrom(pcfAddress, 1 << channel);
   if (Wire.available())
   {
      value = Wire.read();
   }
   Wire.endTransmission();
 
   // Mostrar el valor leido por el monitor serie
   Serial.println(value);
}

Kapenanso gwiritsani ntchito malaibulale, monga PCF8574 yomwe mungathe download pano ndipo gwiritsani ntchito nambala yofanana ndi iyi kuchokera pachitsanzo chomwe chimabwera ndi laibulale iyi:

#include <Wire.h>
#include "PCF8574.h"
 
PCF8574 expander;
 
void setup() 
{
  Serial.begin(9600);
  
  expander.begin(0x20);
  
  /* Setup some PCF8574 pins for demo */
  expander.pinMode(0, OUTPUT);
  expander.pinMode(1, OUTPUT);
  expander.pinMode(2, OUTPUT);
  expander.pinMode(3, INPUT_PULLUP);
 
  /* Blink hardware LED for debug */
  digitalWrite(13, HIGH);  
  
  /* Toggle PCF8574 output 0 for demo */
  expander.toggle();
  
  /* Blink hardware LED for debug */
  digitalWrite(13, LOW);
}
 
 
 
void loop() 
{
}


Zomwe zili m'nkhaniyi zikutsatira mfundo zathu za malamulo okonzekera. Kuti mufotokoze cholakwika dinani Apa.

Khalani oyamba kuyankha

Siyani ndemanga yanu

Anu email sati lofalitsidwa. Amafuna minda amalembedwa ndi *

*

*

  1. Wotsogolera pazosankhazi: Miguel Ángel Gatón
  2. Cholinga cha deta: Control SPAM, kasamalidwe ka ndemanga.
  3. Kukhazikitsa: Kuvomereza kwanu
  4. Kulumikizana kwa zomwe zafotokozedwazo: Zomwezo siziziwululidwa kwa anthu ena kupatula pakukakamizidwa mwalamulo.
  5. Zosunga: Zosungidwa ndi Occentus Networks (EU)
  6. Ufulu: Nthawi iliyonse mutha kuchepetsa, kuchira ndikuchotsa zidziwitso zanu.