06-13-2011 09:52 PM
Hi,
I'm a bit stuck on basic architecture to wire this one.
I want the input value to be compared to a threshold value to determine TRUE/FALSE case.
For the first Input Value ONLY (TRUE CASE), I want the Threshold increment applied to it, but, for all subsequent Increment multipliers, the most recent OUTPUT value should be incremented, NOT the Input value.
In other words, I have a continuous stream of Input Values, some of which will be greater than the threshold, and others will be less than the threshold. Each time the Input Value is greater than the threshold, then, I want the MOST RECENT OUTPUT value to be increased by the increment multiplier to create a new, higher, OUTPUT. How do I use the shift registers to apply the multiplier to the previous OUTPUT value for the TRUE case? I feel like I have to wire two inputs to the multiplier, which is obviously not allowed.
What am I missing?
Thanks for your advice.
06-13-2011 10:45 PM - edited 06-13-2011 10:46 PM
If I am not mistaken and I understand you correctly I think this is what you are looking for.
Note: The random number generation is a substitute for your input stream in this example.
06-14-2011 12:36 AM
Hi,
I think Mark's example will work fine, but if I am not wrong the doubt was about how to use a Shift register. Have a look on the attached code and images. This must be what you are looking for.
Regards,
Nitzz
(Give kudos to good Answers, Mark it as a Solution if your problem is Solved;))
06-14-2011 02:12 AM - edited 06-14-2011 02:16 AM
@dav2010 wrote:
Each time the Input Value is greater than the threshold, then, I want the MOST RECENT OUTPUT value to be increased by the increment multiplier to create a new, higher, OUTPUT.
You seem to be mixing terms. Typically "increased" would impliy addition, but you seem to be multiplying.
What is the formula for the new output that you want?
Is it:
You also don't have any deterministic timing. How often should the loop spin per second?
06-14-2011 02:30 AM - edited 06-14-2011 02:33 AM
06-14-2011 09:23 AM
The reason I used the feedback node was that the OP specified that the first input needed to be used for the initial value. Unless you read the input outside the loop to initialize the shift register you would require some test within the loop to verify whether this is the first time through the loop. Having this test within the loop is wasted processing since it is only meaningful one time. the feedback node allowed the initial value to be initialized inside the loop and eliminated the conditional test.
06-14-2011 09:26 AM
However, if the shift register is initialized with zero, the first value can be added and it would be the same as using the plain fit value the first time.
06-14-2011 09:52 AM
Hi Nitzz, and thank you. Yes, you are right, that an important part of my question was about shift registers. Regarding the code you offered, it looks to me like the OUTPUT value will always be zero because the initial input value is not linked to the increment function. Using your code, how do we get the first OUTPUT value generated from the INPUT value of the first TRUE case? The whole chain of values that are produced through the increment multiplier (or equivalently an addition function) needs to be based on the first INPUT value.
Thanks,
Dave
06-14-2011 12:46 PM
Hi,
Thanks for your question. I intend to increase the value with each TRUE case, and it actually doesn't matter to me whether it is by multiplying or by adding. Either way will work. As I optomize my mechanical system, I should be able to determine by experiment, how much increase is required, and whether it is more convenient to use a multiplier or an addition system. I think that they are interchangeable. In the example code that I listed, my intention was to start with an approach equivalent to your number 2 below, i.e. [New output] = [threshold increment] * [old output]. In this case, the threshold increment would be some number greater than 1.
Regarding the frequency, I would like the code to execute as fast as possible, but, I am writing to a controller over a 9600 baud line, so, that is my limitation. I am in discussions with the vendor of the controller to determine how many commands per second it can receive. But, actually, the spins per second is a lower priority for me at this moment than just getting this increment code doing what I want it to do. How do you put in deterministic timing?
Thanks again,
Dave
06-14-2011 12:47 PM
Hi Mark,
Thank you very much for the sample code. I am anxious to try it. Will you kindly tell me what the name of the function at the top of the box is, with the arrow pointing left? I have not seen that one before.
Thanks,
David