01-18-2016 07:43 AM
Hello,
Is there a simple way to realise Sample & Hold analog circuit: analog value is sampled and stored in variable on a transition of some boolean signal ... TRUE -> FALSE or vice-versa.
Thanks
Best Regards
Pavel
01-18-2016 07:53 AM
Yes, yes there is.
Mike...
PS: Sorry, I couldn't resist. A good way is to emulate the operation of a sample-and-hold circuit in software is to store the number temporarily in a shift register or a functional global variable (FGV). But it sounds like first you would do well to go through the LabVIEW tutorials that you will find online.
01-18-2016 08:11 AM
What do you mean by a Sample-and-Hold circuit? As Mike says, you can make a software S&H circuit by sampling and then saving the result in a Shift Register.
Are you talking about wanting to sample multiple channels where the data are acquired at precisely the same instant? Then you need S&H circuits on each input, triggered by the "Convert" signal (and having the actual conversion be slightly delayed to let the S&H "hold" work). A/D boards used to include this additional circuitry as a matter of course, but I'm not certain that this is still the case.
Bob Schor
01-18-2016 09:18 AM
You can use a Feedback node. Right click and select show enable terminal. When enable is true, the feedback node stores the new value and delays its output, when false it returns the last value. This behavior is better described in the help.
01-18-2016 09:57 AM
Thanks for feedbacks,
Here is my setups:
Setup 1
Setup 2
Certainly, setup 2 would require a shift register, but probably for setup 1 esxists more simple solution (e.g. ready-to-use Sample&Hold block in some of toolboxes ... I've serched already, but have found nothing ... possible my LabView installation isn't complete)
Thanks
Pavel
01-18-2016 10:00 AM
01-18-2016 10:01 AM
01-18-2016 10:18 AM
Hi GerdW,
Almost as on the image below, where:
Input signal - signal A
Sample/Hold Control - output from comparator A > B
The only difference form image - Sample/Hold Control must behave as flip-flop - i.e. edge sensitive.
Best Regards
Pavel
01-18-2016 10:28 AM
This was my thought. You just have to generate your sample and hold pulse. Note the mechanical action behavoir on the sample button.
01-18-2016 10:52 AM
I think you and I may be thinking of different meanings for a Sample-and-Hold circuit. Here's my pseudocode for how a S&H works:
This circuit is trivial to build as a sub-VI -- you need a While Loop with True wired to the Stop Indicator, two nested Case Structures, two Shift Registers, and Input and Output Terminals. Call one Shift Register "Input", the other "Held" (as they will store these values). There are three scenarios:
We can distinguish Case 1 from the other two by wiring Held to the outer Case Statement. By comparing Held to "remembered" Held, we can distinguish Cases 2 and 3.
This should be able to handle both of the S&H Scenarios you outlined. Write it as a sub-VI and it will take up very little space on your Block Diagram. Give the sub-VI an Icon (perhaps text that says "Sample & Hold") and it will be self-documenting on your main VI.
Bob Schor