
AR-B104D
Software Guide V1.0

AR-B104D Software Programming Guide
Revision
Version Date Author Description
0.1 2010/5/17 Bankle Chen Draft
0.2 2010/7/21 Bankle Chen Add Canbus related function
1.0 2010/8/4 Bankle Chen Add callback function table
example and OS notes
i

AR-B104D Software Programming Guide
Table of Contents
Chapter 1 Introduction ..............................................................................1
Chapter 2 Application Interface................................................................ 2
2.1 General Usage..............................................................................2
2.1.1 RegisterCard......................................................................2
2.1.2 ReleaseCard.......................................................................2
2.1.3 GetIOBaseAddr..................................................................2
2.1.4 GetMemBaseAddr .............................................................3
2.1.5 GetEventBuffer .................................................................. 3
2.1.6 GetEventCounter...............................................................3
2.1.7 SetCallbackFunc ...............................................................3
2.2 SRAM ............................................................................................6
2.2.1 ReadMemByte....................................................................6
2.2.2 ReadMemWord ..................................................................6
2.2.3 ReadMemDWord................................................................6
2.2.4 WriteMemByte ...................................................................6
2.2.5 WriteMemWord .................................................................. 7
2.2.6 WriteMemDWord................................................................7
2.2.7 SwitchMemMode ...............................................................7
2.2.8 ReadMemBlock..................................................................7
2.2.9 WriteMemBlock .................................................................8
2.3 General Purpose Input/Output....................................................9
2.3.1 ReadInputChannel.............................................................9
2.3.2 SetInputMode.....................................................................9
2.3.3 GetInputMode ....................................................................9
2.3.4 SetDebounce ...................................................................10
2.3.5 GetDebounce...................................................................10
2.3.6 SetInputInterruptEnable .................................................10
2.3.7 GetInputInterruptEnable ................................................. 10
2.3.8 SetCounterTriggerType................................................... 11
2.3.9 GetCounterTriggerType .................................................. 11
2.3.10 SetCounterMode..............................................................12
2.3.11 GetCounterMode ............................................................. 12
2.3.12 SetCounterTimeout ......................................................... 12
2.3.13 GetCounterTimeout.........................................................13
2.3.14 SetCounterTimeoutBase.................................................13
ii

AR-B104D Software Programming Guide
2.3.15 GetCounterTimeoutBase ................................................ 13
2.3.16 GetCounterValue ............................................................. 14
2.3.17 SetCounterTarget ............................................................ 14
2.3.18 GetCounterTarget............................................................14
2.3.19 WriteOutputChannel........................................................15
2.3.20 ReadOutputChannel........................................................15
2.3.21 SetOutputMode................................................................15
2.3.22 GetOutputMode ............................................................... 16
2.3.23 SetPGState.......................................................................16
2.3.24 GetPGState ......................................................................16
2.3.25 SetPGInterruptEnable ..................................................... 17
2.3.26 GetPGInterruptEnable.....................................................17
2.3.27 SetPGBase.......................................................................17
2.3.28 GetPGBase.......................................................................17
2.3.29 SetPGDuty........................................................................18
2.3.30 GetPGDuty .......................................................................18
2.3.31 SetPGCycle......................................................................19
2.3.32 GetPGCycle......................................................................19
2.3.33 SetPG ...............................................................................19
2.4 Timer ...........................................................................................21
2.4.1 SetTimerInterruptEnable.................................................21
2.4.2 GetTimerInterruptEnable ................................................ 21
2.4.3 SetTimerBase ..................................................................21
2.4.4 GetTimerBase .................................................................. 21
2.4.5 SetTimerValue..................................................................22
2.4.6 GetTimerValue ................................................................. 22
2.5 CAN-bus......................................................................................23
2.5.1 CanSendMessages..........................................................23
2.5.2 CanGetMessages ............................................................23
2.5.3 CanConfig ........................................................................23
iii

