Hello. I try to connect Arduino pro micro to coffemashine by MDB like cashless device. MDB use 9 bits and Arduino pro micro have hardware 9bits port. then I connect Arduino pro micro TX/RX () - MDB RX/TX
create test sketch:
byte EXT_UART_BUFFER[37]; //входящий буфер для полученной команды от VMC
int EXT_UART_BUFFER_COUNT;
byte EXT_ChecksumValidate() {
byte sum = 0;
for (int i=0; i < (EXT_UART_BUFFER_COUNT-1); i++)
sum += EXT_UART_BUFFER[i];
if (EXT_UART_BUFFER[EXT_UART_BUFFER_COUNT-1] == (sum & 0xFF))
return 1;
else
return 0;
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial1.begin(9600);
Serial1.setTimeout(100);
}
void loop() {
// put your main code here, to run repeatedly:
EXT_UART_BUFFER_COUNT = 0; //ставим размер буфера 0
while (Serial1.available()) {
//записываем все данные с порта в приемный буфер
EXT_UART_BUFFER[EXT_UART_BUFFER_COUNT++]=Serial1.read(); //и за одно получаем размер этой команды
delay(20); //задержка а то команда не успевает приняться целиком
}
if (EXT_UART_BUFFER_COUNT > 0) {
Serial.print("Recvd CMD: ");
for (int a = 0; a < EXT_UART_BUFFER_COUNT; a++){
if (EXT_UART_BUFFER[a] < 16) Serial.print("0");
Serial.print(EXT_UART_BUFFER[a], HEX);
}
Serial.println("");
}
}
The devices communicate in a single-master, multiple-slave configuration using the MDB protocol, which is based on a Motorola[specify] 9-bit UART implemented as an 8-bit data value with an additional mode bit.
Nonsense. The 32U4 has native USB support that is used for communication over USB with the PC. The UART (on pins 0 and 1) is not involved in the communication with the PC.
If MDB uses 9-bit communication you will need a library that enabled the 9-bit feature of the UART hardware. The Arduino library does not include 9-bit support. There may even be someone who had made an MDB library. Try google.