04-24-2018 04:48 AM
I am unable to integrate a temperature sensor, a photo-sensor and a motion sensor into one VI in LabVIEW. I am doing a small project on smart office and will be using a thermistor, a photoresistor and a motion sensor, but I am unable to make one VI which integrates all 3 together. Can anyone please help?
04-24-2018 05:36 AM
Hi ammes,
but I am unable to make one VI which integrates all 3 together. Can anyone please help?
What have you tried so far?
Where are you stuck?
Which problems occur?
How does your VI look like?
Did you try to use the example VIs coming with LabVIEW?
Which interface(s)/DAQ hardware do you use to communicate with your sensors?
04-24-2018 09:26 PM
I have attached the block diagram. I have tried to communicate with just the temperature sensor. I don't know how to go ahead from here (how to add photo-sensor and motion sensor to this VI). I am using a PSoC to communicate with my sensors. I am a student and I have very limited knowledge of LabVIEW.
04-24-2018 09:42 PM
You have three sensors you want to read from. Do you want to take any actions based on the results, or just read the current values?
When reading the values, should all values be read at the same rate (frequency)? For example, once per second? Or do you want to read the sensors at different rates? Should this be a variable?
If you only need to read the values, first write working VIs for each of the 3 sensors. Then, you can probably copy and paste each while loop into one new VI, with now 3 while loops, and all should run (depending on the interfaces you're using - DAQmx can for example require that multiple channels be in the same task, which will complicate this).
If you only need one rate, you should put all three in the same While loop, and just place them one above another. This would be like copying the contents of each of your 3 While loops into a new loop, rather than the entire loops into a new VI.
04-24-2018 10:22 PM
We want to read the current values and take action on it. For the temperature sensor, if the temp rises above a certain fixed value it should turn on a fan and if temp goes below the fixed value, it should turn off the fan. For the photo-sensor, depending on the illumination inside the room, the photo-sensor should either increase the light intensity or decrease or shut-off the lights. The motion sensor would be used to detect the presence of a person in the room and switch on the lights. If no one is present in the room, it should switch the lights off.
We want to read the values of all 3 sensors differently.
04-24-2018 11:06 PM - edited 04-24-2018 11:07 PM
Some quick follow-up questions:
04-24-2018 11:30 PM
1. me and teammates are not familiar with any other programming language 😞
2. we have actually spent 1 week on it and plan to spend 1 more
3. We don't need to consider different types of sensors.
4. Our supervisors helped us build the VI that I sent earlier. (attached here too)
5. we are using the 2017 version of LabVIEW - 32 bit
04-25-2018 12:01 AM
Ok, so with a week to go it's probably not the time to try too many exotic ideas.
Are all of the sensors connected and communicated with via VISA Serial connections (e.g. RS232 or similar?).
If so, use the sensor manuals to determine the commands necessary to get the values, and use code similar to what you already have to get the other two values.
It might be better to use 3 separate While loops as discussed earlier - each will have its own VISA Resource Name and VISA Configure Serial Port + Close, and in the loops you can use Format to String to structure the messages as needed with the values you need to send. Reading will depend on the response, but either convert directly to numbers as you're doing in the image, if only an image is returned, or use something like Scan from String to get values from a more complicated response.
If turning on and off the lights is done via the same communication as changing the intensity, it might be simpler to have only two While loops and put those two sections in the same loop.
04-29-2018 02:52 AM
we just need to read 3 variables and write 3 variables through USB to a micro controller, right now we can just read and write just 1 variable, but we need to send and receive all the information (from 3 variables) through the same communication bus.
how can we separate the received string in 3 parts? or how can we know which string is which variable? and how can we create 1 string of data with 3 variables?
04-29-2018 03:09 AM
I'm concerned that maybe we're still short some necessary information to make well informed suggestions or give good advice. For example, now you're mentioning a shared bus and microcontroller.
Can you perhaps link to pdf copied of all of the documentation you have for each sensor, or describe in more detail exactly what you're trying to connect to? (Sensor device IDs/part numbers)
What's this microcontroller you mention?
How many USB cables are we talking about? 3 or 1?
In terms of separating a string, can you give an example string that you receive? The actual documentation will probably provide most of the answers needed, so as above, perhaps the best thing to do is upload that PDF.
If you can't give the documentation, the best I can suggest is Scan from String and Format to String with appropriate format strings, but I can't guess blindly what those might be - sorry!