"Simple" NI-DAQmx programming

Using a NI-PCI 6024E card with NI-DAQmx and C, I would like to acquire sequentially (at 200kHz) a single sample on the "ai0" to "ai5" analog inputs on every rising edge of the "pfi0/ai start" input (driven by a signal at 50Hz)...
What clock and timing to program for a task to do this simple thing?!

Would you believe it? It is as simple as:
DAQmxCHECK (DAQmxCfgSampClkTiming (hTask,
"/dev1/pf0", 50, DAQmx_Val_Rising,
DAQmx_Val_HWTimedSinglePoint, 2)
Trigger is about triggering the TASK, not the acquisition. I completely missed this point :-(
Perhaps I will like DAQmx after all...

Similar Messages

  • Problems with a simple stop watch program

    I would appreciate help sorting out a problem with a simple stop watch program. The problem is that it throws up inappropriate values. For example, the first time I ran it today it showed the best time at 19 seconds before the actual time had reached 2 seconds. I restarted the program and it ran correctly until about the thirtieth time I started it again when it was going okay until the display suddenly changed to something like '-50:31:30:50-'. I don't have screenshot because I had twenty thirteen year olds suddenly yelling at me that it was wrong. I clicked 'Stop' and then 'Start' again and it ran correctly.
    I have posted the whole code (minus the GUI section) because I want you to see that the program is very, very simple. I can't see where it could go wrong. I would appreciate any hints.
    public class StopWatch extends javax.swing.JFrame implements Runnable {
        int startTime, stopTime, totalTime, bestTime;
        private volatile Thread myThread = null;
        /** Creates new form StopWatch */
        public StopWatch() {
         startTime = 0;
         stopTime = 0;
         totalTime = 0;
         bestTime = 0;
         initComponents();
        public void run() {
         Thread thisThread = Thread.currentThread();
         while(myThread == thisThread) {
             try {
              Thread.sleep(100);
              getEnd();
             } catch (InterruptedException e) {}
        public void start() {
         if(myThread == null) {
             myThread = new Thread(this);
             myThread.start();
        public void getStart() {
         Calendar now = Calendar.getInstance();
         startTime = (now.get(Calendar.MINUTE) * 60) + now.get(Calendar.SECOND);
        public void getEnd() {
         Calendar now1 = Calendar.getInstance();
         stopTime = (now1.get(Calendar.MINUTE) * 60) + now1.get(Calendar.SECOND);
         totalTime = stopTime - startTime;
         setLabel();
         if(bestTime < totalTime) bestTime = totalTime;
        public void setLabel() {
         if((totalTime % 60) < 10) {
             jLabel1.setText(""+totalTime/60+ ":0"+(totalTime % 60));
         } else {
             jLabel1.setText(""+totalTime/60 + ":"+(totalTime % 60));
         if((bestTime % 60) < 10) {
             jLabel3.setText(""+bestTime/60+ ":0"+(bestTime % 60));
         } else {
             jLabel3.setText(""+bestTime/60 + ":"+(bestTime % 60));
        private void ButtonClicked(java.awt.event.ActionEvent evt) {                              
         JButton temp = (JButton) evt.getSource();
         if(temp.equals(jButton1)) {
             start();
             getStart();
         if(temp.equals(jButton2)) {
             getEnd();
             myThread = null;
         * @param args the command line arguments
        public static void main(String args[]) {
         java.awt.EventQueue.invokeLater(new Runnable() {
             public void run() {
              new StopWatch().setVisible(true);
        // Variables declaration - do not modify                    
        private javax.swing.JButton jButton1;
        private javax.swing.JButton jButton2;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JLabel jLabel3;
        private javax.swing.JPanel jPanel1;
        // End of variables declaration                  
    }

    Although I appreciate this information, it still doesn't actually solve the problem. I can't see an error in the logic (or the code). The fact that the formatting works most of the time suggests that the problem does not lie there. As well, I use the same basic code for other time related displays e.g. countdown timers where the user sets a maximum time and the computer stops when zero is reached. I haven't had an error is these programs.
    For me, it is such a simple program and the room for errors seem small. I am guessing that I have misunderstood something about dates, but I obviously don't know.
    Again, thank you for taking the time to look at the problem and post a reply.

  • Simple Data Base Program for Mountain Lion

    Does anyone have a recommendation for a simple data base program that will import comma delimited fields from early versions of Filemaker Pro (v 3.0, v5.0)
    The ability to import Filemaker Templates and Layouts would be a big plus.
    I do not need the a highly sophisticated program just something with the ability to import data from several different data bases and create layouts that look like I want them to look.  
    Also what is the earliest version of Filemaker that will run well on Mountain Lion ?
                                                                            Thanks....Ken

    I suggest Bento (by Filemaker), simple database, imports Filemaker Pro files and doesn't cost very much

  • How to compile a simple "Hello World" program in Java by using Netbeans

    Hi all, I am very new to java programming arena. i am trying to learn the most demanding language for the time being. To program, i always use IDE's as it makes programming experience much easier by underline the syntax errors or sometimes showing codehint. However, I am facing some problem when i use Netbeabs to compile a simple "Hello world" program. my problem is whenever i write the code and press compile button, netbeans says "main class not found". Consequently,i am becoming frustated. So, i am here in this forum to get some kind help on How i can compile java programs in Netbeans. Please help me out, otherwise i may lose my enthusiasm in Java. please help me, i m stuck

    Go to http://www.netbeans.org/
    You should find tutorials there.

  • Steps To execute Simple Hello world programs of struts

    Hi,
    Can u tell me how to execute the simple hello world programs in struts by using eclipse ID..
    and send me the screen shots and what all the jar files we have to copy in lib folder.

    >
    Can u tell me how to execute the simple hello world programs in struts by using eclipse ID..
    and send me the screen shots and what all the jar files we have to copy in lib folder.
    >
    No. Post the question in an Eclipse forum.

  • How do I create a simple "prize draw" program?

    Hey, I'd like to create a simple "prize draw" program
    that randomly selects a name (or number) from a list of names, I'd like it to be my own custom version. For a programmer this is probably the easiest thing but I'm new to programming (beginner), don't eve know if I'm in the right subcategory (flash). Is there a tutorial or something somewhere that you guys think could help me out, please?

    Create the list as an array and use the Math methods to randomly pick one of the values from the array.
    var prizeArray = new Array("name1","name2");
    var drawnPrize = prizeArray[Math.floor(Math.random()*prizeArray.length)];
    trace(drawnPrize);
    If you don't know if you should be using Flash, then you probably don't want to be looking for help until you figure out what you intend to do for your custom design.

  • Looking for simple line drawing program [Solved]

    I am looking for a simple line drawing program with the following features :
    command-driven ( line, circle, ellips and such commands)
    used commands need to be exportable or copyable
    2D
    a canvas with arbitrary size
    libreoffice Draw, Koffice Karbon and xfig are not suitable for this.
    I have some experience with Autocad, but no access to that anymore.
    Any suggestions ?
    Last edited by Lone_Wolf (2011-04-03 13:34:57)

    keenerd wrote:For really simple stuff (and extremely keyboard driven!) I'll make an SVG by hand.  Any xml aware text editor works great.  The spec is pretty simple.  Use an image viewer that will automatically redraw when the SVG is updated.
    +1 http://www.w3schools.com/svg/tryit.asp? … 1&type=svg
    I think TeX can draw alright.
    A bunch of links - never tried them, don't know if they even work:
    http://www.ribbonsoft.com/qcad.html
    http://www.linuxcad.com/
    http://ipe7.sourceforge.net/
    Last edited by karol (2011-04-03 01:12:44)

  • I would like to purchase a simple photo editing program for my mac which will enable me to write on photos

    I have only had an imac for 3 weeks would like to know of a simple photo editing programe that will enable me to write captions on a photo any help appreciated

    Here is another suggestion - GraphicConverter:
    http://www.lemkesoft.com/
    I've used it for years - an excellent app.

  • Creation of Simple JSP DynPage program

    Hi Experts,
    Could you please send me some link to create simple JSP DynPage program.
    Regards,
    RK

    Hi,
      Check these..
    http://help.sap.com/saphelp_nw2004s/helpdata/en/f5/cfa441cd47a209e10000000a155106/frameset.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/d0/d4a441cd47a209e10000000a155106/content.htm
    https://www.sdn.sap.com/irj/sdn/thread?messageID=223649#223649
    Regards,
    Harini S

  • "Simple" C NI-DAQmx programming

    After days of comprehensive DAQmx C functions documentation parsing, I still cannot do a very basic acquisition task... I do not understand clearly how to set timing and trigger functions!
    On a 200 kS/s PCI-6024E card, I would like to acquire signals on analog inputs "ai0" to "ai5" on every rising edge on port "pfi0/ai start" (ca. 50Hz). On every rising edge of "pfi0", I would like to convert the signal on port "ai0", then 5µs later on port "ai1", and so on up to port "ai5" where conversion should start 25µs later. And the whole process would run again 20ms later.
    This should occur in a THREAD_PRIORITY_TIME_CRITICAL thread in my process. This thread would "idle" wait for each "pf0" rising edge and subsequent conversions with the "DA
    QmxReadAnalogF64()" function.
    Thanks for your help ;-)

    NI-DAQmx installs examples in Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\. There are lots of simple example applications for various aspects of NI-DAQmx.
    In your first post, you show examples of DAQmx calls. They aren't organized into code snippets, so I presume that in the real code you are checking the return error codes!
    I also notice that at one point you have "/dev1/pf0". I bet you meant to type "/dev1/pfi0"
    John Weeks
    WaveMetrics, Inc.
    Phone (503) 620-3001
    Fax (503) 620-6754
    www.wavemetrics.com

  • Simple Java 3D program’s CPU Usage spikes to up to 90 percent!

    Hi, everyone. I’m completely new to Java 3D and I’m toying around with basic program structure right now. My code is based off of that in the first chapter on 3D in Killer Game Programming in Java. I removed most of the scene elements, replacing them with a simple grid, Maya style. (Yes, I’m starting off small, but my ambitions are grand – I intend on creating a polygonal modeling and animation toolset. After all, the Maya PLE is dead – damn you, Autodesk! – and I just plain dislike Blender.) I implement a simple OrbitBehavior as a means for the user to navigate the scene. That part was basically copy and paste from Andrew Davison’s code. The mystery, then, is why the program’s framerate drops below 1 FPS and its CPU Usage spikes to up to 90 percent, according to the Task Manager, when I tumble the scene. I’d appreciate anyone taking the time to look at the code and trying to identify the problem area. (I’ve undoubtedly missed something totally newbish. -.-) Thank you!
    (Also, I had the worst possible time wrestling with the posting process. Is anyone else having trouble editing their posts before submitting them?)
    import java.awt.*;
    import javax.swing.*;
    public class MAFrame
        public static final Dimension SCREEN_SIZE = Toolkit.getDefaultToolkit().getScreenSize();
        public MAFrame ()
            System.out.println("Initializing...");
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            catch (Exception e) {
                e.printStackTrace();
            JFrame frame = new JFrame ("Modeling and Animation");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            MAViewPanel panel = new MAViewPanel ();
            frame.getContentPane().add(panel);
            frame.pack();       
            frame.setLocation(((int)SCREEN_SIZE.getWidth() / 2) - (frame.getWidth() / 2),
                              ((int)SCREEN_SIZE.getHeight() / 2) - (frame.getHeight() / 2));     
            frame.setVisible(true);
    import com.sun.j3d.utils.behaviors.vp.*;
    import com.sun.j3d.utils.geometry.*;
    import com.sun.j3d.utils.universe.*;
    import java.awt.*;
    import javax.media.j3d.*;
    import javax.swing.*;
    import javax.vecmath.*;
    public class MAViewPanel extends JPanel
        public static final int GRID_SIZE = 12;
        public static final int GRID_SPACING = 4;
        public BoundingSphere bounds;
        public BranchGroup sceneBG;
        public SimpleUniverse su;
        public MAViewPanel ()
            GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
            Canvas3D canvas3D = new Canvas3D (config);               
            canvas3D.setSize(600, 600);
            add(canvas3D);
            canvas3D.setFocusable(true);
            canvas3D.requestFocus();
            su = new SimpleUniverse (canvas3D);
            createSceneGraph();
            initUserPosition();
            orbitControls(canvas3D);
            su.addBranchGraph(sceneBG);
        public void createSceneGraph ()
            sceneBG = new BranchGroup ();
            bounds = new BoundingSphere (new Point3d(0, 0, 0), 1000);
            // ambient light
            Color3f white = new Color3f (1.0f, 1.0f, 1.0f);
            AmbientLight ambientLight = new AmbientLight (white);
            ambientLight.setInfluencingBounds(bounds);
            sceneBG.addChild(ambientLight);
            // background
            Background background = new Background ();
            background.setColor(0.17f, 0.65f, 0.92f);
            background.setApplicationBounds(bounds);       
            sceneBG.addChild(background);
            // grid
            createGrid();
            sceneBG.compile();
        public void createGrid ()
            Shape3D grid = new Shape3D();
            LineArray lineArr = new LineArray (GRID_SIZE * 8 + 4, GeometryArray.COORDINATES);
            int offset = GRID_SIZE * GRID_SPACING;
            // both sides of the grid plus the middle, done for both directions at once (each line defined by two points)
            for (int count = 0, index = 0; count < GRID_SIZE * 2 + 1; count++) {
                // vertical, left to right
                lineArr.setCoordinate(index++, new Point3d (-offset + (count * GRID_SPACING), 0, offset));  // starts near
                lineArr.setCoordinate(index++, new Point3d (-offset + (count * GRID_SPACING), 0, -offset)); // ends far
                // horizontal, near to far
                lineArr.setCoordinate(index++, new Point3d (-offset, 0, offset - (count * GRID_SPACING))); // starts left
                lineArr.setCoordinate(index++, new Point3d (offset, 0, offset - (count * GRID_SPACING)));  // ends right
            grid.setGeometry(lineArr);
            sceneBG.addChild(grid);
        public void initUserPosition ()
            ViewingPlatform vp = su.getViewingPlatform();
            TransformGroup tg = vp.getViewPlatformTransform();
            Transform3D t3d = new Transform3D ();
            tg.getTransform(t3d);
            t3d.lookAt(new Point3d (0, 60, 80), new Point3d (0, 0, 0), new Vector3d(0, 1, 0));
            t3d.invert();
            tg.setTransform(t3d);
            su.getViewer().getView().setBackClipDistance(100);
        private void orbitControls (Canvas3D c)
            OrbitBehavior orbit = new OrbitBehavior (c, OrbitBehavior.REVERSE_ALL);
            orbit.setSchedulingBounds(bounds);
            ViewingPlatform vp = su.getViewingPlatform();
            vp.setViewPlatformBehavior(orbit);     
    }

    Huh. A simple call to View.setMinimumFrameCycleTime() fixed the problem. How odd that there effectively is no default maximum framerate. Of course simple programs like these, rendered as many times as possible every second, are going to consume all possible CPU usage...

  • How to run the simple java card program in eclipse?

    I am trying to run a simple HelloWorld program in eclipse 3.5 having java card development kit 2.2 installed in it.
    Firstly,I go to the JCWDE tab and press start..then when trying to deploy that package its giving me error like " com.hw.HelloWorld: unsupported class file format of version 50.0." can any one help me in this what is this error???n how to resolve n run this program..

    Hi,
    It is because the converter works on byte code and it only supports a subset of the Java language (see the JC specifications). It is kind of like compiling you code on Java 6 and trying to run it on Java 5. The JCDK outlines the required compiler version.
    Cheers,
    Shane

  • Simple Module Pool Program

    Hello all,
    can any one give one simple program for                Insert Update Delete
    i have taken 9 fields and in a simple screen.
    and have 3 button. through this i want to Insert Update and Delete Data in customize table.
    Thaks.
    Rajesh.

    * MODULE POOL                                                          *
    PROGRAM  YP_BOOKMASTER_MAINTENANCE  MESSAGE-ID ZZ.
    *                       TABLES                                         *
    TABLES ZBKMA.                                         "book master table
    *                      VARIABLES                                       *
    DATA : V_NUMBER(5) TYPE N,            "variable to store random number
           V_LINE TYPE I,                 "variable to get total no of lines
           V_FLAG LIKE SY-TABIX.          "variable for checking
    *                     INTERNAL TABLE                                   *
    * internal table to store book numbers (i.e random numbers)
    DATA : BEGIN OF IT_RANDOMNUMBERS OCCURS 0,
           BKNUM LIKE ZBKMA-BKNUM,                   "book number
           END OF IT_RANDOMNUMBERS.
    * internal table to store only numeric part of book number
    * eg : if book no is HUM00100 ,this table will only store 00100
    DATA : BEGIN OF IT_NUMBERS OCCURS 0,
           NUMBER(5) TYPE N,                          " a number
           END OF IT_NUMBERS.
    *internal table to store book details
    DATA : BEGIN OF IT_BOOKMASTER OCCURS 0,
           BKNUM LIKE ZBKMA-BKNUM,            "BOOK NUMBER
           BKNAM LIKE ZBKMA-BKNAM,            "BOOK NAME
           AUTHR LIKE ZBKMA-AUTHR,            "AUTHOR
           SRCHT LIKE ZBKMA-SRCHT,            "SEARCH TERM
           PUBSH LIKE ZBKMA-PUBSH,            "PUBLISHER
           YRPUB LIKE ZBKMA-YRPUB,            "YEAR OF PUBLISHING
           VERNO LIKE ZBKMA-VERNO,            "VERSION NUMBER
           DATPR LIKE ZBKMA-DATPR,            "DATE OF PURCHASE
           BKCOD LIKE ZBKMA-BKCOD,            "BOOKCODE
           END OF IT_BOOKMASTER .
    *& Module  STATUS_0090  OUTPUT
    *  PBO OF SCREEN 090(screen contains three buttons ADD , DELETE , MODIFY)
    MODULE STATUS_0090 OUTPUT.
      SET PF-STATUS 'BOOKMASTER_FIRST'.
      SET TITLEBAR 'BOOKMASTER'.
    ENDMODULE.                 " STATUS_0090  OUTPUT
    *&      Module  USER_COMMAND_0090  INPUT
    *      PAI OF SCREEN 90
    MODULE USER_COMMAND_0090 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN '0'.            "go back
        WHEN 'EXIT'.
          LEAVE PROGRAM.                  "exit the program
        WHEN 'CANCEL'.
          leave to screen '0'.             "cancel the screen
        WHEN 'ADD'.
          CLEAR IT_BOOKMASTER.             "clears the contents of the fields.
          CALL SCREEN '0100'.
        WHEN 'DELETE'.
          CLEAR IT_BOOKMASTER.             "clears the contents of the fields.
          CALL SCREEN '0200'.
        WHEN 'MODIFY'.
          CLEAR IT_BOOKMASTER.             "clears the contents of the fields.
          CALL SCREEN '0300'.
      ENDCASE.        "end sy-ucomm
    ENDMODULE.                 " USER_COMMAND_0090  INPUT
    *&      Module  STATUS_0100  OUTPUT
    *       PBO OF 100 ( ADD THE BOOKS )
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'BOOKMASTER'.
      SET TITLEBAR 'UPDATE BOOKMASTER'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *         PAI OF 100 ( ADD THE BOOKS )
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.            "check the screen 100 actions
        WHEN 'BACK'.
          LEAVE TO SCREEN '0'.      "go back
        WHEN 'EXIT'.
          LEAVE PROGRAM.            "exit the program
        WHEN 'CANCEL'.
          LEAVE to screen '0' .      "cancel the screen 100
        WHEN 'ADD'.
    *      add the books to the master records
          PERFORM FORM_ADDBOOK.      " add the
        WHEN 'RESET'.
          CLEAR IT_BOOKMASTER.        "reset the screen
          SET SCREEN '0100'.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  FORM_ADDBOOK
    *       ADDING THE BOOKS
    FORM FORM_ADDBOOK .
    *TO ASSIGN BOOK NUMBER
      PERFORM FORM_ASSIGN_BOOKNO.
    * INSERTING THE BOOKS
      ZBKMA-BKNAM = IT_BOOKMASTER-BKNAM.
      ZBKMA-AUTHR = IT_BOOKMASTER-AUTHR.
      ZBKMA-SRCHT = IT_BOOKMASTER-SRCHT.
      ZBKMA-PUBSH = IT_BOOKMASTER-PUBSH.
      ZBKMA-YRPUB = IT_BOOKMASTER-YRPUB.
      ZBKMA-VERNO = IT_BOOKMASTER-VERNO.
      ZBKMA-DATPR = IT_BOOKMASTER-DATPR.
      ZBKMA-BKCOD = IT_BOOKMASTER-BKCOD.
    IF NOT IT_BOOKMASTER-BKNAM IS INITIAL.  "if the book number is not initial
      INSERT ZBKMA.
    ENDIF.   "endif check initial
      IF SY-SUBRC = 0.
        MESSAGE S003(ZCHA) WITH IT_BOOKMASTER-BKNUM.
      ENDIF.    "endif success
    ENDFORM.                    " FORM_ADDBOOK
    *&      Form  FORM_DELETEBOOK
    *       delete books from the master data
    *  -->  p1        text
    *  <--  p2        text
    FORM FORM_DELETEBOOK .
    * check the it is initial
      IF NOT IT_BOOKMASTER-BKNUM IS INITIAL.
    *get the book numbers present already
        SELECT SINGLE BKNUM
               FROM ZBKMA
               INTO ZBKMA-BKNUM
               WHERE BKNUM = IT_BOOKMASTER-BKNUM.
    *check if select is successful
        IF SY-SUBRC = 0.
          DELETE FROM ZBKMA WHERE BKNUM = IT_BOOKMASTER-BKNUM.
          MESSAGE S004(ZCHA) WITH IT_BOOKMASTER-BKNUM.      "if book deleted
        ELSE.
          MESSAGE S005(ZCHA) WITH IT_BOOKMASTER-BKNUM.      "if book not found
        ENDIF.
      ENDIF.
    ENDFORM.                    " FORM_DELETEBOOK
    *&      Form  FORM_MODIFYBOOK
    *       MODIFING THE BOOK
    FORM FORM_MODIFYBOOK.
    *validiate the book number
      SELECT SINGLE BKNUM
                FROM ZBKMA
                INTO ZBKMA-BKNUM
                WHERE BKNUM = IT_BOOKMASTER-BKNUM.
    *check for the success
      IF SY-SUBRC NE 0.
        MESSAGE S005(ZCHA) WITH IT_BOOKMASTER-BKNUM.
      ENDIF.
      ZBKMA-BKNUM = IT_BOOKMASTER-BKNUM.
      ZBKMA-BKNAM = IT_BOOKMASTER-BKNAM.
      ZBKMA-AUTHR = IT_BOOKMASTER-AUTHR.
      ZBKMA-SRCHT = IT_BOOKMASTER-SRCHT.
      ZBKMA-PUBSH = IT_BOOKMASTER-PUBSH.
      ZBKMA-YRPUB = IT_BOOKMASTER-YRPUB.
      ZBKMA-VERNO = IT_BOOKMASTER-VERNO.
      ZBKMA-DATPR = IT_BOOKMASTER-DATPR.
      UPDATE ZBKMA.      "update the book master table
      IF SY-SUBRC = 0.
        MESSAGE S006(ZCHA) WITH IT_BOOKMASTER-BKNUM.
      ENDIF.
    ENDFORM.                    " FORM_MODIFYBOOK
    *&      Form  FORM_ASSIGN_BOOKNO
    *       TEXT
    FORM FORM_ASSIGN_BOOKNO .
    *select the books already there from bookmaster
      SELECT BKNUM
             FROM ZBKMA
             INTO TABLE IT_RANDOMNUMBERS
             WHERE BKCOD = IT_BOOKMASTER-BKCOD.
    *if the book is first book i.e. first entry
      IF IT_RANDOMNUMBERS[] IS INITIAL.
        V_NUMBER = 1.                          "start with 1
        CONCATENATE IT_BOOKMASTER-BKCOD  V_NUMBER INTO IT_BOOKMASTER-BKNUM.
        ZBKMA-BKNUM = IT_BOOKMASTER-BKNUM.      "assign booknumber
        EXIT.
      ENDIF.        "check for initial
      CLEAR IT_NUMBERS[].        "clear the temporary table
      CLEAR IT_NUMBERS.
    * check for the book numbers if there is no book start from first in other
    * cases look for first gap and assign that number
      LOOP AT IT_RANDOMNUMBERS.
        IT_NUMBERS-NUMBER   = IT_RANDOMNUMBERS-BKNUM+3(5). "get the last 5 digits
                                                            "and store it in it_number
        APPEND IT_NUMBERS.
      ENDLOOP.
      SORT IT_NUMBERS BY NUMBER.          "sort
      DESCRIBE TABLE IT_NUMBERS LINES V_LINE.    "get no. of lines in table
    *check for book number gap
      LOOP AT IT_NUMBERS.
        V_FLAG = SY-TABIX.
    * if the book number is not equal to the index of table i.e. some gap in book number
    * or only one record
        IF IT_NUMBERS-NUMBER NE SY-TABIX OR V_LINE = 1.
           V_NUMBER = SY-TABIX.          "fill the gap
            if v_line = 1.                "if only one record
                  v_number = v_line + 1.   "increment the book number
            endif.          "only one record check
              CONCATENATE IT_BOOKMASTER-BKCOD  V_NUMBER INTO IT_BOOKMASTER-BKNUM.
              ZBKMA-BKNUM = IT_BOOKMASTER-BKNUM.      "assign
              EXIT.
       ENDIF.      "check for gap
    *if no gap in book number assign next number
                  IF V_FLAG = V_LINE.
                         V_NUMBER = IT_NUMBERS-NUMBER + 1.
                         CONCATENATE IT_BOOKMASTER-BKCOD  V_NUMBER INTO IT_BOOKMASTER-BKNUM.
                        ZBKMA-BKNUM = IT_BOOKMASTER-BKNUM.
                        EXIT.
                  ENDIF.      "book number increment
      ENDLOOP.        "check number gap
    ENDFORM.                    " FORM_ASSIGN_BOOKNO
    *&      Module  STATUS_0200  OUTPUT
    *       PBO OF SCREEN 200 ( DELETE BOOKS)
    MODULE STATUS_0200 OUTPUT.
      SET PF-STATUS 'DELETE'.
      SET TITLEBAR 'DELETE'.
    ENDMODULE.                 " STATUS_0200  OUTPUT
    *&      Module  USER_COMMAND_0200  INPUT
    *       PAI OF SCREEN 200 (DELETE BOOKS)
    MODULE USER_COMMAND_0200 INPUT.
      CASE SY-UCOMM.        "check for screen 200 actions
        WHEN 'BACK'.
          LEAVE TO SCREEN '0'.        "go back
        WHEN 'EXIT'.
          LEAVE PROGRAM.              "leave program
        WHEN 'CANCEL'.
          LEAVE to screen '0'.        "cancel screen
        WHEN 'DELETE'.
    * delete the book from master data
          PERFORM FORM_DELETEBOOK.
        WHEN 'RESET'.                  "reset the screen
          CLEAR IT_BOOKMASTER.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0200  INPUT
    *&      Module  STATUS_0300  OUTPUT
    *       PBO OF SCREEN 300 ( FOR MODIFYING )
    MODULE STATUS_0300 OUTPUT.
      SET PF-STATUS 'MODIFY'.
      SET TITLEBAR 'MODIFY'.
    ENDMODULE.                 " STATUS_0300  OUTPUT
    *&      Module  USER_COMMAND_0300  INPUT
    *       text
    MODULE USER_COMMAND_0300 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN '0'.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
        WHEN 'CANCEL'.
          LEAVE TO SCREEN '0'.
        WHEN 'MODIFY'.
          PERFORM FORM_MODIFYBOOK.        "update the record
        WHEN 'RESET'.
          CLEAR IT_BOOKMASTER.            "screen reset
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0300  INPUT
    *&      Module  MODULE_CANCEL  INPUT
    *       ACTIONS AT EXIT COMMAND
    MODULE MODULE_CANCEL INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE TO SCREEN '0'.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
        WHEN 'CANCEL'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " MODULE_CANCEL  INPUT
    Message was edited by: Chandrasekhar Jagarlamudi

  • Are there any simple LabVIEW motion program for Newport MM4006 controller

    My system consists of a PC with a IEEE488.2 from NI that connects to 2 Newport MM4006 controllers, which, in turn control a high-precision stage.
    I would like to know if you can provide me with any simple motion programs in LabVIEW. Since I am starting to learn motion programming, I would like to know if there are any existing LabVIEW VIs that allow easy inputting of the motion commands.
    I am having some trouble in ordering each motion segment's commands in LabVIEW environment, so I guess some examples might help me to clarify the correct syntax and logic in LabVIEW. Right now, I am using mostly the SendCommand sub VI in the MM4006 package downloaded from National Instruments to issue the seque
    nce of the commands that are supposed to be executed one after the other in order to perform a specific path. Do you know if there exists any other bette way of issuing a long sequence of the motion
    commands?
    Alos, can FlexMotion be used for my system? What are the requirement for usign FlexMotion in LabVIEW. Is it the best way to program a motion VI for my system?

    The FlexMotion VIs can only be used with our FlexMotion controllers, not GPIB devices. For your Newport controllers, the best thing to use is the instrument driver that you downloaded off of our website. This code was contributed to our website so we don't have any example programs to go with it. I looked on Newport's website and they mentioned that they had sample code for this controller. You might want to contact them and see what they have.
    Jack Arnold
    Application Engineer
    National Instruments

  • Is there a simple example (desktop programming C++) for Bluetooth Low Energy devices?

    Hello
    i am trying to code a simple desktop application (C++ in console) to connect to a custom Bluetooth low energy service. But before i go to that, i need to code a simple application to even get the GATT properties of a BLE device.
    Is there any code sample that i can use? I am having a hard time going through the examples that are given with the GATT**** functions. 
    And the code samples in WDK seem to be of drivers and for metro apps. None for a desktop application.
    thanks a ton!

    So i was able to code a program for reading (read) variables and setting notifications for (notifiable) variables from an HR BLE monitor.
    Pasting it here so that it may help someone looking for an example. (may have minor bugs, but seems to work with an MIO ALPHA HR monitor). Project properties may have to be set to stdcall (Project properties->c/c++->advanced->calling convention)
    //How to get notification values from a HR BLE monitor
    //Ensure that you have paired the HR BLE monitor with the computer
    #include <stdio.h>
    #include <windows.h>
    #include <setupapi.h>
    #include <devguid.h>
    #include <regstr.h>
    #include <bthdef.h>
    #include <Bluetoothleapis.h>
    #pragma comment(lib, "SetupAPI")
    #pragma comment(lib, "BluetoothApis.lib")
    #define TO_SEARCH_DEVICE_UUID "{0000180D-0000-1000-8000-00805F9B34FB}" //we use UUID for an HR BLE device
    //this is the notification function
    //the way ValueChangedEventParameters is utilized is shown in
    //HealthHeartRateService::HeartRateMeasurementEvent()
    //a function in Windows Driver Kit (WDK) 8.0 Samples.zip\C++\WDK 8.0 Samples\Bluetooth Low Energy (LE) Generic Attribute (GATT) Profile Drivers\Solution\WpdHealthHeartRate\HealthHeartRateService.cpp
    void SomethingHappened( BTH_LE_GATT_EVENT_TYPE EventType, PVOID EventOutParameter, PVOID Context)
    printf("notification obtained ");
    PBLUETOOTH_GATT_VALUE_CHANGED_EVENT ValueChangedEventParameters = (PBLUETOOTH_GATT_VALUE_CHANGED_EVENT)EventOutParameter;
    HRESULT hr;
    if (0 == ValueChangedEventParameters->CharacteristicValue->DataSize) {
    hr = E_FAIL;
    printf("datasize 0\n");
    } else {
    printf("HR ");
    //for(int i=0; i<ValueChangedEventParameters->CharacteristicValue->DataSize;i++) {
    // printf("%0x",ValueChangedEventParameters->CharacteristicValue->Data[i]);
    // if the first bit is set, then the value is the next 2 bytes. If it is clear, the value is in the next byte
    //The Heart Rate Value Format bit (bit 0 of the Flags field) indicates if the data format of
    //the Heart Rate Measurement Value field is in a format of UINT8 or UINT16.
    //When the Heart Rate Value format is sent in a UINT8 format, the Heart Rate Value
    //Format bit shall be set to 0. When the Heart Rate Value format is sent in a UINT16
    //format, the Heart Rate Value Format bit shall be set to 1
    //from this PDF https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=239866
    unsigned heart_rate;
    if (0x01 == (ValueChangedEventParameters->CharacteristicValue->Data[0] & 0x01)) {
    heart_rate = ValueChangedEventParameters->CharacteristicValue->Data[1]*256 + ValueChangedEventParameters->CharacteristicValue->Data[2];
    } else {
    heart_rate = ValueChangedEventParameters->CharacteristicValue->Data[1];
    printf("%d\n", heart_rate);
    //this function works to get a handle for a BLE device based on its GUID
    //copied from http://social.msdn.microsoft.com/Forums/windowshardware/en-US/e5e1058d-5a64-4e60-b8e2-0ce327c13058/erroraccessdenied-error-when-trying-to-receive-data-from-bluetooth-low-energy-devices?forum=wdk
    //credits to Andrey_sh
    HANDLE GetBLEHandle(__in GUID AGuid)
    HDEVINFO hDI;
    SP_DEVICE_INTERFACE_DATA did;
    SP_DEVINFO_DATA dd;
    GUID BluetoothInterfaceGUID = AGuid;
    HANDLE hComm = NULL;
    hDI = SetupDiGetClassDevs(&BluetoothInterfaceGUID, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
    if( hDI == INVALID_HANDLE_VALUE ) return NULL;
    did.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
    dd.cbSize = sizeof(SP_DEVINFO_DATA);
    for(DWORD i = 0; SetupDiEnumDeviceInterfaces(hDI, NULL, &BluetoothInterfaceGUID, i, &did); i++)
    SP_DEVICE_INTERFACE_DETAIL_DATA DeviceInterfaceDetailData;
    DeviceInterfaceDetailData.cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
    DWORD size = 0;
    if(!SetupDiGetDeviceInterfaceDetail(hDI, &did, NULL, 0, &size, 0) )
    int err = GetLastError();
    if( err == ERROR_NO_MORE_ITEMS ) break;
    PSP_DEVICE_INTERFACE_DETAIL_DATA pInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)GlobalAlloc(GPTR , size);
    pInterfaceDetailData->cbSize = sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA);
    if( !SetupDiGetDeviceInterfaceDetail(hDI, &did, pInterfaceDetailData, size, &size, &dd) )
    break;
    hComm = CreateFile(
    pInterfaceDetailData->DevicePath,
    GENERIC_WRITE | GENERIC_READ,
    FILE_SHARE_READ | FILE_SHARE_WRITE,
    NULL,
    OPEN_EXISTING,
    0,
    NULL);
    GlobalFree(pInterfaceDetailData);
    SetupDiDestroyDeviceInfoList(hDI);
    return hComm;
    int main( int argc, char *argv[ ], char *envp[ ] )
    //Step 1: find the BLE device handle from its GUID
    GUID AGuid;
    //GUID can be constructed from "{xxx....}" string using CLSID
    CLSIDFromString(TEXT(TO_SEARCH_DEVICE_UUID), &AGuid);
    //now get the handle
    HANDLE hLEDevice = GetBLEHandle(AGuid);
    //Step 2: Get a list of services that the device advertises
    // first send 0,NULL as the parameters to BluetoothGATTServices inorder to get the number of
    // services in serviceBufferCount
    USHORT serviceBufferCount;
    // Determine Services Buffer Size
    HRESULT hr = BluetoothGATTGetServices(
    hLEDevice,
    0,
    NULL,
    &serviceBufferCount,
    BLUETOOTH_GATT_FLAG_NONE);
    if (HRESULT_FROM_WIN32(ERROR_MORE_DATA) != hr) {
    printf("BluetoothGATTGetServices - Buffer Size %d", hr);
    PBTH_LE_GATT_SERVICE pServiceBuffer = (PBTH_LE_GATT_SERVICE)
    malloc(sizeof(BTH_LE_GATT_SERVICE) * serviceBufferCount);
    if (NULL == pServiceBuffer) {
    printf("pServiceBuffer out of memory\r\n");
    } else {
    RtlZeroMemory(pServiceBuffer,
    sizeof(BTH_LE_GATT_SERVICE) * serviceBufferCount);
    // Retrieve Services
    USHORT numServices;
    hr = BluetoothGATTGetServices(
    hLEDevice,
    serviceBufferCount,
    pServiceBuffer,
    &numServices,
    BLUETOOTH_GATT_FLAG_NONE);
    if (S_OK != hr) {
    printf("BluetoothGATTGetServices - Buffer Size %d", hr);
    //Step 3: now get the list of charactersitics. note how the pServiceBuffer is required from step 2
    // Determine Characteristic Buffer Size
    USHORT charBufferSize;
    hr = BluetoothGATTGetCharacteristics(
    hLEDevice,
    pServiceBuffer,
    0,
    NULL,
    &charBufferSize,
    BLUETOOTH_GATT_FLAG_NONE);
    if (HRESULT_FROM_WIN32(ERROR_MORE_DATA) != hr) {
    printf("BluetoothGATTGetCharacteristics - Buffer Size %d", hr);
    PBTH_LE_GATT_CHARACTERISTIC pCharBuffer;
    if (charBufferSize > 0) {
    pCharBuffer = (PBTH_LE_GATT_CHARACTERISTIC)
    malloc(charBufferSize * sizeof(BTH_LE_GATT_CHARACTERISTIC));
    if (NULL == pCharBuffer) {
    printf("pCharBuffer out of memory\r\n");
    } else {
    RtlZeroMemory(pCharBuffer,
    charBufferSize * sizeof(BTH_LE_GATT_CHARACTERISTIC));
    // Retrieve Characteristics
    USHORT numChars;
    hr = BluetoothGATTGetCharacteristics(
    hLEDevice,
    pServiceBuffer,
    charBufferSize,
    pCharBuffer,
    &numChars,
    BLUETOOTH_GATT_FLAG_NONE);
    if (S_OK != hr) {
    printf("BluetoothGATTGetCharacteristics - Actual Data %d", hr);
    if (numChars != charBufferSize) {
    printf("buffer size and buffer size actual size mismatch\r\n");
    //Step 4: now get the list of descriptors. note how the pCharBuffer is required from step 3
    //descriptors are required as we descriptors that are notification based will have to be written
    //once IsSubcribeToNotification set to true, we set the appropriate callback function
    //need for setting descriptors for notification according to
    //http://social.msdn.microsoft.com/Forums/en-US/11d3a7ce-182b-4190-bf9d-64fefc3328d9/windows-bluetooth-le-apis-event-callbacks?forum=wdk
    PBTH_LE_GATT_CHARACTERISTIC currGattChar;
    for (int ii=0; ii <charBufferSize; ii++) {
    currGattChar = &pCharBuffer[ii];
    USHORT charValueDataSize;
    PBTH_LE_GATT_CHARACTERISTIC_VALUE pCharValueBuffer;
    // Determine Descriptor Buffer Size
    USHORT descriptorBufferSize;
    hr = BluetoothGATTGetDescriptors(
    hLEDevice,
    currGattChar,
    0,
    NULL,
    &descriptorBufferSize,
    BLUETOOTH_GATT_FLAG_NONE);
    if (HRESULT_FROM_WIN32(ERROR_MORE_DATA) != hr) {
    printf("BluetoothGATTGetDescriptors - Buffer Size %d", hr);
    PBTH_LE_GATT_DESCRIPTOR pDescriptorBuffer;
    if (descriptorBufferSize > 0) {
    pDescriptorBuffer = (PBTH_LE_GATT_DESCRIPTOR)
    malloc(descriptorBufferSize
    * sizeof(BTH_LE_GATT_DESCRIPTOR));
    if (NULL == pDescriptorBuffer) {
    printf("pDescriptorBuffer out of memory\r\n");
    } else {
    RtlZeroMemory(pDescriptorBuffer, descriptorBufferSize);
    // Retrieve Descriptors
    USHORT numDescriptors;
    hr = BluetoothGATTGetDescriptors(
    hLEDevice,
    currGattChar,
    descriptorBufferSize,
    pDescriptorBuffer,
    &numDescriptors,
    BLUETOOTH_GATT_FLAG_NONE);
    if (S_OK != hr) {
    printf("BluetoothGATTGetDescriptors - Actual Data %d", hr);
    if (numDescriptors != descriptorBufferSize) {
    printf("buffer size and buffer size actual size mismatch\r\n");
    for(int kk=0; kk<numDescriptors; kk++) {
    PBTH_LE_GATT_DESCRIPTOR currGattDescriptor = &pDescriptorBuffer[kk];
    // Determine Descriptor Value Buffer Size
    USHORT descValueDataSize;
    hr = BluetoothGATTGetDescriptorValue(
    hLEDevice,
    currGattDescriptor,
    0,
    NULL,
    &descValueDataSize,
    BLUETOOTH_GATT_FLAG_NONE);
    if (HRESULT_FROM_WIN32(ERROR_MORE_DATA) != hr) {
    printf("BluetoothGATTGetDescriptorValue - Buffer Size %d", hr);
    PBTH_LE_GATT_DESCRIPTOR_VALUE pDescValueBuffer = (PBTH_LE_GATT_DESCRIPTOR_VALUE)malloc(descValueDataSize);
    if (NULL == pDescValueBuffer) {
    printf("pDescValueBuffer out of memory\r\n");
    } else {
    RtlZeroMemory(pDescValueBuffer, descValueDataSize);
    // Retrieve the Descriptor Value
    hr = BluetoothGATTGetDescriptorValue(
    hLEDevice,
    currGattDescriptor,
    (ULONG)descValueDataSize,
    pDescValueBuffer,
    NULL,
    BLUETOOTH_GATT_FLAG_NONE);
    if (S_OK != hr) {
    printf("BluetoothGATTGetDescriptorValue - Actual Data %d", hr);
    //you may also get a descriptor that is read (and not notify) andi am guessing the attribute handle is out of limits
    // we set all descriptors that are notifiable to notify us via IsSubstcibeToNotification
    if(currGattDescriptor->AttributeHandle < 255) {
    BTH_LE_GATT_DESCRIPTOR_VALUE newValue;
    RtlZeroMemory(&newValue, sizeof(newValue));
    newValue.DescriptorType = ClientCharacteristicConfiguration;
    newValue.ClientCharacteristicConfiguration.IsSubscribeToNotification = TRUE;
    hr = BluetoothGATTSetDescriptorValue(
    hLEDevice,
    currGattDescriptor,
    &newValue,
    BLUETOOTH_GATT_FLAG_NONE);
    if (S_OK != hr) {
    printf("BluetoothGATTGetDescriptorValue - Actual Data %d", hr);
    } else {
    printf("setting notification for serivice handle %d\n", currGattDescriptor->ServiceHandle);
    //set the appropriate callback function when the descriptor change value
    BLUETOOTH_GATT_EVENT_HANDLE EventHandle;
    if (currGattChar->IsNotifiable) {
    printf("Setting Notification for ServiceHandle %d\n",currGattChar->ServiceHandle);
    BTH_LE_GATT_EVENT_TYPE EventType = CharacteristicValueChangedEvent;
    BLUETOOTH_GATT_VALUE_CHANGED_EVENT_REGISTRATION EventParameterIn;
    EventParameterIn.Characteristics[0] = *currGattChar;
    EventParameterIn.NumCharacteristics = 1;
    hr = BluetoothGATTRegisterEvent(
    hLEDevice,
    EventType,
    &EventParameterIn,
    SomethingHappened,
    NULL,
    &EventHandle,
    BLUETOOTH_GATT_FLAG_NONE);
    if (S_OK != hr) {
    printf("BluetoothGATTRegisterEvent - Actual Data %d", hr);
    if (currGattChar->IsReadable) {//currGattChar->IsReadable
    // Determine Characteristic Value Buffer Size
    hr = BluetoothGATTGetCharacteristicValue(
    hLEDevice,
    currGattChar,
    0,
    NULL,
    &charValueDataSize,
    BLUETOOTH_GATT_FLAG_NONE);
    if (HRESULT_FROM_WIN32(ERROR_MORE_DATA) != hr) {
    printf("BluetoothGATTGetCharacteristicValue - Buffer Size %d", hr);
    pCharValueBuffer = (PBTH_LE_GATT_CHARACTERISTIC_VALUE)malloc(charValueDataSize);
    if (NULL == pCharValueBuffer) {
    printf("pCharValueBuffer out of memory\r\n");
    } else {
    RtlZeroMemory(pCharValueBuffer, charValueDataSize);
    // Retrieve the Characteristic Value
    hr = BluetoothGATTGetCharacteristicValue(
    hLEDevice,
    currGattChar,
    (ULONG)charValueDataSize,
    pCharValueBuffer,
    NULL,
    BLUETOOTH_GATT_FLAG_NONE);
    if (S_OK != hr) {
    printf("BluetoothGATTGetCharacteristicValue - Actual Data %d", hr);
    //print the characeteristic Value
    //for an HR monitor this might be the body sensor location
    printf("\n Printing a read (not notifiable) characterstic (maybe) body sensor value");
    for(int iii=0; iii< pCharValueBuffer->DataSize; iii++) {// ideally check ->DataSize before printing
    printf("%d",pCharValueBuffer->Data[iii]);
    printf("\n");
    // Free before going to next iteration, or memory leak.
    free(pCharValueBuffer);
    pCharValueBuffer = NULL;
    //go into an inf loop that sleeps. you will ideally see notifications from the HR device
    while(1){
    Sleep(1000);
    //printf("look for notification");
    CloseHandle(hLEDevice);
    if ( GetLastError()!=NO_ERROR &&
    GetLastError()!=ERROR_NO_MORE_ITEMS )
    // Insert error handling here.
    return 1;
    return 0;
    I can't run this code. I use VS2010 and Windows 8.1. When I debug my project , it show error "cannot open file 'BluetoothAPis.h'" Can you help me?

Maybe you are looking for

  • User Profile Companies & departments filtering

    User Profile Store has different companies & departments. List of department shall be filtered based on the different Company selection. There is a company dropdown & department dropdown .

  • Accidental sync!! Help!!

    I just got an iPhone... as in, I got back from the Verizon store about 20 minutes ago. When I got home, I plugged my phone into my computer (a MacBook Pro), expecting to upload my iTunes library to my phone. Instead, iTunes treated my iPhone as my iP

  • OCR and Voting Disk partition

    Dear all I uninstall clusterware. And i want to install again that but when i made partition in windows 2003 then CVU fail the stage command. I did the following things.. 1) diskpart --->select Disk 1----> clean -->exit (both the nodes) 2) diskpart -

  • Oracle 10g Scheduled Backup

    Hai, I submitted a job using oracle 10g feature of scheduled backup feature in Windows environment. When I selected the option of disk the screen displays the message that the backup will be in Flash Recovery Area in Windows environment. Please let m

  • Does 'homeshare' only work with iTunes purchased music?

    I have some internet downloaded music and music from various other sources. I recently bought an iMac and turned on homeshareing to transfer my music from my old PC laptop to this new desktop. Only about 50 of my over 3,000 songs transfered. I'm thin