How to I measure time between sending serial data and receiving it?  - Page 1
Forum section: electronics / beginners

author: francoisgenolini
author_rank: Newbie
timestamp: June 19, 2015, 09:05:49 am
content: Hi,This is probably a logic analyser question.I am a software engineer, originally trained as an electronics engineer (some time ago, in the 1980's).I would like to measure the time it takes for a system under test to process serial data.I have one unit under test with one serial input port (RS-232) and one serial output port (RS-232).The unit under test does some calculation after input, and then outputs.The objective is to measure the (output - input) time of about 100 milliseconds (or small multiples of this), and be able to see the variations (how many milliseconds or tens of milliseconds variation could there be).So far we have connected the unit under test to a standard Windows PC (no special precautions or preparations). This PC sends the serial data to the unit under tests, then waits for the response, and calculates the time taken between sending the test serial data, and receiving the result.This PC uses serial to USB converters, uses .Net and a user interface and logs all results to file.I would like now to have an independent alternative set of measurements.First I will use an industrial PC with a special chipset that has multiple serial ports connected directly to the motherboard, no USB conversion. I intend to recompile a customised real-time version of the Linux kernel in a command line only Linux distribution, and then log the results to memory.I would have more confidence in the reliability of the data I get from this Linux box due to its much simpler make up, and the fact that I have more control over what runs on the system.Then I would like to use a logic analyser.I would expect to be able to configure the Linux box to send well defined serial data to the unit under test, then get the logic analyser to wait and trigger a serial capture and time stamp as soon as this specific serial data is detected in the input port of the unit under test, then configure the logic analyser to wait on the output serial port of the unit under test for a different specific serial data, and here again capture and time stamp the serial data on that second (output) serial port.Is this the kind of test that logic analyser can do? What make and model would I need for this? Do they come with probes that are suitable for serial (RS-232)? Would you know any UK shop or company that could help with purchasing or renting such a logic analyser?Regards,Francois GenoliniAberdeen, Scotland

author: f5r5e5d
author_rank: Frequent Contributor
timestamp: June 19, 2015, 09:55:04 am
content: if the serial data is easily isolated by short message time with no other confusing traffic then just look at the data lines with a digital 'scope with decent memory depth - even a low cost Rigoland getting digital scope with a serial decode function is cheap too todayas for a board level/software solution "bare metal" (just C or assy, simple loop, interrupt, timer hardware - no OS ) serial monitoring with a demo board/arduino will be a lot more deterministichttps://www.google.com/#q=serial+bus+decoding

author: tautech
author_rank: Super Contributor
timestamp: June 19, 2015, 10:19:50 am
content: If you are just wishing to measure the time AND nothing else a DSO will do it.Attach one channel to the incoming and the other to the outgoing, set the trigger to the outgoing with the appropriate rising or falling setting, then use "single shot".Resultant capture "should" show the last of the incoming, triggered by the first of the outgoing.Use graticules and the timebase setting to calculate the time.Visualise that?

author: f5r5e5d
author_rank: Frequent Contributor
timestamp: June 19, 2015, 10:24:17 am
content: can buy DB-9 inline breakout boards too - no soldering, opening boxes needed

author: EEVblog
author_rank: Unknown
timestamp: June 19, 2015, 10:27:51 am
content: If you had access to the firmware source code you'd normally just make it toggle a pin when received and when sending and measure the time difference on a scope.otherwise still just use a digital scope and measure the time period between the end of the receive packet and the start of the transmit packet.

author: francoisgenolini
author_rank: Newbie
timestamp: June 19, 2015, 11:49:21 am
content: Thanks to all,I like the Arduino answer best; I forgot about that.Regards,François GenoliniAberdeen, Scotland