Power I/O Wildcard User Guide
<< Previous |
Software
To control the eight high current, isolated MOSFET outputs use the software primitives StoreChar, ToggleBits, ChangeBits, SetBits, or ClearBits (C!, TOGGLE.BITS, CHANGE.BITS, SET.BITS, or CLEAR.BITS in FORTH). To read back the state of the eight outputs or the four inputs, use the software primitive FetchChar (C@ in FORTH). The hexadecimal address of the output port is 0xC000 and the address of the input port is 0xC001. The page corresponds to the wildcard address. Code Listings 1-1 and 1-2 provide functions that set, clear, and read the high current isolated outputs, and a function that reads the high voltage isolated inputs.
Listing 1-1 C Code to control the Power I/O Wildcard.
#include
#define OUTPUT_REGISTER 0xC000
#define INPUT_REGISTER 0xC001
\\ module_num = the hardware jumper setting described in Table 1-2.
\\ valid module numbers are 0 tp 7.
\\ bit = a bit mask with 1’s in the position of bits to be set.
void SetOutput( uchar bit, uchar module_num )
{
EXTENDED_ADDR module_addr;
module_addr.sixteen_bit.page16 = module_num;
module_addr.sixteen_bit.addr16 = OUTPUT_REGISTER;
SetBits(bit,module_addr.addr32);
}
\\ module_num = the hardware jumper setting described in Table 1-2.
\\ valid module numbers are 0 tp 7.
\\ bit = a bit mask with 1’s in the position of bits to be cleared.
void ClearOutput( uchar bit, uchar module_num )
{
EXTENDED_ADDR module_addr;
module_addr.sixteen_bit.page16 = module_num;
module_addr.sixteen_bit.addr16 = OUTPUT_REGISTER;
ClearBits(bit,module_addr.addr32);
}
\\ module_num = the hardware jumper setting described in Table 1-2.
\\ valid module numbers are 0 tp 7.
uchar ReadOutput( uchar module_num )
{
EXTENDED_ADDR module_addr;
uchar output_status;
module_addr.sixteen_bit.page16 = module_num;
module_addr.sixteen_bit.addr16 = OUTPUT_REGISTER;
output_status = FetchChar( module_addr.addr32 );
return( output_status );
}
\\ module_num = the hardware jumper setting described in Table 1-2.
\\ valid module numbers are 0 tp 7.
uchar ReadInput( uchar module_num )
{
EXTENDED_ADDR module_addr;
uchar input_status;
module_addr.sixteen_bit.page16 = module_num;
module_addr.sixteen_bit.addr16 = INPUT_REGISTER;
input_status = FetchChar( module_addr.addr32 );
return( input_status );
}
|
Listing 1-2 Forth Code to control the Power I/O Wildcard.
HEX
C000 CONSTANT OUTPUT_REGISTER
C001 CONSTANT INPUT_REGISTER
\ bit = a bit mask with 1’s in the position of the bits to be set.
\ module_num = the hardware jumper setting described in Table 1-2.
\ Valid module numbers are 0 to 7.
: SETOUTPUT ( b1/b2 -- | b1 = bit, b2 = module_num )
locals{ &module &bit }
&bit OUTPUT_REGISTER &module SET.BITS
;
\ bit = a bit mask with 1’s in the position of bits to be cleared.
\ module_num = the hardware jumper setting described in Table 1-2.
\ Valid module numbers are 0 to 7.
: CLEAROUTPUT ( b1/b2 -- | b1 = bit, b2 = module_num )
locals{ &module &bit }
&bit OUTPUT_REGISTER &module CLEAR.BITS
;
\ module_num = the hardware jumper setting described in Table 1-2.
\ Valid module numbers are 0 to 7.
: READOUTPUT ( b1 -- b2 | b1 = module_num, b2 = output_status )
OUTPUT_REGISTER SWAP C@
;
\ module_num = the hardware jumper setting described in Table 1-2.
\ Valid module numbers are 0 to 7.
: READINPUT ( b1 -- b2 | b1 = module_num, b2 = input_status )
INPUT_REGISTER SWAP C@
;
|
<< Previous |
|