AR-B104D Software Programming Guide
Chapter 1 Introduction
AR-B104D is a PCI-104 board which contains 12 general purposed input
channels with pulse counter alternative function, 12 general purposed output
channels with pulse generator alternative function, SRAM with battery supplied,
hardware timer, and CAN-bus interface.
In order to ease the customer’s operation on AR-B104D, Acrosser provides
device driver, application interface (API), and source code of demo application.
The provided software is available on Windows XP and Linux. The API can be
classified into five catalogs: General usage, SRAM, GPIO, Timer, CANBUS.
The details are described in Chapter 2. All software can be located on the
bundled disc.
There are some limitations on AR-B104D driver:
It can only run on the system with ACPI and APIC enabled.
It has completely tested on Windows XP SP3 with ACPI supported.
Thus, we recommend operating AR-B104D on such environment.
1

AR-B104D Software Programming Guide
Chapter 2 Application Interface
This chapter describes the details of the provided API function. To prevent
using the function under wrong operation system, we add the operation system
prefix in front of function name and separate by underline, e.g.
WXP_RegisterCard or LNX_RegisterCard.
2.1 General Usage
2.1.1 RegisterCard
♦ Description
This function is used to register the selected AR-B104D card. The card has
to be registered by this function before other functions are called.
♦ Syntax
XXX_RegisterCard (i16* CardNum)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
2.1.2 ReleaseCard
♦ Description
This function is used to release the resource of the selected AR-B104D
card.
♦ Syntax
XXX_ReleaseCard (i16 CardNum)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
2.1.3 GetIOBaseAddr
♦ Description
This function is used to get the I/O base address of the selected AR-B104D
card.
♦ Syntax
XXX_GetIOBaseAddr (i16 CardNum, u32* IOBaseAddr)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
IOBaseAddr: The I/O base address of the selected AR-B104D card.
2

AR-B104D Software Programming Guide
2.1.4 GetMemBaseAddr
♦ Description
This function is used to get the SRAM base address of the selected
AR-B104D card.
♦ Syntax
XXX_GetMemBaseAddr (i16 CardNum, u32* MemBaseAddr)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
MemBaseAddr: The SRAM base address of the selected AR-B104D
card.
2.1.5 GetEventBuffer
♦ Description
Get an event from device event queue.
♦ Syntax
XXX_GetEventBuffer (i16 CardNum, event* Event)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
Event: The memory address of buffer to put the event from queue. The
types of event are listed: 0input, 1counter timeout, 2counter
overflow, 3pulse generator finished,4timer finished,5counter
reach to target.
2.1.6 GetEventCounter
♦ Description
Get how many events stayed in device event queue.
♦ Syntax
XXX_GetEventCounter (i16 CardNum, u16* Count)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
Count: The memory address of buffer to put the number of events in
queue.
2.1.7 SetCallbackFunc
♦ Description
Set the callback function pointer.
♦ Syntax
3

AR-B104D Software Programming Guide
XXX_SetCallbackFunc (i16 CardNum, agc_callback_t func)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
func: The callback function pointer.
♦ Example
void IOIST(event Event)
{
switch( Event.Type )
{
case INPUT:
printf("Get input event: Channel %d is %s.\n", Event.Channel,
(Event.Value)? "high":"low");
break;
case COUNTER_TO:
printf("Get counter timeout event: Counter %d, value = %d.\n",
Event.Channel, Event.Value);
break;
case COUNTER_OF:
printf("Get counter overflow event: Counter %d.\n", Event.Channel);
break;
case PG_FIN:
printf("Get pluse generator finish event: PG %d.\n", Event.Channel);
break;
case TIMER_FIN:
printf("Get timer finish event: Timer %d.\n", Event.Channel);
break;
case COUNTER_REACH:
printf("Get counter reach event: Counter %d.\n", Event.Channel,
Event.Value);
}
4

AR-B104D Software Programming Guide
}
----------------------------------------------------------------------------------------------------
Errbox = LNX_RegisterCard( &CardNum );
if(Errbox != 0)
printf(" Register Card Error\n");
if( CardNum == 0xff )
{
printf("[Not Found]\n");
return -1;
}
LNX_SetCallbackFunc(CardNum, &IOIST);
5

