![](/images/new-backgrounds/1166768/16676851x1.webp)
Chapter 5 - Software
This chapter covers programming techniques such as constructing a command string, receiving data and manipulating data. The various steps and examples are shown in QuickBasic. If you are programming in another language, these sections can be used as a guideline for programming the 485SDA10.
Read A/D Command
The Read A/D channels command returns two bytes for each channel read. The two bytes represent the most significant byte (MSB) and least significant byte (LSB) of the reading. The MSB is received first, followed by the LSB. This command requires a data byte. The data byte is used to specify the number of the highest channel to be read. All channels less than this channel will be read as well.
The steps to reading an A/D command are given below:
1.Constructing the command string:
Command$ = “!” + CHR$(addr) + “RA” + CHR$(channel)
The value of channel is equal to the highest channel to be read.
2.Transmitting the command string:
Print #1, Command$;
3.Receiving the data:
MSB$ = INPUT$(1, #1) LSB$ = INPUT$(1, #1)
4.Manipulating the data:
reading = (ASC(MSB$) * 256) + ASC(LSB$)
The value of reading is the result of the A/D conversion.
5.Repeat Steps 3 & 4 until each channel has been completed.
Example 5.1 - Read A/D channels 1 and 0 of the module with an address of 5.
channel = 1 addr = 5
Command$ = “!” + CHR$(addr) + “RA” + CHR$(channel) Print #1, Command$;
22 | 485SDA103798 Manual |
B&B Electronics
PH (815)