Go to Post Life has its Ups and Downs, you can stay down or push yourself. - Mike Schroeder [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 04-12-2011, 01:02
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,088
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Windows jitter

(I moved the following post to this new thread so as not to hijack Dr Joe's thread on CAN)


Quote:
Originally Posted by Greg McKaskle View Post
Since I don't happen to have a scope, or a PC with a serial port for that matter, does anyone have a screen to share, or a description of the effect?
I don't have a digital storage scope either, but here's a graph showing the timing jitter of 10,000 samples I just collected of a 20ms period task running on an XP machine.

Looks pretty good, but 10,000 samples at 50Hz is only 3.3 minutes, and I didn't have anything else running.

I'll post more detail later tomorrow how I acquired the data if there's interest.


Attached Thumbnails
Click image for larger version

Name:	WindowsJitter20ms.png
Views:	149
Size:	21.4 KB
ID:	11151  
  #2   Spotlight this post!  
Unread 04-12-2011, 22:57
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,088
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Windows jitter


Quote:
Originally Posted by Ether View Post
...and I didn't have anything else running.
See attached graph of samples collected while surfing the web. Yikes!



Attached Thumbnails
Click image for larger version

Name:	WindowsJitter2.png
Views:	104
Size:	19.0 KB
ID:	11153  
  #3   Spotlight this post!  
Unread 05-12-2011, 08:56
Hugh Meyer's Avatar
Hugh Meyer Hugh Meyer is offline
Registered User
FRC #1741 (Red Alert Robotics)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Greenwood Indiana
Posts: 158
Hugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud of
Re: Windows jitter

Ether,

Now you are starting to see what I was talking about!

I hope to get your code and test it on a classmate in a FRC driver station. There is no serial port, so I was planning to use an output pin on the cypress board that we use for driver station IO. It may be a few weeks before I get this done.

Can you describe how you are collecting and plotting this data. As I recall, in a previous thread, you said you didn't have a scope? I do have a scope and will see the jitter as a vertical line smeared on the horizontal scale.

-Hugh
  #4   Spotlight this post!  
Unread 05-12-2011, 11:35
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,088
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Windows jitter

Quote:
Originally Posted by Hugh Meyer View Post
Ether,

Now you are starting to see what I was talking about!

I hope to get your code and test it on a classmate in a FRC driver station. There is no serial port, so I was planning to use an output pin on the cypress board that we use for driver station IO. It may be a few weeks before I get this done.

Can you describe how you are collecting and plotting this data. As I recall, in a previous thread, you said you didn't have a scope? I do have a scope and will see the jitter as a vertical line smeared on the horizontal scale.

-Hugh
Hugh,

Keep in mind that the data I generated was from a small app I wrote in which I made no attempt to optimize the realtime behavior. I don't know what steps were taken in the Driver Station app to make its realtime behavior more stable and accurate.

To collect the data shown in my previous two posts, I wrote a simple 32-bit Windows console app (different from this) which allowed me to run a test and grab the data all on one machine. It basically does this (pseudo-code):

Code:
first collect the samples:

samples=10000;

for(i=0,i<=samples,i++){
sleep(20);
// grab RDTSC1 here
}

then write them to a file:

for(i=1,i<=samples,i++){
// write i and (sample[i]-sample[i-1]) to the output file
}
So basically, I am sampling the time at each start of a 20ms periodic task. The difference in start times between consecutive periods is what I plotted.


To plot the data:
- import the data into Excel

- plot the data and locate the "quiescent" value

- go back and multiply each data point by 20/quiescent

- re-plot the data

Then I realized I have an old DOS machine in the basement which could easily be used to make a poor-man's scope of sorts. Old DOS machines are great for data acquisition and other time-critical tasks because DOS is not multitasking, and it lets you work directly with the hardware. The MC146818 realtime clock chip can be programmed to generate interrupts up to 8092Hz. I use this interrupt to increment a 32-bit counter, and that gives me a counter that increments every 123.5 microseconds that I can use for timing measurements. I wrote a small program that basically does this:
while (1) if(CTS_has_changed_state) readCounter;
That will capture the timing of the rising and falling edges of the changes at the CTS pin (pin8 of the RS232 port). No logic is necessary to detect CTS_has_changed_state; it can be read directly from bit0 of the Modem Status Register.

I haven't had a chance to do this yet, but my plan is to make an RS232 cable to connect the DOS machine's COM1 port CTS pin to the RTS pin of my machine-under-test (XP) which is running the RTS toggler I posted here.


Since you want to run a test on the Driver Station on a machine that does not have an RS232 port, there's really nothing in the RTS toggler app that would be of any use to you (all it does is toggle the RTS pin). Is the source code available for the Driver Station? If so, I suppose what you could do is edit and re-compile the Driver Station to toggle the output pin of the Cypress board like you said. Raise the pin at the start of the task and lower it at the end, then either measure the waveform with an oscilloscope or use some other test equipment (like my DOS machine discussed above) to capture the timings of the transitions of the pin.




1the RDTSC is a screaming fast read-only 64-bit hardware counter that can be latched and read "bare metal" with only 1 assembly instruction (Windows allows you to read it directly from the hardware; no API required). On the XP machine I ran it on, it ticks at about 3GHz. Note: there are some issues with RDTSC on newer machines so YMMV.



Last edited by Ether : 05-12-2011 at 12:11.
  #5   Spotlight this post!  
Unread 05-12-2011, 12:36
Hugh Meyer's Avatar
Hugh Meyer Hugh Meyer is offline
Registered User
FRC #1741 (Red Alert Robotics)
Team Role: Mentor
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Greenwood Indiana
Posts: 158
Hugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud ofHugh Meyer has much to be proud of
Re: Windows jitter

Ether,

You know you can still do this all in assembler... If you don't already know about this, you might like this link.

http://masm32.com/

I often use lines on the parallel ports for stuff like this. There is less "junk" in the way. :-)

-Hugh
  #6   Spotlight this post!  
Unread 05-12-2011, 21:06
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Windows jitter

If the point is to measure the jitter of the DS, why not do what Marshall did and measure it at the robot? After all, the jitter would include that introduced by the DS, by the networking code of the DS laptop, each network switch, router, AP, or other appliance, and finally the network code on the robot. All contribute, so measuring only the DS is measuring only a portion of the jitter.

Greg McKaskle
  #7   Spotlight this post!  
Unread 05-12-2011, 21:35
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,088
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Windows jitter

Quote:
Originally Posted by Greg McKaskle View Post
If the point is to measure the jitter of the DS, why not do what Marshall did and measure it at the robot? After all, the jitter would include that introduced by the DS, by the networking code of the DS laptop, each network switch, router, AP, or other appliance, and finally the network code on the robot. All contribute, so measuring only the DS is measuring only a portion of the jitter.

Greg McKaskle
All very true indeed.

Can't speak for others, but I did what I did because I wanted to put something together that could very easily be replicated in the classroom as a teaching tool for students to show them (seeing is believing) what happens to a program in a preemptive multitasking environment.

Rookie teams don't have a robot yet, and may not have access to one.



  #8   Spotlight this post!  
Unread 11-12-2011, 21:40
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,088
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Windows jitter

Quote:
Originally Posted by Ether View Post
I haven't had a chance to do this yet, but my plan is to make an RS232 cable to connect the DOS machine's COM1 port CTS pin to the RTS pin of my machine-under-test (XP) which is running the RTS toggler I posted here.
OK I did it:

XP machine running a process which toggles the COM1 RTS pin at 50Hz 25% duty cycle (5ms ON, 15ms OFF).

Null modem cable connects the COM1 port of the XP machine to COM1 of a Gateway 9550 laptop booted to FreeDOS and running an app which timestamps* the rising and falling edges of the signal on its COM1 CTS pin.

Attached is a plot of a portion of the data.


*with a 1.13 GHz counter

Attached Thumbnails
Click image for larger version

Name:	50Hz 25% duty.gif
Views:	46
Size:	6.9 KB
ID:	11184  
Attached Files
File Type: txt 50Hz 25% duty data.txt (5.3 KB, 13 views)

Last edited by Ether : 11-12-2011 at 22:00. Reason: attached raw data file
  #9   Spotlight this post!  
Unread 08-01-2012, 01:22
kamocat's Avatar
kamocat kamocat is offline
Test Engineer
AKA: Marshal Horn
FRC #3213 (Thunder Tech)
Team Role: Mentor
 
Join Date: May 2008
Rookie Year: 2008
Location: Tacoma
Posts: 894
kamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nicekamocat is just really nice
Send a message via AIM to kamocat Send a message via MSN to kamocat
Re: Windows jitter

Hey folks,
Glad to see you're still creating tools to quantify the quality of communication between the Driver Station and robot.
On that note, I wanted to thank Greg for the new "Charts" tab in the driver station this year, which indicates when packets are dropped. (I haven't tested that it works, but I'm assuming). This serves as a basic diagnostic tool during competition. I've seen a number of matches where a robot lost communication and was temporarily disabled, but the team didn't have enough data to convince the referees it was a communication error. (It usually tends to be blamed on the positioning of the radio within the robot, or an Ethernet cable, or the power connector on the radio).
__________________
-- Marshal Horn
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:06.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi