05-05-2019 07:53 AM
Hi, I am trying to model a step function using a thermocouple. I can acquire the data and display this - showing the step function using the gate and trigger vi. However, I cannot seem to get the curve fitting to work. Instead of the best fit showing a step function, it is looking more like an exponential.
I think it might be to do with my 'location' inputs but I thought this would just be the time channel?
Thanks,
Scot07
05-05-2019 10:27 AM
I haven't (yet) looked at your code, but I'm tempted to say "Of course it looks like an Exponential, since the response I'd expect for a thermocouple to a step input would be an Exponential ..." [Do you know about Resistor-capacitor (RC) circuits, and what the voltage across the capacitor looks like when you connect a battery? Do you know why?]..
On the other hand, you should be able to (trivially!) fit a Step to the data -- before you turn on the juice, measure the voltage -- this is the "base" of your step. Now go out 2-3 time constants and take the mean value where it "levels off" -- this is the size of your step!
Now I'll look at your code, and maybe make another post. [I can not even imagine what you mean by "showing the step function using the gate and trigger vi".]
Bob Schor
05-05-2019 01:00 PM - edited 05-05-2019 01:07 PM
In any case, reduce the VI to something that only contains the data shown in your charts and we might be able to help. Can't be very hard.
05-05-2019 02:04 PM
Here's a very simple way to fit a delayed exponential using conventional code (most advanced users stay far away from express VIs and dynamic data!)
Maybe it can give you some hints:
05-05-2019 04:40 PM
We have been told to use the express VIs so no option to get rid of them!
I've removed the while loop - the reason for the intialize to default was that I was using it in a producer-consumer loop previously and you cannot use a latch mechanism for local variables!
The spike from the initial graph is noise picked up - I've attached a better diagram to show the 'step function' - I'm aware this is not a perfect step function but this is not possible with the hardware.
I know it's possible to use the setup I have to get the output I want but I think I'm not putting the correct input into the Locations terminal of the Curve Fitting Express VI. I did have the wrong setup for this initially but I have now changed this to non-linear but still getting the same issue.
I'm happy with most of the code - I just can't get the best fit to follow the 'step function'
05-05-2019 08:10 PM
As we said, it's not a "Step function" but close to an exponential decay from one to another steady state value. Express VI fitting is not really usable unless you clip the data first so time zero is exactly at the start. Why sets these arbitrary restrictions to use express VIs? Makes no sense. You need to use the right tools for the job.
What parameters are you interested in? Just where the step is? The time constant? The difference between start and end values? Something else? Once you define the problem in detail, we can better see what needs to be done.
05-08-2019 12:05 PM
Maybe I should reword my question:
I have a transient from a thermocouple as it goes from one steady temperature (around 20C) to another temperature (50C). I want to measure the time constant and plot a best fit curve (we have to use the curve fitting express vi). I can clip the data to wherever is best - I was looking at around 500 points before and after the threshold but I can change this to immediate if need be?
I am probably not wiring up (or settting up) the curve fitting express vi. There are no examples from NI that show how to do this.
I assume that the locations input is just the time variable?
Do I need to change the equation and initial guesses in the express vi? If so - what is the best equation to use?
Thanks,
Scot07
05-08-2019 12:24 PM
If you want to include the 500 before points, your nonlinear model needs to reflect that and return a constant y value for all these points.
(Still curious who is forcing you to use express VIs. Completely arbitrary and even dumb restriction.)
05-09-2019 09:34 AM
I eventually got this to work. I just changed the function in the curve fitting vi.
(This is a university assignment and the lecturer wants us to use express vi's - Not what I would use either but them's the rules)
Now to find the time constant...
05-09-2019 10:50 AM
@Scot07 wrote:
I eventually got this to work. I just changed the function in the curve fitting vi.
...
Now to find the time constant...
If you "got it to work" and implemented the function correctly, one of the parameters is the time (or rate) constant already, depending on how you define it. (For example, the fourth parameter here is it)