LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fuzzy based Window motor control for maintaining temperature

Solved!
Go to solution

Hello,

I have to control a window opening/closing DC motor based on temperature. I am trying to make a fuzzy-based code. As I have to operate the same DC motor in two directions (upward (opening) & downward (closing)), I am using two relay switches following the attached diagram.


As my plan, the temperature will be measured first, and the motor will be run (upward/downward). For example, if the temperature is 20C, the motor will run upward and open window 25%, then after 1 hour, if the temperature is 30C, the motor will run upward and the window needs to open 50% (actually, 50-25 =25% more). Similarly, if the temperature is 15C, the motor will run down and the window will close.

 

I need to compare the present temperature reading with previous and take the decision whether the motor will run upward/downward. I was searching for such an option/logic in the LabVIEW which will (1) automatically update/record the previous temperature reading for comparison, (2) select the positive value (the window will open), and a negative value (the window will close). 

 

I have attached my code here. Would anyone help me to solve this problem or give me any better idea, please?

Download All
0 Kudos
Message 1 of 10
(2,415 Views)
Solution
Accepted by topic author Chowdhury_Milon

Hi Milon,

 


@Chowdhury_Milon wrote:

I need to compare the present temperature reading with previous and take the decision whether the motor will run upward/downward. I was searching for such an option/logic in the LabVIEW which will (1) automatically update/record the previous temperature reading for comparison, (2) select the positive value (the window will open), and a negative value (the window will close).


Why don't you use the PID approach you worked on last year?

 

1) use shift registers to hold "previous values". This is pretty basic LabVIEW stuff…

2) set the output range of your fuzzy (or PID) control to a range of -100% to +100%: now it's easy do decide the working direction of the motor. How do you measure the current position of the window pane?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 10
(2,404 Views)

Dr. GerdW,
Greetings. I hope you are fine despite the corona epidemic. Thanks for your quick reply. Actually, the window motor runs very slowly (5rpm). The application of the PID logic wouldn't be a good idea (my thinking). I have modified the code as I have understood. It is not working 😞 😞 . Would you please check it?

As we are using 'shift registers', the previous position will be the present position of the motor. But I am afraid about the 1st run because the shift register will be '0' in that condition, and the motor will run in the opposite direction that time like, (0-30= -30, but it should be 30). Any idea?

0 Kudos
Message 3 of 10
(2,367 Views)

Hi Milon,

 


@Chowdhury_Milon wrote:

Actually, the window motor runs very slowly (5rpm). The application of the PID logic wouldn't be a good idea (my thinking).


Why do you think so?

 


@Chowdhury_Milon wrote:

As we are using 'shift registers', the previous position will be the present position of the motor. But I am afraid about the 1st run because the shift register will be '0' in that condition, and the motor will run in the opposite direction that time like, (0-30= -30, but it should be 30). Any idea?


Simple idea: don't do anything in the first iteration! (A simple case structure, connected to iterator of the loop, will do this.)

But: how do you know the motor/window position in the first iteration (or when your VI starts) at all? You don't seem to measure the position and you don't seem to move the window to a known position (like an end position switch test)…

 

Other questions:

Why do you setup a "Finite Samples" DAQmx task when you are reading samples continuously in the producer loop?

Why do you need to configure the DAQmx input buffer on your own?

I don't think the logic in your consumer loop is right: why do you need to switch both DO channels for a certain amount of time? I thought you want to switch only one relais depending on movement direction!?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 10
(2,358 Views)

Hello Mr.GerdW,

Greetings. I am sorry because I am continuing this conversation. The problem was almost solved, but I couldn't solve one issue yet. The attached LabVIEW code is working well, but facing problem during controlling the window opening/closing motor. The window motor takes 2 minutes to open/close the window fully. But the inside setup takes 5~10 minutes to reach in the target temperature level. As a result, the window motor keeps working (more than 2 minutes) and breaks the window frame. In this situation, how can I control the time limit?

0 Kudos
Message 5 of 10
(2,243 Views)

Hi Milon,

 

I didn't upgrade to LV2020 yet…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(2,237 Views)

Hello Mr. GerdW,

Greetings. I have attached a picture of that LabVIEW code here. Would you please take a look? Thanks in advance.

Chowdhury_Milon_0-1590455948545.png

 

0 Kudos
Message 7 of 10
(2,219 Views)

Hi Milon,

 

all I can detect in this image are those two classic Rube-Goldberg constructs!

What's the point of those Select nodes with TRUE/FALSE inputs? This is just a NOT! And you don't even need a NOT when you use other comparison functions upstream…

 

Why do you need a local variable of "Target" when the terminal is just 100 pixels away? Are you run out of wire?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 10
(2,211 Views)

Mr. GerdW

Thanks for your reply. 'How can I manage the time'-that was the question, as I can't allow/run the motor more than 2 minutes. Would you please focus on this issue?  TIA

0 Kudos
Message 9 of 10
(2,207 Views)

Hi Milon,

 


@Chowdhury_Milon wrote:

'How can I manage the time'-that was the question, as I can't allow/run the motor more than 2 minutes.


I don't see any timing on this image.

The loop certainly iterates much faster than once each 2mins, so it should be easy to control the motor…

 


@Chowdhury_Milon wrote:

Thanks for your reply. … Would you please focus on this issue?  TIA


It's hard to focus with such glaring Rube-Goldbergs! 😊

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 10
(2,201 Views)