software Serial interpretation of Datastream

Hi,

first of all my apologies in case I am asking dam stupid questions as I am a beginner.

I searched a lot but could not yet find any hint hence trying here to get a move in the right direction.

I have a electric converted car and intend to modify the electronics a bit. Specifically I have a serial connected Display showing me some Controller details of a Curtis motor controller. I intend to read such values in to transform them into a variable analog signal to connect it to my cockpit instruments. Frist step is to read the Data before then secondly I make use of the data.

If I connect putty, I clearly can read the data stream.
What I see on Putty is then : " P: 0.0kW P: 0.1kW P: 0.5kW P: 10kW P: 0.0kW P:-2.0kW......"

Now I connect my Arduino Uno via RX, having used the sample for SoftwareSerial, however on the Serial monitor I only see unreadable characters coming in.

I guess I need some way of Interpretation of the high and low signal stream, so something like a VT100 Protocol interpretation.

Am I right? Where and how to get there, I really have not found any hint anywhere.

Thanks for your support.

Heiner

Please, post your complete Arduino codes using code tags </>.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

The examples will also work fine with SoftwareSerial.

Be aware the SoftwareSerial does not work at high baud rates. 9600 is good and 38400 should work.

If you do need a high baud rate you should use an Arduino Mega which has 3 spare HardwareSerial ports.

...R

I think Heiner also needs to add a schematic; a photo/scan of a hand drawn one is fine. The mention of differential SoftwareSerial and rx-pin might indicate a wiring problem.

Another problem might be baud rate.

Hi,

ok, the wiring is this Laptop USB—Arduino–RX Pin 0 to TX of controller
–GND to GND of controller

the Laptop is running Win 10, Arduino IDE with open Serial monitor

The code is the sample code further minimised and I am sure I understand it:

<

#include <SoftwareSerial.h>

SoftwareSerial mySerial(0); // RX

