Skip to content

Add fixed point support using variants #7

Open

Description

@smithed

You can set the type of the variable to "variant" and perform reads. Since variants automagically coerce data to the selected type, we can read fxp values and just autoconvert to dbl. Slow, yes, but better than not supporting them if we need them (which we don't right now).

Activity

  1. pollockm commented on Mar 29, 2016

    @pollockm
    Contributor

    I did some testing on this, and reading/writing fixed point values (either shared variables or UDVs) works correctly if we tell the Read/Write Variable function that it is actually accessing a DBL (wire a DBL constant to the data type input). Looks like the function will already handle the conversion for us.

  2. srsmith99 commented on Jan 20, 2017

    @srsmith99

    I have been attempting to make this change to our DCAF project. We have analog input modules on the cRIO-9030 going through the FPGA where we do some filtering. At the moment we are using the I16 data type for our UDV's but would like to switch to fixed point so we could use the calibrated voltages.

    As a start I changed the analog input UDVs to fixed point and all related items in the DCAF configuration editor were set to doubles.

    When I run the cRIO Main.vi I get a command error in the init.vi. The error occurs when the Open Variable Connection function tries to open the variable location thinking it is a double. This appears to be the first place where the Tag data and actual variable come together. Apparently the open variable connection function does not like the fixed point type. Any recommendations?

  3. pollockm commented on Jan 20, 2017

    @pollockm
    Contributor

    A simple test in LV 2015 with a network published shared variable (though not a UDV) works well:

    fxp.zip

  4. pollockm commented on Jan 20, 2017

    @pollockm
    Contributor

    Next is to try the UDV case. This would be interesting, since typically UDV and regular shared variables share the same properties in terms of access. I had assumed that they would work the same in this case as well, but perhaps that was incorrect. Let's find out!

  5. srsmith99 commented on Jan 20, 2017

    @srsmith99

    The shared variable works fine with LV 2016 as well.

  6. srsmith99 commented on Jan 24, 2017

    @srsmith99

    I ran another test and the FXP to DBL is not working properly. cRIO 9030 in hybrid mode. I removed all FPGA processing, just analog inputs to FIFO and then wait for the scan engine and out to UDV. Everything to this point is FXP.

    Using the DCAF Execution Service template for the project with the modified init.vi (Clear Errors.vi set for error -66212 following the Open Variable Connection.vi). Without the Clear Errors mod the shared memory won't even initialize due to a -66212 command fault. DCAF configuration set with Scan Engine channel set: ni.var.io://localhost/User-Defined Variables/M1_AI0 as a Double. Mapped to a Tag also set as a Double.

    When I deploy and run this the UDVs are active (per Distributed System Manager). With a calibrated voltage input the voltages show up as an integer; tenths of a volt are rounded up or down but not displayed. The shared memory input/output files are initialized and the indexes update but the voltage values are not being written to the memory.

    I took a few screen shots and put a bit more detail in a word doc that is attached.
    Using FXP variables for AI modules testing 012317.docx

  7. pollockm commented on Jan 24, 2017

    @pollockm
    Contributor

    I can reproduce good behavior on my side without DCAF - if accessing a FXP shared variable, the automatic data conversion works without error. If accessing a FXP UDV via the ni.var.io protocol, I get data type does not match error on opening the variable connection. If accessing the same FXP UDV via the ni.var.psp protocol (going through the network published shared variable interface), I do not get any errors and can see the value update.

    Try modifying the URL to use ni.var.psp instead of ni.var.io and see if you can reproduce the good behavior.

    Will post project shortly.

  8. pollockm commented on Jan 24, 2017

    @pollockm
    Contributor
  9. pollockm commented on Jan 24, 2017

    @pollockm
    Contributor

    For the above workaround to work, you'll need to have the UDVs marked as 'Enable Network Publishing' in their properties dialogs. This is the default for UDVs.

  10. srsmith99 commented on Jan 24, 2017

    @srsmith99

    Modified the URLs to use ni.var.psp, network publishing enabled. I've got the same integer result for the UDVs in the Distributed System Manager and shared memory input/output files are not initializing. I'll check out the fxp test.zip you sent.

  11. pollockm commented on Jan 24, 2017

    @pollockm
    Contributor

    The working theory at this point is the psp interface has a data conversion layer in its stack, whereas the udv interface does not. The underlying data is the same, but one access method is permissive of different (but convertible) data type and the other is not. Note that these interfaces are not part of DCAF, they're part of LabVIEW itself. We won't be able to change the interfaces, just which one we use.

    If you can reproduce good behavior without DCAF, then it's just a matter of finding if there are any tweaks to DCAF necessary to allow that logic flow. I'll see what I can find.

  12. DCAF-Builder commented on Jan 24, 2017

    @DCAF-Builder
    Contributor

    Reproduced good behavior with DCAF. Project attached. You'll of course need to change the IP addresses for the UDP module to work right, and the usual FPGA stuff to get it compiling on a 9030.

    image

    dcaf fxp.zip

  13. srsmith99 commented on Jan 24, 2017

    @srsmith99

    Tested the fxp test.zip. Modified for my 9030, downloaded the FPGA and ran the RT vi interactively. It works!

    The integer issue I was seeing may be because I did not redeploy the UDVs when I was doing my previous testing. Could have made all the difference - I will retest that tomorrow. Just saw your post, that's good news!

  14. pollockm commented on Jan 24, 2017

    @pollockm
    Contributor

    Let me know what you find. If it works tomorrow for you I'll consider the issue closed, since it would have been shown to work on my machine and yours.

  15. srsmith99 commented on Jan 25, 2017

    @srsmith99

    Several issues with dcaf fxp.zip.

    1. Can't open the pcfg file - Error 1108 occurred at Unflatten From XML in Standard Engine Configuration.lvclass:from string.vi->NISE_CEF_TreeSerializer.lvlib:strings to memory.vi->NISE_CEF_HierarchyRepo.lvclass:Open.vi->Standard Editor.lvlib:Configuration Utility.vi, Possible reason(s): LabVIEW: XML value text is illegal or out of range for type and/or format.
    2. fxp fpga.vi is missing

    FYI-UDV deployment was not the issue on my end, so something else is causing the integer UDV display in Distributed System Manager (type is correctly listed as fixed point).

  16. DCAF-Builder commented on Jan 25, 2017

    @DCAF-Builder
    Contributor

    dcaf fxp2.zip FPGA VI was in the wrong directory - my mistake. Regarding the config file, this is an error due to my test machine being on the pre-release version of DCAF that is in testing now.

  17. DCAF-Builder commented on Jan 25, 2017

    @DCAF-Builder
    Contributor

    image

    I can see non-integer UDV values in system manager in 2016, but I don't have any sensors to pull actual data from.

    With regard to the config file, that is an error that won't be corrected for a little while - I'd need to downgrade my system to the currently released one and build a new config file (the latest release introduces a change to the config file format such that old files will still work with the new release but new files won't work with the old release).

    I'll spin up another test machine with the previous release and rebuild.

  18. srsmith99 commented on Jan 25, 2017

    @srsmith99

    No problem and thanks. r.e. the integer UDV issue, it appears one of my controls had an improperly configured fxp type. I will recompile fpga and retest but hopefully that issue is solved.

  19. pollockm commented on Jan 25, 2017

    @pollockm
    Contributor

    Reproduced error 1108 on opening config from new version editor in old version runtime. Opened new issue to track that one. LabVIEW-DCAF/StandardEngine#59

  20. srsmith99 commented on Jan 25, 2017

    @srsmith99

    Integer issue is solved. Butterworth filter in FPGA has a word length limit in multi-channel mode of 16. So 32,16 fxp was truncated to 16,16. As expected, not a DCAF issue.

  21. srsmith99 commented on Jan 30, 2017

    @srsmith99

    I modified your dcaf fxp2 to eliminate the UI (we aren't planning to use one) and generated a new config file since I was unable to open the one you provided. I was able to demonstrate fxp data updates from the FPGA into the shared memory using the psp interface by running the cRIO Main.vi interactively. So it does appear to work; unfortunately, I have not been able to get it to run with everything fully deployed to the cRIO chassis but we are working on that.

  22. srsmith99 commented on Feb 1, 2017

    @srsmith99

    Thank you for the help on this one but we are going to abandon this effort for now. In interactive mode the FXP ->DBL works fine. In deployed mode it does not work and continues to throw errors. Instead we are implementing the fixed-point bitwise representation and will pass the FXP as an integer where it can be recovered in our C App control logic running on the Linux RTOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions