User manual

assembled again
040 data_Word = ((HighByte * 256) + LowByte)
041 voltage = data_Word * (5.0 / 1024.0)
042
043 ' RAW value conversion and display as
voltage
044 Label1.Text = Format(voltage, "0.00 V")
045
046 End If
047
048 End If
049
050 Catch ex As Exception
051 End Try
052
053 End Sub
In the function
SerialPort1_DataReceived()
, the most interesting part
of the VB.NET-program will now follow. This function will be
called every time data are received from the serial interface.
Here, we read the bytes that our Arduino™-program sends, and
process them right away. Before reading and processing, we always
check if the connection is opened first and then check how many
bytes are available in the reception buffer. Then we read the
bytes into the
input_data()
-arrays and assign the received values
to the variables
HighByte
,
LowByte
and
crc
. Last, we will calculate
the checksum by applying the same procedure as in our Ar-
duino™-program. If the calculated and the received checksum are
the same, no transmission error has occurred. Now we need to
perform measured value calculation. To get a certain formatting,
we use the
Format()
-function of VB.NET and output the formatted
value on the
Label1
.
16.1 | Expansion of the Measuring Range
If you want to measure higher voltages, you need a pre-voltage
divider, consisting of the resistors R1 and R2. You can use them
to expand the input voltage range as desired. However, observe
that the resolution will also reduce with an increasing input
voltage range.
In our experiment, which is meant for an input voltage of 5 V,
we have a resolution of 0.00488 V or 4.88 mV per conversion step.
Our digital value of the analogue input can dissolve 1,024 steps,
since it has a digital resolution of 10 bits.
Conversion steps (Steps): 1,024 = 2
10
Resolution per Digit = U
ADC
/ Steps