07-09-2010 03:36 PM
Hi all,
Newbie on the line here. I wrote a VI that obtains the reading of channels 1 and 2 from an oscilloscope via GPIB. The readings come out to be decent looking sinusoids when plotted on a waveform graph. However, after multiplying the two, the product is quite distorted and looks nothing like what you would expect. The waveform of the product contains huge jumps from negative to positive values even when outputs #1 and #2 are very continuous. I've also noticed that if you adjust the scaling on the oscilloscope to a certain value, the distortion goes away and the product looks like a normal sinusoid as well. At all other scaling values, the product waveform is distorted. Since the output wires of channels 1 and 2 (to the individual plots) are from the same branch as those going into the multiplication block, I'm wondering how this would make sense. Anyone have an idea?
The output graphs are attached as the following. Much thanks in advance for the help.
07-09-2010 04:19 PM
What data type are you type casting too? If it is I8, you are getting overflow when multiplying. I'm looking at graph time 60. One curve has a value of 10 and the other has a value of 24 at T-60. The product would be 240. Yet on the power graph at T-60, the value is a negative number. If you are type casting to an I8, I would believe the result would be negative since I8 range is from -128 to 127. 240 would fall into the negative range in this case. If this is the case, type case to U16 to prevent overflow.
07-09-2010 05:41 PM
Thanks for your comment! You have a very good point there. However, as I switched the datatype to U16 among other data types, though each would give me a different type of reading on the graphs, none would actually resolve the issue and make the product take a reasonable shape. Just to make sure, I should change the datatype in this case by right clicking the numerical constants in the two arrays (the inputs to the two typecast functions), go to "representation", and change it this way? Would this be correct?
07-09-2010 05:45 PM
No, you need to typecast to the correct type, the overflow is later, at the multiplication. Keep the typecast intact, but insert e.g. a "to I32" right after the two typecast.
07-09-2010 05:55 PM
Thanks a ton for the tip!!! I got it 😃