2.2 SRAM
2.2.1 ReadMemByte
♦ Description
This function is used to read SRAM data in byte alignment.
♦ Syntax
XXX_ReadMemByte (i16 CardNum, u32 Offset, u8* Buffer)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
Offset: SRAM offset to read.
Buffer: The memory address of buffer to put read SRAM data.
2.2.2 ReadMemWord
♦ Description
This function is used to read SRAM data in word alignment.
♦ Syntax
XXX_ReadMemWord (i16 CardNum, u32 Offset, u16* Buffer)
AR-B104D Software Programming Guide
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
Offset: SRAM offset to read (must in word alignment).
Buffer: The memory address of buffer to put read SRAM data.
2.2.3 ReadMemDWord
♦ Description
This function is used to read SRAM data in double word alignment.
♦ Syntax
XXX_ReadMemDword (i16 CardNum, u32 Offset, u32* Buffer)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
Offset: SRAM offset to read (must in double word alignment).
Buffer: The memory address of buffer to put read SRAM data.
2.2.4 WriteMemByte
♦ Description
This function is used to write SRAM data in byte alignment.
♦ Syntax
XXX_WriteMemByte (i16 CardNum, u32 Offset, u8 Value)
6

AR-B104D Software Programming Guide
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
Offset: SRAM offset to read
Value: Value to write to SRAM.
2.2.5 WriteMemWord
♦ Description
This function is used to write SRAM data in word alignment.
♦ Syntax
XXX_WriteMemWord (i16 CardNum, u32 Offset, u16 Value)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
Offset: SRAM offset to read (must in word alignment)
Value: Value to write to SRAM.
2.2.6 WriteMemDWord
♦ Description
This function is used to write SRAM data in double word alignment.
♦ Syntax
XXX_WriteMemDWord (i16 CardNum, u32 Offset, u32 Value)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
Offset: SRAM offset to read (must in double word alignment)
Value: Value to write to SRAM.
2.2.7 SwitchMemMode
♦ Description
This function is used to switch the memory mode.
♦ Syntax
XXX_SwitchMemMode (i16 CardNum, i16 Mode)
♦ Argument
CardNum: The number of AR-B104D. Range from 1~4.
Mode: SRAM Access Mode. 0 indicates “Independent Mode”; 1
indicates “Replicate Mode”.
2.2.8 ReadMemBlock
♦ Description
7

AR-B104D Software Programming Guide
This function is used to read memory with a specified length.
♦ Syntax
XXX_ReadMem_Block (i16 CardNum, u32 Offset, u8* Buffer, u32 Size)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
Offset: SRAM offset to read
Buffer: The start address of memory buffer to put SRAM data.
Size: The memory block size (in byte) to read.
2.2.9 WriteMemBlock
♦ Description
This function is used to write data to memory with a specified length.
♦ Syntax
XXX_WriteMem_Block (i16 CardNum, u32 Offset, u8* Buffer, u32 Size)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
Offset: SRAM offset to write
Buffer: The start address of data buffer to write to SRAM.
Size: The memory block size (in byte) to write.
8

2.3 General Purpose Input/Output
2.3.1 ReadInputChannel
♦ Description
This function is used to read the status of the selected input channel on the
selected AR-104D card.
♦ Syntax
XXX_ReadInputChannel (i16 CardNum, i16 ChannelNum, u8* Value)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Value: The channel status. 0 indicates input low; 1 indicates input high.
2.3.2 SetInputMode
♦ Description
This function is used to set the input operation mode of the selected input
channel on the selected AR-104D card.
AR-B104D Software Programming Guide
♦ Syntax
XXX_SetInputMode (i16 CardNum, i16 ChannelNum, u8 Mode)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Mode: The input channel operation mode. 0 indicates general
purposed input; 1 indicates pulse counter.
2.3.3 GetInputMode
♦ Description
This function is used to get the input operation mode of the selected input
channel on the selected AR-104D card.
♦ Syntax
XXX_ GetInputMode (i16 CardNum, i16 ChannelNum, u8* Mode)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Mode: The input channel operation mode. 0 indicates general
purposed input; 1 indicates pulse counter.
9

