2 Counters Start (DAQ)

I have two counters, counter 2 needs to be start with counter 1.
Example
Counter 1...... have 5 puls..... then counter 2 has to be started.
Counter 1...... have 10 puls.... then counter 2 had to be closed.
I'am using a DAQ usb 6210 for this application.
Can sombody help me with this,
Thanks for your support.

Do you want to control this this a software timed loop control or hardware timed control. Your answer depends of the frequency of your signal and the accuracy you want to obtain .
Wilfried.

Similar Messages

  • PCI6601 - Start and Stop of all 4 counters individually in LabView 5.0

    Hi!
    I work with the PCI6601 card and I want to start and stop each of the 4 counters independent from the others.
    To start only one counter is quite easy, but two or more won't work.
    I have 4 external devices and want to know the counts of each device that means there are four sources.
    The Vi's in LabView 5.0 supports only the AM9513/8254/and the DAQ-STC. Perhaps there is no possibility to work with all features of the 6601 in LV5.0.
    I tried it with the counter list and with group# and the listed counters started with the internal frequency. But this is not what I want.
    Please give me some hints to "rescue the next nights".
    Thanks for your answers!
    Markus

    A couple comments that will hopefully let you sleep well tonight...
    1. If possible, use the counter functions whose icon show a "CTR" in the lower right rather than a "123". Do you have these in LV 5.0? I know they were available by 5.1.1, but am not certain about 5.0
    2. The 6601 doesn't support multiple counters in a group. To program 4 counters requires 4 config chains with 4 separate calls to "Counter Group Config". Note that each call must input a unique group #.
    You'll end up with 4 unique task id's which you can then start & stop independently of the others.
    -Kevin P.

  • LabView (8.2) hangs when using I/O operations with traditiona​l NI-DAQ 7.4.4 after aborting LabView program

    Hello!
    We have the following problem:
    LabView (8.2) hangs when using I/O operations with traditional NI-DAQ 7.4.4 after aborting LabView program
    We freshly installed LabView 8.2 (2006) and NI-DAQ 7.4.4 on a PC running Windows XP (Service Pack 3). We built a larger vi that remotely controls a traditional NI-DAQ card (AT-AO-10) on a second PC via NI-VISA 5.0.3. We were successfully running this program until a power failure caused the first computer to crash. After this crash we were unable to start the program again: LabView freezes while loading the vi. LabView itself can be started but freezes when adding I/O operations from the NI-DAQ palette to a block diagram.
    We have tried to re-install NI-DAQ 7.4.4, but it did not help. We then re-installed all NI software, but still no improvement. In the end we decided to reinstall ALL software, first Windows XP, then LabView and finally NI-DAQ 7.4.4. This worked. However, after a few days of running the program we had to abort LabView via Windows Task manager and afterward we again experienced the same problem as before: LabView freezes when loading the program.
    Obviously, we cannot afford to reinstall Windows every time. Are there any known Windows XP / NI-DAQ issues that might cause the freezing of LabView? We would be very grateful for any idea.
    Best regards,
    Matthias

    Hello Sprice,
    Browse the shipping examples according to “Directory Structure” and then select
    DAQ to find the Traditional DAQ examples. 
    There a lot of examples that are written for counters (Counter >>
    daq-stc.llb >> Count Edges (DAQ-STC).vi). 
    What kind of signals are your photons creating?  Are they TTL compatible at a certain
    frequency?  You don’t care about overwriting
    your buffer?
    Respectfully,
    Rob F
    Test Engineer
    Condition Measurements
    National Instruments

  • Running VB6 SP5, CW 3.0(536), NI-DAQ V6.7, PCI-6023E. Placed a CWCounter component on my form, setup parameters and c

    alled CWCounter1.Configure which returned a success. Called CWCounter1.Start and got the following error: Run-time error '10123': Start DAQ operation Invalid paramID used. There is no param specified for this method in the doc. Any suggestions? Thanx.

    alled CWCounter1.Configure which returned a success. Called CWCounter1.Start and got the following error: Run-time error '10123': Start DAQ operation Invalid paramID used. There is no param specified for this method in the doc. Any suggestions? Thanx.NI-DAQ 10123 is the generic error for an invalid parameter in counter configuration. Our counters can be used for many things (pulse and period measurement, edge seperation, event counting, etc.) and require different configuration settings. Without seeing the properties you chose and without knowing your specific application, I would recommend starting your development process with our wonderful counter examples that ship with CW. Pick the closest sample to your application and modify as needed. They are usually available in the MeasurementStudio\VB\Samples\DAQ\Counter directory. They should run with the default settings.
    good luck
    ben schulte
    national instruments

  • Service policy counters not working..

    I have a service policy on a 6509 interface so I can see what the packets per second of a video stream coming out of a DVR (digital video recorder) is. This DVR has 16 security cameras attached and I'm concerned that when someone views all 16 cameras the video stream is going to be huge.
    So I create a service policy to match an access list for all IP from the DVR. But no counters increment unless I add in some other match statement. I added in a match protocol telnet and the service policy counters started to work. I removed the match on telnet and the counters stopped. Telnet has nothing to do with the DVR. Here is the config of the class map, policy map and show commands: (By the way video is streaming through this interface continually during this excercise)
    MATCHING ACCESS LIST ONLY:
    class-map match-any DVR
    match access-group 130
    policy-map DVR-test
    class DVR
    ROC-6509-DU-A#sh access-list 130
    Extended IP access list 130
    10 permit ip host 164.72.2.125 any
    ROC-6509-DU-A#sh policy-map int
    GigabitEthernet2/5
    Service-policy output: DVR-test
    Class-map: DVR (match-any)
    0 packets, 0 bytes
    30 second offered rate 0 bps
    Match: access-group 130
    0 packets, 0 bytes
    30 second rate 0 bps
    Class-map: class-default (match-any)
    0 packets, 0 bytes
    30 second offered rate 0 bps, drop rate 0 bps
    Match: any
    ADDING IN TELNET:
    class-map match-any DVR
    match access-group 130
    match protocol telnet
    policy-map DVR-test
    class DVR
    ROC-6509-DU-A#sh policy-map int
    GigabitEthernet2/5
    Service-policy output: DVR-test
    Class-map: DVR (match-any)
    524025 packets, 70724866 bytes
    30 second offered rate 3991000 bps
    Match: access-group 130
    523896 packets, 70689220 bytes
    30 second rate 3991000 bps
    Match: protocol telnet
    129 packets, 35646 bytes
    30 second rate 0 bps
    Class-map: class-default (match-any)
    18696 packets, 11180265 bytes
    30 second offered rate 129000 bps, drop rate 0 bps
    Match: any
    If I remove the 'match protocol telnet' and clear the counters, no longer do the counters for the access-list 130 increment - put back in match telnet and they start to increment.
    This is a Sup720 with IOS 12.2(18)SXE3
    Is this a bug or do I not have my class map or policy map correct?

    The hardware ASICs do not support collecting the individual policer information.
    Try:
    http://www.cisco.com/univercd/cc/td/doc/product/lan/c3550/1216ea1/3550scg/swqos.htm#xtocid1990743

  • How to setup multiple daq lists on a ecu with ecu mc toolkit?

    Has anyone had the pleasure of setting up multiple DAQ lists on a ECU?
    I am using ECU MC Addon for Labview 2011.  I can successfully setup a single DAQ list and read the data correctly.  This method uses DAQ list mode to initilize instead of polling, it really cuts down on CAN traffic.
    I dont have my VI on this PC but it basically is ECU Connect > ECU DAQ List Initilize (sets sample rate and channel list) > ECU Transmit DAQ List to ECU > Start DAQ List > LOOP{ ECU Read } 
    I need to create a second DAQ list to sample at a different speed.  Any ideas?  
    Thanks,
    Ben
    Solved!
    Go to Solution.

    My revised VI is:
    ... >  ECU Connect > ECU DAQ List Initilize (sets sample rate and channel list) > ECU DAQ List Initialize #2 (sets sample rate and channel list) > 2 Parallel Loops of ECU Read
    The ECU DAQ Initialize or the ECU Read VI's appear to transmit the DAQ list to the ECM, so I removed those VIs.  The ECU appears to also start transmitting the channels without a need for the ECU DAQ Start.
    FYI, the  "ECU Transmit DAQ List to ECU" was  "MC DAQ Start Stop .vi" with the mode set to "transmit daq list to ecu".
    Its running great, I am able to run this on a cRIO & 985x or a USB-8473.  Now I am just working on setting up TDMS data logging.

  • Time consume by Daq Task

    Hi everybody
    I am doing a normal DAQ operation(I,e DAQ Create Virtual channel, DAQ start, DAQ write, DAQ stop) I have not incorporated any delay so I expect a spike but all I am getting a pulse which is 7-9mS in duration. Is it normal condition or some problem in DAQ module(I am using NI-9264 AO module). Please give some suggation...
    Thanks in advance....

    Your example is using digital output, but your board is an analog board.  I would recommend you use an analog waveform for your output.  That way you can precisely determine the pulse width using the waveform timing characteristics.  You may want to set up timing and triggering, as well, depending upon what else you are doing.
    Your startup delays are going to be variable, depending upon what you have done before you run the VI.  If you need to load the drivers, it will take awhile.  If the drivers are in memory and the VI has been run once, the delay will be a lot less due to several layers of caching (the operating system, DAQmx, and LabVIEW).  The delay from when you fire the run VI to when the output appears should be fairly constant.  Note that unless your operating system is LabVIEW RT, 30ms to 1s random delays are a fact of life.  They do not always happen, but they do sometimes and you need to prepare for them.  The best preparation is to do as much of your timing and triggering at the board level as you can.
    Let us know if you need more help.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • NI-6602 Two Channel Frequency Measuremen​t using Traditiona​l NI-DAQ and LabView 8.2

    I have been trying to program for some new experiments and have a vi setup to record the time-of-arrival for a signal using buffered event counting on two channels.  We really wanted to be able to measure the frequency of the incoming photons on both channels and thought we could just make a sub vi using simple event counting and count the number of rising edges on a source pin for a second and report that number and repeat the measurement until we were done..
    All of our vi's have to be programed using the Traditional NI-DAQ drivers as the NI-DAQmx drivers do not play well with the FIFO overwrites on the 6602 card that occasionally occur in our measurements (high instantaneous count rates from bursts of photons).  The way other groups using the 6602 card and labview have dealt with this is to ignore the error that come from the Read Buffer.vi used with the Traditional NI-DAQ drivers when a FIFO overwrite occurs.  Trying this same technique with the NI-DAQmx drivers has not worked so we are stuck with the old drivers.
    With this all said I made a vi that counted the freqency on one counter just fine but when I adapted it for two channels it doesn't like me anymore
    I attached the llb file and any comments would be greatly appreciated
    -Shane
    Attachments:
    Counts per second.llb ‏202 KB

    Hello Sprice,
    Browse the shipping examples according to “Directory Structure” and then select
    DAQ to find the Traditional DAQ examples. 
    There a lot of examples that are written for counters (Counter >>
    daq-stc.llb >> Count Edges (DAQ-STC).vi). 
    What kind of signals are your photons creating?  Are they TTL compatible at a certain
    frequency?  You don’t care about overwriting
    your buffer?
    Respectfully,
    Rob F
    Test Engineer
    Condition Measurements
    National Instruments

  • How can I disarm the counter in a specified time?

    I am using 6602 counter. I use 2 counters to perform "Buffered Period Measurement ". I use internal time base (20MHz) as the SOURCE, and wire the signal to the Gate. The counters are triggered by a trigger signal.
    Now I just want to stop counting the signal in a specified time after the counters triggered. After that time, even the input signal is still running,the counting must be stopped. How can I implement this purpose? I don't know how to disarm the counter when the counter are still running, and how to exactly determinate the stop time.
    Thanks for any advise. I have attach my present routine here.
    Attachments:
    counters.vi ‏192 KB

    Just to expand a bit on Justin's answer to outline a few particulars.
    You mentioned using 2 counters to capture buffered periods so I'm assuming that you'll enable triggering to guarantee that they both have the same start time. Note that in this scheme, element #0 of your array of buffered periods will represent the time from the Trigger edge until the first Gate edge.
    Since your description made it sound acceptable to ignore pulse periods occurring later than the interval of interest, perhaps you can collect data for a little longer than necessary, then reset the counters and trim off the periods that came in "too late" using 'Array Subset.' A quick-and-dirty way is to loop over each array of periods, performing a cumulative sum until it exceeds the specified data collection time interval. That'll tell you the length of the subset you need to keep.
    The hard part is that after starting the measurement, you'll need to poll task attributes/properties to determine when the trigger has been received. Only after that's been determined would you start keeping track of approximate time in software.
    There are ways to do the timing in hardware if you get more of the 6602's counters involved. Here's one way:
    1. First configure your 2 counters for buffered period measurement. However, instead of using the internal timebase for a Source, use another counter's output as a Source. Under DAQmx, the internal routing details are handled for you; under traditional NI-DAQ, you'll need to make explicit routing via RTSI.
    Note that in this scheme, these 2 counters don't need to be triggered.
    2. Next, generate a finite-duration pulse train at 20 MHz (examples can be readily found under LabVIEW help or this website). This pulse train should last for your data collection time interval, and will act as the Source signal for your period measurements. It is important that the period-measuring counters are started before the finite pulse train.
    The finite pulse train uses 2 counters -- one to generate the output pulse train at 20 MHz and a "helper" that produces a single pulse whose duration equals your data collection interval time.
    If you need to synchronize to some external trigger signal, you can set the "helper" counter to be triggered, but there'll be one subtle catch. The first period measurement in your buffers will not include the time from the external trigger signal until the beginning of the single "helper" pulse, i.e., the "delay" time spec for the pulse. You can either make this very very short and ignore it, or make it any convenient duration and then add it to the first period measurements. Be careful though: the timebase for this "delay" time isn't necessarily the same as the timebase used to measure periods.
    There's quite a bit of complication there, so let me suggest an easier way that assumes no need to synchronize to an external trigger. (I'll use DAQmx terminology, since the traditional NI-DAQ would get complicated again with explicit RTSI signal routing.)
    A. As describe in #1 above, configure your period-measuring counters to use a 3rd counter's output as the timing source terminal.
    B. After starting your 2 period-measuring counters, start up the 3rd counter to generate a continuous 20 MHz pulse train.
    C. After the 3rd counter starts, call the 'Wait (ms)' function from the Time & Dialog palette. Wait for slightly longer than your desired collection time.
    D. Read all buffered periods from the counters. You may need to first query each to find out how many are waiting to be read.
    E. Reset all 3 counters.
    F. Do the cumulative sum work on the two buffered period arrays to determine where each should be truncated.
    Note that step "C" above will leave you stuck while data is being collected. A small variation would be to read a reference time ("Tick Count (ms)") right after starting your 20 MHz counter, then set up a loop that allows you to terminate early (logical OR of, say, "abort" button, data acq error cluster error, and time comparison). In that loop, you put a delay of maybe 50-200 msec using "Wait (ms)."
    "Wait (ms)" will output a tick count from which you subtract the reference time. When the difference exceeds your data collection time, you can exit the loop and continue with step D above.
    -Kevin P.

  • Two DBConnection_OLAP sources for one ETL

    I have a requirement to pull information from two different EBS instances. I have created the two data sources in the physical tab and when creating the Execution plan, and generating the parameters, it prompts for "how many number of copies"
    Has anyone tried this option for two copies and does it mean that it will run the ETL by pulling information from two EBS sources and put them in the same target datawarehouse.
    Thank you
    Nilesh
    http://www.appsbi.com

    Hello,
    Yes, you are correct the 6036E E-series card does not support the Arm Start Triggering, but the M series cards do support this feature.  For the future possibility of an M series card, I would suggest using the two counters with the arm start trigger. 
    As for the E series card, I was a little confused about the setup you are describing.  You mentioned that you wanted to use the two pulses (the 1 Hz GPS and the 100 Hz IMU) to be the same external sample clock for one counter (counter 0).  However, later in the same post you mentioned wanting to use the two pulses as two different gates.  I am going to assume that you want to use the two pulses as gates on the same counter in-order to have them share the same 100 KHz source.  Then your question was how to differential in-between the two measurement, since you want to use an OR gate.
    The problem is that whether you are using this setup (one counter) or utilizing two counter that share the same 100 KHz source on the E series … you still are not addressing the fact that the two inputs (1 Hz GPS and 100 Hz IMU) are not synchronized.  This will result in an offset signals and your measurements will not be reliable.  Thus the differential question is not as relevant
    I would suggest using Buffered Period Measurements with a M series card for this application.  However, I do realize that in the end you might be trying to find a quick solution with the E series card.  For this, I would suggest taking the GPS out of the picture and just input the fluctuating 100 Hz signal.  With this setup you explore software monitoring options.
    I have included links to articles about counters and Buffered Period Measurements.
    Period Measurement with a Counter
    Measure Buffered Pulse-Period on 2 Counters Simultaneously (DAQ-STC)
    Samantha
    National Instruments
    Applications Engineer

  • I want to update a record in the DB from my menu

    Hi everybody,
    I have an menu applet and I want to fill a DB record when i choose an item from my menu.
    This is my code and I want a connection with the database to update the record word_path:
    please help me !!
    thanks in advance
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.net.*;
    import java.util.*;
    import netscape.javascript.*;
    public class PopupMenuApplet extends Applet implements MouseListener, ActionListener {
    String title, img, bgcolor, text, font, size, style, menufont, menustyle, menusize, data;
    String actions[], targets[];
    Menu menus[];
    MenuItem menuItems[];
    int fontsize, menufontsize;
    CardLayout cardlayout;
    PopupMenu mainMenu;
    Image bgImage = null;
    boolean parseError = false, imgError = false;
    URL imgUrl;
    Label label;
    Font labelFont, menuFont;
    //Construct the applet
    public PopupMenuApplet() {
    //Initialize the applet
    public void init() {
    cardlayout = new CardLayout();
    title = getParameter("title");
    if (title == null) title = "Menu";
    // the colors for bgcolor and text are used only for the applet label
    // Java 1.1 menus themselves don't support colors, although some Unix implementations
    // allow a menu's background color to be inherited from the object it's attached to.
    bgcolor = getParameter("bgcolor");
    if (bgcolor == null) bgcolor = "white";
    else bgcolor = bgcolor.toLowerCase();
    text = getParameter("text");
    if (text == null) text = "blue";
    else text = text.toLowerCase();
    // font, size and style are used for the applet's text label (if any)
    font = getParameter("font");
    if (font == null) font = "SansSerif";
    size = getParameter("size");
    if (size == null) fontsize = 11;
    else
    try {
    fontsize = Integer.parseInt(size);
    } catch(NumberFormatException f) {
    fontsize = 11;
    style = getParameter("style");
    if (style == null) style = "plain";
    labelFont = new Font(font, translateStyle(style), fontsize);
    // menufont, menusize and menustyle default to font, size and style if undefined,
    // but they can be also defined explicitely in case we want the popup menu to look different
    // from the applet's text label (if any)
    menufont = getParameter("menufont");
    if (menufont == null) menufont = font;
    menusize = getParameter("menusize");
    if (menusize == null) menufontsize = fontsize;
    else
    try {
    menufontsize = Integer.parseInt(menusize);
    } catch(NumberFormatException f) {
    menufontsize = 11;
    menustyle = getParameter("menustyle");
    if (menustyle == null) menustyle = style;
    menuFont = new Font(menufont, translateStyle(menustyle), menufontsize);
    data = getParameter("data");
    parseData(data);
    this.addMouseListener(this);
    this.setBackground(translateColor(bgcolor));
    this.setForeground(translateColor(text));
    this.setFont(labelFont);
    this.setLayout(cardlayout);
    img = getParameter("img");
    if (img != null) {
    try { // absolute URL
    imgUrl = new URL(img);
    bgImage = this.getImage(imgUrl);
    } catch(MalformedURLException a) {
    try { // relative URL
    imgUrl = new URL(this.getDocumentBase(), img);
    bgImage = this.getImage(imgUrl);
    } catch(MalformedURLException r) {
    imgError = true;
    bgImage = this.getImage(this.getDocumentBase(), img);
    } else {
    label = new Label(title);
    label.setAlignment(1);
    label.addMouseListener(this);
    this.add(title, label);
    //Start the applet
    public void start() {
    //Stop the applet
    public void stop() {
    //Destroy the applet
    public void destroy() {
    //Get Applet information
    public String getAppletInfo() {
    return(
    "Title:\t\tPopupMenuApplet\n" +
    "Version:\t1.1.1\n" +
    "Date:\t\t11/15/2001\n" +
    "Author:\t\tErwin (http://www.centric.nl/)\n" +
    "Description:\tA configurable menu applet based on the\n" +
    "\t\tJava (TM) 1.1 PopupMenu class."
    //Get parameter info
    public String[][] getParameterInfo() {
    String pinfo[][] =
    {"title", "String", "Menu title"},
    {"img", "URL", "Background image"},
    {"bgcolor", "Color or Hex RGB value", "Menu background color"},
    {"text", "Color or Hex RGB value", "Menu foreground color"},
    {"font", "Font name", "Menu font name"},
    {"size", "Integer", "Menu font size"},
    {"style", "Sum of BOLD,PLAIN,ITALIC", "Menu font style"},
    {"menufont", "Font name", "Menu font name"},
    {"menusize", "Integer", "Menu font size"},
    {"menustyle", "Sum of BOLD,PLAIN,ITALIC", "Menu font style"},
    {"data", "Menu item names, actions and targets", "Menu data"},
    return pinfo;
    public void paint(Graphics g) {
    if (bgImage != null)
    g.drawImage(bgImage,0,0,this);
    if (imgError)
    this.showStatus("PopupMenuApplet: invalid URL for img parameter " + img);
    if (parseError)
    this.showStatus("PopupMenuApplet Error: unbalanced braces in data parameter tag.");
    public void mousePressed(MouseEvent e) {
    public void mouseReleased(MouseEvent e) {
    public void mouseClicked(MouseEvent e) {
    popup();
    public void mouseEntered(MouseEvent e) {
    popup();
    public void mouseExited(MouseEvent e) {
    public void actionPerformed(ActionEvent e) {
    int elt = Integer.parseInt(e.getActionCommand());
    String cmd = actions[elt];
    String target = targets[elt];
    if (cmd.length() > 7 && cmd.substring(0,7).equalsIgnoreCase("script=")) {
    // catch exception thrown by the appletviewer (but not a browser)
    // just so we can test the menu appearance with the appletviewer.
    try {
    cmd = cmd.substring(7); // trim the "script=" identifier
    if (target.equalsIgnoreCase("_self") || target.equalsIgnoreCase("_parent")
         || target.equalsIgnoreCase("_top"))
    target = target.substring(1).toLowerCase(); // allow for leading underscore HTML syntax
    cmd = target + "." + cmd;
    JSObject win = JSObject.getWindow(this);
    win.eval(cmd);
    } catch(Exception n) {
    this.showStatus("PopupMenuApplet: Error running script " + cmd);
    } else {
    try { // absolute URL
    URL dest = new URL(cmd);
    this.getAppletContext().showDocument(dest, target);
    } catch(MalformedURLException a) {
    try { // relative URL
    URL dest = new URL(this.getDocumentBase(), cmd);
    this.getAppletContext().showDocument(dest, target);
    } catch(MalformedURLException r) {
    this.showStatus("PopupMenuApplet: invalid URL " + cmd);
    public void popup() {
    if (!parseError)
    mainMenu.show(this,this.getSize().width/2,this.getSize().height/2);
    private Color translateColor(String c) {
    if(c.equalsIgnoreCase("white"))
    return(Color.white);
    else if(c.equalsIgnoreCase("lightgray"))
    return(Color.lightGray);
    else if(c.equalsIgnoreCase("gray"))
    return(Color.gray);
    else if(c.equalsIgnoreCase("darkgray"))
    return(Color.darkGray);
    else if(c.equalsIgnoreCase("black"))
    return(Color.black);
    else if(c.equalsIgnoreCase("red"))
    return(Color.red);
    else if(c.equalsIgnoreCase("pink"))
    return(Color.pink);
    else if(c.equalsIgnoreCase("orange"))
    return(Color.orange);
    else if(c.equalsIgnoreCase("yellow"))
    return(Color.yellow);
    else if(c.equalsIgnoreCase("green"))
    return(Color.green);
    else if(c.equalsIgnoreCase("magenta"))
    return(Color.magenta);
    else if(c.equalsIgnoreCase("cyan"))
    return(Color.cyan);
    else if(c.equalsIgnoreCase("blue"))
    return(Color.blue);
    // allow for Hex RGB values (and an optional leading #, as in HTML syntax)
    else if (c.length() == 6 || (c.length() == 7 && c.charAt(0) == '#')) {
    if (c.length() == 7)
    c = c.substring(1);
    return(new Color(hexToInt(c.substring(0,2)),
    hexToInt(c.substring(2,4)),hexToInt(c.substring(4,6))));
    else
    return(Color.white);
    private int hexToInt(String c) {
    try {
    return(Integer.parseInt(c, 16));
    } catch(NumberFormatException h) {
    return 0;
    private int translateStyle(String s) {
    int style = 0;
    String token = null;
    StringTokenizer st = new StringTokenizer(s,",+ \t\n\r");
    do {
    try {
    token = st.nextToken();
    } catch(NoSuchElementException n) {}
    if (token.equalsIgnoreCase("PLAIN"))
    style += Font.PLAIN;
    else if (token.equalsIgnoreCase("BOLD"))
    style += Font.BOLD;
    else if (token.equalsIgnoreCase("ITALIC"))
    style += Font.ITALIC;
    } while (st.hasMoreTokens());
    return style;
    private void parseData(String s) {
    // menuItem counters start at -1 so that at first increment, they get set to
    // the first array subscript value of 0
    // menu counters start at 0 so that at first increment, they get set to
    // the array subscript value of 1, the first value (0) being reserved for the main menu
    int levelCtr = -1, menuCtr = 0, menuItemCtr = -1;
    int levelCount = 0, menuCount = 0, menuItemCount = -1;
    int parentMenuPtr[];
    String itemToken = null, datatoken = null;
    String title = "", action = "", target = "_self";
    boolean newMenu = false;
    if (s == null || s.indexOf("{") == -1) {
    parseError = true;
    return;
    StringTokenizer braces = new StringTokenizer(s,"{}",true);
    StringTokenizer braceCtr = new StringTokenizer(s,"{}",true);
    StringTokenizer asterisks;
    // Get the number of menus and menuItems for which to allocate array space
    do {
    try {
    itemToken = braceCtr.nextToken();
    } catch(NoSuchElementException i) {}
    if (itemToken.charAt(0) == '{') {
    if (newMenu)
    menuCount++;
    newMenu = true;
    levelCtr++;
    if (levelCount < levelCtr) levelCount = levelCtr;
    } else if (itemToken.charAt(0) == '}') {
    if (newMenu)
    menuItemCount++;
    newMenu = false;
    levelCtr--;
    } while (braceCtr.hasMoreTokens());
    if (levelCtr != -1) {
    parseError = true;
    return;
    // allocate one more element than the counter values , since the first subscript value is 0
    actions = new String[menuItemCount+1];
    targets = new String[menuItemCount+1];
    menuItems = new MenuItem[menuItemCount+1];
    menus = new Menu[menuCount+1];
    parentMenuPtr = new int[levelCount+1];
    mainMenu = new PopupMenu(title);
    menus[0] = (Menu)(mainMenu);
    this.add(mainMenu);
    itemToken = null;
    newMenu = false;
    // Parse the data Param and build the menu and menu items
    do {
    try {
    itemToken = braces.nextToken();
    } catch(NoSuchElementException i) {}
    if (itemToken.charAt(0) == '{') {
    if (newMenu) {
    menuCtr++;
    menus[menuCtr] = new Menu(title);
    menus[menuCtr].setFont(menuFont);
    menus[parentMenuPtr[levelCtr]].add(menus[menuCtr]);
    parentMenuPtr[levelCtr+1] = menuCtr;
    newMenu = true;
    levelCtr++;
    } else if (itemToken.charAt(0) == '}') {
    if (newMenu) {
    menuItemCtr++;
    actions[menuItemCtr] = action;
    targets[menuItemCtr] = target;
    menuItems[menuItemCtr] = new MenuItem(title);
    menuItems[menuItemCtr].setFont(menuFont);
    menuItems[menuItemCtr].addActionListener(this);
    menuItems[menuItemCtr].setActionCommand(new Integer(menuItemCtr).toString());
    menus[parentMenuPtr[levelCtr]].add(menuItems[menuItemCtr]);
    newMenu = false;
    levelCtr--;
    } else if (!itemToken.trim().equals("")) {
    asterisks = new StringTokenizer(itemToken,"*");
    try {
    title = asterisks.nextToken();
    // a menu separator is a -, but allow for hr as well, as in HTML syntax
    if (title.equals("-") || title.equalsIgnoreCase("HR"))
    title = "-";
    } catch(NoSuchElementException i) {
    title = "-";
    try {
    action = asterisks.nextToken();
    } catch(NoSuchElementException i) {
    action = "";
    try {
    target = asterisks.nextToken();
    } catch(NoSuchElementException i) {
    target = "_self";
    } while (braces.hasMoreTokens());

    Ok, well you'll need to do something like this. Now this part is a little dependent on your database server:
           try {
                Class.forName("org.gjt.mm.mysql.Driver").newInstance();
                Connection c = DriverManager.getConnection(
                                                           "jdbc:mysql://{database-server}/{database-name}:3306?user={username}&password={password}");
                Statement Stmt = c.createStatement();
                int count = Stmt.executeUpdate(cmd);
                if(count>0) {
                     System.out.println("count: " + count);
            } catch (Exception e) {
                e.printStackTrace();
        }That was some sample code for a MySQL database.
    Note that the applet can only contact the server that is was loaded from, so you might want to do a getCodeBase() or something like that to get the server address.
    Hope this is helpful.

  • PCI-MI0-16XE-50 Failing Self-test

    I am using a PCI-MI0-16XE-50 which is failing the self-test in MAX 3.1.1.3004.  I have used the E Series Diagnostic Utility which gives the error "Error 10809 occurred at cwdaq:  Starting DAQ operation Attempted to start a pulse width measurement with the pulse in the phase to be measured (e.g., high phase for high-level gating)."  Windows XP detects the device fine, as does MAX.  The obvious answer is that the device is broken, but is it feasible or economical to have the device repaired?  What tends to cause this type of problem and/or how can it be corrected?
    Thanks,
    Brandon

    Hello C.
    You will need to contact National Instruments for a quote for repairing
    you board. If you bought less than a year ago, it may still be under
    warranty in which case it would not cost you anything to repair.
    However, I would suggest in case you need to pay for repair to consider
    getting one of the new improved and more performent yet low cost M Series devices.
    Hope this helps.

  • Can anyone solve this one?

    Hi,
    I've got a problem with compiling the code below.
    I've downloaded a java and a class file. The class file is working (it's a slide-menu).
    Because I wanted to update a record in a DB, I changed the java file. The part I changed is the part under ActionPerformed. The actionPerformed code is working independently.
    But when I implement it in the java file, he stops compiling.
    I tried to compile the original code, but it stopped also at the same line. In the new code it's line 318.
    The line is:
    this.add(mainMenu);
    and the error is:
    method add(java.awt.Menu) not found in class FisMenu.
    The strangest thing is that he gives an error in the code which is used in the WORKING class file.
    I have had a hint to use Japplet instead of Applet, that�s why I post this problem here.
    can anyone help me out?
    thanks in advance.
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.net.*;
    import java.util.*;
    import netscape.javascript.*;
    import sqlj.runtime.*;
    import sqlj.runtime.ref.*;
    import java.sql.*;
    import java.lang.*;
    public class FisMenuApplet extends Applet implements MouseListener, ActionListener {
    String title, img, bgcolor, text, font, size, style, menufont, menustyle, menusize, data;
    String actions[], targets[];
    java.awt.Menu menus[];
    MenuItem menuItems[];
    int fontsize, menufontsize;
    CardLayout cardlayout;
    java.awt.Menu mainMenu;
    Image bgImage = null;
    boolean parseError = false, imgError = false;
    URL imgUrl;
    Label label;
    Font labelFont, menuFont;
    //Construct the applet
    public FisMenuApplet() {
    //Initialize the applet
    public void main() {
    cardlayout = new CardLayout();
    title = getParameter("title");
    if (title == null) title = "Menu";
    // the colors for bgcolor and text are used only for the applet label
    // Java 1.1 menus themselves don't support colors, although some Unix implementations
    // allow a menu's background color to be inherited from the object it's attached to.
    bgcolor = getParameter("bgcolor");
    if (bgcolor == null) bgcolor = "white";
    else bgcolor = bgcolor.toLowerCase();
    text = getParameter("text");
    if (text == null) text = "blue";
    else text = text.toLowerCase();
    // font, size and style are used for the applet's text label (if any)
    font = getParameter("font");
    if (font == null) font = "SansSerif";
    size = getParameter("size");
    if (size == null) fontsize = 11;
    else
    try {
    fontsize = Integer.parseInt(size);
    } catch(NumberFormatException f) {
    fontsize = 11;
    style = getParameter("style");
    if (style == null) style = "plain";
    labelFont = new Font(font, translateStyle(style), fontsize);
    // menufont, menusize and menustyle default to font, size and style if undefined,
    // but they can be also defined explicitely in case we want the popup menu to look different
    // from the applet's text label (if any)
    menufont = getParameter("menufont");
    if (menufont == null) menufont = font;
    menusize = getParameter("menusize");
    if (menusize == null) menufontsize = fontsize;
    else
    try {
    menufontsize = Integer.parseInt(menusize);
    } catch(NumberFormatException f) {
    menufontsize = 11;
    menustyle = getParameter("menustyle");
    if (menustyle == null) menustyle = style;
    menuFont = new Font(menufont, translateStyle(menustyle), menufontsize);
    data = getParameter("data");
    parseData(data);
    this.addMouseListener(this);
    this.setBackground(translateColor(bgcolor));
    this.setForeground(translateColor(text));
    this.setFont(labelFont);
    this.setLayout(cardlayout);
    img = getParameter("img");
    if (img != null) {
    try { // absolute URL
    imgUrl = new URL(img);
    bgImage = this.getImage(imgUrl);
    } catch(MalformedURLException a) {
    try { // relative URL
    imgUrl = new URL(this.getDocumentBase(), img);
    bgImage = this.getImage(imgUrl);
    } catch(MalformedURLException r) {
    imgError = true;
    bgImage = this.getImage(this.getDocumentBase(), img);
    } else {
    label = new Label(title);
    label.setAlignment(1);
    label.addMouseListener(this);
    this.add(title, label);
    //Start the applet
    public void start() {
    //Stop the applet
    public void stop() {
    //Destroy the applet
    public void destroy() {
    //Get parameter info
    public String[][] getParameterInfo() {
    String pinfo[][] =
    {"title", "String", "Menu title"},
    {"img", "URL", "Background image"},
    {"bgcolor", "Color or Hex RGB value", "Menu background color"},
    {"text", "Color or Hex RGB value", "Menu foreground color"},
    {"font", "Font name", "Menu font name"},
    {"size", "Integer", "Menu font size"},
    {"style", "Sum of BOLD,PLAIN,ITALIC", "Menu font style"},
    {"menufont", "Font name", "Menu font name"},
    {"menusize", "Integer", "Menu font size"},
    {"menustyle", "Sum of BOLD,PLAIN,ITALIC", "Menu font style"},
    {"data", "Menu item names, actions and targets", "Menu data"},
    return pinfo;
    public void paint(Graphics g) {
    if (bgImage != null)
    g.drawImage(bgImage,0,0,this);
    if (imgError)
    this.showStatus("FisMenuApplet: invalid URL for img parameter " + img);
    if (parseError)
    this.showStatus("FisMenuApplet Error: unbalanced braces in data parameter tag.");
    public void mousePressed(MouseEvent e) {
    public void mouseReleased(MouseEvent e) {
    public void mouseClicked(MouseEvent e) {
    popup();
    public void mouseEntered(MouseEvent e) {
    popup();
    public void mouseExited(MouseEvent e) {
    public void actionPerformed(ActionEvent e)
    // Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    try
    Connection con = DriverManager.getConnection("jdbc:odbc:tom", "", "");
    System.out.println("jdbc:odbc connectie...");
    Statement stmt = con.createStatement();
    //Update database record
    stmt.executeUpdate(
    "update fis_tuser_preferences set word_path = 'ffisau01' ");
    System.out.println("ffisau01");
    //Close conection and commit transaction
    con.close();
    System.out.println("connection closed");
    catch (Exception f)
    System.err.println("problems connecting to URL");
    public void popup() {
    // if (!parseError)
    // mainMenu.show(this,this.getSize().width/2,this.getSize().height/2);
    private Color translateColor(String c) {
    if(c.equalsIgnoreCase("white"))
    return(Color.white);
    else if(c.equalsIgnoreCase("lightgray"))
    return(Color.lightGray);
    else if(c.equalsIgnoreCase("gray"))
    return(Color.gray);
    else if(c.equalsIgnoreCase("darkgray"))
    return(Color.darkGray);
    else if(c.equalsIgnoreCase("black"))
    return(Color.black);
    else if(c.equalsIgnoreCase("red"))
    return(Color.red);
    else if(c.equalsIgnoreCase("pink"))
    return(Color.pink);
    else if(c.equalsIgnoreCase("orange"))
    return(Color.orange);
    else if(c.equalsIgnoreCase("yellow"))
    return(Color.yellow);
    else if(c.equalsIgnoreCase("green"))
    return(Color.green);
    else if(c.equalsIgnoreCase("magenta"))
    return(Color.magenta);
    else if(c.equalsIgnoreCase("cyan"))
    return(Color.cyan);
    else if(c.equalsIgnoreCase("blue"))
    return(Color.blue);
    // allow for Hex RGB values (and an optional leading #, as in HTML syntax)
    else if (c.length() == 6 || (c.length() == 7 && c.charAt(0) == '#')) {
    if (c.length() == 7)
    c = c.substring(1);
    return(new Color(hexToInt(c.substring(0,2)),
    hexToInt(c.substring(2,4)),hexToInt(c.substring(4,6))));
    else
    return(Color.white);
    private int hexToInt(String c) {
    try {
    return(Integer.parseInt(c, 16));
    } catch(NumberFormatException h) {
    return 0;
    private int translateStyle(String s) {
    int style = 0;
    String token = null;
    StringTokenizer st = new StringTokenizer(s,",+ \t\n\r");
    do {
    try {
    token = st.nextToken();
    } catch(NoSuchElementException n) {}
    if (token.equalsIgnoreCase("PLAIN"))
    style += Font.PLAIN;
    else if (token.equalsIgnoreCase("BOLD"))
    style += Font.BOLD;
    else if (token.equalsIgnoreCase("ITALIC"))
    style += Font.ITALIC;
    } while (st.hasMoreTokens());
    return style;
    private void parseData(String s) {
    // menuItem counters start at -1 so that at first increment, they get set to
    // the first array subscript value of 0
    // menu counters start at 0 so that at first increment, they get set to
    // the array subscript value of 1, the first value (0) being reserved for the main menu
    int levelCtr = -1, menuCtr = 0, menuItemCtr = -1;
    int levelCount = 0, menuCount = 0, menuItemCount = -1;
    int parentMenuPtr[];
    String itemToken = null, datatoken = null;
    String title = "", action = "", target = "_self";
    boolean newMenu = false;
    if (s == null || s.indexOf("{") == -1) {
    parseError = true;
    return;
    StringTokenizer braces = new StringTokenizer(s,"{}",true);
    StringTokenizer braceCtr = new StringTokenizer(s,"{}",true);
    StringTokenizer asterisks;
    // Get the number of menus and menuItems for which to allocate array space
    do {
    try {
    itemToken = braceCtr.nextToken();
    } catch(NoSuchElementException i) {}
    if (itemToken.charAt(0) == '{') {
    if (newMenu)
    menuCount++;
    newMenu = true;
    levelCtr++;
    if (levelCount < levelCtr) levelCount = levelCtr;
    } else if (itemToken.charAt(0) == '}') {
    if (newMenu)
    menuItemCount++;
    newMenu = false;
    levelCtr--;
    } while (braceCtr.hasMoreTokens());
    if (levelCtr != -1) {
    parseError = true;
    return;
    // allocate one more element than the counter values , since the first subscript value is 0
    actions = new String[menuItemCount+1];
    targets = new String[menuItemCount+1];
    menuItems = new MenuItem[menuItemCount+1];
    menus = new java.awt.Menu[menuCount+1];
    parentMenuPtr = new int[levelCount+1];
    mainMenu = new java.awt.Menu(title);
    menus[0] = (java.awt.Menu)(mainMenu);
    this.add(mainMenu);
    itemToken = null;
    newMenu = false;
    // Parse the data Param and build the menu and menu items
    do {
    try {
    itemToken = braces.nextToken();
    } catch(NoSuchElementException i) {}
    if (itemToken.charAt(0) == '{') {
    if (newMenu) {
    menuCtr++;
    menus[menuCtr] = new java.awt.Menu(title);
    menus[menuCtr].setFont(menuFont);
    menus[parentMenuPtr[levelCtr]].add(menus[menuCtr]);
    parentMenuPtr[levelCtr+1] = menuCtr;
    newMenu = true;
    levelCtr++;
    } else if (itemToken.charAt(0) == '}') {
    if (newMenu) {
    menuItemCtr++;
    actions[menuItemCtr] = action;
    targets[menuItemCtr] = target;
    menuItems[menuItemCtr] = new MenuItem(title);
    menuItems[menuItemCtr].setFont(menuFont);
    menuItems[menuItemCtr].addActionListener(this);
    menuItems[menuItemCtr].setActionCommand(new Integer(menuItemCtr).toString());
    menus[parentMenuPtr[levelCtr]].add(menuItems[menuItemCtr]);
    newMenu = false;
    levelCtr--;
    } else if (!itemToken.trim().equals("")) {
    asterisks = new StringTokenizer(itemToken,"*");
    try {
    title = asterisks.nextToken();
    // a menu separator is a -, but allow for hr as well, as in HTML syntax
    if (title.equals("-") || title.equalsIgnoreCase("HR"))
    title = "-";
    } catch(NoSuchElementException i) {
    title = "-";
    try {
    action = asterisks.nextToken();
    } catch(NoSuchElementException i) {
    action = "";
    try {
    target = asterisks.nextToken();
    } catch(NoSuchElementException i) {
    target = "_self";
    } while (braces.hasMoreTokens());

    Congratulations!
    I understand completely that you don't like to look at my code and I don't aspect you to help me.
    But I'll sure appriciate any help from you or anyone else, today and in the future :)
    about the working class file, I downloaded it once and it's working, but when I compile the java file it crashes (even in de original downloaded code).
    I just need a way for my code to accept the add method (even if there are major changes needed).

  • Suggestion for pH adjustment alogrithm

    Hi, here is my code for judging pH and adjusting pH value using state machine.
    I only finished the cases when pH >7.5, I havent done the cases for pH<7.5.
    I understand its very akward because it lacks of real control alogrithm; But I really dont know how to program a controller to relate time and pH value together.
    In the VI, you will see I adjust pH by opening/closing relay board which further drives valve to open/close to let electrolyte flow out/stop.
    We will do experiment to determine the time for opening/closing valves... It will invlove a lot of work and I am aware of it.
    Any suggestion regarding programing technique, bug, etc will be appreciated. Thank u!
    p.s the BEi delay VI is provided by one of NI forum adminstrators.
    Solved!
    Go to Solution.
    Attachments:
    main_code_2_20_2013.vi ‏284 KB
    case_for_testing.ctl ‏5 KB
    BEI Delay.vi ‏30 KB

    I found one problem myself,
    in the case of ''start DAQ'', I want the VI to take measurement for 5 seconds and stop, then it can calculate mean value. The mean value will be used for later cases.
    The problem is the start DAQ keeps running, when 5 seconds is reached, the mean pH value is calulated but the Vi is stilling reading data...

  • 6008USB: simple measuremen​t of two temperatur​es

    I have to measure two temperatures:
    the first one outdoor,
    the second one indoor.
    I was thinking to use two common
    sensors: AD590 for the outdoor
    and LM335 for the indoor.
    Temperatures must be displayed
    in °C so I have to make
    a conversion via software.
    I was thinking to do as follows:
    For the outdoor:
    Input0 (as RSE), a 10k resistor
    between AI0 and GND (so to make
    conversion 10mV/°K)
    For the indoor:
    Input1 (as RSE), a 4~5k resistor
    between AI1 and +5V pin;
    LM335 between Input1 and GND
    What do you think about?
    Is it ok or it's too minimal?
    Is there any alternatives do
    you suggest to adopt instead?
    Thanks in advance

    Hello Sprice,
    Browse the shipping examples according to “Directory Structure” and then select
    DAQ to find the Traditional DAQ examples. 
    There a lot of examples that are written for counters (Counter >>
    daq-stc.llb >> Count Edges (DAQ-STC).vi). 
    What kind of signals are your photons creating?  Are they TTL compatible at a certain
    frequency?  You don’t care about overwriting
    your buffer?
    Respectfully,
    Rob F
    Test Engineer
    Condition Measurements
    National Instruments

Maybe you are looking for