-
MenuVoltar
-
Menu
-
Arduino & Raspberry & Micro:bit
-
-
-
-
-
Placas Controladoras
-
-
-
Baterias & Pilhas
-
Componentes & Ferramentas
-
-
Oficina & Equipamentos
- Alicates & Chaves
- Breadboards
- Brocas & Fresas
- Caixas de Arrumação
- Caixas Eletrónica
- Equipamentos de Bancada
- Malas de Ferramentas & Kits
- Manga Térmica
- Multímetros
- Osciloscópios
- Parafusos & Espaçadores
- Placas de Cobre PCI
- Programadores ICs
- Protecção Pessoal
- Protoboards
- Soldadura
- Sprays & Tinta condutora
- Suportes Calha DIN
- Outros
-
-
-
-
-
Som & Audio
-
-
-
-
Comunicações & Smart Home
-
-
Displays & Teclados
-
-
Fontes & Energia Renovável
-
-
-
ENERGIA RENOVÁVEL
-
-
-
Impressão 3D & DRONES
-
-
Motores & Relés
-
-
ROBÓTICA
-
-
Sensores
-
-
- Catálogo
- Novos Produtos
- Promoções
- Tutoriais
- Contactos
2 GPIO via 1-Wire BUS - DS2413
Agora pode utilizar quantos módulos DS2413 desejar numa única linha I/O, cada um unicamente endereçavel e partilhando um único pinoo I/O sem problemas. As duas linhas I/O controláveis (PIOA e PIOB) podem ser utilizadas como entradas ou saidas.
DESCRIÇÃO EM PORTUGUÊS BREVEMENTE DISPONÍVEL
Se tiver alguma dúvida neste produto não hesite em contactar-nos.
*Atenção: as imagens são meramente ilustrativas.
-
DESCRIPTION
You're too cool for I2C, and SPI has so many wires, 8-bit parallel... how can that be fashionable!? You are a 1-Wire kinda gal, and you want more 1-Wire breakouts in your life to complement all of your great engineering. Well rock on, because here you go, it's a 1-Wire controller with two open-drain GPIO.
They are open-drain, so if you want to power an LED or something, you'll need a remote power supply (see Maxim's product page for more details)
We have a basic Arduino sketch that uses the OneWire library to communicate with this chip. Don't forget to add the 4.7Kohm resistor from I/O to your 1-Wire controller power supply (3.3V - 5V) on the Arduino side of the wires.DS2413 1-Wire Two GPIO Controller Breakout (4:45)
-
TECHNICAL DETAILS
- Dimensions: 15.78mm / 0.62" x 9.96mm / 0.39" x 2.94mm / 0.11"
#include <OneWire.h>
#define DS2413_ONEWIRE_PIN (8)
#define DS2413_FAMILY_ID 0x3A
#define DS2413_ACCESS_READ 0xF5
#define DS2413_ACCESS_WRITE 0x5A
#define DS2413_ACK_SUCCESS 0xAA
#define DS2413_ACK_ERROR 0xFF
OneWire oneWire(DS2413_ONEWIRE_PIN);
uint8_t address[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
void printBytes(uint8_t* addr, uint8_t count, bool newline = 0)
{
for (uint8_t i = 0; i < count; i++)
{
Serial.print(addr[i] >> 4, HEX);
Serial.print(addr[i] & 0x0f, HEX);
Serial.print(" ");
}
if (newline)
{
Serial.println();
}
}
byte read(void)
{
bool ok = false;
uint8_t results;
oneWire.reset();
oneWire.select(address);
oneWire.write(DS2413_ACCESS_READ);
results = oneWire.read(); /* Get the register results */
ok = (!results & 0x0F) == (results >> 4); /* Compare nibbles */
results &= 0x0F; /* Clear inverted values */
oneWire.reset();
// return ok ? results : -1;
return results;
}
bool write(uint8_t state)
{
uint8_t ack = 0;
/* Top six bits must '1' */
state |= 0xFC;
oneWire.reset();
oneWire.select(address);
oneWire.write(DS2413_ACCESS_WRITE);
oneWire.write(state);
oneWire.write(~state); /* Invert data and resend */
ack = oneWire.read(); /* 0xAA=success, 0xFF=failure */
if (ack == DS2413_ACK_SUCCESS)
{
oneWire.read(); /* Read the status byte */
}
oneWire.reset();
return (ack == DS2413_ACK_SUCCESS ? true : false);
}
void setup(void)
{
Serial.begin(9600);
Serial.println(F("Looking for a DS2413 on the bus"));
/* Try to find a device on the bus */
oneWire.reset_search();
delay(250);
if (!oneWire.search(address))
{
printBytes(address, 8);
Serial.println(F("No device found on the bus!"));
oneWire.reset_search();
while (1);
}
/* Check the CRC in the device address */
if (OneWire::crc8(address, 7) != address[7])
{
Serial.println(F("Invalid CRC!"));
while (1);
}
/* Make sure we have a DS2413 */
if (address[0] != DS2413_FAMILY_ID)
{
printBytes(address, 8);
Serial.println(F(" is not a DS2413!"));
while (1);
}
Serial.print(F("Found a DS2413: "));
printBytes(address, 8);
Serial.println(F(""));
}
void loop(void)
{
/* Read */
/*
uint8_t state = read();
if (state == -1)
Serial.println(F("Failed reading the DS2413"));
else
Serial.println(state, BIN);
*/
/* Write */
bool ok = false;
ok = write(0x3);
if (!ok) Serial.println(F("Wire failed"));
delay(1000);
ok = write(0x0);
if (!ok) Serial.println(F("Wire failed"));
delay(1000);
}