After searching the internet and trying different examples, I always get the same wrong response in the serial monitor.
Picture 1 shows the wrong results. At first i thought it was decimal and I just had to convert it to ASCII. But that wasn't the problem.
Picture 2 shows the results that I expect. It's from the Logic Analyzer that sits on a breadbord to "sniff" the communication. I expect N+0000.0\r
Picture 3 shows the settings or the logic analyzer. Please ignore the "SPI MISO" it's just an old description.
I have no other approach left in my mind.
I would appreciate any hint. :) Thank you in advance.
You will find the Arduino sketch below the pictures.
#include <SPI.h>
#include <Controllino.h> /* Usage of CONTROLLINO library allows you to use CONTROLLINO_xx aliases in your sketch. */
const int numBytes = 20;
int incomingBytes[numBytes]; // for incoming serial data
void setup() {
/* Initialize serial port for debug messages. */
Serial.begin(9600);
/* Initialize CONTROLLINO RS485 direction control DE/RE pins and Serial3 */
Serial3.begin(9600,SERIAL_8N2); //Initialisierung Serial Controllino(RS 485)
//Beim Mega oder Maxi Zugang zum /OVL pin und RS458 /RE DE Pins
//Zuweisung /RE (PJ5) DE (PJ6) pins als Ausgang (1). Für /OLV (PE7) als Eingang (0)
DDRJ |= B01100000;
DDRE &= B01111111;
//Controllino_RS485Init(9600);
//Controllino_RS485RxEnable();
Serial.println("Recieving RS485...");
}
void loop() {
DatenEmpfangen();
delay(1000);
DatenAnzeigen();
}
void DatenEmpfangen()
{
static byte ndx = 0;
int rc;
PORTJ &= B10011111;//Empfangen MODUS
//Controllino_RS485RxEnable();
delay(1000);
do
{
if (Serial3.available() > 0)
{
// digitalWrite(CONTROLLINO_D1, HIGH);
rc = Serial3.read();
incomingBytes[ndx] = rc;
ndx++;
}
} while (Serial3.available() > 0);
}
void DatenAnzeigen()
{
static byte count = 0;
//int Xor = 0;
//Xor = receivedIntegersA[0];
Serial.println("Daten");
for (count=0;count<9;count++)
{
Serial.println((incomingBytes[count]));
}
}


