Buon giorno a tutti, ho comprato queso componente SparkFun Transceiver Breakout - RS-485 - BOB-10124 - SparkFun Electronics
che puo' essere alimentato a 5V e a 3.3 V.
ora la mia domanda è questa devo usare una resistenza da 120 ohm se uso l'alimentazione a 5 v. ?
e se uso quella a 3.3 V di quano deve essere?
scusatemi ma non capisco molto di elettronica.
grazie a tutti
La resistenza di 120 Ohm nei bus 485 va messa alla fine ed all'inizio del bus (in parallelo tra A e B) indipendentemente dall'alimentazione. Non so se era la risposta che cercavi...
#include <SimpleModbusMaster.h>
#include <LiquidCrystal.h>
//////////////////// Port information ///////////////////
#define baud 9600
#define timeout 1000
#define polling 200 // the scan rate
// If the packets internal retry register matches
// the set retry count then communication is stopped
// on that packet. To re-enable the packet you must
// set the "connection" variable to true.
#define retry_count 10
// used to toggle the receive/transmit pin on the driver
#define TxEnablePin 2
//#define LED 9
#define LED 3
// This is the easiest way to create new packets
// Add as many as you want. TOTAL_NO_OF_PACKETS
// is automatically updated.
enum
{
PACKET1,
//PACKET2,
TOTAL_NO_OF_PACKETS // leave this last entry
};
// Create an array of Packets to be configured
Packet packets[TOTAL_NO_OF_PACKETS];
packetPointer packet1 = &packets[PACKET1];
// Data read from the arduino slave will be stored in this array
// if the array is initialized to the packet.
unsigned int readRegs[2];
LiquidCrystal lcd(12, 11, 9, 8, 7, 6); // PER LCD
void setup()
{
/*
ID:5 indica l'indirizzo dello slave modbus
READ_HOLDING_REGISTERS: FUNZIONE RICHIESTA LETTURA DATI
19: E' LA FUNZIONE 20 DIMINUITA DI UNO COME DA MANUALE
WORD: 2 SONO I VALORI DOPO L'INDIRIZZO DELLA FUNZIONE (NEL MIO CASO 19
readRegs: Dove andare a copiare i risultati) ***/
modbus_construct(packet1, 5, READ_HOLDING_REGISTERS, 19, 2, readRegs);
// write 1 register starting at address 1
// modbus_construct(packet2, 1, PRESET_MULTIPLE_REGISTERS, 1, 1, writeRegs);
// P.S. the register array entries above can be different arrays
/* Initialize communication settings: These are already defined in the Arduino global name space. */
// il miter usa il sistema di comunicazione SERIAL_8N1
modbus_configure(&Serial, baud, SERIAL_8N1, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS);
pinMode(LED, OUTPUT);
}
void loop()
{
modbus_update(); // si fà update dei dati
lcd.clear();
/**servono per debug*/
lcd.print("REQ:"); // numero richieste
lcd.print(packet1->requests);
lcd.print("SUC:"); // richieste con successo
lcd.print(packet1->successful_requests);
lcd.print("FAL:"); // richieste fallite
lcd.print(packet1->failed_requests);
/*dati che vengono letti */
lcd.print("R1:");
lcd.print(readRegs[0]);
lcd.print("R2:");
lcd.print(readRegs[1]);
delay(1000);
}
ho messo sia una resistenza da 120 ohm sia al 485 del rs485breakout che davanti al miter
ecco tutto quello che mi avete chiesto...
grazie mille per l'aiuto
Ciao,
vorrei chiedervi consiglio su come interfacciare arduino tramite max485 sul contatore monofase dzt-6001 tramite protocollo modbus rtu.
per i collegamenti ok prendo lo schema sopra riportato, ma non so come interrogare i registri per prelevare i dati.
in allegato ho il file con i dati forniti dal costruttore.
gigi77:
Ciao,
vorrei chiedervi consiglio su come interfacciare arduino tramite max485 sul contatore monofase dzt-6001 tramite protocollo modbus rtu.
per i collegamenti ok prendo lo schema sopra riportato, ma non so come interrogare i registri per prelevare i dati.
in allegato ho il file con i dati forniti dal costruttore.