
Branqs CAN Modules Windows Driver
Version: 03 - Revision: 07
September - 2010
Table of Contents
Overview
Functions
- BC8E
- BC4EA
- BC4TP
- BC4SA
- Internal Driver State
- BC8S
Appendix 1
Overview
This driver performs communication with Branqs CAN modules through BCCAN interface.
Functions
BC8E
getDigitalInput
int getDigitalInput( int moduleAddress );
Read the BC8E module inputs
| Parameters: |
|---|
| moduleAddress | CAN module address defined by J1 to J4 jumpers configuration |
Return value: Input states. Each bit value corresponds to each input. Ex: 197 = 11000101
To invoke from managed code:
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="getDigitalInput")]
static extern int getDigitalInput(int moduleAddress);
BC4EA
getAnalogInput
int getAnalogInput(
int moduleAddress,
int channel );
Read the BC4EA inputs
| Parameters: |
|---|
| moduleAddress | CAN module address defined by J1 to J4 jumpers configuration |
| channel | Input number (1,2,3 or 4) |
Return value: Input value (0 = 0 Volts, 4000 = 10 Volts)
To invoke from managed code:
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="getAnalogInput")]
static extern int getAnalogInput(int moduleAddress, int channel);
BC4TP
getTemperature
int getTemperature(
int moduleAddress,
int channel,
int termocoupleType );
Read the BC4TP inputs
| Parameters: |
|---|
| moduleAddress | CAN module address defined by J1 to J4 jumpers configuration |
| channel | Input number (0=environment temperature) (1,2,3 or 4 for each input) |
| termocoupleType | 0 = J_Type , 1 = K_Type |
Return value: Input value in Celsius degrees
To invoke from managed code:
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="getTemperature")]
static extern int getTemperature(int moduleAddress, int channel, int termocoupleType);
BC4SA
setAnalogOutput
setAnalogOutput(
int moduleAddress,
int channel,
int value );
Defines BC4SA module outputs state
| Parameters: |
|---|
| moduleAddress | CAN module address defined by J1 to J4 jumpers configuration |
| channel | Output number (1,2,3 or 4) |
| value | Output value (0 = -10 Volts, 2048 = 0 Volts, 4095 = 10 Volts) |
To invoke from managed code:
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="setAnalogOutput")]
static extern void setAnalogOutput(int moduleAddress, int channel, int value);
Internal Driver State
getSPIdelay
int getSPIdelay();
Gets the software loop delay counter to perform SPI communication into BCCAN
Return value: SPI software loop counter delay
Note: Normaly, this register don't need to be modified. This register is originaly defined with a constant that performs a 20ms delay in SPI communication. Corresponds to the original "refAtrasoSPI"
To invoke from managed code:
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="getSPIdelay")]
static extern int getSPIdelay();
getMaxCommunicationDelay
int getMaxCommunicationDelay();
Gets the maximum counter time to complete communication with any module
Return value: Time counter
Note: This state register the maximum time spent to communicate with a module. During a communication, if this register reaches the "TimeoutLimit", the driver indicates a communication error increasing the "CommunicationErrors" state. Corresponds to the original "statusCAN_maxContadorTimeout".
To invoke from managed code:
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="getMaxCommunicationDelay")]
static extern int getMaxCommunicationDelay();
getCommunicationErrors
int getCommunicationErrors();
Gets the accumulated communication errors counter
Return value: Errors counter
Note: This register is increased, each time occurs a communication error. Corresponds to the original "statusCAN_numeroConfigMCP".
To invoke from managed code:
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="getCommunicationErrors")]
static extern int getCommunicationErrors();
getTimeoutLimit
int getTimeoutLimit();
Gets the timeout limit counter defined during initialization
Return value: Timeout limit
Note: This register is originaly defined with the value 400. Corresponds to the original "configCAN_limiteTimeout"
To invoke from managed code:
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="getTimeoutLimit")]
static extern int getTimeoutLimit();
setSPIdelay
setSPIdelay( int newValue );
Sets the software loop delay counter to perform SPI communication into BCCAN
| Parameters: |
|---|
| newValue | The new SPI software loop delay |
Note: Normaly, this register don�t need to be modified. This register is originaly defined with a constant that performs a 20ms delay in SPI communication. Be carefull to change this register. Corresponds to the original "refAtrasoSPI"
To invoke from managed code:
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="setSPIdelay")]
static extern void setSPIdelay(int newValue);
setMaxCommunicationDelay
setMaxCommunicationDelay( int newValue );
Sets the maximum counter time to complete communication with any module
| Parameters: |
|---|
| newValue | New maximum time counter |
Note: You can change this register to "reset" to a initial value. Corresponds to the original "statusCAN_maxContadorTimeout"
To invoke from managed code:
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="setMaxCommunicationDelay")]
static extern void setMaxCommunicationDelay(int newValue);
setCommunicationErrors
setCommunicationErrors( int newValue );
Sets the accumulated communication errors count
| Parameters: |
|---|
| newValue | A new "errors count" |
Note: You can change this register to "reset" to a initial value. Corresponds to the original "statusCAN_numeroConfigMCP"
To invoke from managed code:
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="setCommunicationErrors")]
static extern void setCommunicationErrors(int newValue);
setTimeoutLimit
setTimeoutLimit( int newValue );
Sets the timeout limit counter constant
| Parameters: |
|---|
| newValue | A new timeout limit constant |
Note: This register is originaly defined with the value 400. If desired, you can change this register to a secure value. Corresponds to the original "configCAN_limiteTimeout".
To invoke from managed code:
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="setTimeoutLimit")]
static extern void setTimeoutLimit(int newValue);
BC8S
setDigitalOutput
setDigitalOutput(
int moduleAddress,
int value );
Defines BC8S module output state
| Parameters: |
|---|
| moduleAddress | CAN module address defined by J1 to J4 jumpers configuration |
| value | Output value. Each bit value corresponds to each output state. Ex: 197 = 11000101 |
To invoke from managed code:
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="setDigitalOutput")]
static extern void setDigitalOutput(int moduleAddress, int value);
Messages
Appendix 1 - Managed Code Summary
// BC8E
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="getDigitalInput")]
static extern int getDigitalInput(int moduleAddress);
// BC4EA
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="getAnalogInput")]
static extern int getAnalogInput(int moduleAddress, int channel);
// BC4TP
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="getTemperature")]
static extern int getTemperature(int moduleAddress, int channel, int termocoupleType);
// BC4SA
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="setAnalogOutput")]
static extern void setAnalogOutput(int moduleAddress, int channel, int value);
// Internal Driver State
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="getSPIdelay")]
static extern int getSPIdelay();
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="getMaxCommunicationDelay")]
static extern int getMaxCommunicationDelay();
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="getCommunicationErrors")]
static extern int getCommunicationErrors();
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="getTimeoutLimit")]
static extern int getTimeoutLimit();
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="setSPIdelay")]
static extern void setSPIdelay(int newValue);
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="setMaxCommunicationDelay")]
static extern void setMaxCommunicationDelay(int newValue);
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="setCommunicationErrors")]
static extern void setCommunicationErrors(int newValue);
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="setTimeoutLimit")]
static extern void setTimeoutLimit(int newValue);
// BC8S
[DllImport("canModules_WindowsDriverV03R07.dll", EntryPoint="setDigitalOutput")]
static extern void setDigitalOutput(int moduleAddress, int value);
End of this documento