Skip to content

CAN BUS_Shield_V1.0_(SKU_DFR0269)

Angelo edited this page Sep 21, 2016 · 2 revisions

Module is introduced

    SPI turn the can module function: 1、read the state; 2、 Read and write data; 3、Can input and output identification Settings (SPI from the device).

Hardware

Part 1, spi only need mosi, miso, CLK can work.(andunio_spi clock frequency: SPI_CLOCK_DIV64 orSPI_CLOCK_DIV128).

Part 2, can the DB9 standard interface for CANL 2, 7 for CANH.

Sequential operation (250 k SPI clock)

1:read the sequence

A: writing 8-bit register;

B: 1 time delay us

C: 8 bytes of data

D: 2 bytes of time delay

2: write sequence

A: writing 8-bit register;

B: 8 bytes of data

Register

1: read data register 11

2: reading a status register 33

3: write data register, 22

4: logo register read input and output 55 (address)

5: 44 identity register write input and output (address)

Note:

1: input and output a total of 8 bytes, four for receiving logo (the first two bytes for the standard identification, after two to extension);

After four bytes for sending logo (the first two bytes for the standard identification, after two to extension).

2: the value of the status register

0x00 : can write unreadable

0x01 : do not write do not read

0x10 : can write can read

0x11 : do not write readable

Note: the module's address specified is specified in the module after the electricity (the default value is 00001234, after the reset to restore the default value)

Module electric reset registers on the default values

Status register: 01

Data register: AA 55 55 55 00 00 AA AA

Mark register: 0012324001234

Address

Read the instruction format: 55 aa55 XXXXXXXX XXXXXXXX (x said any decimal number)

55 aa for head

55 for instruction

Top four for the standard identifier (receiving address), after four to extension logo (sending address).

Write instruction format: 55 aa44 00001234 00001234

55 aa for head

55 for instruction

Before four for receiving address, after four for sending address.

Data transmission module

1: the status register read: 55 aa33 XXXXXXXX XXXXXXXX (x said any decimal number);

55 aa for head

33 for instruction

2: data register read: 55 aa11 XXXXXXXX XXXXXXXX (x said any decimal number);

55 aa for head

11 for instruction

Data register write: 55 aa22 XXXXXXXX XXXXXXXX (x said any decimal number);

55 aa for head

22 for instruction

Arduino libraries

byte a[11]

1: SPItoCAN. Write (byte [] a);Write the data

The data format:

a[0] register

a[1]~a[9] to send data

2: SPItoCAN. Read (byte a[]);Read the data

The data format:

a[0] register

a[1]~a[9] receive data

a[10], a[11] 0 as the time delay

3: SPItoCAN. Readzt (byte a[]);Read the state

The data format:

a[0] register

a[1] to receive status information

a[2], a[3] 0 as delay

4: SPITtoCAN. Readdz (byte a[]);Read the id The data format: a[0] register a[1] ~ a[9] receives a logo a[10], a[11] 0 as the time delay

5: SPItoCAN. Writedz (byte a[]);Write logo The data format: a[0] register a[1] ~ a[9] send logo

Examples demonstrate:

1、the module identifier (address) specify the instance:

a、the reset。 b、a serial port baud rate: 9600 c、reading module address instruction:55aa55 xxxxxxxx xxxxxxxx(x said any decimal number);   Read the current module address:input instructions:55aa550000523400005234 as shown in figure: center Send instruction execution as a result, as shown in figure: center d、write module address instruction:55aa55 xxxxxxxx xxxxxxxx(x said any decimal number);   Write the current module address:input instructions:55aa550000523400005234 as shown in figure: center Send instruction execution result address have changed,as shown in figure: center

2、the data transmission module:

The following is a data transmission example of two modules:

A、hardware preparation:

center ====B、software to prepare==== 1、the arduino development kit。

2、canbus library。

3、serial debugging software。

1、electric reset。Open the serial port as shown in figure: center 2、 input instruction 55 aa3300aa523400aa5234 and 55 aa330000523400005234 send execution results center 3、clear window, input instructions: 55 aa1100aa523400aa5234 and 55 aa110000523400005234;Send the results: center 4、clear window, input instructions: 55 aa3300aa523400aa5234 and 55 aa330000523400005234;Send the results: center 5、clear window, input instructions: 55 aa2200aa523400aa5234 and 55 aa220000523400005234;Send the results: center 6、clear window, input instructions: 55 aa3300aa523400aa5234 and 55 aa330000523400005234;Send the results: center 7、clear window, input instructions: 55 aa1100aa523400aa5234 and 55 aa110000523400005234;Send the results: center 8、data transfer success OK!

Clone this wiki locally