LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Turning on a Device for a Specific amount of Time

Okay so I have created a VI which simulates my fuzzy controller, as you change both the temperature and humidity, you will see the value on the guage change.  This is really the duration of time to turn on the fan and the humidifier.  I didn't include any coding for the arduino as yet, but this VI which simulates my controller is the heart of the project.  The arduino is just used to read in the data every 1 minute and send it to the controller.  Then based on the time, turn on the respective devices simultaneously.  Thats all I am doing in LabView really, so how do I merge my previous VI and this new one so that it resets appropriately.

0 Kudos
Message 11 of 21
(1,635 Views)

Hey man, can you please help me out with this, I am stuck on this last part and I need to figure it out soon for my final year project.

0 Kudos
Message 12 of 21
(1,635 Views)

Well, I can't simply tell you the answer if I knew it (which I don't because I don't know enough about your project and fuzzy logic controllers).

When your "event" occurs (when you need to turn on one of the digital pins) is when you need to reset the "start" time (so that it will enable the pin for X seconds).  You can reset the start time with a simple case structure. 

Are you only executing the fuzzy logic VI once every minute? 

0 Kudos
Message 13 of 21
(1,635 Views)

Okay so I was able to get the two LED to turn on/off for specific durations and repeat for a spcified time (Turning on two LED with Repeat.vi attached).  Now I attempted to merge this with the VI I created for my fuzzy controller. I have attached a zip folder, with the two VI and the combined VI labelled Fuzzy Controller for a greenhouse complete testing.  So I set the temperature and humidity so that I get a positive time value for both and set the time interval for about 30seconds, and when I first run it, the LED comes on for the specific amount of time and repeats, buy when I attempt to change the temperature and humidity to simulate new times about 5 seconds before the 30 seconds (just to simulate what would happen when I get new data from the sensor), nothing happens. The times don't change.  I dont know what I am doing wrong.

Download All
0 Kudos
Message 14 of 21
(1,635 Views)

There are two things in your program that are possible signs that you are probably doing something wrong.  1) More than one stop button and 2) while loops inside of while loops.  The latter can actually be done but care must be taken to prevent the inner while loop from taking too long or executing infinitely.

In your case, you should not be doing either one of the aforementioned things.  To better understand why, you should read up about "data flow" in LabVIEW (this it the number 1 thing that needs to be understood when trying to program in LabVIEW).

Basically, you will need everything to be in the same loop.  This means that you'll need to control when the fuzzy logic controller VIs are executed (only every 60 seconds).  You can basically do the same thing as with the other stuff using timestamps.

0 Kudos
Message 15 of 21
(1,635 Views)

Just another thing that I'd suggest.  If you can't figure it out after learning more about the fundamentals of LabVIEW, I'd highly recommend posting on the general LabVIEW forums.  There are many LabVIEW professionals that are willing to help including many engineers that work for National Instruments. 

Once you get the program working with your LEDs and having the fuzzy logic functions only executing every 60 seconds, add in the Arduino functionality (I'd highly recommend using LINX if at all possible since it's the only Arduino+LabVIEW solution currently supported).  If you have trouble with adding in the LINX/Arduino functionality, feel free to post on the forums:  http://www.labviewhacker.com/forums

P.S.  Don't mention Arduino because they might assume the issues are due to the Arduino and try to send you back over here .  Simply keep with the LEDs like you have in your example program.  You'll probably want to say that you will be getting your sensor data from "a data acquisition device".

0 Kudos
Message 16 of 21
(1,635 Views)

Hi Nathan,

I was able to get the VI to loop the way I wanted it to.  I then created a simple VI to test it out, without using the sensor. I attached it below (Working VI without Sensor.zip) and if you run it you will see the way I want it to work.  You just have to set the time interval 3 and time interval 4 to about 40 you will see the leds come on for the correct amount of time.  I tested this code out using actually leds with the arduino and it worked.  But when I attempted to implement it with my temp/hum sensor (DHT22) using a modified version of your VI I found on another post in this same community I am getting some problems. I have attached some of the ways I attempted to combine my working VI with the VI for the sensor. I am not sure what I am doing wrong.  In some cases the sensor measure the value and displays it but the controller part of the VI does nothing (i.e. the leds dont come turn on and I can see on the VI that no time was set for the leds to turn on).  In another case the sensor does not meaure the temp/hum but it turns on the led but not at the correct time.  For example I see on the VI that the leds should be on for about 5 and 20 seconds, and they turn off on the VI but not when connected to the arduino.  I would appreciate some help in this please.

Download All
0 Kudos
Message 17 of 21
(1,635 Views)

Hi Pastormikes,

There are several little (or major!!)  general errors in your VIs. For  example, you have the pin assignment inside the loop which almost always causes problems.

But most of all, I would say the biggest issue is having parallel loops work properly.

I would be willing to bet! that once the signals get to the arduino loop, they stay there and your other loop(s) do not execute.

My suggestion is that create a more simple (just display a message) for your Fuzzy logic loop(s) and keep the arduino loop(s) as they are and verify that your loops behave the way you want; that is, all of them actually execute.

and if my first assuption is true, you may need to use a more disiplied communication between parallel loops,

such as ques

Regards,

Behzad

0 Kudos
Message 18 of 21
(1,635 Views)

Hi Behzad,

Yeah I'm really new to LabVIEW so I think I meesed up with the loops.  But I was able to get it to partially work today.  I have attached the VI which is partially working (Its within the Windows folder, the name is Fuzzy Controller for a greenhouse complete testing2.vi).  Here's the problem I'm getting with my new VI, the temperature readings are out of sync.  Okay so for example, if i set time interval 3 to 30, and run the VI, initially both temperature and humidity are zero, but after the 30 seconds (set in interval 3) has passed, the temperature and humidity update to the values they were supposed to be initally.  So the data ends up being 30 seconds out of sync.  I thought about reducing the time to about 2 seconds but I then the fuzzy controller wont run properly, since the output from the fuzzy controller is usually greater than 2 seconds and less than 30 seconds (hence why I choose 30 seconds initially). But from my basic knowledge of loops, I don't undertand why the time set for interval 3 is causing the data to be out of sync.  If it had to be anything, I would think it would have time internval 4 that would determine when the data is read.  So I don't know if you can help me out with this problem, its working like it should, its just that the data is out of sync.

0 Kudos
Message 19 of 21
(1,635 Views)

Hi Nathan,

I was able to get it to partially work today.  I have attached the VI which is partially working (Its within the Windows folder, the name is Fuzzy Controller for a greenhouse complete testing2.vi).  Here's the problem I'm getting with my new VI, the temperature readings are out of sync.  Okay so for example, if i set time interval 3 to 30, and run the VI, initially both temperature and humidity are zero, but after the 30 seconds (set in interval 3) has passed, the temperature and humidity update to the values they were supposed to be initally.  So the data ends up being 30 seconds out of sync.  I thought about reducing the time to about 2 seconds but I then the fuzzy controller wont run properly, since the output from the fuzzy controller is usually greater than 2 seconds and less than 30 seconds (hence why I choose 30 seconds initially). But from my basic knowledge of loops, I don't undertand why the time set for interval 3 is causing the data to be out of sync.  If it had to be anything, I would think it would have time internval 4 that would determine when the data is read.  So I don't know if you can help me out with this problem, its working like it should, its just that the data is out of sync.

0 Kudos
Message 20 of 21
(1,635 Views)