I have an UNO R3 to read Analog Channels and transfer the data by serial communication via USB to my Window10 PC. There I can evaluate the data. The transfer data speed using 1 channel and 1 byte data is about 38 kHz, using more channels and values up to 1024 is about 8 kHz/(number of channels).
I tried to move to UNO R4, because the reading of analog channels seems to be faster.
But my communication does not work. Using Arduino IDE looks fine, the data arrive, but when I stop IDE and start my Windows Programm nothing happens. I can open the connection, but no data arrive! I use Serial.write(bytebuffer, length).
Is there a difference in communication betwenn UnoR3 and UnoR4?
Welcome to the forum
When you say that you use a Windows program what is it and how is it connected to the Uno (R3 or R4 ?)
If you are communicating using pins 0 and 1 then on the R4 you need to use the Serial1 object rather than the Serial object that refers exclusively to the Serial monitor
I moved your topic to an appropriate forum category @konstanzer.
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
I use the USB connection to communicate. Therefore I have to terminate the Monitor of IDE, otherwise I could not open the connection in my programm. On Windows side the programm was developped using c# und Visual Studio 2022 and .NET classes SerialPort. In the meantime i played a little. Using UnoR3 I can send and receive data, using UnoR4 I can send data from the PC to Arduino, Arduino receives the data an returns them (Serial.write returns 1), but they do not arrive at the pc. The Arduino programm ist very simple.
// Serieller Empfänger
void loop2()
{
// jetzt die Test-Schleife
byte incomingByte = 0;
for (int i = 0 ;; i++)
{
mu0[0] = 0;
mu0[1] = 0;
mu0[2] = 0;
matrix.loadFrame ((const uint32_t *)mu0);
while (Serial.available() == 0)
delay (1);
SetFramePoint(mu0, i*4, 1);
matrix.loadFrame ((const uint32_t *)mu0);
// Die ankommenden Zeichen lesen, und zwar alle und dabei NewLine (== 10) ignorieren
while (Serial.available() > 0)
{
int w = Serial.read();
if (w != 10)
incomingByte = w;
delay (1);
}
SetFramePoint(mu0, i*4 + 1, 1);
matrix.loadFrame ((const uint32_t *)mu0);
int r = Serial.write(incomingByte + 1);
if (r == 1)
SetFramePoint(mu0, i*4 + 2, 1);
else
SetFramePoint(mu0, i*4 + 3, 1);
matrix.loadFrame ((const uint32_t *)mu0);
delay(5000);
}
}
Mit den Funktionen SetFramePoint and matrix.loadFrame versuche ich nur, den Status auf der LED-Matrix sichtbar zu machen.
This is not related to your problem but in this code
int r = Serial.write(incomingByte + 1);
if (r == 1)
SetFramePoint(mu0, i * 4 + 2, 1);
else
SetFramePoint(mu0, i * 4 + 3, 1);
r will always equal 1 so the code in the else clause will never be executed
I assume to get a value != 1 if the system has some problems to perform Serial.write()!
The Serial.write() function just returns how many bytes were written. It has no way of knowing whether it was successful or whether the bytes were received
Hi @konstanzer
I think this type of problem is usually found to be solved by configuring the DTR signal of the serial port in the C# program, like what was shared here:
Hi ptillisch,
This solved my problem! Thank you very much! I changed my code and the communication now works fine!
Its great to get such help in this forum!
Have a goot time!
Hi @UKHeliBob,
Thank you for this information! It is interesting, my expection was quite different from the real behaviour!
You are welcome. I'm glad it is working now.
Regards, Per
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.