Serial Passthrough

what kind of serial monitor are you using, and what was the output you received hooking the ECU straight onto it ?

@Deva_Rishi, it is solved in #14. the bytes are there

UKHeliBob:

Got data

ÿGot data
þGot data
þGot data
þGot data



Those whacky characters at the start of the lines is what is being received from the device and being passed on to Serial

Yes the serial is arriving but somehow the system is not working so there is still something amiss.

Deva_Rishi:
he was using jumpers, so he had the RX1 & TX1 connected as well, now i want to know 'How exactly ?' and 'you' don't know.. so why do you answer ?

Using jumper wires. Tried both configurations of RX/TX

Deva_Rishi:
what kind of serial monitor are you using, and what was the output you received hooking the ECU straight onto it ?

Free Serial Port Monitor 8.10

I know what a packet looks like from the device. I can see it arriving at the Arduino something is going wrong during transmission to the PC. Also commands from the PC side are not making it to the device via the arduino.

Juraj:
@Deva_Rishi, it is solved in #14. the bytes are there

Not quite solved, yes the bytes are there but the system is not working. Still trouble shooting

Does a simple "Hello World" transmission to the Free Serial Port Monitor 8.10 work ?

digitalben:
Free Serial Port Monitor 8.10

I know what a packet looks like from the device. I can see it arriving at the Arduino something is going wrong during transmission to the PC. Also commands from the PC side are not making it to the device via the arduino.

I tried to install the monitor (or at least the one i think you were using this ?but i couldn't get it to work,(i am not the only one it doesn't seem to work on 64-bit although it states that it does.) but what i suspect is that there is a baud rate issue... and your serial monitor is doing some auto detection thing.
So check the monitor and see if it does and/or experiment with some settings on the input side (Serial1)
Or your could change the output to a HEX format.

  if (Serial1.available()) {     // If anything comes in Serial1 (pins 19 & 18)
    Serial.print(Serial1.read(),HEX);   // read it and send it out Serial (USB)
    Serial.print(", ");
  }

So that it can be read as something we understand.
Some data comes in at the Arduino side (non or hardly printables..) and for sure the Arduino can send data to the PC (Got data confirms that)

UKHeliBob:
Does a simple "Hello World" transmission to the Free Serial Port Monitor 8.10 work ?

Yes

Does manual text input to the Serial monitor get displayed OK on the Free Serial Port Monitor ?

UKHeliBob:
Does manual text input to the Serial monitor get displayed OK on the Free Serial Port Monitor ?

Yes.

I think the signal to the device is dropping out, when I hooked up some LEDs to the TX/TX lines going to the device, I noticed they were flashing but not very brightly compared to when I jumpered LED to gnd so it would appear the device isn’t driving the line low enough but oddly it also happens with the Arduino serial1 tx line not just the device TX (Arduino RX). By multi meter the line is around 5v when transmitting tho. Think I need to look at it with my scope when the bits arrive.

The other test I did was my separate USB-TTL adapter connected to the device to watch the TX/RX LEDs and see the pattern then hookup the Ardruino Serial1 and LEDs on TX/RX, by chance when I had both Arduino and USB-TTL converter simultaneously connected the comms to the device didn’t work. This would seem to imply the impedance of the devices TX/RX lines are sensitive to loading? Adding a pull-up resistor to the Arduino Serial1 lines or turning on the internal pull-up resistors didn’t change anything...

OK, so hooked up the scope and tested a few things out.

  • Baud rate from the device is 38400 (26uS/bit)
  • TX of the Serial0/1 is very slow. Both configured to 38400 in the code (ref below)
  • Serial0 is around 39.4uS /bit
  • Serial1 is around 52.0uS /bit
  • Lag between Serial0 and Serial1 is around 269uS (not too concerned with the lag at this stage

Could it be that the Mega8 programmed to be the USB-TTL converter is too slow? [edit. maybe not too slow but borderline because when it is hooked directly to the device it works ok...]

This is the code used, modified for 38400 baud

/*
  Multple Serial test

 Receives from the main serial port, sends to the others.
 Receives from serial port 1, sends to the main serial (Serial 0).

 This example works only with boards with more than one serial like Arduino Mega, Due, Zero etc

 The circuit:
 * Any serial device attached to Serial port 1
 * Serial monitor open on Serial port 0:

 created 30 Dec. 2008
 modified 20 May 2012
 by Tom Igoe & Jed Roach
 modified 27 Nov 2015
 by Arturo Guadalupi

 This example code is in the public domain.

 */


void setup() {
  // initialize both serial ports:
  Serial.begin(38400);
  Serial1.begin(38400);
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte);
  }

  // read from port 0, send to port 1:
  if (Serial.available()) {
    int inByte = Serial.read();
    Serial1.write(inByte);
  }
}

digitalben:
OK, so hooked up the scope and tested a few things out.

  • Baud rate from the device is 38400 (26uS/bit)

I knew it ! your Serial Monitor does have some kind of auto-detect.
Reading a whole byte (or Integer, are you reading an integer ?) and sending that as a whole is always going to cause 'lag' , compared to the direct connection, but why don't you beef-up the Serial-USB up to 250000 (or more if your Serial monitor can handle it. there is no need for both ports to run at the same rate anyway.

digitalben:
Could it be that the Mega8 programmed to be the USB-TTL converter is too slow? [edit. maybe not too slow but borderline because when it is hooked directly to the device it works ok...

No i don't think so, i am a little confused by the discrepancies between the 2 ports, but i am not sure what you measured anyway. Great, solved ! Does the pass through work just fine now also in it's original spec (with char) but at the proper BAUD rate ?[/list]

1 Like

Yes it appears to work now with some tweaking of the code.

Thanks for your input!

1 Like