PXI-6682 read IEEE-1588 timestamp from 7953R over RTSI bus

Hi,
I am relatively new to LabVIEW
programming, although I have two years of hard experience using LabVIEW
FPGA tools.
So, I
have a PXI-1033 chassis, and I have plugged in an PXI-6682 IEEE-1588
card into slot 2 and a PXI-7953R card into slot 4.  (Random selection
for slot 4)  What I am trying to do is read the GPS timestamp from the
6682 card via the RTSI lines directly into the 7953R FPGA card.
 Unfortunately, I have no idea where to start and what to read, and all
the examples (keywords: RTSI, IEEE-1588)  that I find are for how to
read the IEEE-1588 timestamp inside the Host Operating system and
nothing tells me how to do it directly from the FPGA.  My goal is to
build a machine that timestamps network packets that are being read by
the FPGA hosted inside the PXI-7953R card.
Can anybody point me in the right direction?  I
basically want to learn more about RTSI, where the PXI-6682 outputs its
IEEE-1588 timestamp, and how data is transferred over the RTSI bus from
inside a PXI chassis.
Thanks,
John

Thanks for the response Alejandro,
I have a 7953R FlexRIO board with the Mimas Prevas Dual Gigabit Adapter Module (http://www.prevas.com/ethernet_simulator.html) plugged in.  Ethernet packets enter the Mimas Dual Gigabit Adapter and then go directly to the FPGA as raw Ethernet frames.
From what you are telling me it seems like I cannot have a timestamp go from the PXI-6682 to the 7953R via the RTSI lines and to then be appended to the end of the ethernet frame before being retrasmitted out the other port of the Dual Gigabit Adapter. (With proper recalculation of the 32 bit CRC being done inside the FPGA of course)
I will do some more reading of the manuals and will then call NI Support.
Thanks again!

Similar Messages

  • PXI-6682 + multiple Serie S & M cards cause timestamp delay

    I'll try to give as much info as possible and hopefuly someone will have an answer to this problem.
    Language: C++
    Introduction:
    1- I have (1) PXI-6682 (Timing card), (6) PXI-6143 (Serie S (8 analog inputs each)), and (2) PXI-6224 (serie M (8 analog inputs each))
    2- Every card is a task (so that's 8 tasks
    3- Every card is in sync (they give data equal...more or less... to one another
    PROBLEM:
    1- Timestamp is off by up to 200 ms (not drifting...simply off by a set number of ms)
    2- Every call to niSync_ReadMultipleTriggerTimeStamp gives me a timestamp off by that much
    I don't have any info on how the tester managed to know it was 200 ms off, my theory is he tested it with some older equipment to validate the new one

    Hello there,
    Kindly help me with DAQmx Time stamp related problem as described below.
    Setup : PXI 6133 Qty 4 (Slot 3, 4, 5, 6)
    PXI 6255 Qty 1 (Slot 2)
    PXI 6255 doing a Continuous Acquisition at 1 mSec Sampling and 1000 samples/iteration.
    PXI 6133 doing a Ref Triggered Acquisition at 1 uSec Sampling interval and Pre and Post Trigger samples of 100000 Samples each.
    Test : PXI 6133 - Reference Trigger Configured on PFI 1 line of First PXI 6133 card.
                             input Signal given to AI 0 OF First PXI 6133 card.
                             All PXI 6133 cards are included in a single task.
    PXI 6255 - Input given to Channel 0 AI
    External Function generator - One Digital Trigger generated of width 50 mSec High Interval.
                                               Another signal generated for input to above cards. (Square wave of 10 mSec Period - 5 periods generated on the rising edge of trigger)
    So It means When I acquire square wave in my waveform, I can consider rising edge of square wave as a rising edge of trigger (as both signals are generated aligned from external function generator)
    I have attached Screenshots and programs I have used for that.
    Problem: As both singal are generated at a same event, Both 6133 and 6255 should acquire that singnal at a same timestamp.
    I have also read related documents about timestamp but I could not succeeded to find any link in this.
    I am getting square wave 100 msec earlier in 6255 then of 6133.
    If I used only single card of 6133 then that inaccuracy of 100 msec is shifted to 25 msec.
    Please help me as soon as possible.
    Attachments:
    Timestamp mismatch between 6133 and 6255.docx ‏377 KB
    Timestamp mismatch in 6133 & 6255.zip ‏70 KB

  • Help! PXI-6682 timestampi​ng is limited to 2.5Hz

    I am outputting a 30Hz signal from a pulse generator, and I have reduced the vi to the bare minimum, but the program still only logs a timestamp about 2-3 times a second.  Checking timestamping in ni-max test panels has the same result.  The cables are fine and I've tried PFI0, 1, and 2.  What's going on?
    Attachments:
    timestamp_check3.vi ‏18 KB

    Hi Steve-
         You have selected 'Read Single Timestamp' as the polymorphic instance of the niSync Read Trigger Timestamp.vi.  Change that to 'Read Multiple Timestamps' from the drop-down menu.  This will enable you to pull an array of timestamps from the 6682, as opposed to just a single timestamp, as you had it configured.  The reason you were only getting 2-3 Hz is because you were pulling only a single timestamp with every iteration of the while loop, which was only iterating at 2-3 Hz.  With the Multiple Timestamps enabled, your while loop will still iterate at 2-3 Hz, but you can pull several timestamps with every iteration.  To specify the number of timestamps to pull, right-click on the number of timestamps input and select Create»Constant.  Start out with 10 as the constant and increase from there until you are pulling 30 timestamps every second.  Be sure to also wire a timeout value to the timeout input as well (ten seconds should be sufficient, but you can fiddle with this number also). 
         Your number of timestamps indicator will now be the 'detected edges' output of the niSync Read Trigger Timestamp.vi instead of the number of loop iterations.  Be sure to also place an niSync Close.vi at the end of the program to properly close the niSync session and clear it from memory.
         This should now run how you want it to.  I hope this helps, and best of luck with your application!
    Gary P.
    Applications Engineer
    National Instruments
    Visit ni.com/gettingstarted for step-by-step help in setting up your system.

  • Using PXI-6682(H) in PXI Express chassis to replace backplane clock

    I have a PXI-6682H in a PXIe-1075 which I use for event timestamping.  I also have a PXIe-6672 card in the timing slot.
    I would like to replace the 10 MHz backplane clock to use the 6682 as a GPS disciplined oscillator and synchronize multiple PXI chasses.  
    I understand from the block diagram in the manual that the PXI-6682H does not possess the connection to directly replace the backplane clock as the PXI-6682 does in a PXI chassis.  
    Is there any way for me to replace this clock? Perhaps using an external connection?  If so could you briefly explain how this would work and what software steps would be required?

    Hello Gregoryng, 
    It might work since the PXIe-6672 and the PXIe-6674T are both timing and synchronization modules, but the best option would be the PXIe-6674T, which is able to work with other protocols such as GPS while the  other cannot. It seems that in the video they use GPS. 
    I think the PXIe-6672 will not work for this with the PXI-6682H, but you can give it a try.
    The one in the video seems to be a PXIe-6674T.
    Regards. 
    Ernesto.

  • Ethernet/IP module - IEEE-1588 CIP Sync

    Hi,
    I have an application where reatime position setpoint is desired (each 0.008sec). I have to talk from a CVS 1459RT (or any cRIO) to Allen Bradley Kinetix Drive. I've read some document and learn that AB use an addon to Ethernet/IP when deterministic application is require which is called CIP Sync (IEEE 1588) protocol.
    Does the Ethernet/IP module support this protocol? I think AB doesn't support Ethercat...
    I talked to NI and they suggest me to send the position via digital output of the FPGA by simulating an encoder. That is a good idea but is there other way to communicate deterministically? CIP Sync look to be the way ...
    Thank you,
    Patrick

    Hi paubine
    According to my understanding, IEEE 1588 only adds syncronization standards to Ethernet/IP. I am not sure if the Ethernet IP Module would give you predifined functions for that, however, I found this example of IEEE 1588 for cRIO.
    Community: cRIO IEEE 1588 Synchronization Example
    They used basic SMT VIs to build it, so I think you might be able to do the same for the AB PLC.
    WenR

  • Is EVS IEEE-1588 capable?

    I've been working with a NI PXI chassis with a 6682 card that syncs to the IEEE-1588 Master clock in a Rockwell Automation PLC over ethernet.  Can an NI Embedded Vision System (EVS) perform the IEEE-1588 synchronization?  If not now, is there a plan to develop this capability?

    There is no explicit hardware support for 1588 on the EVS, but the NI-TimeSync plugin with software 1588 support should work. I believe you can expect sub-millisecond performance with the software-based solution on RT systems. See this page ( http://joule.ni.com/nidu/cds/view/p/id/2520/lang/en ) for details.
    Eric

  • File Adapter and reading all XML files from direcotry

    Problem occurs on PI 7.1
    I defined sender file adapter. File name mask is: "*.xml" to read all XML messages from directory.
    Quality of service is: Exactly One.
    Poll Interval: 30
    Retry interval: 30
    Processing mode: Archive with option "Add Timestamp".
    Processing sequence: by name.
    I though that with above configuration my File Adapter will be reading folder for all coming XML files. But  somehow it is reading XMLs only when I'm activating it in Integration Builder.
    Any idea what can cause such strange problem?

    Hi Tomasz,
    As per my understanding, you need to activate the file adapter for reading the XML files on your directory. Right?
    If that is the case, then the issue might be with the Cache.
    1. Clear the cache from the Integration Builder.
    2. Check in SXI_CACHE whether there are any issues. Click on Delta Cache refresh to find out if there are any cache related issues.
    Thanks,

  • Server detected a backward timestamp from 1973406 to 0 in file

    In my core.log file I'm receiving these error messages;
    Server detected a backward timestamp from 1973406 to 0 in file:C:\FMSHOME\applications\livepkgr\streams\_definst_\bbc1
    Server detected a backward timestamp from 1973406 to 0 in file:C:\FMSHOME\applications\livepkgr\streams\_definst_\bbc2
    Is this an issue caused by the encoder? I'm using a Viewcast Niagara to encode and not the FMLE. These are the only settings I have available.
    I'm using all default settings on the FMS 4.5 server. 
    Thanks,
    Dave

    I'm checking again with Viewcast support .I don't see how I can check whether ATC is enabled on the encoder. Since it's a portable contained streaming appliance.
    The last response I got from them was.
    "Does this happen every time or only when you restart the profile shortly after stopping it? As a rule time codes are always an off set from 0. However, it does not matter what the time code is. It just matters that the server doesn't get an out of sequence time code. So if you stop an encoder and then start it too quickly you can send a time code to the server before the server has completely torn down the previous stream. You should wait several seconds before restarting a stream."

  • Getting Absolute timestamps from FPGA 7831R

    I am using a LIN card in my PXI Chassis. This is not an NI product and it cannot access any triggering lines. The device itself returns an array of timestamped measurements but the problem is that the are relative timestamps. I need to have an absolute timestamp so that I can compare timing with other DAQ devices. The only way I can access this is by using a 5V trigger output line. I can set this to trigger on each identifier.
    My problem is how to acquire an absolute timestamp. I would not need to get one very often. once every few seconds would be sufficient at worst case.
    I have used an M series card analog input which can be triggered and this has given good results.
    But I have to use this card for other measurements at the same time so I cannot normally use it as I wish.
    The only other option that I have is an FPGA card. RIO 7831R.
    Does anyone know how to get absolute timestamps from such a card without having to connect it to any other card?
    This would be a great help. 
    Thanks in advance
    Jimmy

    Hi Jimmy,
    You can make product suggestions using links on the following web page:
    http://digital.ni.com/public.nsf/websearch/EDA7C01C684ACB6286256FF0000238D5?OpenDocument
    I'm not sure there is anything else we can do to help you - the only other alternative would be to use the FPGA board to monitor this trigger line, and when it sees a trigger fires an IRQ to the host program which is waiting on this - and then at this point get the current time in software.
    I'm not sure that there is a more accurate way of getting this timing information, as it seems its just a limitation of this LIN card that you have.
    Regards
    Hannah
    NIUK & Ireland

  • Can't replace PXI onboard clock with PXI-6682 oscillator clock on PXI back plane

    I have installed a PXI-6682 timing module in slot 2 of a PXI-1031chassis with a PXI-8110 controller running Hypervisor and RT.  The 6682 is installed on the RT system under Hypervisor for GPS timing during measurements but I would like to put the TCXO on the PXI-1031 chassis backplane (replacing the PXI onboard clock).  When I try to run the "Route Clock.vi" that I found in the example finder, all I get are error messages indicating that a parameter for this operation is invalid.  The source terminal is "Oscillator" and the destination terminal is "PXI-Clk10_In".  How do I determine which parameter is invalid?  Any suggestions?  Thanks
    Solved!
    Go to Solution.

    Hi vugt,
    I tested this out and have what I believe to be your final answer.
    The short answer:  The PXI-6682 can be used with NI-Hypervisor on the Windows side, but not on the Real-Time side.
    The long answer:
    While the NI-Hypervisor Manager allow you to put the PXI-6682 on two different systems, it is still only one PXI card on the PCI bus, so really only one system can access it at a time.
    Therefore we need to assign both "devices" to either Windows or Real-Time.  For our purposes, let's assume we assign it to Real-Time.
    On an NI-Hypervisor system, each PCI interrupt line can only be assigned to one operating system.  Either it can be assigned to Windows, or it can be assigned to RT.
    Here is where the problem arises: The PXI-6682 needs to be located in a System Timing slot (generally slot 2).  However, this slot (at least in the 1000B chassis I tested in) is located on the same PCI interrupt line as the chipset.  Windows is required to have access to this PCI interrupt line, so devices used by Real-Time cannot be located on this interrupt line.
    This prevents us from being able to use the PXI-6682 in Real-Time.
    The NI-Hypervisor Manager will try to tell you to resolve this conflict by moving the PXI-6682 to slot 3, however, now the System Timing slot requirement is not met.
    This does not prevent the card from being used on the Windows side of an NI-Hypervisor system, or on a purely Real-Time system.
    Have a great day,
    Chris V
    Applications Engineer
    National Instruments

  • PXI-6682 GPS coordinate​s...

    Hi All!
    Can I obtain GPS coordinates from the PXI-6682 board?
    Jury

    Hi!
    Thank you very much!
    Jury
    Attachments:
    GPS.JPG ‏74 KB

  • How to take timestamp from Transmitted CAN frame ?

    Hello,
    Timestamp from Received CAN frame is simply get as...
    NCTYPE_CAN_STRUCT *RxFrame 
    ... RxFrame->Timestamp ...
    For Transmitted frame I use: 
    ncGetAttribute(hCan, NC_ATTR_ABS_TIME, 8, &TxTime);
    ncWrite(hCan, sizeof(Transmit), &Transmit);
    But sometimes timestamp of Rx frame is BEFORE Tx timestamp ?!?!?!
    Is there any other way to get real Tx frame timestamp  - not by ncGetAttribute(...) ?
    Thank you in advance
    Petko G.

    you would need to set the interface into the Self-reception mode.
    Self-reception specifies whether to echo successfully transmitted CAN frames as received frames. Each reception occurs just as if the frame were received from another CAN device. The self reception mode is not available on the Intel 82527 CAN controller
    used by Series 1 CAN hardware. 

  • Issue with reading a xml file from xsl

    Hi,
    When I am trying to read a xml file from xsl, I am getting unwanted output.
    Following is the XSL:
    <?xml version="1.0" encoding="UTF-8" ?>
    <?oracle-xsl-mapper
      <!-- SPECIFICATION OF MAP SOURCES AND TARGETS, DO NOT MODIFY. -->
      <mapSources>
        <source type="XSD">
          <schema location="../xsd/B2BMarketProperties.xsd"/>
          <rootElement name="ReceipentIDType" namespace="http://www.example.org"/>
        </source>
      </mapSources>
      <mapTargets>
        <target type="XSD">
          <schema location="../xsd/B2BMarketProperties.xsd"/>
          <rootElement name="ReceipentIDType" namespace="http://www.example.org"/>
        </target>
      </mapTargets>
      <!-- GENERATED BY ORACLE XSL MAPPER 11.1.1.4.0(build 110106.1932.5682) AT [TUE DEC 03 16:06:03 EST 2013]. -->
    ?>
    <xsl:stylesheet version="1.0"
                    xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
                    xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
                    xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction"
                    xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
                    xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xmlns:ns0="http://www.example.org"
                    xmlns:dvm="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"
                    xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:med="http://schemas.oracle.com/mediator/xpath"
                    xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
                    xmlns:bpm="http://xmlns.oracle.com/bpmn20/extensions"
                    xmlns:xdk="http://schemas.oracle.com/bpel/extension/xpath/function/xdk"
                    xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
                    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                    xmlns:ora="http://schemas.oracle.com/xpath/extension"
                    xmlns:socket="http://www.oracle.com/XSL/Transform/java/oracle.tip.adapter.socket.ProtocolTranslator"
                    xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
                    exclude-result-prefixes="xsi xsl ns0 xsd bpws xp20 mhdr bpel oraext dvm hwf med ids bpm xdk xref ora socket ldap">
      <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
      <xsl:variable name="ReceipentID" select="document('../xsd/B2BMarketProperties.xml')"/>
      <xsl:template match="/">
        <ns0:ReceipentIDType>
        <xsl:for-each select="$ReceipentID">
          <ns0:ReceipentID>
            <xsl:value-of select="$ReceipentID"/>
          </ns0:ReceipentID>
          </xsl:for-each>
        </ns0:ReceipentIDType>
      </xsl:template>
    </xsl:stylesheet>
    Following is the XML ( B2BMarketProperties.xml)
    <?xml version="1.0" encoding="UTF-8" ?>
    <ReceipentIDType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://www.example.org B2BMarketProperties.xsd"
                     xmlns="http://www.example.org">
      <ReceipentID>123</ReceipentID>
      <ReceipentID>345</ReceipentID>
    </ReceipentIDType>
    The output i am getting with this code is
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:ReceipentIDType xmlns:ns0="http://www.example.org">
        <ns0:ReceipentID>123345</ns0:ReceipentID>
    </ns0:ReceipentIDType>
    But, I need output in the following format
    <ns0:ReceipentIDType xmlns:ns0="http://www.example.org">
        <ns0:ReceipentID>123</ns0:ReceipentID>
         <ns0:ReceipentID>345</ns0:ReceipentID>
    </ns0:ReceipentIDType>
    Could you guys let me know what i am doing wrong. Any help would be appreciated.
    Thanks,

    This worked for me :
      <xsl:template match="/">
        <ns0:ReceipentIDType>
          <xsl:for-each select="document('B2BMarketProperties.xml')/*:ReceipentIDType/*:ReceipentID">
            <xsl:variable name="count" select="position()"/>
            <ns0:ReceipentID>
              <xsl:value-of select="document('B2BMarketProperties.xml')/*:ReceipentIDType/*:ReceipentID[$count]"/>
            </ns0:ReceipentID>
          </xsl:for-each>
        </ns0:ReceipentIDType>
      </xsl:template>

  • I have two email accounts that are set up on the same iPad.  I cannot seem to see, read or send email from the second account

    I just set up a second email account on the same iPad but cannot seem to see, read or send email from the second account. 

    I'm using Windows 8 (not 8.1) and whatever the latest Thunderbird version is. They're both IMAP accounts. I was using Windows Live, but I couldn't get that to work, so I switched to TB. It works JUST fine for the one account, but not the other! They're identical except for the "handle". Both off my local ISP, set them up at the same time.

  • Reading a Random Line from a Text File

    Hello,
    I have a program that reads from a text file words. I currently have a text file around 800KB of words. The problem is, if I try to load this into an arraylist so I can use it in my application, it takes wayy long to load. I was wondering if there was a way to just read a random line from the text file.
    Here is my code, and the text file that the program reads from is called 'wordFile'
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    public class WordColor extends JFrame{
         public WordColor(){
              super("WordColor");
              setSize(1000,500);
              setVisible(true);
              add(new WordPanel());
         public static void main(String[]r){
              JFrame f = new WordColor();
    class WordPanel extends JPanel implements KeyListener{
         private Graphics2D pane;
         private Image img;
         private char[]characterList;
         private CharacterPosition[]positions;
         private int charcounter = 0;
         private String initialWord;
         private File wordFile = new File("C:\\Documents and Settings\\My Documents\\Java\\projects\\WordColorWords.txt");
         private FontMetrics fm;
         private javax.swing.Timer timer;
         public final static int START = 20;
         public final static int delay = 10;
         public final static int BOTTOMLINE = 375;
         public final static int buffer = 15;
         public final static int distance = 4;
         public final static Color[] colors = new Color[]{Color.red,Color.blue,Color.green,Color.yellow,Color.cyan,
                                                                          Color.magenta,Color.orange,Color.pink};
         public static String[] words;
         public static int descent;
         public static int YAXIS = 75;
         public static int SIZE = 72;
         public WordPanel(){
              words = readWords();
              setLayout(new BorderLayout());
              initialWord = getWord();
              characterList = new char[initialWord.length()];
              for (int i=0; i<initialWord.length();i++){
                   characterList[i] = initialWord.charAt(i);
              setFocusable(true);
              addKeyListener(this);
              timer = new javax.swing.Timer(delay,new ActionListener(){
                   public void actionPerformed(ActionEvent evt){
                        YAXIS += 1;
                        drawWords();
                        if (YAXIS + descent - buffer >= BOTTOMLINE) lose();
                        if (allColorsOn()) win();
         public void paintComponent(Graphics g){
              super.paintComponent(g);
              if (img == null){
                   img = createImage(getWidth(),getHeight());
                   pane = (Graphics2D)img.getGraphics();
                   pane.setColor(Color.white);
                   pane.fillRect(0,0,getWidth(),getHeight());
                   pane.setFont(new Font("Arial",Font.BOLD,SIZE));
                   pane.setColor(Color.black);
                   drawThickLine(pane,getWidth(),5);
                   fm = g.getFontMetrics(new Font("Arial",Font.BOLD,SIZE));
                   descent = fm.getDescent();
                   distributePositions();
                   drawWords();
                   timer.start();
              g.drawImage(img,0,0,this);
         private void distributePositions(){
              int xaxis = START;
              positions = new CharacterPosition[characterList.length];
              int counter = 0;
              for (char c: characterList){
                   CharacterPosition cp = new CharacterPosition(c,xaxis, Color.black);
                   positions[counter] = cp;
                   counter++;
                   xaxis += fm.charWidth(c)+distance;
         private void drawThickLine(Graphics2D pane, int width, int thickness){
              pane.setColor(Color.black);
              for (int j = BOTTOMLINE;j<BOTTOMLINE+1+thickness;j++){
                   pane.drawLine(0,j,width,j);
         private void drawWords(){
              pane.setColor(Color.white);
              pane.fillRect(0,0,getWidth(),getHeight());
              drawThickLine(pane,getWidth(),5);
              for (CharacterPosition cp: positions){
                   int x = cp.getX();
                   char print = cp.getChar();
                   pane.setColor(cp.getColor());
                   pane.drawString(""+print,x,YAXIS);
              repaint();
         private boolean allColorsOn(){
              for (CharacterPosition cp: positions){
                   if (cp.getColor() == Color.black) return false;
              return true;
         private Color randomColor(){
              int rand = (int)(Math.random()*colors.length);
              return colors[rand];
         private void restart(){
              charcounter = 0;
              for (CharacterPosition cp: positions){
                   cp.setColor(Color.black);
         private void win(){
              timer.stop();
              newWord();
         private void newWord(){
              pane.setColor(Color.white);
              pane.fillRect(0,0,getWidth(),getHeight());
              repaint();
              drawThickLine(pane,getWidth(),5);
              YAXIS = 75;
              initialWord = getWord();
              characterList = new char[initialWord.length()];
              for (int i=0; i<initialWord.length();i++){
                   characterList[i] = initialWord.charAt(i);
              distributePositions();
              charcounter = 0;
              drawWords();
              timer.start();
         private void lose(){
              timer.stop();
              pane.setColor(Color.white);
              pane.fillRect(0,0,getWidth(),getHeight());
              pane.setColor(Color.red);
              pane.drawString("Sorry, You Lose!",50,150);
              repaint();
              removeKeyListener(this);
              final JPanel p1 = new JPanel();
              JButton again = new JButton("Play Again?");
              p1.add(again);
              add(p1,"South");
              p1.setBackground(Color.white);
              validate();
              again.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent evt){
                        remove(p1);
                        addKeyListener(WordPanel.this);
                        newWord();
         private String getWord(){
              int rand = (int)(Math.random()*words.length);
              return words[rand];
         private String[] readWords(){
              ArrayList<String> arr = new ArrayList<String>();
              try{
                   BufferedReader buff = new BufferedReader(new FileReader(wordFile));
                   try{
                        String line = null;
                        while (( line = buff.readLine()) != null){
                             line = line.toUpperCase();
                             arr.add(line);
                   finally{
                        buff.close();
              catch(Exception e){e.printStackTrace();}
              Object[] objects = arr.toArray();
              String[] words = new String[objects.length];
              int count = 0;
              for (Object o: objects){
                   words[count] = (String)o;
                   count++;
              return words;
         public void keyPressed(KeyEvent evt){
              char tempchar = evt.getKeyChar();
              String character = ""+tempchar;
              if (character.equalsIgnoreCase(""+positions[charcounter].getChar())){
                   positions[charcounter].setColor(randomColor());
                   charcounter++;
              else if (evt.isShiftDown()){
                   evt.consume();
              else{
                   restart();
              drawWords();
         public void keyTyped(KeyEvent evt){}
         public void keyReleased(KeyEvent evt){}
    class CharacterPosition{
         private int xaxis;
         private char character;
         private Color color;
         public CharacterPosition(char c, int x, Color col){
              xaxis = x;
              character = c;
              color = col;
         public int getX(){
              return xaxis;
         public char getChar(){
              return character;
         public Color getColor(){
              return color;
         public void setColor(Color c){
              color = c;
    }

    I thought that maybe serializing the ArrayList might be faster than creating the ArrayList by iterating over each line in the text file. But alas, I was wrong. Here's my code anyway:
    class WordList extends ArrayList<String>{
      long updated;
    WordList readWordList(File file) throws Exception{
      WordList list = new WordList();
      BufferedReader in = new BufferedReader(new FileReader(file));
      String line = null;
      while ((line = in.readLine()) != null){
        list.add(line);
      in.close();
      list.updated = file.lastModified();
      return list;
    WordList wordList;
    File datFile = new File("words.dat");
    File txtFile = new File("input.txt");
    if (datFile.exists()){
      ObjectInputStream input = new ObjectInputStream(new FileInputStream(datFile));
      wordList = (WordList)input.readObject();
      if (wordList.updated < txtFile.lastModified()){
        //if the text file has been updated, re-read it
        wordList = readWordList(txtFile);
        ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream(datFile));
        output.writeObject(wordList);
        output.close();
    } else {
      //serialized list does not exist--create it
      wordList = readWordList(txtFile);
      ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream(datFile));
      output.writeObject(wordList);
      output.close();
    }The text file contained one random sequence of letters per line. For example:
    hwnuu
    nhpgaucah
    zfbylzt
    hwnc
    gicgwkhStats:
    Text file size: 892K
    Serialized file size: 1.1MB
    Time to read from text file: 795ms
    Time to read from serialized file: 1216ms

Maybe you are looking for