AR-B104D Software Programming Guide
2.3.4 SetDebounce
♦ Description
Set the debounce time for the selected channel (in ms).
♦ Syntax
XXX_SetDebounce (i16 CardNum, i16 ChannelNum, u8 Dtime)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Dtime: The de-bounce time. 0 indicates the debounce function is
disabled; others indicate the debounce time in ms, e.g., 1 means
debounce time is 1 ms.
2.3.5 GetDebounce
♦ Description
Get the debounce time for the selected channel (in ms).
♦ Syntax
XXX_GetDebounce (i16 CardNum, i16 ChannelNum, u8* Dtime)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Dtime: The memory address to put the debounce time value. 0
indicates the debounce function is disabled; others indicate the
debounce time in ms.
2.3.6 SetInputInterruptEnable
♦ Description
Enable the interrupt of the selected input channel.
♦ Syntax
XXX_SetInputInterruptEnable (i16 CardNum, i16 ChannelNum, u8 Enable)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Enable: 0 indicates the interrupt of the selected channel is disabled;
others indicate the interrupt of the selected channel is enabled.
2.3.7 GetInputInterruptEnable
10

AR-B104D Software Programming Guide
♦ Description
Get the interrupt enable status of the selected input channel.
♦ Syntax
XXX_GetInputInterruptEnable (i16 CardNum, i16 ChannelNum, u8*
Enable)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Enable: The memory address of buffer to put the interrupt enable
status of the selected input channel. 0 indicates the interrupt of the
selected channel is disabled; others indicate the interrupt of the
selected channel is enabled.
2.3.8 SetCounterTriggerType
♦ Description
Set the counter trigger type of the selected input channel.
♦ Syntax
XXX_SetCounterTriggerType (i16 CardNum, i16 ChannelNum, u8 Type)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Type: The counter trigger type of the selected input channel. 0
indicates counter increased at rising edge; 1 indicates counter
increased at falling edge.
2.3.9 GetCounterTriggerType
♦ Description
Get the counter trigger type of the selected input channel.
♦ Syntax
XXX_ GetCounterTriggerType (i16 CardNum, i16 ChannelNum, u8* Type)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Type: The memory address of buffer to put the counter trigger type of
the selected input channel. 0 indicates counter increased at rising edge;
1 indicates counter increased at falling edge.
11

AR-B104D Software Programming Guide
2.3.10 SetCounterMode
♦ Description
Set the counter value access mode of the selected input channel.
♦ Syntax
XXX_SetCounterMode (i16 CardNum, i16 ChannelNum, u8 Mode)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Mode: The counter value access mode of the selected input channel. 0
indicates a read action to counter value will not reset the counter; 1
indicates a read action to counter value will reset the counter to zero.
2.3.11 GetCounterMode
♦ Description
Get the counter value access type of the selected input channel.
♦ Syntax
XXX_GetCounterMode (i16 CardNum, i16 ChannelNum, u8* Mode)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Mode: The memory address of buffer to put the counter value access
mode of the selected input channel. 0 indicates a read action to
counter value will not reset the counter; 1 indicates a read action to
counter value will reset the counter to zero.
2.3.12 SetCounterTimeout
♦ Description
Set the counter timeout value of the selected input channel. The counter
will trigger an interrupt if the status of the selected input channel remains
unchanged beyond the timeout value.
♦ Syntax
XXX_SetCounterTimeout (i16 CardNum, i16 ChannelNum, u16 Value)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Value: The alarm value of the selected input channel. 0 indicates no
12

