0% found this document useful (0 votes)
382 views10 pages

Arduino and LabVIEW - All

This document provides instructions on how to connect an Arduino board to LabVIEW software to monitor temperature data from an LM35 sensor. It describes setting up the LabVIEW VI and blocks, writing the Arduino code, and includes diagrams of the LabVIEW front panel and block diagram.

Uploaded by

Solo Nunoo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
382 views10 pages

Arduino and LabVIEW - All

This document provides instructions on how to connect an Arduino board to LabVIEW software to monitor temperature data from an LM35 sensor. It describes setting up the LabVIEW VI and blocks, writing the Arduino code, and includes diagrams of the LabVIEW front panel and block diagram.

Uploaded by

Solo Nunoo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 10

let's make

Login(/account/login)
Explore(/tag/typeid/)
| SignUp(/account/gopro?sourcea=header${sourceaurlParams})
Publish(/about/create.jsp)

Featured: share what


IntelIoT(/id/intel/)
LaserCutting(/tag/typeid/categoryworkshop/channellasercutting/)
you make
(/)
LifeHacks(/tag/typeid/categoryhome/channellifehacks/)
Fusion360(/id/Fusion/)

ArduinoandLabVIEW byDeyson(/member/Deyson/)
Download(/id/ArduinoandLabVIEW/?download=pdf)

h(/id/ArduinoandLabVIEW/)
Collection

5Steps
IMadeit!

Favorite

Share

AboutThisInstructable
License:

8 59,444views
95favorites

Deyson
(/member/Deyson/)
Follow
(/file/FP5ADMOI697Q7Q0/)

29

(/member/Deyson/)
Bio:Dude!
MorebyDeyson:

ThisinstructableisaquicktutorialexplaninghowtoconnectyourArduinoto
LabVIEWthoughtUSB.
YoulllearnhowtosendastringandreceivedataavailableatUSBport.

(/id/Android

Firstofall,CprogrammingskillsandLabVIEWdiagramblockknowledgewill
help.
Youwillneed:

BluetoothControlLEDPart2/)

ArduinoUNO
LM35(Orothersensor)
LabVIEWSoftwarewithNIVISADriver

(/id/LEDControl

ThistutorialwillnotexplainhowLM35sensorworks.Seeitsdatasheet
(http://www.ti.com/lit/ds/symlink/lm35.pdf).
What'sLabVIEW?

usingArduinoBluetoothandAndroidPa/)

LabVIEW(LaboratoryVirtualInstrumentEngineeringWorkbench)isavisual
programminglanguagedevelopedbyNationalInstruments.It'sveryusefulfor
dataacquisition(purposeofthistutorial),instrumentcontrol,industry
automations.
Arduino?
Arduinoisanopensourcecomputerhardwareusedtodevelopinteractive
objects,takinginputsfroma
varietyofswitchesorsensors,andcontrollingavarietyoflights,motors,and
otherphysicaloutputs.
Arduinoprojectscanbestandalone,ortheycancommunicatewithsoftware
runningonyourcomputer(e.g.Flash,Processing,MaxMSP.)Theboardscanbe
assembledbyhandorpurchasedpreassembledtheopensourceIDEcanbe
downloadedforfree.(fromArduino(http://arduino.cc/en/guide/introduction)).

(/id/Arduinoand

LabVIEW/)
Tags:

Arduino(/tag/typeid/keywordArduino/)

Labview(/tag/typeid/keywordLabview/)
LabVIEW(/tag/typeid/keywordLabVIEW/)
LM35(/tag/typeid/keywordLM35/)
ArduinoandLabVIEW(/tag/typeid/keywordArduino%20and%20LabVIEW/)

ConnectingArduinotoLabVIEW(/tag/typeid/keywordConnecting%20Arduino%20
microcontroler(/tag/typeid/keywordmicrocontroler/)

Ad

Data(/tag/typeid/keywordData/)

DStv
255.00GhcZappaHDDecoderOnly...
JumiaGhana

Aquisition(/tag/typeid/keywordAquisition/)
and(/tag/typeid/keywordand/)

Related

Step1:LabVIEW:VI's

(/file/FTEMGR1I697QJB5/)

LabVIEW.
1CreateanewVIinFile>NewVI.
2Gotoblockdiagramwindow.AtDataCommunication>Protocols>Serial
selectsomeVI.
3Pick:
VISAConfigureSerialPort:setsuptheserialport.
VISAWrite(2x):writesthedatatothedeviceconnected.
VISARead:readdataavailableatserialportfromthedeviceconnected.
VISAClose:closestheconnectionestablished.
BytesatSerialPort:checksiftheresdataavailable.

DStv

DStv
255.00 Ghc

255.00 Ghc

Zappa HD
Decoder Only...
Jumia Ghana

Zappa HD
Decoder Only...
Jumia Ghana

Step2:LabVIEW:StructuresandJoiningtheDots

(/file/FDWBHZTI697Q6HI/)

HowtoInstallLabVIEW
HomeBundle(/id/Getting
StartedwithLabVIEWHome
Bundle/)
(/id/Getting bySudharsanSukumar
GettingStartedWiththe
RaspberryPi2(LabVIEW)
(/id/GettingStartedWiththe
RaspberryPi2LabVIEW/)
(/id/Getting bySudharsanSukumar
Howtoreadanarduinocard
usingLabVIEW(/id/Howto
readanarduinocardusing
LabVIEW/)
(/id/Howto byDavidW44
GettingstartedwithLabVIEW
andArduino(Complete
tutorials)(/id/Gettingstarted
withLabVIEWandArduino/)
(/id/Getting byMageshJayakumar
Temperature/Humidity
Sensor+Arduino+LabVIEW
DataAcquisition
(/id/TemperatureHumidity
SensorArduinoLabVIEW
(/id/TemperatureHumidity

(/file/FYJJ1YOI697Q6JC/)

(/file/F3IBJ3QI697Q6L7/)

(/file/FIAW13KI697Q6JD/)

(/file/F57E91II697Q6L8/)

(/file/F9H98L1I697Q6OU/)

ShowAllItems

4ItstimetoJointhedots
4.1CreateawhileloopinProgramming>Structures>WhileLoop.(Pict.1)
4.2CreatethreeCasestructuresinsideofwhileloopinProgramming>
Structures>CaseStructure.(Pict.2)
4.3ThefirsttwoCaseareforwritingastringandthelastoneforreading.(Pict.
3)
4.4TheVISAConfigureSerialPortandVISAClosegooutsidethewhileloop.
(Pict.3)
YoucanputVISAConfigureSerialPortinsidethewhileloop.Theexample
above,yougottachoosetheCOMPortfirstbeforerunningthevi,butifyouput
insidetheloopyoucanchoosetheCOMPortanytime.
4.5VisaBytesatPortgoesinsidewhileLoop.ToactivatetheReadingcase,it
hastocheckifthebytesatserialportaregreaterthan0usingaProgramming
>Comparison>Graterthan0VI.(Pict.4)
4.6Ifthebytesatportaregreaterthan0,theTrueCaseStructurewillbe
activatedandtheVISAReadwillreturnthebytesread.
4.7VISAConfigureSerialPortshouldlettheuserchoosewhichserialportto
useandsetupthebaudrate,soVisaresourcenameandBaudRatemustbe
acontrol.Thedefaultbaudrateis9600.(Pict.4)
4.8CreateacommandatVISAWrite>WriteBuffer.Thatstringwillbewritten
toUSBPort.ThistutorialusesTOforTurnOnandTFforTurnOff.(Pict.5)
Ifyouwanttosendcommandsfromkeyboard,youcanusejustoneVISAWrite
andcreateacontrolfor
inputstring.Thistutorialusesbuttons.
5GotoFrontPanelwindowtocreateanuserinterface.
5.1Toshowthedatareceived(temperature),ItdbenicetohaveoneNumerics
>ThermometerandaGraphIndicators>Chart.(Pict.6)
5.2Addthebuttons(Buttons>OKButton)toturnon/turnoffthesensor.
ChangetheMechanicalActiontoSwitchUntilReleasedandaddnuminds
(NumInds>NumIndicator)toseethetemperature.
YoucanalsoaddsomecaptionslikeUSBControlandLM35(Pict.7)
6ReturntoDiagramBlockwindowtosettheButtons,Graph,Thermometer
andNuminds.
ToshowthedatareceivedfromtheUSBPort,itneedstobeconvertedfrom
stringtonumber:
Programming>String>String/NumberConvertions>Fract/ExpStringto
Number:convertsstringtonumber.ThisVImustbeaddedinsidetheread
casestructuretomakesurethatalldatareceivedwillbeconverted.
TheStringinputofthisVIisconnectedtoreadbufferofVISARead.(Pict.8)
7NowconnecttheGaph,ThermometerandNumindtotheNumberoutput
ofFract/ExpStringtoNumber.(Pict.9)
8Connecttheturnonbuttontothefirstcasestructures,theturnoffbuttonto
thesecondcaseandstopbuttontoWhileLoopCondition.(Pict.10)
9Duetothefastprocess,addsomedelayinthewhileloopProgramming>
Timing>Wait(ms)towait600ms,tomakesurethealldatahasbeen
received,oncethearduinowillrefreshthedataevery500ms(SeeArduino
Code).(Pict.10)

VISAConfigureSerialPortisinsidethewhileloopinthe10thpicture.

Step3:LabVIEW:Optionals

(/file/FOL02F9I697R7G9/)

(/file/FLJIVR2I697R96H/)

(/file/FCIQAAHI697R98S/)

(/file/FED06BDI697R7IO/)

YoucancheckiftheUSBPortisavailable,orevencheckiftheresakindof
errorwiththeCOMPort.
This(Programming>DialogandUserInterface>FindFirstError)VI
returntrueiftheresanerror,theniftheCOMportdidntreturnanerror,its
available,otherwise,anerrorwasthrown(Pict.1,3)
Youcancreateanerrorhandler(Programming>DialogandUser
Interface>SimpleErrorHandler).
Itllindicateanerror,whereitisandadescriptionoftheerror.(Pict.2,3).
YoucanalsoresettheVIeveytimeitruns,justusetheVIServerReference
(Programming>ApplicationControl>VIServerReference),andInvoke
Node(Programming>ApplicationControl>InvokeNode).(Pict.4)

Step4:ArduinoCode
1Defineallvariablesandpinsyoulluse.Inthiscase:
1Led(ArduinosLED)
1LM35.
charcommand;
Stringstring;
#defineled13
#definelmA1

2VoidSetup.

voidsetup()
{
Serial.begin(9600);
pinMode(led,OUTPUT);
}

3VoidLoop.
voidloop()
{
if(Serial.available()>0)
{string="";}

while(Serial.available()>0)
{
command=((byte)Serial.read());
if(command==':')
{
break;
}

else
{
string+=command;
}

delay(1);
}

if(string=="TO")
{
TempOn();
}

4Inthecodetherearetwofunctions,TempOn()andTempOff().Theycontrol
thesensor.
4.1:TempOn()isafunctionthatstartsthemeasure:
Youcanuseothersensororevenjustturnon/turnoffleds,allyouhavetodois
changethefunctions
voidTempOn()
{
intx=analogRead(lm);
floattemp=(5.0*x*100.0)/1024.0;
Serial.println(temp);
digitalWrite(led,HIGH);
delay(500);
}

4.2:TempOff()isafunctionthatstopsthemeasure:
voidTempOff()
{
digitalWrite(led,LOW);
delay(500);
}

CodeExplanation:
Thevoidloopisthemostimportantepartofthecode.It'llcheckiftheres
somethingattheSerialPort,thatswhySerial.available()isusedtocheck
bytes.
Ifitsavailable,astringofthosebytesmustbecreated,thenSerial.read()do
thetrickandthecodeline
string=+string+command;

storesthefullcommand.
Thatsitfolks.

Step5:Download
LabVIEW2012VI

ArduinoCode
Ifthere'ssomeerrors,pleasecorrect.
Thanks.

LabVIEW_Write_Read.ino(/files/orig/FVS/9HIR/I697RGW1/FVS9HIRI697RGW1.ino)

ArduinoandLabVIEW.vi(/files/orig/FD7/C8LX/I697RGWP/FD7C8LXI697RGWP.vi)

Ad

DStv
255.00GhcZappaHDDecoderOnly...
JumiaGhana

Wehaveabenicecommentpolicy.

Pleasebepositiveandconstructive.

wIMadeit!

AddImages

IanM180(/member/IanM180)

PostComment

adayago

Reply

2monthsago

Reply

heyihaveaquestion.WhatisASRL6::INST?

MoleiW(/member/MoleiW)madeit!

Hi,
Thereisasmallerrinyourvifile.Forthewritecases,youputthestringas"LT"
and"DT",whichshouldbereplacedby"TO"and"TF".Thetutorialisright,just
theattachedVI.
Thankyou,thetutorialisveryniceandhelpful.

(http://cdn.instructables.com/F6A/YFV8/IKYGCOLI/F6AYFV8IKYGCOLI.LARGE.jpg)

andromeda2020(/member/andromeda2020)

3monthsago

Reply

Hi,canIgettheVIfile?Itisalittlehardtofollowyour
instructionsthanks.

andromeda2020(/member/andromeda2020) . andromeda2020
(/member/andromeda2020)

ooopssillymethedownloadlinkisthereattheend
ofthetutorial

3monthsago

Reply

JangTaeho(/member/JangTaeho)

9monthsago

Reply

Hello!
IamtryingtocommunicatebetweenArduinoDUEand
LabviewforDCmotorfeedbackcontrol.
Now,icancontrolDCmotorusingPWMsignalgivento
DUEfromLabview.
But,whenireceivetheencodersignalfromDUEthrough
VISAfunction,
theencodersignalisnotstable.Itjumpsfrequently.
Iwnoderifyoucanhelpme.
thankyou.
/////////////////////////////////////////////////////////////Arduino
code/////////////////////////////////////
intR_in1=22//Motordriverpin1
intR_in2=24//Motordriverpin2
intR_PWM=2//PWMoutpin
longreadNumber=0
floatA
floatIn1,In2,pwm,newtime
floatnewposition1=0
unsignedintAold1=0
unsignedintBnew1=0
unsignedintAold2=0
unsignedintBnew2=0
volatilelongencoder1Pos=0
volatilelongencoder2Pos=0
intencoder1PinA=52//EncoderApin
intencoder1PinB=53//EncoderBpin
voidsetup(){
pinMode(R_in1,OUTPUT)
pinMode(R_in2,OUTPUT)
Serial.begin(115200)
Serial.flush()
pinMode(encoder1PinA,INPUT)
digitalWrite(encoder1PinA,HIGH)//turnonpullupresistor
pinMode(encoder1PinB,INPUT)
digitalWrite(encoder1PinB,HIGH)//turnonpullupresistor
attachInterrupt(encoder1PinA,d1EncoderA,CHANGE)
attachInterrupt(encoder1PinB,d1EncoderB,CHANGE)
}
voidloop(){
if(Serial.available()){
//castthestringreadinaninteger
readNumber=Serial.parseInt()
}
newposition1=((encoder1Pos/19)/52)*2*PI//Encoder
signal
digitalWrite(R_in1,LOW)//Motorrotationdirectioncontrol
digitalWrite(R_in2,HIGH)//Motorrotationdirectioncontrol
analogWrite(R_PWM,readNumber)//PWMwrite
Serial.println(newposition1)
//delay(5)//50msloopinterval
}
////////////////////////////////////////////////////////////////////////
//EncoderRead///////////////////////////////////////////////
voidd1EncoderA()
{
Bnew1^Aold1?encoder1Pos++:encoder1Pos
Aold1=digitalRead(encoder1PinA)
}
voidd1EncoderB()
{
Bnew1=digitalRead(encoder1PinB)
Bnew1^Aold1?encoder1Pos++:encoder1Pos
}
///////////////////////////////////////////////////////////////end/////////////////////////////////////////////////////

(http://cdn.instructables.com/FJY/QV4Q/ICO0DEXJ/FJYQV4QICO0DEXJ.LARGE.jpg)

BilalMubdir(/member/BilalMubdir) . JangTaeho(/member/JangTaeho)

Dearfriend,mayIhaveacopyfromyour.vifile??

tmoir(/member/tmoir)

Reply

3monthsago

ayearago

Reply

Deyson(/member/Deyson)(author) . tmoir(/member/tmoir) ayearago

Reply

CanyouprovidetheLabviewVisplease,itishardtofollow
yourdiagram

Thanksforcommenting.I'mgoingtofixthetutorialdiagram.
http://www.instructables.com/id/ArduinoandLabVIE...
(http://www.instructables.com/id/ArduinoandLabVIEW/#step5)
Ifyouwantforadifferentversion,justask.

BilalMubdir(/member/BilalMubdir) . Deyson(/member/Deyson)

YesIwantitin2010versionifyoudon'tmind

BilalMubdir(/member/BilalMubdir)

Reply

3monthsago

3monthsago

Reply

5monthsago

Reply

6monthsago

Reply

7monthsago

Reply

Hellofriend,
Wouldyoupleaserecompilethe.vifilein2010version?
becauseIhaveLabview2010.
Thankyouinadvance

KiokoS(/member/KiokoS)

ThankyouIuseditinUltrasonicSensorandtworkedwell
withme.Isitpossibletosenddatatothexaxisaswell?
AsIwanttographdistancegottenfromtheultrasonic
sensorversusanglegottenfromservomotor.
Thankyouinadvance

OuzhanC(/member/OuzhanC)

Thankyouforyourclearandaccurateinstructions

silth(/member/silth)madeit!

Thanksforthetutorial!

(http://cdn.instructables.com/FNG/8COO/IF2WLTTL/FNG8COOIF2WLTTL.LARGE.jpg)

(http://cdn.instructables.com/FJY/VU1Y/IF2WLTTQ/FJYVU1YIF2WLTTQ.LARGE.jpg)

Deyson(/member/Deyson)(author) . silth(/member/silth) 7monthsago

Reply

:)great

X
|
8

tomatoskins(/member/tomatoskins)

ayearago

Reply

OhhowImissLabVIEW!Greatmemoriesfromhighschool!

Deyson(/member/Deyson)(author) . tomatoskins(/member/tomatoskins)
ayearago

:)

Reply

FEATURED CHANNELS

HomeRepair

Knitting

(/tag/type
Survival
id/category
(/tag/type
workshop/channel id/category
home
outside/channel
improvement/)

Newsletter
survival/)

Breakfast
(/tag/type
id/category
food/channel
breakfast/)

Minecraft
(/tag/type
id/category
play/channel

minecraft/)

(/tag/type
id/category
craft/channel
knittingand

crocheting/)

USB
Comics
(/tag/type
(/tag/type
id/category
id/category
WinterDrinks
technology/channel
costumes/channel (/id/Holiday

usb/)

comics/)

Join2million+toreceiveinstant
inspirationinyourinbox.
enteremail

I'min!

Mobile
Downloadourapps!
Android(https://play.google.com/store/apps/details?id=com.adsk.instructables)
iOS(https://itunes.apple.com/app/instructables/id586765571)
Windows(http://apps.microsoft.com/windows/enus/app/7afc8194c771441a959054250d6a8300)

AboutUs

FindUs

WhoWeAre(/about/)

Facebook(http://www.facebook.com/instructables)

Advertise(/advertise/)

Youtube(http://www.youtube.com/user/instructablestv)

Contact(/about/contact.jsp)

Twitter(http://www.twitter.com/instructables)

Jobs(/community/PositionsavailableatInstructables/)
Help(/id/howtowriteagreatinstructable/)

Pinterest(http://www.pinterest.com/instructables)
Google+(https://plus.google.com/+instructables)
Tumblr(http://instructables.tumblr.com)

Resources
ForTeachers(/teachers/)
ArtistsinResidence(/air)
GiftProAccount(/account/give?sourcea=footer)
Forums(/community/)
Answers(/tag/typequestion/?sort=RECENT)
Sitemap(/sitemap/)

TermsofService(http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21959721) |
PrivacyStatement(http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21292079) |
LegalNotices&Trademarks(http://usa.autodesk.com/legalnoticestrademarks/) | MobileSite(http://m.instructables.com)

Drinks/)

Weddings
(/howto/weddings/)

(http://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112)
2016Autodesk,Inc.

You might also like