Transcript
Page 1: Week12: Interface via LabVIEW€¦  · Web viewsubvi LabVIEW เช่น Init, Close, Write Digital, Read Digital, Write Analog, Read Analog เป็นต้น

523372_Embedded Systems_4(3-3-9)Week01: Arduino BasicWeek02: Arduino Shield Week03: LabVIEW Interface from Arduino via VISAWeek04: LabVIEW Interface from Arduino via LIFA

บทนำ�เนื่องจากการต่อวงจรระหวา่ง LabVIEW กับ Arduino ในการทดลอง

“Week03: LabVIEW Interface from Arduino via VISA” จะมกีารเขยีนโปรแกรมใน 2 สว่น คือ LabVIEW และ Arduino เพื่อใหก้ารพฒันาง่ายขึ้น จงึมกีารพฒันา LabVIEW Interface for Arduino (LIFA) Toolkit ขึ้นมา

แนวคิด คือ สรา้ง Arduino Code แล้วโหลดไปยงั Arduino Board และสรา้ง subvi LabVIEW ใหเ้รยีกใชง้านได้ง่าย แต่เบื้องหลังการทำางานยงัเป็นการสื่อสารอนุกรมระหวา่ง Arduino กับ LabVIEW

o Arduino Code คือ VIFA_Base.pdeo subvi LabVIEW เชน่ Init, Close,

Write Digital, Read Digital, Write Analog, Read Analog เป็นต้น

ก�รทดลอง1/3: เตรยีมก�รณ์1.ติดตั้งโปรแกรม LabVIEW  

Page 2: Week12: Interface via LabVIEW€¦  · Web viewsubvi LabVIEW เช่น Init, Close, Write Digital, Read Digital, Write Analog, Read Analog เป็นต้น

2.ติดตั้ง NI-VISA ด�วน์โหลดได้ท่ี http://www.ni.com/download/ni-visa-5.0.3/2251/en/

3.ติดตั้ง l JKI VI Package Manager (VIPM) Community Edition (Free) ด�วน์โหลดได้ท่ี http://jki.net/vipm/download

4. ติดตั้ง LabVIEW Interface for Arduino ทำ�ต�มวธิด้ี�นล่�งได้เลย (ต้องติดต้ัง JKI VI Package Manager ก่อนนะครบั)

Page 4: Week12: Interface via LabVIEW€¦  · Web viewsubvi LabVIEW เช่น Init, Close, Write Digital, Read Digital, Write Analog, Read Analog เป็นต้น

จะม ีWindows Security Alert คลิก Allow access

ห�กมขีอ้คว�ม VIPM-Batch Process Error ขึน้ม�ให้ แก้ไขดังนี้

Page 5: Week12: Interface via LabVIEW€¦  · Web viewsubvi LabVIEW เช่น Init, Close, Write Digital, Read Digital, Write Analog, Read Analog เป็นต้น

เข�้โปรแกรม Labview เข�้เมนู Tools>>Options.

เลือก VI Server คลิก Add ในชอ่ง Machine name/address ใส่ 127.0.0.0 แล้วคลิก OK แล้วลองติดตั้งใหม่

Page 6: Week12: Interface via LabVIEW€¦  · Web viewsubvi LabVIEW เช่น Init, Close, Write Digital, Read Digital, Write Analog, Read Analog เป็นต้น

5.ติดตั้ง โปรแกรม Arduino (แนะนำ�ให้ติดตั้ง เวอรช์ัน่ 1.0.5) ด�วน์โหลดได้ท่ี http://arduino.googlecode.com/files/arduino-1.0.5-r2-windows.exe

Page 7: Week12: Interface via LabVIEW€¦  · Web viewsubvi LabVIEW เช่น Init, Close, Write Digital, Read Digital, Write Analog, Read Analog เป็นต้น

7.โหลด LabVIEW Interface for Arduino Firmware ลงใน Arduino Borad โดยไปโหลดใน C:\Program Files\National Instruments\LabVIEW 2013\

vi.lib\LabVIEW Interface for Arduino\Firmware\LIFA_Base

Page 9: Week12: Interface via LabVIEW€¦  · Web viewsubvi LabVIEW เช่น Init, Close, Write Digital, Read Digital, Write Analog, Read Analog เป็นต้น

เลือก C:\Program Files\National Instruments\LabVIEW 2013\vi.lib\LabVIEW Interface for Arduino\Firmware\ LabVIEWInterface 

หลังจ�ก Add File Sketch ก็ส�ม�รถโหลดลง Arduino ได้เลย

Page 10: Week12: Interface via LabVIEW€¦  · Web viewsubvi LabVIEW เช่น Init, Close, Write Digital, Read Digital, Write Analog, Read Analog เป็นต้น

2/3: ทดสอบโปรแกรมตัวอย่�ง “Knight Rider KITT LEDs.Vi”

o ให้แน่ใจว�่โหลด “VIFA_Base.pde” ไปยงั Arduino ฺBoard แล้วo เลือก COM Port ให้ถกูต้องก่อนสัง่ RUNo เมื่อโปรแกรมทำ�ง�น จะอ่�นค่�จ�กข� A0 เพื่อควบคมุคว�มเรว็ในก�ร

ติด-ดับ ของ LED จำ�นวน 12 ตัว ท่ีต่อกับ ข� 2- ข� 13

Page 11: Week12: Interface via LabVIEW€¦  · Web viewsubvi LabVIEW เช่น Init, Close, Write Digital, Read Digital, Write Analog, Read Analog เป็นต้น

3/3: ทดสอบโปรแกรมอย�่งง่�ย “Hello LIFA.Vi”

o ให้แน่ใจว�่โหลด “VIFA_Base.pde” ไปยงั Arduino ฺBoard แล้วo เลือก COM Port ให้ถกูต้องก่อนสัง่ RUNo เมื่อโปรแกรมทำ�ง�น จะอ่�นค่�จ�ก Switch สง่ไปยงัข� 13 และอ่�น

ค่� ข� 12 ม�แสดงผล

Page 12: Week12: Interface via LabVIEW€¦  · Web viewsubvi LabVIEW เช่น Init, Close, Write Digital, Read Digital, Write Analog, Read Analog เป็นต้น

คำ�ถ�มJob1/3: ทดสอบก�รทำ�ง�น- Arduino Example: Analog Read - Arduino Example: LCD 4-Wire Example- Arduino Example: Seven Segment Display

Job2/3: Relay Control 2 Relay- จาก LabVIEW control 1 Relay {ON-1 OFF-1}- ใหป้รบัแก้เป็น LabVIEW control 2 Relay {ON-1 OFF-1 ON-

2 OFF-2}- แนะนำาให ้สง่ ‘ 1’ Relay1 On, ‘2’ Relay1 Off, ‘3’ Relay2

On, ‘4’ Relay2 Off

Job3/3: Counter and Display on LabVIEW- Arduino นับการกด PB Switch ทัง้ 2 ตัว- สง่ผลท่ีนับได้แสดงท่ี LabVIEW

อ�้งอิงo http://home.hit.no/~hansha/?

%20equipment=arduino o http://vishots.com/getting-started-with-the-

labview-interface-for-arduino/o https://decibel.ni.com/content/groups/labview-

interface-for-arduinoo http://9thatree.blogspot.com/2014/05/labview-

arduino-labview-interface-for.html#.VSlMMtysXNE


Top Related