Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Quick and dirty test of serial data?

Status
Not open for further replies.

MikeMl

Well-Known Member
Most Helpful Member
I have a "black box" which outputs a poorly-documented Serial data stream. I think the data stream may be coming directly from a PIC UART with no intervening Max232 driver chip between the PIC pin and the external connector pin. I cannot open the box. I think the data is 9600baud N81, but I am not sure of that.

If so, is this data stream "inverted" with respect to the signals expected by the serial port input to an old DELL laptop I intend to use to capture the stream to be able to see the data?

What is the simplest way of interfacing the data to the laptop?

A single NPN transistor inverter with a pull-up to a 9V battery?
 
hi Mike,
A quick and cheap way to connect is shown in this circuit [ ignore the PIC's main functions ]
Use any general purpose transistor.

E

It uses the PC's -V, that is standing on the PC's RXD line.
 

Attachments

  • AAesp03.gif
    AAesp03.gif
    26.7 KB · Views: 257
Hi MikeML,
The signal to the RS232 port on the laptop should swing from a negative voltage to a positive voltage. (I think the RS232 spec says - 10v to + 10V but laptops often only go from -5 to +5) Weather it will work with a swing from zero to +5V depends on the interface design of the laptop. I suggest seeing if the laptop will display what is typed with a diode with the negative end to the transmit pin and the positive to the receive pin. If this works ( 0 to + 4.4V swing.) then it should work with your single NPN inverter. If there are gaps in the data string then this should be the state when the RS232 signal is in the negative state. (Or 0 volts with your single ended signal.) This should help you to decide if the signal needs to be inverted. If you are sure that the PIC is using its hardware UART then an inverter will be required ad a MAX232 inverts the TX signal.

Edit I've just seen ericgibbs reply. Using his method will generate the bipolar signal. You may even find that one of the modem control signals from the laptop is sitting at + 5 volts so that you do not need an external + 5V supply.

Les.
 
Last edited:
The circuit I posted does invert the signal and also swings neg/pos.
It is a commonly used option, it works.;)

EDIT:
Just seen Les's edit.
Thanks Les.:)
 
The testers use 2 leds on each line one RED for -ve GRN for +Ve reverse connected.
I had made a few up (befor ebay) with various gender sockets for back in the 25pin com days.
Max.
 
I have a "black box" which outputs a poorly-documented Serial data stream. I think the data stream may be coming directly from a PIC UART with no intervening Max232 driver chip between the PIC pin and the external connector pin. I cannot open the box. I think the data is 9600baud N81, but I am not sure of that.

If so, is this data stream "inverted" with respect to the signals expected by the serial port input to an old DELL laptop I intend to use to capture the stream to be able to see the data?

What is the simplest way of interfacing the data to the laptop?

A single NPN transistor inverter with a pull-up to a 9V battery?
Yes a simple inverter is all that is needed. They use TTL input thresholds 1.2~1.4 on RS232
 
RS-232 accepts +/3V to +/-30V but the threshold is roughly the same as TTL with optional hysteresis dependent on implemenation.

The bipolar signal give the single-ended signal more noise immunity but the 232 Rx input threshold is still nearly the same as TTL so that a floating input is a 0 for control signals (off) but a "break" for data.

trivia... TTL input is 2 diode drops or 2 Vbe drops. since 74xx to 74S to 74L to 74LS but CMOS types 74HC used Vcc/2 were still TTL compatible. and RS232 although bipolar is also TTL compatible or CMOS
 
Last edited:
A PICkit2 has a USART function that works on 0 - 3 V or 0 - 5 V levels. Idle is high, the start bit is low, the stop bit high, and 1 is a high level.

Run the PICkit2 software (not MPLAB), and connect ground (pin3) and the input (pin4) to the circuit. Select any PIC, as the USART function isn't available unless one is selected. Select the USART function (under "Tools"). You need to tick the box at the top to power the circuit from the PICkit2, even though you aren't doing that. Select the baud rate and click on "Connect".

Use an oscilloscope to find the baud rate, or expect quite a bit of trial and error.

To test that the USART is working, short pins 4 and 5, and anything you type is echoed, so appears twice, but only once without the short.

What appears can be logged, and you can copy and paste from what is on screen.

I've used that many times to quickly read the 0 - 3 V serial streams. It behaves much the same as an RS232 converter feeding into a serial port and terminal emulator, as long as there is no hardware handshaking. I think the baud rate on the PICkit2 is limited to 30k or so.
 
Hi Driver300,
The Arduino software in conjunction with an Arduino Uno can be used in a similar way. As well as the ATmega328 the Uno board uses an ATMEGA16U2 as a USB to serial converter. I have used this in the past to configure Bluetooth modules. Here are the notes I made on the subject.

Using the Arduino Uno to configure an HC05 Bluetooth module.


