Go Down

Topic: Serial Data not being received? (Read 5157 times) previous topic - next topic

tocpcs

I'm trying to connect the arduino in line with two serial devices. They talk to each other using one bi directional line at 10400kbps.

So, I connect those two serial devices to each other, and then, have just the bi-directional serial line over on a breadboard, to which I have a resistor, and then from the resistor, a 5.1V Zener to ground, and then the forward side of the zener goes into the arduino RX pin.

The arduino has an NRF24L01 connected via SPI using "Mirf" library, and the code is fairly simple - read serial bytes, transmit over Mirf to another arduino which displays that. The other arduino uses a baud rate of 9600 and should display all data received.
I tested it using a baud rate of 9600, and from the computer to computer I can happily send messages.

However, at 10400 baud, from the other serial device, I don't seem to get any data over the wireless - it doesn't appear to be receiving it.

The bi-directional line is idle at 12V and low at 0V, so I thought the zener and then the 10k resistor would be fine.. any suggestions as to what I should look for as to why I'm getting no data?

MarkT

Possible issues:

UART setup wrong for polarity, start/stop bits, parity?

5.1V Zener is too high a value and causing CMOS latch-up?  Try 3.9V zener (or much simpler for testing a 10k/6k8 resistor divider).

10400 baud isn't being generated accurately enough since its a non-standard value?

noise pickup on the line

Oscilloscopes are very useful for tracking down issues like this...  There are sketches that turn an Arduino into a simple oscilloscope BTW.
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

tocpcs

Arduino - you can't set those right?
All I'm doing is:
- Bidirectional line from device to breadboard.
- A 10k resistor takes that signal to another row.
- A 5.1V Zener diode is on that new row, the line on the zener faces the row, the other end goes to ground.
- Then on that same row after the Zener diode has the jumper wire going from the breadboard to arduino pin 0.

Arduino is setup with the baud rate - Serial.begin(10400), I also tried 9600 for good measure - no joy.
I did test wireless link is working, and it is.

All the code is doing is listening on serial for activity (i.e. Serial.available), and then Serial.printing that to the wireless (which is via SPI).

Something to note - the lights for TX / RX don't come up on the arduino despite data being sent.
A multimeter connected from the wire leading to the arduino RX pin and ground shows it changes when data is commanded, however, the arduino doesn't seem to be seeing that data, and as above, TX/RX lights don't change - I thought they would, aren't they electrically related or driven differently?

How does parity come into it?
Anything I've missed in the above? Any other way ?

AWOL

You didn't really mean 10400kbps, did you?

MarkT

UART serial protocol is not one protocol, you can choose the number of start and stop bits (in multiples of 1/2 bit), choose the signal polarity, choose the number of data bits (7 or 8, typically) and select an optional parity bit (and this can be either even or odd parity).  Unless both parties are set up the same there is no guarantee things work even at the same baud rate (typically you get something garbled or an error condition in the UART).   It is very common these days for 8 bits data, 1 start bit, 1 stop bit and no parity, but this is by no means a given.
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

tocpcs


You didn't really mean 10400kbps, did you?


D'oh, no - 10.4kbps


UART serial protocol is not one protocol, you can choose the number of start and stop bits (in multiples of 1/2 bit), choose the signal polarity, choose the number of data bits (7 or 8, typically) and select an optional parity bit (and this can be either even or odd parity).  Unless both parties are set up the same there is no guarantee things work even at the same baud rate (typically you get something garbled or an error condition in the UART).   It is very common these days for 8 bits data, 1 start bit, 1 stop bit and no parity, but this is by no means a given.


That's what I was thinking, I don't get anything.

MarkT

Do you have datasheets for the serial devices?  Or an oscilloscope?
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

tocpcs

Nah, but I thought I'd test the ELM327 scan tool I have to see if that's of any help.

No data from that either, weird.

I start two arduinos side by side, use NewSoftSerial, RX to TX, and no dice.
I connect TX to RX (despite no desire to receive data on the other side), and data starts flowing. Weird.

http://blog.perquin.com/prj/obdii/obdii_avr.gif

That's roughly the circuit I should be aiming for, but I don't want to send, just receive. I was aiming to go from the bidirectional line to the RX pin on the arduino through the resistor, with a 5.1V zener to clamp the voltage down.

