|
CAN_setup |
Top |
|
CAN_setup Set up CAN Bus controller (CAN Bus Analyzer/Simulator from Dafulai Electronic Inc ) Since R2019b
Library: CAN Bus Controller ( Dafulai Electronics) /CAN_setup
Description
This block sets up all parameters of CAN Bus Analyzer/Simulator from Dafulai Electronic Inc And it will refresh all Can bus receiver buffers every sampling cycle automatically if parameter "Enable auto-refresh" is true (Default is true). Otherwise, you must call "refresh" block by yourself in order to get the latest received frames. You must put this block in your simulation model in order to access CAN Bus by CAN Bus Analyzer/Simulator.
Firstly, let us introduce CAN Bus Controller function. Our CAN Bus controller can transmit/Receive standard or/and extended CAN Bus data and RTR frames as general CAN bus node. And furthermore, transmitting CAN Bus Frame can be synchronized by special CAN BUS transmitting frame or receiving frame. If Sync is enabled, CAN Bus controller only can transmit CAN Bus frame when it receives or transmits this special CAN BUS frame. This special CAN BUS frame is called "Sync frame" Another feature is that our CAN Bus Controller has Watchdog function. Watchdog purpose is for getting communication fault information. Received Watchdog ( Call it RxWatchdog) is for itself to know whether CAN BUS communication OK or not. Transmitted Watchdog ( Call it TxWatchdog) is for other CAN bus nodes to know whether CAN BUS communication OK or not. TxWatchdog CAN Bus frame send out periodically automatically by hardware, You don't need to send by calling transmit block. Similarly, if "Sync frame" is "Transmit frame", "Sync frame" send out periodically automatically by hardware, You don't need to send by calling transmit block.
This block will set up "Sync" frame and TxWatchdog/RxWatchdog frame, and set up Filter/mask in order to decrease receiving traffic from hardware.
Parameters
There are many parameters for this block. Please double click this block to open parameters dialog below:
Many parameters are self-explanation from the label. We only explain some special parameters.
When source is from RxWatchdog or TxWatchdog. You will use RxWatchdog or TxWatchdog CAN ID, just ignore SyncCANID parameter. In this situation, Watchdog will have dual functions, one is for watchdog, the other is for Sync.
Mode 0: Watchdog initial value is 0. Watchdog is free running up-counter each ms. Watchdog Counter will return 0 if we receive value from Watchdog CAN Bus frame, and value is different from previous received one. When Watchdog Counter is over RxWatchdog Period, it will keep the Rxwatchdog value and communication fault will occur. We don't need our Matlab to detect RxWatchdog. Hardware will do it automatically, and you just use refresh method and receiveRaw method to get status. Mode 1: Watchdog initial value is 0. Watchdog is free running up-counter each ms. When it arrive at periods value, it will keep it, and one communication fault will occur. RxWatchdog Data packet (receiving watchdog data packet) can change counter value to avoid communication fault. We don't need our Matlab to detect RxWatchdog. Hardware will do it automatically, and you just use refresh method and receiveRaw method to get status. Mode 2: Watchdog initial value is equal to periods. Watchdog is free running down-counter each ms. When it arrive at 0, it will keep 0 and communication fault will occur. RxWatchdog Data packet (receiving watchdog data packet) can change counter value to avoid communication fault. We don't need our Matlab to detect RxWatchdog. Hardware will do it automatically, and you just use refresh method and receiveRaw method to get status.
Mode 0 : TxWatchdog value is decided by Method "sendTxWatchdogValue". Value 's position and Length in CAN BUS data packet is decided by "TxWatchdogSartPos" and "TxWatchdogLen". You don't need to send CAN Bus TxWatchdog CAN Bus frame because Hardware sent out automatically, Mode 1: TxWatchdog value increases 1 every TxWatchdog's period by hardware automatically. You don't need to use Method "sendTxWatchdogValue" to give TxWatchdog value. Value 's position and Length in CAN BUS data packet is decided by "TxWatchdogSartPos" and "TxWatchdogLen". Value is unsigned. When value > maximum unsigned number, it will return 0. You don't need to send CAN Bus TxWatchdog CAN Bus frame because Hardware sent out automatically. Mode 2: TxWatchdog value decreases 1 every TxWatchdog's period by hardware automatically. You don't need to use Method "sendTxWatchdogValue" to give TxWatchdog value. Value 's position and Length in CAN BUS data packet is decided by "TxWatchdogSartPos" and "TxWatchdogLen". Value is unsigned. When value =0, it will return maximum unsigned number. You don't need to send CAN Bus TxWatchdog CAN Bus frame because Hardware sent out automatically. Mode 3: TxWatchdog will have no any value, its data packet length is zero. It is used for CANOpen Sync frame.
Filter1 to Filter8 (Group1) are used Mask1, Filter9 to Filter12 (Group2) are used Mask2, Filter13 to Filter16 (Group3) are used Mask3. CAN bus Controller Hardware only receives CAN Frame with CAN ID meets the condition below: FilterN "Logical bitwise And" Mask1 = CAN ID "Logical bitwise And" Mask1 (N=1 to 8) or FilterN "Logical bitwise And" Mask2 = CAN ID "Logical bitwise And" Mask2 (N=9 to 12) or FilterN "Logical bitwise And" Mask3 = CAN ID "Logical bitwise And" Mask3 (N=13 to 16)
That is to say, If bit in Mask =1, we will care the same bit in received CAN ID, it must be the bit value in filter. Otherwise, if bit in Mask =0, we can receive any bit value in received CAN ID.
Ports
Input
None
Outpot
None |