Bonjour,
j'ai refais des essais, et sur ses test j'ai bien le signal au carré sur ma sortie TX0 qui entre en DI
la trame s'affiche sur le moniteur série mais aucune information du slave !
pas d'info du signal pourtant a l'osciloscope j'ai bien la trame sur la borne A du slave.
je vous joint la doc de la vanne ainsi que le shield RS485 si cela peut aider.
merci
#include <SoftwareSerial.h>
// assemble message
byte msgpertama [] = {
0x0B, // slave address
0x0F, // function code
0x02, // data address coil
0x11, // data address coil
0x00, // status to write
0x01, // status to write
0x01, // status to write
0x92, // CRC
0xC9, // CRC
};
byte msgkedua [] = {
0x0B, // slave address
0x0F, // function code
0x02, // data address coil
0x11, // data address coil
0x01, // status to write
0x01, // status to write
0x92, // CRC
0xC9, // CRC
};
#define pushpertama 4 // define first pushbutton to commandOFF
#define pushkedua 5 // define second pushbutton to commandON
#define TX_ENABLE_PIN 9 // define the EIA-485 transmit driver pin ( RE + DE pin's modules)
SoftwareSerial rs485(0, 1); // SoftwareSerial rs485(RX-RO, TX-DI); pins name on the module
void setup()
{ // klasifikasi variabel
pinMode(TX_ENABLE_PIN, OUTPUT);
pinMode(pushpertama,INPUT_PULLUP);
pinMode(pushkedua, INPUT_PULLUP);
rs485.begin (9600); // vitesse com
Serial.begin(9600);
}
void loop()
{
if(digitalRead(pushpertama)== HIGH)
{
digitalWrite (TX_ENABLE_PIN, HIGH); // enable transmit driver
for (int i = 0; i < 9; i++)
{
Serial.print(msgpertama[i], HEX); // console print the data
rs485.write(msgpertama[i]); // flip display print
if (i < 8)
{
Serial.print(", "); // print a comma between data
}
}
Serial.println();
delay(6);
digitalWrite(TX_ENABLE_PIN, LOW); // disable transmit driver
delay(500);
}
if(digitalRead(pushkedua)== HIGH)
{
digitalWrite (TX_ENABLE_PIN, HIGH); // enable transmit driver
for (int j = 0; j < 8; j++)
{
Serial.print(msgkedua[j], HEX); // console print the data
rs485.write(msgkedua[j]); // flip display print
if (j < 7)
{
Serial.print(", "); // print a comma between data
}
}
Serial.println();
delay(6);
digitalWrite(TX_ENABLE_PIN, LOW); // disable transmit driver
delay(500);
}
rs485.read();
}
AMPV_Modbus_Manual_en_2.1.pdf (580 KB)