Jump to content

JRys

MCC Staff
  • Posts

    1,499
  • Joined

  • Last visited

Posts posted by JRys

  1. Hell Sai,

    The example program prints out one row or line of data from the data buffer and it does this for simplicity and because printing is a time consuming operation. Use your programming skills and modify the example so it prints all the data that was read.  To do this, you will need to know more about the a_in_scan_read function and this can be found in the MCC DAQ Hat Library Documentation. https://mccdaq.github.io/daqhats/index.html You will see that the function can return all the available data each time it's called or a lesser amount, it's up to you. It also will inform you what it has read so use the return variable to print all the data read. 

    I wasn't sure if you are using Python or C so my answer is fairly generic.

    Best regards,

    John

  2. Hey Jen,

    Launch the UL Help, it's available from the Start Programs Measurement Computing folder (see below). If you're missing UL Help, reinstall InstaCal but this time from the MCC DAQ Software CD download. https://www.mccdaq.com/downloads/MCCDaqCD/mccdaq.exe

    Click the Search tab and search on USB-201 to get to its reference page. Find the Digital I/O section and click UL Net function DConfigBit. Next, click on MccDaq.DigitalPortType in the C# function prototype. There you'll find the port types. Your port type is "AuxPort", which equals 1. Do the same for port direction (input = 2, output = 1). Bit numbers are 0 - 7. To set bits, use DBitOut or DBitIn to read it state.

    Best regards,

    John

    image.png.502aa64ae5c347fafeddd3de45c910bb.png

  3. Hello, 

    The following Python for Windows program demonstrates how to collect data with a USB-205. The while...loop that reads the data controls how long it will run. It does not write to a file but it does print one row of data from each buffer read - this is done for simplicity. Use your Python skills to modify it adding a routine that can write a List along with a timestamp to the file. Do take note, there is very little memory used because you do not need a bigger buffer to continuously read data. Copy this example (attached) to the Console example program folder. 

    best regards,

    John

     

     

    from __future__ import absolute_import, division, print_function

    import time

    from builtins import *  # @UnusedWildImport
    from time import sleep
    from ctypes import cast, POINTER, c_double, c_ushort, c_ulong

    from mcculw import ul
    from mcculw.enums import ScanOptions, FunctionType, Status
    from mcculw.ul import ULError, a_input_mode
    from mcculw.enums import InterfaceType
    from mcculw.enums import ULRange
    from mcculw.enums import AnalogInputMode

    use_device_detection = True


    def run_example():
        board_num = 0
        board_index = 0
        find_device = "USB-205"
        if use_device_detection:
            board_num = -1
            ul.ignore_instacal()
            dev_list = ul.get_daq_device_inventory(InterfaceType.USB)
            if len(dev_list) > 0:
                for device in dev_list:
                    if str(device) == find_device:
                        print(f"Found {find_device} board number = {board_index}")
                        print(f"Serial number: {device.unique_id}")
                        print(f"Product type: {hex(device.product_id)}")
                        board_num = board_index
                        ul.create_daq_device(board_num, device)
                    board_index = board_index + 1

                if board_num == -1:
                    print(f"Device {find_device} not found")
                    return
            else:
                print("No devices detected")
                return
        # **********End of Discovery************

        rate = 10000
        # buffer sized to hold one second of data. Make larger if your data handling requires more.
        points_per_channel = 10000
        low_chan = 0
        high_chan = 3
        num_chans = 4

        total_count = points_per_channel * num_chans
        half_count = int(total_count / 2)
        # The SCALEDATA option, returns volts instead of A/D counts
        scan_options = ScanOptions.CONTINUOUS | ScanOptions.BACKGROUND | ScanOptions.SCALEDATA

        memhandle = ul.scaled_win_buf_alloc(total_count)
        buf_data = cast(memhandle, POINTER(c_double))

        # Check if the buffer was successfully allocated
        if not memhandle:
            print("Failed to allocate memory.")
            return

        try:
            # Start the scan
            ul.a_in_scan(
                board_num, low_chan, high_chan, total_count,
                rate, ULRange.BIP10VOLTS, memhandle, scan_options)

            # Create a format string that aligns the data in columns
            # plus two for curr_index and curr_count
            row_format = "{:8}" * (num_chans + 3)

            # Print the channel name headers
            labels = []
            for ch_num in range(low_chan, high_chan + 1):
                labels.append("CH" + str(ch_num) + "\t")

            labels.append("index\t")
            labels.append("count\t")
            labels.append("diff")
            print(row_format.format(*labels))

            # boolean flag used to toggle reading upper and lower buffer
            read_lower = True
            # Start updating the displayed values
            status, curr_count, curr_index = ul.get_status(
                board_num, FunctionType.AIFUNCTION)

            last = 0
            diff = 0
            while status != Status.IDLE and curr_count < 200000:
                # Make sure a data point is available for display.
                if curr_count > 0:
                    # curr_index points to the start of the last completed
                    # channel scan that was transferred between the board and
                    # the data buffer. Display the latest value for each
                    # channel.

                    # display_data = []
                    if (curr_index > half_count) and (read_lower == True):
                        diff = curr_count - last
                        ul.scaled_win_buf_to_array(memhandle, buf_data, 0, int(half_count))
                        print(
                            '{:.3f}\t {:.3f}\t {:.3f}\t {:.3f}\t {:d}\t {:d}'.format(buf_data[0], buf_data[1],
                                                                                            buf_data[2],
                                                                                            buf_data[3],
                                                                                            curr_index,
                                                                                            curr_count))
                        read_lower = False

                    elif (curr_index < half_count) and (read_lower == False):
                        diff = curr_count - last
                        ul.scaled_win_buf_to_array(memhandle, buf_data, int(half_count), int(half_count))
                        print(
                            '{:.3f}\t {:.3f}\t {:.3f}\t {:.3f}\t {:d}\t {:d}'.format(buf_data[0], buf_data[1],
                                                                                            buf_data[2],
                                                                                            buf_data[3],
                                                                                            curr_index,
                                                                                            curr_count))
                        read_lower = True
                sleep(0.1)
                status, curr_count, curr_index = ul.get_status(board_num, FunctionType.AIFUNCTION)

            # Stop the background operation (this is required even if the
            # scan completes successfully)
            ul.stop_background(board_num, FunctionType.AIFUNCTION)

            print("Scan completed successfully.")
        except ULError as e:
            print(e.message)
        finally:
            # Free the buffer in a finally block to prevent errors from causing
            # a memory leak.
            ul.win_buf_free(memhandle)

            if use_device_detection:
                ul.release_daq_device(board_num)


    if __name__ == '__main__':
        run_example()
     

    a_in_scan_USB200.py

  4. 1. Your assumption is mostly correct. The offset is listed as a maximum not absolute and your offset may be less. You could measure it ahead of time then subtract the measured value from the data. To measure it, turn off IEPE source current and short the input. My 172 is, in a 22 Deg C environment, measured 200uVrms (approximately 1.2mV). 

    2. There no such thing as a perfect DAQ board, so 144 dB is out of reach. The A/D itself isn't perfect plus there are amplifiers, filters and source current electronics that add error. As result, it is more like a very good 16-bit converter.  

    3. The input measurement range is +/- 5 volts. You could test the inputs by turning off IEPE source current and applying a good quality 5 volt sine wave. Dynamic range is a signal to noise specification. Use it when comparing the 172 to other dynamic signal analyzers. 

    best regards, 
    John

  5. Review the Analog Discovery Reference page.

    https://digilent.com/reference/test-and-measurement/analog-discovery-2/start?redirect=1

    There you will see the specifications, which list the digital IO features and use:

    image.png.95bdcbaaca64435c65b6f4286e9852f8.png

     

    There should be plenty of information on the Internet about using digital IO to control LEDs, buttons and switches. Likewise for topics like "what are logic analyzers?" and "what are digital pattern generators?".

    best regards,

    John

  6. I believe you self diagnosed your system. The error was apparently being caused because you left out the Clear Task when the loop exited. I experienced the error on the second time running the worksheet - without exiting LabVIEW or closing the VI. I added in the Clear Task and Status check inside the loop. Seems to run okay, I ran it about 10 times in a row without issue. 

    Take care,

    John

    EE_SuperSimple_DAQ_MCC_r2.vi EE_DAQ_Force_Matrix_Constant.vi

  7. Hello,

    There is no good way to create a Slope trigger that has a value change number as well as minimum time. If you can do with a method to log data every time the value increases/decreases by an amount, use the Trigger on Demand module. It will produce a pulse each time the value changes by the specified amount. Use a Combi Trigger to stretch the pulse to 10 seconds to close a Relay allowing data to flow to a Write Data module for file logging. I've attached a DASYLab 2020.1 example to demonstrate.

    Best regards,
    John

    TriggerOnDemand.thumb.png.bb8e5f55abb1efb89966cf78790259d7.png

    TriggerOnDemand.DSB

  8. Hello,

    The ULx for LabVIEW support requires that the device be configured with InstaCal before starting LabVIEW itself. Make sure to close InstaCal before starting LabVIEW, I'll explain. InstaCal will create/update the system cb.cfg file when it is closed. This is important because when LabVIEW is started, it loads an MCC dll that reads this file. If left open, ULx for LabVIEW is unaware of the changes you've made. Reading of the cb.cfg system file happens once when LabVIEW is started, not when you drop the first VI on your block diagram. 

    Next, a lot of the initial ULx for LabVIEW development work used LabVIEW 8.5 and because of this, you may see file path warning indicating that your path structure is different. The warning can be ignored and will go away once you have saved your work to a new location. The current version of ULx for LabVIEW supports versions 2010 through 2021 both 32-bit and 64-bit. With this said, we have seen some installation issues with systems that have multiple versions of LabVIEW. If you're experiencing problems, it best to first uninstall both InstaCal and ULx for LabVIEW, then re-install both using the current MCC DAQ Software CD download.  The ULx for LabVIEW installation will list the versions you have, deselect all but the version you intend to use. You can get the current CD download from https://www.mccdaq.com/Software-Downloads.

    Finally, the USB-2408 channels can be set to either voltage or thermocouple. When reading a mixture, read the channels as if they all are voltage. I recommend starting with the example ULx Cont Acq&Chart Samples-SW Timed.vi, which is in your LabVIEW 2018 \Examples\ULx\Analog In\Measure Slow Varying Signal.llb library. Even if all the channels are set to thermocouple, this example should work. 

    Best regards,

    John

  9. Hello,

    I ran your super simple daq mcc vi using one of my USB devices and didn't experience the problem. The problem description you provided sounds a lot like a mismatch between versions of ULx for LabVIEW and InstaCal. My recommendation is to uninstall both InstaCal and ULx for LabVIEW, then reinstall from the latest MCC DAQ Software CD. The following is a link to the CD download: https://www.mccdaq.com/downloads/MCCDaqCD/mccdaq.exe Don't worry about the device InstaCal configuration, uninstalling it leaves behind the configuration file and it should be intact after the reinstalled.

    regards...

  10. Hello,

    I've looked into your application further and using the ULx Timing VI to achieve higher throughput will not work in PID applications. This is because the underlying resources were designed to stream waveforms not single values. The waveform output works by first preloading the output buffer using the ULx Write Vi. For a clock rate of 1000, the buffer must be at least 5000 otherwise an error will occur. The buffer is not directly accessible and all additional ULx Writes get appended to the end.

    Take a look at the ULx Cont Gen Voltage Wfm-Int Clk-Non Regeneration.vi for an example of this. It is located in the \National Instruments\LabVIEW 2021\Examples\ULx\Analog Out\Generate Voltage.llb library.

    regards,

     

  11. Hey Walda14,

    If you're using a voltmeter to measure the output voltage and are touching to probe tips to the screw terminal tops, make sure the terminal is anchored down on a wire or screwed down completely. With this in mind, you could use the Measurement Computing DAQami program to test the outputs to make sure they are working. DAQami is $49 but runs as a trial for 28-days. After the trial has expired, it still can be used but not to save analog input data. Use the following link to download DAQami: https://www.mccdaq.com/downloads/DAQami/daqamisetup.exe

    regards...

     

  12. Hello,

    I did not see an input noise specification in the Analog Discovery 2 (AD2) Resource Center (reference page). However, when I do a similar test with the BNC adapter board and a scope probe (DC coupling), my results are 10 - 12 mVpp. This equates to roughly 4 counts of p-p noise where each count is 3mV.  An FFT of the signal did not show a significant 60 Hz noise component however, if the probe is switched to 10x, then a 60 Hz component did appeared. 

    regards...

     

    AD2 Probe Grounded.png

  13. Hello,

    The cable layout on the Analog Discovery 2 (AD2) Resource Center page shows how the individual wires are arranged with the cable inserted into the AD2. If you open the plastic case and look at the header connector solder pads, you will see that one of them is square, this is pin 1 (digital bit 7). The pins on that side of the connector are odd number and the other side are even. For example, digital bit 6 is pin 3, digital bit 5 is pin 5 and so on.

    image.png.057041bf678d72205802d60f4e72e684.png

    regards,

    John

     

  14. Hello,

    You must have InstaCal 6.73 install on Windows 11 for it to work. The first time you run InstaCal with the USB-TEMP/TC you should get a window indicating you must perform an update. After running the update, either restart Windows or repower the device by plugging it back in. Run InstaCal again and it should recognize your device and allow  you to configure it. 

    If you do not have InstaCal 6.73, download our latest DAQ Software CD using the following:

    https://www.mccdaq.com/downloads/MCCDaqCD/mccdaq.exe

    Regards,

    John

  15. Hello,

    Often overlooked is our UL Help that can provide useful information about a specific product. The shortcut to it can be found on the Measurement Computing start program menu. A good place to start is to click the Search tab and perform a search on "USB-1208HS-4AO". This will provide a link to the device's page, which lists the functions and scan options to use. There you will see that both the AInScan and AOutScan functions support the external trigger option - EXTTRIGGER.  If you include this option in the scan options for both functions, neither process will start until a rising edge of a +5 volt pulse is detected on pin 39 - see page 0 in the user manual for pinout names. 

    There is another better way, instead of EXTTRIGGER use EXTCLOCK. With this option, neither will run (and continue to run) until a +5 volt square wave clock is applied to pins 35 & 37. For a clock signal, use the timer output and connect pin 43 to 35 & 37. This assures both run in lock-step until the clock is removed.

    regards,
    John

  16. Hello,

    It's not recommended to create board objects each time a single temperature value is needed. Instead, create them once as a global object. Take a look at the MCC118 example called "mult_hat_synchronous_scan.py". It has a function called "select_hat_devices(filter_by_id, number_of_devices" and it returns a list of daqhat objects. Copy the function to your program and call it once to establish a list of MCC134 objects. Here's an example of how you would use it:

    DEVICE_COUNT = 4

    hats = slect_hat_devices(HatIDs.MCC_134, DEVICE_COUNT) 

    The hats list now contains the four mcc134 objects.

    Right after this function call, you could configure the thermocouple types too. Then all that is need in your Rec_Data() function is to iterate the object list reading the four channels from each board.

    Regards,

    John

  17. Hi Marcel,

    See if you have a ULx folder in \National Instruments\Shared\ and in \National Instruments\LabVIEW 2021\Examples\. If the ULx folders are present the support is install. However, the menu file somehow vanished. The following KB article addresses this topic:

    https://kb.mccdaq.com/KnowledgebaseArticle50382.aspx

    The help file should be in C:\Program Files (x86)\National Instruments\Shared\ULx. If it is there, you could make your own shortcut.

    Best regards,

    John

  18. Hello Alexandre,

    It makes no sense that the storage temperature is less than the operating temperature. Therefore, I am thinking that the storage specification is incorrect. From what I can tell, it uses the FT232HQ chip and its specification lists a storage temperature of -65 to 150 Degrees C - see below.

    Here is a link to the data sheet I found: https://ftdichip.com/products/ft232hq/

    image.png.e50a359a95fef673657d735daa3aa778.png

    Best regards,

    John

  19. Hello Paul,

    The Analog Discovery 2 (AD2) measures voltage. Its input impedance is approximately 1M ohm.

    It's not recommended to work directly with high voltage because if something were to go wrong, the voltage could make it way back to the operator. Its best to use an isolation signal conditioning module between your test rig and the AD2 inputs. The 8B series from www.dataforth.com has 1500 volts of isolation and will provide some protection. However, these may be a problem for you because their bandwidth is less than that of the AD2. 

    Going back to your question, what I see is a 100:1 voltage divider. If the discharge voltage hits 10000 volts, the voltage at the AD2 terminals could reach 100 volts, which exceeds the 25 volt maximum input range and damage the unit.

    John

×
×
  • Create New...