Pokaż wiadomości

Ta sekcja pozwala Ci zobaczyć wszystkie wiadomości wysłane przez tego użytkownika. Zwróć uwagę, że możesz widzieć tylko wiadomości wysłane w działach do których masz aktualnie dostęp.


Wiadomości - Touny

Strony: [1]
1
EU07 Simulator English forum / Maszyna with Arduino
« dnia: 09 Lipca 2020, 20:35:22 »
Greetings everyone. I'm missing english version of topics "Nastawnik/Pulpit do komputera" and "MaSzyna z portem COM" so i decided to create this topic.
---------------------

My question:

I've managed to get communication to work thanks to this: https://eu07.pl/forum/index.php/topic,13529.msg529872.html#msg529872
My RX and TX LEDs are blinking, output from Maszyna - CA/SHP LED works fine. However, I can't get any input to Maszyna. For input I tried this: https://eu07.pl/forum/index.php/topic,13529.msg524782.html#msg524782 so then the whole code in Arduino looks like this:

volatile uint8_t zPC[52] = {0}; // standardowe bajty przekazywane do kodu Arduino
volatile uint8_t doPC[20] = {0xEF, 0xEF, 0xEF, 0xEF, 0}; // standardowe bajty przyjmowane z kodu Arduino

void setup()
{
pinMode(48, OUTPUT); //ustawienie pinu 48 (wbudowana w Arduino dioda LED) jako wyjście cyfrowe
digitalWrite(48, LOW); //ustawienie stanu niskiego na pinie 48

pinMode(33, INPUT_PULLUP);

Serial.begin(115200); //nawiązanie komunikacji z prędkością 115200b/s
Serial.setTimeout(10);
while(!Serial){}; //czekanie do nawiązania komunikacji z komputerem
}

void loop()
{

digitalWrite(48, (bitRead(zPC[8], 7))); // lampka CA/SHP
bitWrite(doPC[0], 7, !digitalRead(33)); // przycisk CA/SHP

while (!Serial.available()) {};
Serial.readBytes((char*)zPC, 52);
Serial.write((char*)doPC, 20);

}

Problem 1: When I press the button (33), RX and TX LEDs stop blinking and Arduino does not respond until simulator restart. (CA/SHP LED keeps turned on, etc.)

Problem 2: Also I'm very confused by the bytes and bits layouts. Understanding output layout was easy with this (UART xml): https://eu07.pl/forum/index.php/topic,28460.msg430131.html#msg430131 but I cant understand the input - combination of switch group, bytes and bits exceeding number 7 in input-uart.ini. Solving problem 1 will surely help solving problem 2 by trial and error.

Strony: [1]