AR-B104D Software Programming Guide
interrupt triggered if the selected input channel remains unchanged;
others indicate the timeout value in timeout timebase.
2.3.13 GetCounterTimeout
♦ Description
Get the counter timeout value of the selected input channel.
♦ Syntax
XXX_GetCounterTimeout (i16 CardNum, i16 ChannelNum, u16* Value)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Value: The memory address of buffer to put the timeout value of the
selected input channel. 0 indicates no interrupt triggered if the selected
input channel remains unchanged; others indicate the timeout value in
timeout timebase.
2.3.14 SetCounterTimeoutBase
♦ Description
Set the counter timeout timebase of the selected input channel.
♦ Syntax
XXX_SetCounterTimeoutBase (i16 CardNum, i16 ChannelNum, u8 Base)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Base: The counter timeout timebase of the selected input channel. 0
indicates the base is 1 ms; 1 indicates the base is 100 ms.
2.3.15 GetCounterTimeoutBase
♦ Description
Get the counter timeout timebase of the selected input channel.
♦ Syntax
XXX_GetCounterTimeoutBase (i16 CardNum, i16 ChannelNum, u8* Base)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Base: The memory address of buffer to put the counter timeout
13

AR-B104D Software Programming Guide
timebase of the selected input channel. 0 indicates the base is 1 ms; 1
indicates the base is 100 ms.
2.3.16 GetCounterValue
♦ Description
Get the counter value of the selected input channel.
♦ Syntax
XXX_GetCounterValue (i16 CardNum, i16 ChannelNum, u16* Value)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Value: The memory address of buffer to put the counter value of the
selected input channel.
2.3.17 SetCounterTarget
♦ Description
Set the counter target value of the selected input channel. An interrupt will
trigger if the counter value is equal to counter target value.
♦ Syntax
XXX_SetCounterTarget (i16 CardNum, i16 ChannelNum, u16 Value)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Value: The counter target value of the selected input channel.
2.3.18 GetCounterTarget
♦ Description
Get the counter target value of the selected input channel. An interrupt will
trigger if the counter value is equal to counter target value.
♦ Syntax
XXX_GetCounterTarget (i16 CardNum, i16 ChannelNum, u16* Value)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Input channel number. Range from 0~11.
Value: The memory address of buffer to put the counter target value of
the selected input channel.
14

AR-B104D Software Programming Guide
2.3.19 WriteOutputChannel
♦ Description
Write the status of the selected output channel on the selected AR-104D
card.
♦ Syntax
XXX_WriteOutputChannel (i16 CardNum, i16 ChannelNum, u8 Value)
♦ Argument
CardNum: The number of AR-B104D. Range from 1~4.
ChannelNum: Output channel number. Range from 0~11.
Value: The channel status. 0 indicates output low; 1 indicates output
high.
2.3.20 ReadOutputChannel
♦ Description
Read the status of the selected output channel on the selected AR-104D
card.
♦ Syntax
XXX_ReadOutputChannel (i16 CardNum, i16 ChannelNum, u8* Value)
♦ Argument
CardNum: The number of AR-B104D. Range from 1~4.
ChannelNum: Output channel number. Range from 0~11.
Value: The channel status. 0 indicates output low; 1 indicates output
high.
2.3.21 SetOutputMode
♦ Description
Set the output operation mode of the selected output channel.
♦ Syntax
XXX_SetOutputMode (i16 CardNum, i16 ChannelNum, u8 Mode)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Output channel number. Range from 0~11.
Mode: The output operation type of the selected output channel. 0
indicates the output channel works as a general-purpose output; 1
indicates the output channel works as a pulse generator.
15

AR-B104D Software Programming Guide
2.3.22 GetOutputMode
♦ Description
Get the output operation mode of the selected output channel.
♦ Syntax
XXX_GetOutputMode (i16 CardNum, i16 ChannelNum, u8* Mode)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: output channel number. Range from 0~11.
Mode: The memory address of buffer to put the output operation mode
of the selected output channel. 0 indicates the output channel works as
a general-purpose output; 1 indicates the output channel works as a
pulse generator.
2.3.23 SetPGState
♦ Description
Set the pulse generator state of the selected output channel.
♦ Syntax
XXX_SetPGState (i16 CardNum, i16 ChannelNum, u8 State)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Output channel number. Range from 0~11.
State: The pulse generator state of the selected output channel. 0
indicates the related pulse generator is running; 1 indicates the related
pulse generator is stopped.
2.3.24 GetPGState
♦ Description
Get the pulse generator state of the selected output channel.
♦ Syntax
XXX_SetPGState (i16 CardNum, i16 ChannelNum, u8* State)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: output channel number. Range from 0~11.
State: The memory address of buffer to put the pulse generator state of
the selected output channel. 0 indicates the related pulse generator is
running; 1 indicates the related pulse generator is stopped.
16

