From: James on 15 Feb 2010 13:04 I'm using the Simscape temperature sensor to provide input to a Simulink block. I keep getting a 'divide by zero' error in the Simulink block and it appears that the Simulink output port of the Simscape temperature sensor is zero during initialization despite the fact that the sensor is connected to a thermal mass that has a nonzero intial temperature. How do I get the initial temperature of the thermal mass to be the intial condition coming out of the Simscape's Simulink port?
From: James on 16 Feb 2010 10:49 "Arnaud Miege" <arnaud.miege(a)nospam.mathworks.co.uk> wrote in message <hldrdt$aju$1(a)fred.mathworks.com>... > > "James " <jclawson(a)stellarsolutions.com> wrote in message > news:hlc2aj$ao9$1(a)fred.mathworks.com... > > I'm using the Simscape temperature sensor to provide input to a Simulink > > block. I keep getting a 'divide by zero' error in the Simulink block and > > it appears that the Simulink output port of the Simscape temperature > > sensor is zero during initialization despite the fact that the sensor is > > connected to a thermal mass that has a nonzero intial temperature. How do > > I get the initial temperature of the thermal mass to be the intial > > condition coming out of the Simscape's Simulink port? > > > > You probably haven't connected your temperature sensor block correctly. Have > a look at the 3 thermal demos that come with Simscape. For example, in the > DC motor thermal circuit example, there is a temperature sensor connected to > the rotor thermal mass. The thermal mass has an initial temperature of 300 > K, and the initial value out of the sensor block is also 300 K, as can be > seen on the scope. > > Temperature is an across variable, which means you are measuring a > temperature difference between ports A & B of the sensor block. If those > ports are at the same temperature (because of what they are connected to), > then the temperature difference will be zero. My guess is that's what's > happening in your case. > > HTH, > > Arnaud > I believe it to be wired correctly. It's tied to a thermal mass with an initial temp and the zero reference on the other port. However, it might not be the problem. I'm chasing down a divide by zero error at startup. The displays that I've hooked up to the temp sensor flash zero at sim start and I thought that might be the issue. I've since put together a simpler model and they seem to work fine. I'm calculating the effectiveness of a fluid to fluid heat exchanger. I have a lookup table for the Cp of each fluid based on the average temperature of each fluid (Tin+Tout)/2 and multiply by mass flow of each fluid to determine the Cmin and Cmax. Together with the UA of the heat exchanger I calculate the effectiveness, but one of the inputs involves dividing Cmin by Cmax and this is where the error is popping up. I've constrained the min output of the Min and Max blocks, but I still get the error. I've tried both using all PS blocks and all Simulink blocks. I had a related question with regards to the PS Lookup table. As I mentioned, I'm using the lookup to get Cp based on temperature. So, my input has temperature units and my output has Cp units. The PS Lookup table doesn't seem to support this type of cross unit lookup and I can't figure out how to apply the Cp units after the lookup. Is the only way to multiply by a new unit by using the Sim to PS converter to apply units to an input? Why can't I apply units to a constant block?
From: Arnaud Miege on 16 Feb 2010 05:18 "James " <jclawson(a)stellarsolutions.com> wrote in message news:hlc2aj$ao9$1(a)fred.mathworks.com... > I'm using the Simscape temperature sensor to provide input to a Simulink > block. I keep getting a 'divide by zero' error in the Simulink block and > it appears that the Simulink output port of the Simscape temperature > sensor is zero during initialization despite the fact that the sensor is > connected to a thermal mass that has a nonzero intial temperature. How do > I get the initial temperature of the thermal mass to be the intial > condition coming out of the Simscape's Simulink port? > You probably haven't connected your temperature sensor block correctly. Have a look at the 3 thermal demos that come with Simscape. For example, in the DC motor thermal circuit example, there is a temperature sensor connected to the rotor thermal mass. The thermal mass has an initial temperature of 300 K, and the initial value out of the sensor block is also 300 K, as can be seen on the scope. Temperature is an across variable, which means you are measuring a temperature difference between ports A & B of the sensor block. If those ports are at the same temperature (because of what they are connected to), then the temperature difference will be zero. My guess is that's what's happening in your case. HTH, Arnaud
From: Arnaud Miege on 16 Feb 2010 12:15 "James " <jclawson(a)stellarsolutions.com> wrote in message news:hleeph$6l7$1(a)fred.mathworks.com... >> > I believe it to be wired correctly. It's tied to a thermal mass with an > initial temp and the zero reference on the other port. However, it might > not be the problem. I'm chasing down a divide by zero error at startup. > The displays that I've hooked up to the temp sensor flash zero at sim > start and I thought that might be the issue. I've since put together a > simpler model and they seem to work fine. > > I'm calculating the effectiveness of a fluid to fluid heat exchanger. I > have a lookup table for the Cp of each fluid based on the average > temperature of each fluid (Tin+Tout)/2 and multiply by mass flow of each > fluid to determine the Cmin and Cmax. Together with the UA of the heat > exchanger I calculate the effectiveness, but one of the inputs involves > dividing Cmin by Cmax and this is where the error is popping up. I've > constrained the min output of the Min and Max blocks, but I still get the > error. I've tried both using all PS blocks and all Simulink blocks. > > I had a related question with regards to the PS Lookup table. As I > mentioned, I'm using the lookup to get Cp based on temperature. So, my > input has temperature units and my output has Cp units. The PS Lookup > table doesn't seem to support this type of cross unit lookup and I can't > figure out how to apply the Cp units after the lookup. Is the only way to > multiply by a new unit by using the Sim to PS converter to apply units to > an input? Why can't I apply units to a constant block? > I think the zero temperature is a non-issue. If you solve your other problem and get the model to run, this shoudl go away. I would have thought that using a PS saturation block on the output of the PS Lookup table to make sure it is strictly positive before doing the division should fix it. You might want to contact tech support if it doesn't. Also trying on a simpler model with the just the blocks that you believe are causing the problem (as you have done) often helps in finding where the issue actually is (more often than not, it's not where you think it is :-)). The various physical signal blocks do not support unit propagation. I believe the only workaround is to make sure that the output of your PS Lookup table is in the same units as the physical input port it is connected to and make sure that the units are consistent. Again, a constant block needs to bein the same unit as the port it feeds into. You might want to double-check with tech support. For example, I have just tried feeding a PS Constant block of 1 into an Ideal Angular Velocity Source, and actually measuring the angular velocity and feeding to a display block through a PS to Simulink converter block. Because the source code for the Ideal Angular Velocity Source is defined as inputs S = { 0, 'rad/s' }; % S:bottom end then that "1" output of the constant block is in rad/s. If I change the unit in my PSS block to rpm, I get 9.549 in the display block, which is right, since 9.549 rpm = 1 rad/s. HTH, Arnaud
|
Pages: 1 Prev: Play Matlab Movie from GUI Next: Changing the MKL version in MATLAB |