Either remove the ATMEGA328P or program it with this sketch which will not enable the TX pin on the ATMEGA328P. (It just runs a tight loop doing nothing.)


Connect the RX pin on the Aduino board to the RX on the HC05 module via a potential divider consisting of a 5K6 restistor from the RX pin on the Arduino and a 10 K resistor to ground. NOTE Connecting the RX pin to the RX pin seems strange but the RX pin on the Arduino board is actualy the TX pin on the ATMEGA16U2.

Connect the TX pin on the Arduino to the TX pin on the HC05 together with a 3.3 volt zenner to ground. (+ to TX pin - to ground.)


In the Arduino window click on the "Tools" dropdown box and select "Serial monitor"

In the "serial monitor window" set the baud rate to 38400 bauds. In the box to the left of the baud rate box select "Both NL & CR"
Type the required AT command in the send window then click send.
You will see the response in the main part of the serial monitor window.
I can't remember weather there is a way to capture a long string of received characters.

Les.
 
I think the port itself on the pc only needs 5v, Max is a converter so it can go longer distances, which confused me, in the end check your box to ensure it only outputs 5v, in my experience all you need is dat and ground to get data in to the terminal, i have driven PC serial port direct from 5v Uc's
 
hi,
Yes, I know, I sometimes have to take that route. ;)

Post #12 said, I think the port itself on the pc only needs 5v,
Which it normally does, but the user should be aware of possible signal inversion

Also in case a newbie misunderstood this statement: in my experience all you need is dat and ground to get data in to the terminal

E.
OT. Hope you are enjoying the nice weather.
 
It is more likely that the designer would encode TX/RX pins as end user interface, if it were uart the pin would more likely be along with/like ICSP bus , so we would have 5 pin coming out, clr,vcc,gnd,clk,dat

serial implies we are looking at 9 wire, and inversion is already thought of, on both encoder and decoder:
**broken link removed**

of course we are still speculating here, my camera outputs 9600b serial and has 4 wire. our box could just as well be outputting alieneese encryption,

FOR SAFETY: check that we are not using the +10 - -10 v encryption, I have read about these so I know what others are talking about, but this is mostly associated with old modems and long wires(im sure other things as well *or something like that), none of the serial devices in my bsmt here drive at anything other than 5v, and i have never seen one that does, BUT check to be sure!!! if only 5v on our power and data pins , sounds like green light to me!

I think it would be best to describe/image how many wires are coming out and what shape they are in,.
Our best tool in this scenario is a scope, if no scope than logic analyzer on pickit,
if not either of those then just plug in, why not, by doing so we will not be able to see exactly what is coming through but you can see noise get decoded as long as you ensure to have the start/stop bits on the correct edge of the "noise signal" to allow the dataflow,
or what i mean is:
1)setup terminal so there is no stop bit and no parity
2)terminal now acts as sloppy scope , by changing the baud we will see your data resolve from more than FF's and 00's
3) after we are getting any input maybe turn stop bit back on , it will be trial and error on our exact: baud,parity,stop,handshake setting. If we don.t have the papers.
4)It is this point we will know if Eric's inverter is required(if we need to translate by inversion).
Certain serial handshakes require RTS and other pins as well, i think default is: XON/XOFF

Also if we are splicing our own plugs don't get confused that ones TX is the others RX
The second electrical incompatibility could be this: if your PC outputs logic1, and device outputs logic0 connecting these two TX wires would/could be hazard for system. Same thing if we get vcc/gnd backwards. We should be able to presume that this is a completed functioning device, but should go through steps where doubt is in order about design flaws.

BTW! Br@y Terminal ROCKS!
 
Last edited:
Although probably too late....

Your idea would work, even 5V would be fine - laptop comm ports tend to output +/-6V at best, as their charge pump drivers are 3.3V - but that's assuming its serial, and you'll have to fiddle with baud settings until you get consistent results.
When dealing with unknown comms (suspected SPI, PPM, serial etc...) and left my gear at work , I tend to just use an NPN, with a base resistor, zener to ground, and another series resistor, along with a collector pull up (to 3-5V) straight into my 'line-in' on my soundcard and use Audacity. At a push, I have just used a single resistor, and back-to-back 1n4148's for clamping. Even TTL logic is fine as long as the series resistors are large enough for protection. Its not like we're dealing with mains power (or are we?!)

Sure, I have logic analyzers, endless micro's with hardware modules to program and 'read in' data, to spit them out on an LCD or via USB, but the above can be done in a few minutes - very handy for just 'seeing what it looks like'. From that you can guess the format, and measure the baud (most audio editing software will measure between two points, using sample-rate as a timebase) and then switch to something specific to that protocol - be it UART, CANbus, I2C etc.. The ability to record hours of data packets to view later is a bonus.
 
Status
Not open for further replies.
Back
Top