Your questions are moving further and further away from the original topic in this thread. In the future, please start a new thread for any issues not related to the original question.
I don't actually use the PID Toolkit/Control Design Simulation Module, but you definitely don't want to be creating/starting/stopping/clearing your task inside your Control & Simulation Loop. It should be more like this (using a While Loop because I don't have the Control Design Simulation Module):
Are you saying the output is not being set to 0 despite writing a 0 to the task? This doesn't make much sense--I think the problem is more likely within the context of your application (i.e. does "I/O of switch" get set to FALSE while the loop is still running?).
As for the formula node, you're getting a big number because you are dividing by 0:
L, C, R, B, H, and y are all int32s yet you are trying to assign them decimal values. They are getting coerced (implicit cast) to the closest int32 (which happens to be 0). Dividing by 0 results in NaN, but since y is an int as well this is coerced to the max value of int32 (2147483647). Make all of your variables float64 in the formula node.
Thank you so much for your prompt reply! I will follow your direction and start a new thread if there is new questions.
But I have to mention the question that why the input signal ai6 and ai7 can't get the data at the same time? This problems puzzled me long time, I marked the problems in the last post attachment. Would you please kindly give me some suggestions?
Thanks a lot once more!
I think the most likely explanation is if you were using the single channel variant of convert to dynamic data. It should be configured as shown below (double-click the Convert to Dynamic Data express VI on the block diagram to get the configuration window):
It's impossible to tell from the screenshot though since the icon for single channel and multiple channels is the same.
By the way, you can use the index array function on the array of DBL instead of converting to dynamic data and then using Split Signal.
Another possibility would be if the scale isn't what you think it is for ai7 (I can tell you're using a scale since the data from ai6 reads 6.58E+5).
I can't say for sure without knowing what's inside this:
Your troubleshooting is so prompt!! Actually, the icon that you are not sure about is the two input channels(I guess), because I use the same DAQ assistant to get the two analog ai6, ai7 signals and then transfer to the code automatically. I will follow your direction and see what happens.
Thank you so much!!
As for the problems that I listed last post, your direction is very good! But only the calculation problems puzzled me for the whole weekend. Please have a look at the attachment.
I had thought it's peanut. But I tried many times, it's always the same error, I don't know why?
Would you please have a look? Thanks a lot!
Use periods ('.') instead of commas (',') for the decimal points.
You are definitely Labview expert!!! Would you please tell me the reason why? Actually, I had thought that I just input the decimal "." from the Num Lock keyboard, but it automatically changed to ",", now I find in USA keyboard is the same ".", but in Italy keyboard is ",". How do you think about it?
Thank you very very much!
Italy is one of the countries that uses a comma instead of a period as a decimal separator for everyday use, but this doesn't carry over to programming languages (which must follow a certain pre-defined syntax).
I suppose if C had originated in Italy (as opposed to the United States) we might be using different syntax today...
I have to ask help once more for the absolute encoder. Please refer to the attachment.
I keep the shaft of the encoder stationary. Theoretically, the output shaft should be a horizontal line.
But the line changed automatically. What's more, the scope of the angle I would like to measure in 120 degree.
I don't know why like this? And also, if I change the value I mark in the attachment, the output will be changed somehow.
I'm wondering that the setup value is reasonable or not? How can I adjust the value to the right one?
Looking forward to your reply.Thanks a lot!
The timing in the original example was based off of this:
You changed the "time interval" to 5 us for some reason--it was 500 ns in the original example. I would leave this at 500 ns, but going higher than this shouldn't be an issue as far as I can tell from the data sheet.
Change the timing inputs to the ctr2 task (which were all 1E-7 in the original example) to 4E-7. I was reading the "data output valid wrong"--you must wait at least this long (375 ns) before reading.
The sample rate on the digital input task shouldn't make any difference.
Anyway, if changing the timing on the ctr2 task doesn't help, I would check the DAQ outputs (CS and CLK) with a scope to make sure you are getting what you think you should.