K8055

Hi,
I am using the vellaman usb card k8055 to genrate digital i/o.I managed to find out an VI from their website that can be used to run the card and it works fine.I would like to extend this to use it in 4 cards at the same time,since my application involves a lot of digital i/os.I tried using the same call function in one VI and it dosent work.Could anyone please give me any advice on how to implement this on one VI for 4 cards.
I have attached the VI which is runnign fine for one card.
Kindly to give your suggestions
Kind regards
Joseph
Attachments:
K8055.vi ‏27 KB

Hi Phil,
The cards do open fine,it dose show 0 when im trying to open card 0 and 1 when its 1.(ive connected 2 cards at ta moment). The application works fine for diffrent cards on a single VI,ie i can change the number of card and use it,but it dose not when i use two loops.Ive just attached a VI tat i was trying to do,with two sets of outs and in for the two cards seperatly.The LEDs on one card ( card 0) do come on and off while the program is running,on the other card ( card 1) the LEDs opeate only when the program starts or stops.Also i noted that the CPU is 100% when the VI runs.what do you think I am doing wrong here?
Regards
Joseph
Attachments:
sample.vi ‏30 KB

Similar Messages

  • K8055 Need help making boolean pulse at ms rate

    Hey
    I have board set up and connected. the board consists of 8 digital output 2 analoge 2 pwm outputs these outputs are switched that toogle on and of and have a led to display there state. i currentlly have it set up so i can turn the on and of with a boolean switch. what i want to do is pulse one of the boolen switches on and of at a ms rate prob about every 3ms how do i set up this on the current wiring i have. file attached
    Attachments:
    labview8_k8055.zip ‏191 KB

    I believe the sampling rate for the k8055 is around 100 Hz, so you'll struggle to get better than a 10ms rate.
    If you still want to proceed, a state machine with some timing added is a way forward. This will allow you to have different states for digital out, analog out etc so that you can perform the right actions in the right order in a sensible fashion. Ditching the stacked sequence in the Velleman demo code that you posted would be a good move!
    Ian

  • Calling a method from a callback function under ARC

    Hi All
    I previously wrote some HIDManager software. The HIDManager references were done in a Objective C class so within this object you have the code:
        IOHIDManagerRegisterDeviceMatchingCallback( k8055HIDManager, k8055BoardWasAdded, (__bridge void*)self );
    Which registers with the HIDManager
    The Callback function which is outside the class was as follows:
    static void k8055BoardWasAdded(void* inContext, IOReturn inResult, void* inSender, IOHIDDeviceRef k8055HIDDevice)
        IOHIDDeviceOpen(k8055HIDDevice, kIOHIDOptionsTypeNone);
        CCVellemanK8055Driver * k8055 = (__bridge CCVellemanK8055Driver *)inContext;
        [k8055 setHardwareConnectionStatus : YES];
    Any how my problem is in converting the code to ARC as under OS X 10.9 SDK and 64bit I'm now getting a EXC_BAD_ACCESS (Code=EXC_I386_GPFLT) at this line
        CCVellemanK8055Driver * k8055 = (__bridge CCVellemanK8055Driver *)inContext;
    although removing the method
    [k8055 setHardwareConnectionStatus : YES];
    will alow it to build but then obviously the app won't work as required.
    Could someone suggest a ARC safe way of accessing the passed instance so I can again call methods on it.
    Cheers
    Steve

    Try using blocks instead. This is the callback I am using for libcurl.
    static size_t callback(
      void * contents, size_t size, size_t nmemb, void * context)
      size_t (^block)(void *, size_t) =
        (__bridge size_t (^)(void *, size_t))context;
      size_t result = block(contents, size * nmemb);
      return result;

  • Is this good or bad programmin​g?

    Hi,
    Just trying to learn as I go along what is good programming in Labview and what is not. Any advice gratefully recieved.
    The subvi's just call a dll.
    Thanks
    Attachments:
    K8055 8 CH Digital Signal Control.vi ‏122 KB

    Hello therealkilkenny,
    some comments:
    1) In the inner case statements you always have a "Set Channel" and a "Clear Channel" in the true/false cases with the same channel number wired to it. Why not make a subvi that has two inputs: channel number and a boolean flag (Set/Clear). Then your main vi only uses one subvi and in this subvi you make the difference between "Set Channel" and "Clear Channel". Btw. most times the difference between a Set and a Clear operation is only the parameter of a given command. Why not join those two vi to one and send only the right command to your DAQ device? (Example: A device needs the command F0 to clear a channel and F1 to set a channel. Then I make a vi with a boolean input, wire this input to "format into string" with format strin "F%b" and send the resulting string. It's easy to program and to debug.)
    2) You compare controls with some hidden controls. It's much better to use some shift registers for this purpose. Then it is clear that you compare the actual value with the value from the last loop iteration. And it's easier to "read"...
    3) If you change the comparision to "non equal" (instead of "equal") you get an array of bits, where (normally) only one bit is set (except the user can change switches faster than you check them). Instead of searching for a bit in that array, like you do at the moment, you convert the array to a number ("boolean array to number", numbers/conversions palette). Now you can use cases with appropriate numbers, which are easy to calculate. Example: bit 0 is set -> case number 1, bit 2 is set -> case number 2 and so on (powers of two...)
    4) You included a delay of 1 ms. For a normal user interface a value of 100-200 ms is ok. How often can you click in a second? You can also use "Wait for Front Panel Activity" (time & dialog palette), perhaps with an appropriate timeout value.
    5) Have a look at "LabView Development Guidelines", it should have come with your Labview installation. (Chapter 6, "wiring")
    Hope this helps,
    GerdW
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Netbeans - refactoring from in a package to the default package

    Hello,
    I have a problem, I have some JNI code (two .dll's) and a wrapper that connects my java program to an external USB board.
    I didn't write the original code, that was done by Mike Peter and the dlls have been compiled so that I can call the JNI functions only in the default package. Whenever I try to put the code in a package of its own, the JNIs stop working. So my problem now is that I want to access this interface class from my code that is in a package.
    I don't know how to import the code as a library into my programs package so perhaps a solution might be to de-package my program code so that it can access Mike Peters code.
    Trouble is I have used the netbeans GUI editor that does not let me access all the code and I dont know how to refactor the package from being in one to not being in one.
    removing the package declartion from my code manually causes lots of errors.
    Any ideas?
    Mike Peters code downloadable here:
    http://www.re-applications.be/downloads/J-K8055-Wrapper.zip
    the usb_interface class has no constructor and is not in a package, how do I go about making it a library and importing it?
    I'd greatly appreciate it if anyone can help, if more details are needed I can try to provide them but I didn't think it was worth putting up all my code here as there is no real problem with it, just an access issue.

    What I really need to do is find a way to import a class from the default package.
    I was led to believe that classes in the default package should be readily accessible, however my compiler says otherwise when my code is in a package and the class I want to access can only be accessed when my code is not in a package. This is really frustrating because the GUI editor doesn't like it when the GUI is not in a package... so I either lose and my USB interface doesn't work or I lose and my GUI doesn't work.
    help!

  • Capacitor tester

    Hi everybody, 
    I'm new at labview and was hoping if someone could help with a basic question.
    I have to make a program that checks capacitors, the program uses a Velleman card VM110N or K8055.
    I try to give is short and simple:
    -Measure time.
    -send 5 volts (255) to the card (which has a resistor and a capacitor wired up to it)
    -measure the time it takes to get over 63% (this is 1 Tau)
    -charge another 5 tau until fully charged.
    the program also has to discharge, measure time etc again, calculate tau again, discharge another 5 tau, rinse and repeat, with the data you can calculate the capacity of capacitor and give approval or disapproval by a led lighting up and finally save it into an excel document.
    but for now I'd like it to just charge, measure time until 63%, then I'd have 1 Tau,  (and then charge 5XTau.)
    The rest I should be able to manage.
    even if you don't have that velleman card I hope you can give some comments what I did wrong, I set it up pretty basic, remember I'm just a beginner, only the stuff in the flat sequence is mine, the rest was set up already, I've been at this for ages (really, I'm too embarrassed to even say how long), I'm sure it's quite simple, but if someone could just give me a clue or two.
    Hope someone can help me, thanks so much in advance!
    (ps I posted this somewhere else too, but I thought this was a better location for my question even though this thread is very old)
    Solved!
    Go to Solution.
    Attachments:
    for forum.vi ‏27 KB

    Mark1357,
    It would be better to start a new thread since this one is marked solved. Many people do not pay much attention to old, solved threads. This is probably the best Board for your question.
    1. Please look at the online tutorials for Getting Started with LabVIEW.
    2. With a state machine architecture you would only need one loop and no local variables. Multiple loops are not a problem although the way you have used them limits the flexibility of your program. Local variables may lead to race conditions. The Con local might be written before or after the terminal is written inside the loop. In practice it will amost always be written first but this cannot be guaranteed by your code. Similarly the 1 Tau local in the seqeunce structure might be read before or after the terminal is written.  These race condtions can produce unexpected results.
    3. The Tick count in the first frame of the sequence structure executes in parallel with the CLFN (Output). No way to know which happens first.
    If the DLL takes less than a millisecond to execute, it does not matter. It would be better to put the Tick Count in a separate frame after the CLFN node.
    4. The one iteration loops could be eliminated by wiring the error clusters in and out. Learn how data flow works to your advantage.
    5. There is no need to write the Scope property nodes every millisecond. Learn to use the event structure so that you only write to the property nodes if the x-axis length changes.
    6. If the device is not connected the middle while loop still runs once and the inner loops will still wait for the user to press the end program (Stop) button. Better: Enclose the middle loop in the True case of a case structure.
    7. There is no need for the 1 ms Wait in the outer loop when the inner loop has a 20 ms wait.
    Lynn

  • Compiling a .dll in netbeans (Almost there)

    (I have the GNU g++ cygwin compile installed and selected to be used as C compiler in netbeans)
    I have got so far but falling at the last hurdle.
    I have modified a java wrapper so that I can put it in a package, I adjusted the code, compiled it, called javah on the source class using:
    javah packagename.classname
    which worked
    I've then re-written the wrapper.c file so that it includes this new header file classname.h
    I've re-written the methods so that they start with Java_packagename1_classname1_ (the way they appear in the header)
    I've created a new C/C++ project in netbeans (Selected dynamic linked library in options)
    I've added the exsisting classname.h files + Cdll.h file to the header files (both included in the wrapper.c)
    Now I should be set to compile my wrapper.c into a .dll file
    I press the build button and I get this:
    Running "C:\cygwin\bin\make.exe  -f Makefile CONF=Debug" in C:\Documents and Settings\test\DynamicLibrary_3
    /usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
    make[1]: Entering directory `/cygdrive/c/Documents and Settings/test/DynamicLibrary_3'
    mkdir -p build/Debug/Cygwin-Windows/_ext/C_/Documents_and_Settings/test/DynamicLibrary_3/../My_Documents/Java_Projects/USB_K8055/build/classes
    gcc.exe    -c -g -IC\:/Program\ Files/Java/jdk1.6.0_01/include -IC\:/Program\ Files/Java/jdk1.6.0_01/include/win32 -fPIC  -o build/Debug/Cygwin-Windows/_ext/C_/Documents_and_Settings/test/DynamicLibrary_3/../My_Documents/Java_Projects/USB_K8055/build/classes/J-k8055-wrapper.o ../My\ Documents/Java\ Projects/USB_K8055/build/classes/J-k8055-wrapper.c
    ../My Documents/Java Projects/USB_K8055/build/classes/J-k8055-wrapper.c:1: warning: -fPIC ignored for target (all code is position independent)
    ../My Documents/Java Projects/USB_K8055/build/classes/J-k8055-wrapper.c:18:41: USB_interface_usb_interface.h: No such file or directory
    ../My Documents/Java Projects/USB_K8055/build/classes/J-k8055-wrapper.c:19:22: K8055D_C.h: No such file or directory
    ../My Documents/Java Projects/USB_K8055/build/classes/J-k8055-wrapper.c: In function `Java_USB_1interface_usb_1interface_JReadAllAnalog':
    ../My Documents/Java Projects/USB_K8055/build/classes/J-k8055-wrapper.c:97: error: request for member `NewLongArray' in something not a structure or union
    ../My Documents/Java Projects/USB_K8055/build/classes/J-k8055-wrapper.c:98: error: request for member `GetLongArrayElements' in something not a structure or union
    ../My Documents/Java Projects/USB_K8055/build/classes/J-k8055-wrapper.c:117: error: request for member `ReleaseLongArrayElements' in something not a structure or union
    ../My Documents/Java Projects/USB_K8055/build/classes/J-k8055-wrapper.c: In function `Java_USB_1interface_usb_1interface_JReadDigitalChannel':
    ../My Documents/Java Projects/USB_K8055/build/classes/J-k8055-wrapper.c:210: error: `false' undeclared (first use in this function)
    ../My Documents/Java Projects/USB_K8055/build/classes/J-k8055-wrapper.c:210: error: (Each undeclared identifier is reported only once
    ../My Documents/Java Projects/USB_K8055/build/classes/J-k8055-wrapper.c:210: error: for each function it appears in.)
    ../My Documents/Java Projects/USB_K8055/build/classes/J-k8055-wrapper.c: In function `Java_USB_1interface_usb_1interface_JSetCurrentDevice':
    ../My Documents/Java Projects/USB_K8055/build/classes/J-k8055-wrapper.c:319: error: parameter name omitted
    ../My Documents/Java Projects/USB_K8055/build/classes/J-k8055-wrapper.c:319: error: parameter name omitted
    make[1]: *** [build/Debug/Cygwin-Windows/_ext/C_/Documents_and_Settings/test/DynamicLibrary_3/../My_Documents/Java_Projects/USB_K8055/build/classes/J-k8055-wrapper.o] Error 1
    make[1]: Leaving directory `/cygdrive/c/Documents and Settings/test/DynamicLibrary_3'
    make: *** [.build-impl] Error 2
    Build failed. Exit value 2.Any ideas ?
    Thanks.

    Ok I'm still stuck here is my test code as simple as I can make it:
    Main.java
    package dlltestapp;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    public class Main {
        static {
             System.loadLibrary( "J-K8055-wrapper" );
        public static void main(String[] args) {
            USB_interface_K8055.JOpenDevice(0);
            USB_interface_K8055.JSetAllDigital();
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            USB_interface_K8055.JClearAllDigital();
            USB_interface_K8055.JCloseDevice();
    }USB_interface_K8055.java
    package dlltestapp;
    public class USB_interface_K8055 {
    public static native long JOpenDevice(long i);
    public static native void JCloseDevice();
    public static native void JSetAllDigital();
    public static native void JClearAllDigital();
    }dlltestapp_USB_interface_K8055.h
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class dlltestapp_USB_interface_K8055 */
    #ifndef _Included_dlltestapp_USB_interface_K8055
    #define _Included_dlltestapp_USB_interface_K8055
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class:     dlltestapp_USB_interface_K8055
    * Method:    JOpenDevice
    * Signature: (J)J
    JNIEXPORT jlong JNICALL Java_dlltestapp_USB_1interface_1K8055_JOpenDevice
      (JNIEnv *, jclass, jlong);
    * Class:     dlltestapp_USB_interface_K8055
    * Method:    JCloseDevice
    * Signature: ()V
    JNIEXPORT void JNICALL Java_dlltestapp_USB_1interface_1K8055_JCloseDevice
      (JNIEnv *, jclass);
    * Class:     dlltestapp_USB_interface_K8055
    * Method:    JSetAllDigital
    * Signature: ()V
    JNIEXPORT void JNICALL Java_dlltestapp_USB_1interface_1K8055_JSetAllDigital
      (JNIEnv *, jclass);
    * Class:     dlltestapp_USB_interface_K8055
    * Method:    JClearAllDigital
    * Signature: ()V
    JNIEXPORT void JNICALL Java_dlltestapp_USB_1interface_1K8055_JClearAllDigital
      (JNIEnv *, jclass);
    #ifdef __cplusplus
    #endif
    #endifK8055D_C.h
    ** Microsoft Visual C++ 2005 Project for the K8055 USB I/O Card **
    **                    Copyright Velleman 2006                   **
    **                        www.Velleman.be                       **
    **                         Developed by                         **
    **                       RE-Applications                        **
    **                   www.RE-Applications.be                     **
    #ifdef __cplusplus
    extern "C" {
    #endif
    #define FUNCTION __declspec(dllexport)
    FUNCTION long __stdcall OpenDevice(long CardAddress);
    VOID __stdcall CloseDevice();
    FUNCTION long __stdcall ReadAnalogChannel(long Channel);
    VOID __stdcall ReadAllAnalog(long *Data1, long *Data2);
    VOID __stdcall OutputAnalogChannel(long Channel, long Data);
    VOID __stdcall OutputAllAnalog(long Data1, long Data2);
    VOID __stdcall ClearAnalogChannel(long Channel);
    VOID __stdcall ClearAllAnalog();
    VOID __stdcall SetAnalogChannel(long Channel);
    VOID __stdcall SetAllAnalog();
    VOID __stdcall WriteAllDigital(long Data);
    VOID __stdcall ClearDigitalChannel(long Channel);
    VOID __stdcall ClearAllDigital();
    VOID __stdcall SetDigitalChannel(long Channel);
    VOID __stdcall SetAllDigital();
    FUNCTION bool __stdcall ReadDigitalChannel(long Channel);
    FUNCTION long __stdcall ReadAllDigital();
    FUNCTION long __stdcall ReadCounter(long CounterNr);
    VOID __stdcall ResetCounter(long CounterNr);
    VOID __stdcall SetCounterDebounceTime(long CounterNr, long DebounceTime);
    VOID __stdcall Version();
    FUNCTION long __stdcall SearchDevices();
    FUNCTION long __stdcall SetCurrentDevice(long lngCardAddress);
    #ifdef __cplusplus
    #endifJwrapperZC.cpp (To be compiled to J-K8055-wrapper.dll)
    #include <stdio.h>
    #include <windows.h>
    #include <jni.h>
    #include <dlltestapp_USB_interface_K8055.h>
    #include <K8055D_C.h>
    JNIEXPORT jlong JNICALL Java_dlltestapp_USB_1interface_1K8055_JOpenDevice
      (JNIEnv *env, jclass in_cls, jlong CardAddress)
       long retCode = -1 ;
       retCode = OpenDevice(CardAddress);
       return retCode;
    JNIEXPORT void JNICALL Java_dlltestapp_USB_1interface_1K8055_JCloseDevice
      (JNIEnv *env, jclass in_cls)
         CloseDevice();
         return ;
    JNIEXPORT void JNICALL Java_dlltestapp_USB_1interface_1K8055_JSetAllDigital
      (JNIEnv *env, jclass in_cls)
         SetAllDigital();
         return ;
    JNIEXPORT void JNICALL Java_dlltestapp_USB_1interface_1K8055_JClearAllDigital
      (JNIEnv *env, jclass in_cls)
         ClearAllDigital();
         return ;
    }Attempting to compile the .dll I get:
    Running "C:\cygwin\bin\make.exe  -f Makefile CONF=Debug" in C:\Documents and Settings\Administrator\My Documents\NetBeansProjects\DLLtestAppC++
    /usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
    make[1]: Entering directory `/cygdrive/c/Documents and Settings/Administrator/My Documents/NetBeansProjects/DLLtestAppC++'
    mkdir -p build/Debug/Cygwin-Windows
    g++.exe -mno-cygwin -Wl,--add-stdcall-alias -shared -m32   -c -g -IC\:/Program\ Files/Java/jdk1.5.0_06/include -IC\:/Program\ Files/Java/jdk1.5.0_06/include/win32 -I. -fPIC  -o build/Debug/Cygwin-Windows/JwrapperZC.o JwrapperZC.cpp
    JwrapperZC.cpp:1: warning: -fPIC ignored for target (all code is position independent)
    g++: --add-stdcall-alias: linker input file unused because linking not done
    mkdir -p dist/Debug/Cygwin-Windows
    g++.exe -mno-cygwin -Wl,--add-stdcall-alias -shared -m32    -mno-cygwin -shared -o dist/Debug/Cygwin-Windows/libDLLtestAppC__.dll -fPIC build/Debug/Cygwin-Windows/JwrapperZC.o 
    build/Debug/Cygwin-Windows/JwrapperZC.o: In function `Java_dlltestapp_USB_1interface_1K8055_JOpenDevice':
    /cygdrive/c/Documents and Settings/Administrator/My Documents/NetBeansProjects/DLLtestAppC++/JwrapperZC.cpp:15: undefined reference to `_OpenDevice@4'
    build/Debug/Cygwin-Windows/JwrapperZC.o: In function `Java_dlltestapp_USB_1interface_1K8055_JCloseDevice':
    /cygdrive/c/Documents and Settings/Administrator/My Documents/NetBeansProjects/DLLtestAppC++/JwrapperZC.cpp:28: undefined reference to `_CloseDevice@0'
    build/Debug/Cygwin-Windows/JwrapperZC.o: In function `Java_dlltestapp_USB_1interface_1K8055_JSetAllDigital':
    /cygdrive/c/Documents and Settings/Administrator/My Documents/NetBeansProjects/DLLtestAppC++/JwrapperZC.cpp:43: undefined reference to `_SetAllDigital@0'
    build/Debug/Cygwin-Windows/JwrapperZC.o: In function `Java_dlltestapp_USB_1interface_1K8055_JClearAllDigital':
    /cygdrive/c/Documents and Settings/Administrator/My Documents/NetBeansProjects/DLLtestAppC++/JwrapperZC.cpp:58: undefined reference to `_ClearAllDigital@0'
    collect2: ld returned 1 exit status
    make[1]: *** [dist/Debug/Cygwin-Windows/libDLLtestAppC__.dll] Error 1
    make[1]: Leaving directory `/cygdrive/c/Documents and Settings/Administrator/My Documents/NetBeansProjects/DLLtestAppC++'
    make: *** [.build-impl] Error 2
    Build failed. Exit value 2.Plz. help
    Thanks.

Maybe you are looking for