Hi,
I use arduino side as in schema, arduino have ch340 as USB. On other side have usb to rs485 converter as in picture http://img.dxcdn.com/productimages/sku_296620_3.jpg
void setup() {
Serial.begin(9600);
}
byte cntrl;
byte node = 0xAC;
byte snd[7] = { 0xAA, 0xBA, 0xCA, 0xAA, 0xBA, 0xAA, 0xFF };
void loop() {
if(Serial.available()) {
delayMicroseconds(50);
cntrl = Serial.read();
}
if(cntrl == node) {
digitalWrite(2, HIGH);
delay(250);
// Serial.write(snd, 7);
Serial1.write(0xAC);
delay(250);
digitalWrite(2, LOW);
cntrl = 0;
}
}
Strange thing is when i press MCU and release, computer got all 7bytes correctly, on other way, when press without release, or power restart MCU, got only part of that chain, or don`t got anything. There is no bad contacts, that behaviour is on same MCU type from other sellers too.
I suppose that when press, MCU got some logical 0 or 1 or something like that and start working. But i`m not sure what can be cause, and what can do to avoid that behaviour.
From computer(os X) send over coolTerm: hex: AC and respond need to be from example, one byte, or 7 byte depend what line i use.