Malam hari yang indah ditemani lantunan piano nan mesra, kali ini saya akan menjelaskan mengenai bagaimana cara membuat timbangan digital menggunakan loadcell atau strain gauge dengan modul amplifier HX711, output dari modul HX711 adalah berupa sinyal digital sehingga untuk mengolahnya perlu menggunakan counter. Sebenarnya tidak harus menggunakan modul HX711, pada postingan saya sebelumnya saya menggunakan IC INA114 sebagai amplifiernya, ya memang harganya lebih mahal dari pada HX711, maka dari itu kalau mau cari yang murah pakailah modul HX711, perbedaan keduanya yaitu pada outputnya, jika IC INA114 outpunya berupa tegangan sehingga masuk ke port ADC, jika modul HX711 outputnya berupa data digital sehingga harus diolah menggunakan pin digital atau pwm. untuk lebih jelasnya berikut skema dan programnya.
a. Minimum System
b. Modul HX711
c. Loadcell 5kg
d. Program Bascom AVR
'Dibuat Oleh Yanuar Mukhammad
'Diterbitkan pada august 2015
'Email = yanuarm@hotmail.com
$regfile = "m32def.dat"
$crystal = 12000000
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2
Cls
Cursor Off
Ddrd.4 = 1
Ddrd.5 = 0
Adsk Alias Portd.4 ' use pin D.4 as output sck
Addo Alias Pind.5 ' use pin D.5 as input Dataout
Config Adsk = Output
Config Addo = Input
Dim Count As Long
Dim I As Byte
Dim Hx711_read As Long
Dim Hx711 As String * 10
Dim Datafix As Integer
Do
Addo = 1
Adsk = 0
Count = 0
While Addo = 1
Wend
For I = 1 To 24
Adsk = 1
Shift Count , Left , 1
Adsk = 0
If Addo = 1 Then Incr Count
Next
Adsk = 1
Count = Count Xor &H800000
Adsk = 0
Hx711_read = Count
Hx711 = Str(hx711_read)
Hx711 = Left(hx711 , 3)
Datafix = Val(hx711)
Upperline
Lcd "nilai = " ; Datafix
Waitms 200
Loop
$crystal = 12000000
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2
Cls
Cursor Off
Ddrd.4 = 1
Ddrd.5 = 0
Adsk Alias Portd.4 ' use pin D.4 as output sck
Addo Alias Pind.5 ' use pin D.5 as input Dataout
Config Adsk = Output
Config Addo = Input
Dim Count As Long
Dim I As Byte
Dim Hx711_read As Long
Dim Hx711 As String * 10
Dim Datafix As Integer
Do
Addo = 1
Adsk = 0
Count = 0
While Addo = 1
Wend
For I = 1 To 24
Adsk = 1
Shift Count , Left , 1
Adsk = 0
If Addo = 1 Then Incr Count
Next
Adsk = 1
Count = Count Xor &H800000
Adsk = 0
Hx711_read = Count
Hx711 = Str(hx711_read)
Hx711 = Left(hx711 , 3)
Datafix = Val(hx711)
Upperline
Lcd "nilai = " ; Datafix
Waitms 200
Loop
e. Cara merubah Data Out ke Nilai terukur menggunakan regresi linier
- Siapkan timbangan digital toko yg sudah terkalibrasi
- Untuk kalibrasi pakailah benda yg bisa diatur beratnya (misal : beras, gula, dll)
- Ukur berat beras pakai timbangan digital toko (misal : 100 gram)
- Catat hasil output timbangan dan masukkan ke ms. Excel
- Lalu buat grafik menggunakan scatter
- Pilih add trendline lalu pilih linier
- Maka akan terlihat nilainya
- Masukkan rumus tersebut ke program bascom avr
- Sehingga didapat Rumus
- Masukkan ke program Bascom
$regfile = "m32def.dat"
$crystal = 12000000
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2
Cls
Cursor Off
Ddrd.4 = 1
Ddrd.5 = 0
Adsk Alias Portd.4 ' use pin D.4 as output sck
Addo Alias Pind.5 ' use pin D.5 as input Dataout
Config Adsk = Output
Config Addo = Input
Dim Count As Long
Dim I As Byte
Dim Hx711_read As Long
Dim Hx711 As String * 10
Dim Datafix As Integer
Dim Dataok As Single
Dim Strdatok As String * 5
Do
Addo = 1
Adsk = 0
Count = 0
While Addo = 1
Wend
For I = 1 To 24
Adsk = 1
Shift Count , Left , 1
Adsk = 0
If Addo = 1 Then Incr Count
Next
Adsk = 1
Count = Count Xor &H800000
Adsk = 0
Hx711_read = Count
Hx711 = Str(hx711_read)
Hx711 = Left(hx711 , 3)
Datafix = Val(hx711)
Dataok = Datafix - 859
Dataok = Dataok / 0.047
Strdatok = Fusing(dataok , "#.##")
Upperline
Lcd "nilai = " ; Datafix
Lowerline
Lcd "Berat = " ; Strdatok
Waitms 500
Cls
Loop
f. VIDEO HASILNYA
- Catat hasil output timbangan dan masukkan ke ms. Excel
- Lalu buat grafik menggunakan scatter
- Pilih add trendline lalu pilih linier
- Maka akan terlihat nilainya
- Masukkan rumus tersebut ke program bascom avr
Berat - gr | Output |
0 | 859 |
50 | 862 |
100 | 864 |
150 | 866 |
200 | 868 |
250 | 870 |
300 | 872 |
350 | 874 |
400 | 877 |
450 | 879 |
500 | 882 |
550 | 884 |
600 | 886 |
650 | 889 |
700 | 891 |
750 | 894 |
800 | 896 |
850 | 898 |
900 | 901 |
950 | 903 |
1000 | 906 |
1050 | 908 |
1100 | 910 |
1150 | 912 |
1200 | 914 |
1250 | 917 |
1300 | 920 |
1350 | 923 |
1400 | 925 |
1450 | 927 |
1500 | 930 |
1550 | 932 |
1600 | 934 |
1650 | 936 |
1700 | 938 |
1750 | 940 |
1800 | 943 |
1850 | 945 |
1900 | 948 |
1950 | 950 |
2000 | 953 |
- Sehingga didapat Rumus
y = 0.047x + 859
R² = 0.999
X = (Y - 859) / 0.047 R² = 0.999
- Masukkan ke program Bascom
$regfile = "m32def.dat"
$crystal = 12000000
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2
Cls
Cursor Off
Ddrd.4 = 1
Ddrd.5 = 0
Adsk Alias Portd.4 ' use pin D.4 as output sck
Addo Alias Pind.5 ' use pin D.5 as input Dataout
Config Adsk = Output
Config Addo = Input
Dim Count As Long
Dim I As Byte
Dim Hx711_read As Long
Dim Hx711 As String * 10
Dim Datafix As Integer
Dim Dataok As Single
Dim Strdatok As String * 5
Do
Addo = 1
Adsk = 0
Count = 0
While Addo = 1
Wend
For I = 1 To 24
Adsk = 1
Shift Count , Left , 1
Adsk = 0
If Addo = 1 Then Incr Count
Next
Adsk = 1
Count = Count Xor &H800000
Adsk = 0
Hx711_read = Count
Hx711 = Str(hx711_read)
Hx711 = Left(hx711 , 3)
Datafix = Val(hx711)
Dataok = Datafix - 859
Dataok = Dataok / 0.047
Strdatok = Fusing(dataok , "#.##")
Upperline
Lcd "nilai = " ; Datafix
Lowerline
Lcd "Berat = " ; Strdatok
Waitms 500
Cls
Loop
f. VIDEO HASILNYA
No comments:
Post a Comment