LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling motor wired to Arduino from Labview

Hi I have managed to Read values from different sensors wired up to my Arduino. I have been using VISA Serial and VISA Read block for that.Now I want to control a pump based on my Fuzzy logic controller output value.Please view my attached VI. 

What I want to know is if there is a way to control the motor by using VISA Write blocks or do I need to use something else. I tried using these specialized Arduino blocks where you Set Digital PINs etc, but it didn't work.My complete Serial communication got screwed and I couldn't even get the readings correct after that. I am a bit unsure if you can use Arduino blocks with Serial VISA in the same VI.

I need some help on how to control this motor. Basically the output from the fuzzy logic controller is the time for which the motor is suppose to run, so I guess I need some kind of timer as well

Any tips?.....

Thanks in advance....

0 Kudos
Message 1 of 7
(4,840 Views)

Have you tried searching the LabVIEW Forum?  It seems to me that I've seen many posts in the last few months that mention Arduino and LabVIEW, many of those discussing motors.  Do some research on your own, see what others have suggested, try it out, and if you get stuck or it doesn't work, come back with a more complete VI and more specific questions.

 

Bob Schor

 

P.S. -- a Confession -- I wrote the above without looking at your VI.  However, I felt a little guilty about that, so I took a look.  I don't see anything there that has anything (obvious) to do with Arduino!  You need to do a little more organization and planning (maybe "Write the Documentation First"?) of what it is you want to do.  For example, your VI has Temperature, Light Intensity, Humidity, etc., but nothing about a Motor or a Pump (though there is a Reservoir).  It looks like a confusing mish-mash.

 

Here's a suggestion -- try to write code that does one thing, maybe controls a pump based on your Fuzzy Logic Controller Output Value (what's this?  an explanation would be helpful, or perhaps just getting code that controls a pump based on an On/Off Switch, or a Speed Control ...).

0 Kudos
Message 2 of 7
(4,800 Views)

 


@Bob_Schor wrote:

Have you tried searching the LabVIEW Forum?  It seems to me that I've seen many posts in the last few months that mention Arduino and LabVIEW, many of those discussing motors.  Do some research on your own, see what others have suggested, try it out, and if you get stuck or it doesn't work, come back with a more complete VI and more specific questions.


@Bob_Schor wrote:

Have you tried searching the LabVIEW Forum?  It seems to me that I've seen many posts in the last few months that mention Arduino and LabVIEW, many of those discussing motors.  Do some research on your own, see what others have suggested, try it out, and if you get stuck or it doesn't work, come back with a more complete VI and more specific questions.

 

Bob Schor

 

P.S. -- a Confession -- I wrote the above without looking at your VI.  However, I felt a little guilty about that, so I took a look.  I don't see anything there that has anything (obvious) to do with Arduino!  You need to do a little more organization and planning (maybe "Write the Documentation First"?) of what it is you want to do.  For example, your VI has Temperature, Light Intensity, Humidity, etc., but nothing about a Motor or a Pump (though there is a Reservoir).  It looks like a confusing mish-mash.

 

Here's a suggestion -- try to write code that does one thing, maybe controls a pump based on your Fuzzy Logic Controller Output Value (what's this?  an explanation would be helpful, or perhaps just getting code that controls a pump based on an On/Off Switch, or a Speed Control ...).


Hi Bob, thanks for the reply.I have tried researching the forum and I found many posts regarding communication with Labview and Arduino, but many use LINX or LIFA which I tried and it didn't work, si O will use VISA Write and Read blocks etc.

Firstly,to explain my little project quickly.I am working on building an automated monitoring and irrigation system for a potted houseplant.

I measure soil-moisture,temperature,air-humidity and light.I have also an water reservoir from where I pump my water for the plant with a simple peristaltic 12V DC pump.

I have built a fuzzy-logic controller that is really simple, it has one input and one output. Based on soil measurements  we control for how long the pump shall work.If the soil contains 0 to10% moisture then pump shall go VL=VER LONG (100sec), if its 10 to 20% then it shall run L=LONG (50sec) and if its 20 to 30% it shall go SH=SHORT (10 sec) etc. You get the picture.I use fuzzy linguistic hedges.

I have managed to get all my sensor data to be read inside Labview from Arduino but when I try to write from Labview to control my pump-motor in Arduino I have problems.There are issues with serial communication between Labview and Arduino. And it seems that when I try to read and write to/from Labview and Arduino confilcts occur and I am not able to control my pump.

I guess I could use an extra pair of eyes to look at this. Hope you have some suggestions. Thanks.

 

 

 

0 Kudos
Message 3 of 7
(4,745 Views)

@Bob_Schor wrote:

Have you tried searching the LabVIEW Forum?  It seems to me that I've seen many posts in the last few months that mention Arduino and LabVIEW, many of those discussing motors.  Do some research on your own, see what others have suggested, try it out, and if you get stuck or it doesn't work, come back with a more complete VI and more specific questions.

 

Bob Schor

 


Firstly,to explain my little project quickly.I am working on building an automated monitoring and irrigation system for a potted houseplant.

I measure soil-moisture,temperature,air-humidity and light.I have also an water reservoir from where I pump my water for the plant with a simple peristaltic 12V DC pump.

I have built a fuzzy-logic controller that is really simple, it has one input and one output. Based on soil measurements  we control for how long the pump shall work.If the soil contains 0 to10% moisture then pump shall go VL=VER LONG (100sec), if its 10 to 20% then it shall run L=LONG (50sec) and if its 20 to 30% it shall go SH=SHORT (10 sec) etc. You get the picture.I use fuzzy linguistic hedges.

I have managed to get all my sensor data to be read inside Labview from Arduino but when I try to write from Labview to control my pump-motor in Arduino I have problems.There are issues with serial communication between Labview and Arduino. And it seems that when I try to read and write to/from Labview and Arduino confilcts occur and I am not able to control my pump.

I guess I could use an extra pair of eyes to look at this. Hope you have some suggestions. Thanks.

 

 

 

0 Kudos
Message 4 of 7
(4,742 Views)

Looking at your code, I see a VISA Read (presumably from the Arduino) going to a number of controls, and also some Fuzzy Logic functions that do "something".  What you are asking about is driving a pump with the Arduino.

 

Write a new, very tiny, VI that has a control, Pump Speed (or whatever parameter pertains to the Pump, for example a Boolean On/Off if it is a fixed-speed pump) and try to get that program to send data to the Arduino to control the pump.  Don't worry about the sensors, the Fuzzy Logic, or anything else -- your problem is "driving the pump", so write just enough code to drive the pump.

 

I'll defer to your expertise in writing to the Arduino.  I confess that I'm much more comfortable spending a little more and getting, say, an NI USB-6002 that interfaces very nicely with MAX, has multiple A/D and D/A channels, as well as digital I/O, and can be programmed with DAQmx.  It is more expensive, but you definitely "get what you pay for".  [Hmm -- I haven't priced a myDAC against the USB-6002 -- I presume you are a Student, and student prices for myDACs are very reasonable ...].

 

Bob Schor

0 Kudos
Message 5 of 7
(4,734 Views)

Hi Again, I have updated my VI, and here,please view the screenshot of my front panel.

Yes this is a small school project but I have been struggling as I don't have too much experience with neither Arduino nor Labview programming. After a bit of testing back and forward I have discovered that the main issue is on the Arduino side and how Serial information is received and sent between Arduino and Labview.


Bob_Schor wrote:

Write a new, very tiny, VI that has a control, Pump Speed (or whatever parameter pertains to the Pump, for example a Boolean On/Off if it is a fixed-speed pump) and try to get that program to send data to the Arduino to control the pump.  Don't worry about the sensors, the Fuzzy Logic, or anything else -- your problem is "driving the pump", so write just enough code to drive the pump.

 

 

Bob Schor


I have made a small Labview program from which I have managed to control my pump wired to Arduino from Labview frontpanel. Please view the attached motor_VISA file.I have copied this one from a site I found online. 

I guess I was hoping to find some people that have done something similar to this and managed to get  it to work. As this is a fairly simple system where you basically read sensor data from Arduino and start a simple 12V DC motor simply by turning it ON/OFF I assumed it must be a lot out there, but it appeared to be harder to find than I expected.

 

irrigation_CP2.jpg

Download All
0 Kudos
Message 6 of 7
(4,731 Views)

OK, you now have a very simple "Output" VI, let's work on the "Input" VI a bit.  It looks very complicated to me, and very undocumented.  It's not at all clear (from the code) what is being done, what the Fuzzy Logic is doing, etc.  Simplify, simplify, and then when it works, make it more complex!

 

A note on reading from VISA.  Many (don't know about Arduino) VISA devices and protocols like to end their writes with an End of Line signal, often the characters <CR> and <LF>.  You can configure a VISA Open to use a character (such as LF) as a terminator character.  If you've done this, you say to VISA "Read 1000 characters" (knowing you'll never get a 1000-character message).  It gives you, say, 12 characters (up to the Termination Character), which you happily process.  Alternatively, "no-one is talking", and VISA Times Out (you set a TimeOut also when you open VISA).  This can also be useful information, so if it Times Out, you do one thing, otherwise you process whatever it sent you (which will be a complete line, shorter than 1000 characters).

 

Bob Schor

0 Kudos
Message 7 of 7
(4,726 Views)