Data logger
Last updated
Last updated
Assoc. Prof. Wiroon Sriborrirux, Founder of Advance Innovation Center (AIC) and Bangsaen Design House (BDH), Electrical Engineering Department, Faculty of Engineering, Burapha University
data logger เป็นอุปกรณ์สำหรับบันทึกข้อมูลเซนเซอร์พร้อมกับค่าเวลาจริงที่รับค่าจากเซนเซอร์ หลักการทำงานของ data logger จะเป็นการรับค่าสัญญาณ analog จากเซนเซอร์มาแปลงเป็นข้อมูล digital แล้วเก็บเป็นชุดข้อมูลที่ประกอบด้วย ค่าเซนเซอร์ และเวลาที่ได้รับค่าเซนเซอร์ มาเก็บไว้ในหน่วยความจำ สำหรับ data logger จะมีทั้งเป็นอุปกรณ์สำเร็จรูปที่มาพร้อมกับเซนเซอร์ โดยสามารถวัดค่าเซนเซอร์และเก็บข้อมูลได้ในตัว หรือเราสามารถสร้างdata logger ได้โดยใช้บอร์ดสมองกลฝั่งตัวในการเขียนโปรแกรมให้อ่านค่าเซนเซอร์และเวลา บันทึกลงไฟล์ต่าง ๆ เช่น .txt .csv .json เป็นต้น
เครื่องคอมพิวเตอร์ หรือ บอร์ดสมองกลฝั่งตัว (Embedded boards) สามารถอ่านข้อมูลจาก data logger เพื่อนำไปใช้งานต่าง ๆ เช่น การแสดงกราฟข้อมูลเซนเซอร์ในแต่ละช่วงเวลา หรือการนำข้อมูลไปวิเคราะห์เปรียบเทียบข้อมูลแต่ละช่วงเวลา( time series) เป็นต้น
ไลบารี่สำหรับเขียนและอ่านไฟล์ของ c++ โดยกำหนดประเภทสำหรับการทำงานเป็นดังนี้
สำหรับการเริ่มต้นใช้งานให้ทำการ include ไลบารี่ fstream
Class
Description
ifstream
ใช้สำหรับอ่านข้อมูลจากไฟล์
ofstream
ใช้สำหรับสร้างไฟล์ และเขียนข้อมูลลงไฟล์
fstream
ใช้สำหรับเขียนและอ่านไฟล์