AR-B104D Software Programming Guide
2.3.25 SetPGInterruptEnable
♦ Description
Enable the interrupt of the selected output channel (pulse generator).
♦ Syntax
XXX_SetPGInterruptEnable (i16 CardNum, i16 ChannelNum, u8 Enable)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Output channel number. Range from 0~11.
Enable: 0 indicates no interrupt triggers if the preset cycle of the
related pulse generator is finished; 1 indicates interrupt triggers if the
preset cycle of the related pulse generator is finished.
2.3.26 GetPGInterruptEnable
♦ Description
Get the interrupt status of the selected output channel (pulse generator).
♦ Syntax
XXX_GetPGInterruptEnable (i16 CardNum, i16 ChannelNum, u8* Enable)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: output channel number. Range from 0~11.
Enable: 0 indicates no interrupt triggers if the preset cycle of the
related pulse generator is finished; 1 indicates interrupt triggers if the
preset cycle of the related pulse generator is finished.
2.3.27 SetPGBase
♦ Description
Set the pulse generator timebase of the selected output channel.
♦ Syntax
XXX_SetPGBase (i16 CardNum, i16 ChannelNum, u8 Base)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Output channel number. Range from 0~11.
Base: The pulse generator timebase of the selected output channel. 0
indicates the base is 1 ms; 1 indicates the base is 100 ms.
2.3.28 GetPGBase
17

AR-B104D Software Programming Guide
♦ Description
Get the pulse generator timebase of the selected output channel.
♦ Syntax
XXX_GetPGBase (i16 CardNum, i16 ChannelNum, u8* Base)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Output channel number. Range from 0~11.
Base: The memory address of buffer to put the pulse generator
timebase of the selected output channel. 0 indicates the base is 1 ms;
1 indicates the base is 100 ms.
2.3.29 SetPGDuty
♦ Description
Set the pulse generator high-low duty of the selected output channel.
♦ Syntax
XXX_SetPGDuty (i16 CardNum, i16 ChannelNum, u8 High, u8 Low)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Output channel number. Range from 0~11.
High: The time of the related pulse generator remains high in one
cycle.
Low: The time of the related pulse generator remains low in one cycle.
2.3.30 GetPGDuty
♦ Description
Get the pulse generator high-low duty of the selected output channel.
♦ Syntax
XXX_GetPGDuty (i16 CardNum, i16 ChannelNum, u8* High, u8* Low)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Output channel number. Range from 0~11.
High: The memory address of buffer to put the time of the related pulse
generator remains high in one cycle.
Low: The memory address of buffer to put the time of the related pulse
generator remains low in one cycle.
18

AR-B104D Software Programming Guide
2.3.31 SetPGCycle
♦ Description
Set the pulse generator cycles of the selected output channel.
♦ Syntax
XXX_SetPGCycle (i16 CardNum, i16 ChannelNum, u16 Cycle)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Output channel number. Range from 0~11.
Cycle: The number of the related pulse generator running cycle.
2.3.32 GetPGCycle
♦ Description
Get the pulse generator cycles of the selected output channel.
♦ Syntax
XXX_GetPGCycle (i16 CardNum, i16 ChannelNum, u16* Cycle)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Output channel number. Range from 0~11.
Cycle: The memory address of buffer to put the number of the related
pulse generator running cycle.
2.3.33 SetPG
♦ Description
Set all pulse generator parameters of the selected output channel and
immediately start the pulse generator.
♦ Syntax
XXX_SetPG (i16 CardNum, i16 ChannelNum, u8 Base, u8 High, u8 Low,
u16 Cycle)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
ChannelNum: Output channel number. Range from 0~11.
Base: The pulse generator timebase of the selected output channel. 0
indicates the base is 1 ms; 1 indicates the base is 100 ms.
High: The time of the related pulse generator remains high in one
cycle.
19

