Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Software Algorithm for BasicX-24 Microcontroller in Quality Control of Consumable Liquids, Study Guides, Projects, Research of Electrical and Electronics Engineering

An algorithm for a basicx-24 microcontroller that is used to determine the quality of consumable liquids such as milk, orange juice, and beer. The algorithm captures pulse widths of a signal for each trigger, calculates pulse widths in microseconds and pulses, and compares the captured pulse widths with predefined pulse widths to determine the quality of the liquids. If the pulse widths match the predefined values, the algorithm prints 'good', otherwise, it prints 'bad' and activates an led indicator.

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 03/10/2009

koofers-user-vw4
koofers-user-vw4 🇺🇸

10 documents

1 / 5

Toggle sidebar

Related documents


Partial preview of the text

Download Software Algorithm for BasicX-24 Microcontroller in Quality Control of Consumable Liquids and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity! Appendix (Software Algorithm for the BasicX-24 Microcontroller) Option Explicit Dim FinalByte as New ByteVectorDataRW Dim bits_array as New ByteVectorDataRw Dim library1 As New ByteVectorData Dim library2 As New ByteVectorData Dim library3 As New ByteVectorData Public Sub Main() Dim i as Integer Dim n as Integer n=0 Dim PulseTrain (1 to 42) as New UnsignedInteger 'declare an array to store the pulse widths Dim Final (1 to 42) as Single Call FinalByte.Source("temp.txt") 'Call PutPin(26,0) Label1: Call PutPin(12, bxInputTristate) 'Forces Pin 12 of the chip to tristate (necessary for InputCapture function) 'Call PutPin(25,0) Call InputCapture(PulseTrain, 42, 1) 'captures the pulse widths of the signal for each trigger Call PutPin(26,0) Call PutPin(25,0) For i = 1 to 42 Step 1 Final(i) = Csng(PulseTrain(i)) / 7372800.0 Next For i = 1 to 42 Step 1 Final(i) = Final(i) * 1000000.0 Next For i = 1 to 42 Step 1 Debug.Print "PulseTrain(" & Cstr(i) &")= " & Cstr(Final(i)) & "usec" Next For i = 1 to 42 Step 1 Final(i) = (Final(i) / 2440.0) Next For i = 1 to 42 Step 1 Debug.Print "PulseTrain(" & Cstr(i) &")= " & Cstr(Final(i)) & " pulse" Next For i = 1 to 42 Step 1 FinalByte(i) = CByte(Final(i)) Next For i = 1 to 42 Step 1 Debug.Print "PulseTrain(" & Cstr(i) &")= " & Cstr(FinalByte(i)) & " pulse" Next Dim m As Integer m=1 Do While (n=0) If (FinalByte(m)=4) then n=m end if m=m+1 Loop If (n>13) Then n=0 Call Delay(0.01857) Goto Label1 End if Debug.Print "n=" & Cstr(n) Call bits_array.Source("bits.txt") 'ID code of the tag Dim bit as Integer bit=1 Dim k as Integer 'bits_array index k=1 Dim L as Integer 'Pulse value: L Even => Logic "High", L Odd => Logic "Low" L=2 Dim j as Byte 'Pulse count Dim z as Byte '# of pulses per sample Dim p as Integer For p=(n+2) to (n+20) Step 1 z=FinalByte(p) If p=(n+2) Then z=CByte(1)
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved