B&B Electronics RS-485 manual Read Digital I/O Command, Command$ = ! + CHR$addr + RD

Page 27

‘Get the value of channel 1

MSB$ = INPUT$ (1, #1)

LSB$ = INPUT$ (1, #1)

reading1 = (ASC(MSB$) * 256) + ASC(LSB$) ‘Get the value of channel 0

MSB$ = INPUT$ (1, #1)

LSB$ = INPUT$ (1, #1)

reading0 = (ASC(MSB$) * 256) + ASC(LSB$) The value of reading1 is the result of the A/D conversion on channel 1. The value of reading0 is the result of the A/D conversion on channel 0.

Read Digital I/O Command

The Read Digital I/O command returns a byte which represents the states of the 3 digital input and 3 digital output states. Bits 3-5 correspond to the states of digital inputs 0-2, and bits 0-2 correspond to the states of digital outputs 0-2. If a bit is a 0 then the digital state of that digital I/O is LOW. If a bit is a 1 then the digital state of the I/O is HIGH.

The steps to reading a digital I/O command are given below:

1.Constructing the command string:

Command$ = “!” + CHR$(addr) + “RD”

2.Transmitting the command string:

Print #1, Command$;

3.Receiving the data:

Reply$ = INPUT$ (1, #1)

4.Manipulating the data: states = ASC(Reply$)

5.Determining an I/O’s status status = states AND mask

6.Repeat Step 5 until the status of each I/O has been determined.

By “ANDing” the value of states with the appropriate mask of an I/O line, the status of can be determined. If status is equal to zero then the I/O line is LOW. If status is not equal to zero then the I/O line is HIGH. Table 5.1 shows the mask values for each I/O.

485SDA103798 Manual

23

B&B Electronics -- 707 Dayton Rd. -- PO Box 1040 -- Ottawa, IL 61350

PH (815) 433-5100 -- FAX (815) 434-7094

Image 27 Contents
Electronics Mfg. Co. Inc Designed and Manufactured Ottawa, IllinoisInternet Table of Contents Tables Software485SDA103798 Manual Table of Contents Iii 485SDA10 Unit 485SDA10 FeaturesPacking List Software InstallationWindows 9x and Windows NT UninstallGetting Started WindowsA/D with Variable Resistor 485SDA10 Specifications Ref Input + Inputs #0-10Ref Input Analog GroundTypical Connections Digital Outputs #0-2 Digital I/O Connections485SDA10 I/O Port Pinout Digital Inputs #0-2Typical Digital I/O Connections Digital GroundRS-485 Terminal Block Connections Serial Port ConnectionsTypical RS-485 2-wire Connection Power Supply Connections485SDA10 Commands CommandsReading A/D Channels Command SyntaxEquivalent Values AddrRA# Ch#MSBch#LSBch#-1MSB...ch0MSBch0LSBRead A/D Response Read Digital I/O Response for Outputs Reading Digital I/O CommandAddrRD StatesSet Digital Output Data Byte Values Set Digital Output CommandSet Module Address Command AddrSOstatesSet Power-up States Command Set Turn-around Delay CommandRead Module Configuration Command Addressstatesdelay Sampling Rate Input RangeReference Inputs Converting Data Data RangePage MSB$ = INPUT$1, #1 LSB$ = INPUT$1, #1 Read A/D CommandCommand$ = ! + CHR$addr + RA + CHR$channel Print #1, Command$Read Digital I/O Command Command$ = ! + CHR$addr + RDReply$ = INPUT$ 1, #1 Digital I/O Mask Values Set Digital Output StatesAddr = Command$ = !0SO + CHR$statesCommand$ = ! + CHR$addr + SO + CHR$newaddr Set Module AddressAddr = 5 states = States = states and NOTmaskCommand$ = ! + CHR$addr + SC + CHR$delay Set Turn-around DelayRead Module Configuration #addrRA00FF 00FF01FEComp = not x and &HFF Table A-1 Extended Commands Appendix B Analog Input Impedance 1 2 LSB = R s + 1k Ω × 60pF × ln2048 Simplified Analog Input Analysis485SDA103798 Manual Appendix B Table C-1 Decimal to HEX to Ascii Table Appendix C Decimal to HEX to Ascii TableClass a Equipment
Related manuals
Manual 39 pages 36.61 Kb Manual 46 pages 1.37 Kb