<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Sensor Output 0 using VISA Read in LabVIEW</title>
    <link>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3792278#M1069887</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I’m using the VISA&amp;nbsp;Read to read data from 3 sensors, and occasionally, the graph is plotting sensor output of 0.&amp;nbsp; &amp;nbsp;I believe the issue has to do with timing in my Labview 2017's while loop (see attached pic 0 for my Labview block diagram).&amp;nbsp; Has anyone experienced this issue and how to solve it?&lt;/P&gt;
&lt;P&gt;-----------------&lt;/P&gt;
&lt;P&gt;Here is a detailed description of my issue:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hardware configuration:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Using a microcontroller (MSP430F5529) to read 3 accelerometer sensors (MC3672)&lt;/LI&gt;
&lt;LI&gt;Using UART at baud rate of 115200 bit per second to capture sensor output data&lt;/LI&gt;
&lt;LI&gt;Using Labview’s VISA Configure Serial Port to capture and graph sensor output data&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Problem:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;If the while loop waits 2ms (or 3ms…or 10ms) to run, then occasionally, the graph shows that the sensor has an output of 0 (see pic 1 in attachment)&lt;/LI&gt;
&lt;LI&gt;Pic 1 shows the 0-issue occurring at sensor accelerometer #1 in the Z-axis, but I’ve seen it occur for sensor #2 and sensor #3 as well.&lt;/LI&gt;
&lt;LI&gt;If the while loop waits 1ms (or no wait at all), then I see the 0 occurring a LOT more (pic 2). This leads me to think that the issue is this while loop’s wait time.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Other Troubleshooting techniques:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;I don’t think the issue is the sensor outputting the 0’s because I am constantly polling the output of the sensor in my microcontroller code, putting a breakpoint in the code if the sensor outputs 0, and I have never been able to capture this sensor reading of 0’s (see pic 3 for a snippet of my microcontroller code)&lt;/LI&gt;
&lt;LI&gt;I am also attaching a picture of the I2C capture from an oscilloscope (pic 4) if that’s helpful. This picture just shows that each sensor reading takes about 2ms&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Sun, 13 May 2018 16:36:30 GMT</pubDate>
    <dc:creator>amyle</dc:creator>
    <dc:date>2018-05-13T16:36:30Z</dc:date>
    <item>
      <title>Sensor Output 0 using VISA Read</title>
      <link>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3792278#M1069887</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I’m using the VISA&amp;nbsp;Read to read data from 3 sensors, and occasionally, the graph is plotting sensor output of 0.&amp;nbsp; &amp;nbsp;I believe the issue has to do with timing in my Labview 2017's while loop (see attached pic 0 for my Labview block diagram).&amp;nbsp; Has anyone experienced this issue and how to solve it?&lt;/P&gt;
&lt;P&gt;-----------------&lt;/P&gt;
&lt;P&gt;Here is a detailed description of my issue:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hardware configuration:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Using a microcontroller (MSP430F5529) to read 3 accelerometer sensors (MC3672)&lt;/LI&gt;
&lt;LI&gt;Using UART at baud rate of 115200 bit per second to capture sensor output data&lt;/LI&gt;
&lt;LI&gt;Using Labview’s VISA Configure Serial Port to capture and graph sensor output data&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Problem:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;If the while loop waits 2ms (or 3ms…or 10ms) to run, then occasionally, the graph shows that the sensor has an output of 0 (see pic 1 in attachment)&lt;/LI&gt;
&lt;LI&gt;Pic 1 shows the 0-issue occurring at sensor accelerometer #1 in the Z-axis, but I’ve seen it occur for sensor #2 and sensor #3 as well.&lt;/LI&gt;
&lt;LI&gt;If the while loop waits 1ms (or no wait at all), then I see the 0 occurring a LOT more (pic 2). This leads me to think that the issue is this while loop’s wait time.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Other Troubleshooting techniques:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;I don’t think the issue is the sensor outputting the 0’s because I am constantly polling the output of the sensor in my microcontroller code, putting a breakpoint in the code if the sensor outputs 0, and I have never been able to capture this sensor reading of 0’s (see pic 3 for a snippet of my microcontroller code)&lt;/LI&gt;
&lt;LI&gt;I am also attaching a picture of the I2C capture from an oscilloscope (pic 4) if that’s helpful. This picture just shows that each sensor reading takes about 2ms&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Sun, 13 May 2018 16:36:30 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3792278#M1069887</guid>
      <dc:creator>amyle</dc:creator>
      <dc:date>2018-05-13T16:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: Sensor Output 0 using VISA Read</title>
      <link>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3792280#M1069889</link>
      <description>&lt;P&gt;I think your first problem is you are using Bytes at Port.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does your incoming data have a termination character?&amp;nbsp; I would guess it does since you have enabled the termination character in your VISA Serial Configure.&amp;nbsp; Take advantage of it! Get rid of Bytes at Port and wire in a constant that is larger than the longest message you ever expect to receive.&amp;nbsp; That way you know you are getting complete messages.&amp;nbsp; Right now, you might be getting incomplete messages which would cause some to channels to be interpreted as zero.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, Index Array is resizable.&amp;nbsp; Just drag down the bottom border.&amp;nbsp; The indices will automatically be 0, 1, 2, 3, ... without wiring up any constants.&amp;nbsp; That saves you lots of extra Index Array nodes, wires, and constants.&lt;/P&gt;</description>
      <pubDate>Sun, 13 May 2018 16:48:49 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3792280#M1069889</guid>
      <dc:creator>RavensFan</dc:creator>
      <dc:date>2018-05-13T16:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: Sensor Output 0 using VISA Read</title>
      <link>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3792281#M1069890</link>
      <description>&lt;P&gt;In addition to what Ravens Fan pointed out.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use join numbers to convert 2 U8s to a U16.&amp;nbsp; &amp;nbsp;that will simplify your 2's complement vi Better yet use split array to return the 0th element and the array of sensor data then cat the sensor data array of U8s to an array of I16s (as Altenbach will point out - there is way too much code there you could fit it on a postage stamp!)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The VISA Close is unnecessary but the way you are using it is "Wrong"&amp;nbsp; Did you know you are tring to close a Session with the name of the read buffer?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try something like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="The chart is  set to &amp;quot;Stack Plots&amp;quot;" style="width: 873px;"&gt;&lt;img src="https://forums.ni.com/t5/image/serverpage/image-id/227962i7051DF1A94F31B32/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.png" alt="The chart is  set to &amp;quot;Stack Plots&amp;quot;" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;The chart is  set to "Stack Plots"&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 13 May 2018 17:19:42 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3792281#M1069890</guid>
      <dc:creator>JÞB</dc:creator>
      <dc:date>2018-05-13T17:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sensor Output 0 using VISA Read</title>
      <link>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3793110#M1070167</link>
      <description>&lt;P&gt;Thank you for all of your help.&amp;nbsp; We found out&amp;nbsp;the issue is that VISA READ may be misinterpreting my sensor output as a new line of data, and therefore, VISA READ is sometimes grabbing incomplete transfers, and Labview is graphing the incomplete data as 0's.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We solved this issue by creating a while loop, adding shift registers, and making sure I always get 9 bytes of data before plotting them.&amp;nbsp; See attached block diagram for my solution.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 18:25:30 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3793110#M1070167</guid>
      <dc:creator>amyle</dc:creator>
      <dc:date>2018-05-15T18:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Sensor Output 0 using VISA Read</title>
      <link>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3793122#M1070173</link>
      <description>&lt;P&gt;Hi amyle,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;there seems to something wrong with your "solution"…&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="padding-left: 30px;"&gt;&lt;FONT color="#FF0000"&gt;We found out&amp;nbsp;the issue is that VISA READ may be misinterpreting my sensor output as a new line of data&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Because YOU explicitely enabled the TermChar at SerialPortInit, using a default LF termchar!&lt;/P&gt;
&lt;P&gt;When your communication protocol doesn't use a TermChar then DISABLE it…&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Get rid of BytesAtPort! When you want to read exactly 9 bytes then set VISARead to read 9 chars (after disabling the TermChar)! No loop needed, no shift register, no ConcatString, no StringLength…&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure you want to build an array containing a timestamp and 4 zero values when "write to file" is FALSE?&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 19:07:31 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3793122#M1070173</guid>
      <dc:creator>GerdW</dc:creator>
      <dc:date>2018-05-15T19:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Sensor Output 0 using VISA Read</title>
      <link>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3793600#M1070334</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.ni.com/t5/user/viewprofilepage/user-id/351684"&gt;@amyle&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for all of your help.&amp;nbsp; We found out&amp;nbsp;the issue is that VISA READ may be misinterpreting my sensor output as a new line of data &lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Lesson to learn here: If you are using binary/hex data, &lt;STRONG&gt;turn the termination character off&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And since you know every message is 9 bytes, just tell the VISA Read to read 9 bytes.&amp;nbsp; You are making life way too difficult on yourself.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 15:49:48 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3793600#M1070334</guid>
      <dc:creator>crossrulz</dc:creator>
      <dc:date>2018-05-16T15:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Sensor Output 0 using VISA Read</title>
      <link>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3794064#M1070506</link>
      <description>&lt;P&gt;Thanks, I definitely have to clean up my code a bit, but the 0 issue has not returned.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 May 2018 16:38:51 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/3794064#M1070506</guid>
      <dc:creator>Amy4082001</dc:creator>
      <dc:date>2018-05-17T16:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: Sensor Output 0 using VISA Read</title>
      <link>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/4238671#M1231830</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;
&lt;P&gt;Can you share your final VI???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 15:17:41 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/Sensor-Output-0-using-VISA-Read/m-p/4238671#M1231830</guid>
      <dc:creator>User002</dc:creator>
      <dc:date>2022-06-22T15:17:41Z</dc:date>
    </item>
  </channel>
</rss>