I've got to go to work now, but I think if I put the transmit side together, and connected that to the TX (despite having no desire to TX), I'll get data..?

I could have sworn I've used RX only before with nothing on TX and got data from another device...

tocpcs

I put together the circuit exactly as per http://blog.perquin.com/prj/obdii/obdii_avr.gif  however, I can't get it talking.

Is the next best option setting up the arduino as an oscilloscope, or is there something wrong with that circuit?

I have 9V in use instead of 12V (which should accomplish the same result) it's intention is to drive a higher voltage and to drive the direction of the of the signal correctly..
I wonder if the zener diode on the receive side is making things not work?

tocpcs

Still no luck.

I got started into Arduino Oscilloscope, it's working fairly well, but there's no serial data. The line remains high (at 3.59V).

It's at 3.5V. The start was supposed to be 12V, but I'm feeding 9V instead- shouldn't be an issue I'd have thought?
Then, it goes through a 10k resistor, then a wire goes to analog in, and then the end of that goes to ground.

I know the signal is normally Idle high, so I was hoping it'd go low when I got it to send data - not so.

So I tested some more- took the TX pin of the arduino and went direct to analog in - it bounces exactly as it should.

The circuit would normally expect an ECU at the other end - I'm trying to pretend to be a ECU receiving commands, so what I have should be correct, right? Any suggestions at all?

tocpcs

I've got the oscilloscope going with the cable, I get to see just one blip on the screen representing the transmission (can't be right).

Using the sketch in Processing, is there a way I can determine the ms scale? I think it might be going too slow for it to catch (and when I zoom in more, I won't be able to view the scope ...)

I think I need better resolution and a time scale to determine what's happening, the missing 'blips' would be due to the serial print taking the extra time? i.e. if the line is changing state inside of 25us then the serial port won't see it in time (not to mention ADC conversion times?)


tocpcs

I've done some more testing, and come up with some confusing results...
- I removed the resistor, put in a 3.9V zener diode, and tested communication - I get communication but the data is inconsistent (i.e. it doesn't relate as I expect it to, I get FA when I should get FC, CA instead of C1).

I put a 4.7k resistor, as suggested by this page here:
http://sterntech.com/obdii_protocols_iso.php
( apart way down, K-line goes through 4.7k resistor, 5.1 zener to ground, the continues to arduino RX pin (pin 0!)).

Then, I'm listening for communication at baud rate 10400, and I get nothing.. very different to what I was expecting as above- where it works without the resistor, but the data is wrong..

http://blog.perquin.com/prj/obdii/

That's the same sort of idea (half way down), and I expected to get data doing that - but no data.

However, when I connect through a 10k resistor, 5.1V zener, and then have an arduino hooked up as a logic sniffer (http://arduino.cc/forum/index.php?topic=52881.0) - then I can see data but it's wildly inaccurate (I was thinking that due to the 1K sample size and the 10kHz rate that it was missing some packets..)

I did a test the other day with *sending* data - that's utilising the transistor circuit showing at http://blog.perquin.com/prj/obdii/ and that seemed fine (I could determine that the data I was sending was being received and was accurate).

Any ideas on the reason why the resistor stops data getting through? Is that the arduino getting confused in the RX / TX packets ?
I should add, I'm trying to fake being an ECU 'receiving' a request to send data. I don't know if that matters though ?
Any pointers?

tocpcs

Well.. No idea how / why / what / when - but I got my desired bytes from an eBay ELM327 knock off...

I started to monitor data - and these 5 bytes are all I was looking for:
81 10 FC 81 0E

A lot of time for just 5 bytes.

tocpcs

Not content with just that result, I wanted to ensure the cause of the problem (aside from User error).

I was using the arduino for UART (Serial.begin 10400), and NewSoftSerial at 19200 via a USB chip I have but this wasn't receiving any data.
Last ditch effort 10 seconds ago, NewSoftSerial library to 9600 baud (it's wrong, but hey, errors are better than nothing), and the arduino at 19200 baud..

Send random characters - hey! There's some data in the terminal window...

Any thoughts on why the arduino board didn't like 10400?

Go Up