AR-B104D Software Programming Guide
Low: The time of the related pulse generator remains low in one cycle.
Cycle: The number of the related pulse generator running cycle.
20

2.4 Timer
2.4.1 SetTimerInterruptEnable
♦ Description
Enable the selected timer interrupt. Timer will start automatically once
interrupt is set to enable.
♦ Syntax
XXX_SetTimerInterruptEnable (i16 CardNum, i16 TimerNum, u8 Enable)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
TimerNum: Timer number. Range from 0~12.
Enable: 0 indicates the timer interrupt is disabled; 1 indicates the timer
interrupt is enabled.
2.4.2 GetTimerInterruptEnable
♦ Description
Get the interrupt status of the selected timer.
AR-B104D Software Programming Guide
♦ Syntax
XXX_GetTimerInterruptEnable (i16 CardNum, i16 TimerNum, u8* Enable)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
TimerNum: Timer number. Range from 0~12.
Enable: 0 indicates the timer interrupt is disabled; 1 indicates the timer
interrupt is enabled.
2.4.3 SetTimerBase
♦ Description
Set the time base of the selected timer.
♦ Syntax
XXX_SetTimerBase (i16 CardNum, i16 TimerNum, u8 Base)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
TimerNum: Timer number. Range from 0~12.
Base: The time base of the selected output channel. 0 indicates the
base is 1 ms; 1 indicates the base is 100 ms.
2.4.4 GetTimerBase
21

AR-B104D Software Programming Guide
♦ Description
Get the time base of the selected timer.
♦ Syntax
XXX_GetTimerBase (i16 CardNum, i16 TimerNum, u8* Base)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
TimerNum: Timer number. Range from 0~12.
Base: The memory address of buffer to put the time base of the
selected output channel. 0 indicates the base is 1 ms; 1 indicates the
base is 100 ms.
2.4.5 SetTimerValue
♦ Description
Set the timer value of the selected timer.
♦ Syntax
XXX_SetTimerValue (i16 CardNum, i16 TimerNum, u16 Value)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
TimerNum: Timer number. Range from 0~12.
Value: The timer value of the selected timer.
2.4.6 GetTimerValue
♦ Description
Get the timer value of the selected timer.
♦ Syntax
XXX_GetTimerValue (i16 CardNum, i16 TimerNum, u16* Value)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
TimerNum: Timer number. Range from 0~23.
Value: The memory address of buffer to put the timer value of the
selected timer.
22

2.5 CAN-bus
2.5.1 CanSendMessages
♦ Description
Send messages via CAN-bus interface.
♦ Syntax
XXX_CanSendMessages (i16 CardNum, canmsg_t* Buffer, u8 Count)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
Buffer: The memory buffer which stores the messages to send.
Count: The number of messages to send in the buffer.
2.5.2 CanGetMessages
♦ Description
Get messages via CAN-bus interface.
♦ Syntax
XXX_CanGetMessages (i16 CardNum, canmsg_t* Buffer, u8 Count)
AR-B104D Software Programming Guide
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
Buffer: The memory buffer which stores the received messages.
Count: The number of messages to store in the buffer.
2.5.3 CanConfig
♦ Description
Set the baud rate of CAN-bus interface.
♦ Syntax
XXX_CanConfig (i16 CardNum, i32 Baud)
♦ Argument
CardNum: The card number of AR-B104D. Range from 1~4.
Baud: The baud rate to set. The CAN-bus interface on AR-B104D
supports 10, 20, 50, 100, 125, 250, 500, 800, 1000 as the input and the
unit is kbps. The maximum acceptable baud rate is therefore 1Mbps.
23