void setup() {
// Open serial communications towards USB port of the Arduio UNO and wait for port to open:
Serial.begin(57600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

Serial.println(“Goodnight moon!”);

// set the data rate for the SoftwareSerial port towards the controller
mySerial.begin(9600);

}

void loop() { // run over and over
if (mySerial.available()) {
Serial.write(mySerial.read());
}
}
/>

The Baudrate works for Putty and show the expected outcome. The Arduino Serial monitor I expect to show the same but just show unreadable characters coming in with many “???”

Only if this outcome on the serial monitor is readable I can start to think about parsing.

Am I wrong?

Many thanks again.

Don't use software serial on pins 0 and 1.

As suggested in Post#5, avoid using Hardware UART Port (RX, TX) for your controller. You codes could be re-arranged (using software UART Port) as follows (untested):

#include <SoftwareSerial.h>
SoftwareSerial mySerial(4, 5);       //SRX , STX
// SRX = 4 connect this DPin-4 with TX-pin of your controller; DPin-5 with RX-pin of the controller
// GND line with GND line of the controller

void setup() 
{
  Serial.begin(9600);
  mySerial.begin(9600);

  Serial.println("Goodnight moon!");
}

void loop() 
{ 
   if (mySerial.available()>0) 
   {
      char c = mySerial.read();  //assuming that your controller is sending ASCII codes    
      Serial.print(c);                //human friendly characters should appear on Serial Monitor
   }
}

Hi I tried, and I think I understand the code, I used port 4 now as suggested but the response still is not readable.

In there I see Goodnight moon! but many more strange caracters like boxes and mirrored question mark.

Where in the code i can say to use 8 databits, 1 stop nit, no parity etc. Those infos are in putty default beside baudrate. In the code i only have the option to define baudrate....

8N1 is the default.

Serial.begin() can take an additional parameter. But you want to use it on SoftwareSerial and SoftwareSerial does not support it (to my knowledge). There are other libraries that possibly support it (NeoSWSerial and AltSoftSerial).

For your PuTTY test, how do you connect the controller to the the PC? Are you using a USB-to-RS232 cable? If so, you need a level converter / inverter like a MAX232.

Hi,

to connect Arduino to PC I use a USB to serial Adapter and nothing more and it works. the Adapter has a PL2303 Chip which to my understanding need just 5V

I checked the Controller Signal which is 5V

My aim is to use the Controller information. How to do it, I do not really care. I thought SoftwareSerial might be most straight forward.

Would you go for a different preference? and why (just to understand)

Heiner1967:
to connect Arduino to PC I use a USB to serial Adapter and nothing more and it works.

What Arduino Board are you using?

Most Arduinos have a socket for direct connection of a USB cable to a PC.Why are you not using that?

Post a link to the datasheet for your USB-Serial adapter.

It would be a big help if you post a simple diagram showing how you plan to connect things. It would be much clearer than a verbal description. See this Simple Image Guide

...R

For read a Serial comunication you HAVE TO know the rate of transmition, the controls (vecause there are many different possibility of controls made by Serial.write() and "destroyed" by Serial.read(), but all the talkers have to know and use the same rules.
Secondary (I don't know if it is your case) but it MAY BE that in the Serial pass strange (for you) data, transformed into value by a controller in the destination.
Fo you know this informations?

Robin2:
What Arduino Board are you using?

Most Arduinos have a socket for direct connection of a USB cable to a PC.Why are you not using that?

Post a link to the datasheet for your USB-Serial adapter.

It would be a big help if you post a simple diagram showing how you plan to connect things. It would be much clearer than a verbal description. See this Simple Image Guide

...R

I asked how OP could read the device using the PC to eliminate possible RS232 involvement; for that, the PL2303 adapter was used.

OP is using the Arduino in between a device and the PC; PC possibly only for debugging.

sterretje:
I asked how OP could read the device using the PC to eliminate possible RS232 involvement; for that, the PL2303 adapter was used.

OP is using the Arduino in between a device and the PC; PC possibly only for debugging.

Thank you.

IMHO this is a case where it would help the OP to clarify his understanding of his own problem if he takes the trouble to answer my questions.

...R

Hi, apologies I did a mistake.

My Arduino Uno is connected via USB cable to the PC. The controller signal is 5V and connected directly to the relevant PIN of the Arduino as per SW code. What I read on the serial Monitor is unreadable characters.

IF however I take the controller signal direct to a USB to Serial Adapter (PL2303) plugged to my PC, and let run the PUTTY SW application I read in clear text. IT works even no max232 is used which was asked.

Both I do with a BAUD rate of 9600.
No more config in Putty, and effectively no more config in the SW code for the Arduino.

Any more idea where the problem sit? Am I right to assume Putty shall show the same as serial Monitor?

Sorge,
So you KNOW the baud, and all the other caracteristics of the transition, but you can’t revive by Arduino, but only by computer?

Heiner1967:
My Arduino Uno is connected via USB cable to the PC. The controller signal is 5V and connected directly to the relevant PIN of the Arduino as per SW code. What I read on the serial Monitor is unreadable characters.

Post the latest version of your Arduino program?

If you include (in setup() ) Serial.println("Arduino Starting"); do you see the text correctly?

...R

HI, I use Arduino 1.8.5 (Windows Store 1.8.10.0)

and to Robin yes I see on the Serial Monitor "Ardunino Starting" in readable letters followed by random characters.

Heiner1967:
HI, I use Arduino 1.8.5 (Windows Store 1.8.10.0)

and to Robin yes I see on the Serial Monitor "Ardunino Starting" in readable letters followed by random characters.

Please post the program that gave that result.

...R

Hi this code show "Arduino starting in clear Test in the Serial Monitor, but by Controllersignal is still not readable.

And I do not wonder as this is directly going from the code to the Serial port to the PC, and not from the Controllersignal.

#include

SoftwareSerial mySerial(10, 11); // RX, TX

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

Serial.println(“Arduino Starting”);

// set the data rate for the SoftwareSerial port
mySerial.begin(9600);
}

void loop() { // run over and over
if (mySerial.available()) {
Serial.write(mySerial.read());
}
}