QuickBasic (DEMO232.EXE and DEMO232.BAS)
This section shows steps and examples of programming the 232DRIO in QuickBasic. If you are programming in another language, this section can be helpful as a guideline for programming the 232DRIO.
Using the 232DRIO.LIB with QuickBasic:
Using this library will make it easier to program the 232DRIO
module and allows greater flexibility in choosing serial ports. At the DOS prompt, start QuickBasic with the 232DRIO Quick Library by typing:
QB program.bas /L 232DRIO.QLB
This allows you to call the 232DRIO functions from the QuickBasic editor.
‘$INCLUDE: ‘232DRIO.BI’ Æ Include the function definitions mem =
232DRIO library to use
Read I/O States Command
states = bbDRIOReadIOLines(hComDev, mode)
When the line is executed, states will contain a byte that can be read by “ANDing” states with the appropriate mask.
Example 5.1 - Determining the status of Relay #1 If (states AND 0x01) Æ True if relay 1 is on
If (states & 0x01)
Set Output States Command
status = bbDRIOSetOutputLines(unsigned short hComDev, unsigned char states, int mode) Æ Returns a negative number
on error
Example 5.2 – Various ways to
1)A relay can be energized by “ORing” states with the appropriate mask.
states = states OR &H01 Æ Will energized Relay #1
2)A relay can be
states = states AND &HFE Æ Will
3)A relay can be switched by “Exclusive ORing” states with the appropriate mask.
states = states XOR &H01 Æ Will energized Relay #1 if it is
20 | |
B&B Electronics | PO Box 1040 |
PH (815)