Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
projects:pic32mx_obd_evaluation_board [2017/01/03 11:29] admin [PIC core module] |
projects:pic32mx_obd_evaluation_board [2019/08/20 18:33] admin [PIC32MX OBD Evaluation Board] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== PIC32MX OBD Evaluation Board ====== | ====== PIC32MX OBD Evaluation Board ====== | ||
- | {{:projects:dsc_5593_800x536.jpg?512 |}} | + | {{:projects:dsc_5593_800x536.jpg?456 |}} |
===== Requirements ===== | ===== Requirements ===== | ||
===== Basics of communication protocol ===== | ===== Basics of communication protocol ===== | ||
Line 73: | Line 73: | ||
^ R | RFID module | | ^ R | RFID module | | ||
^ Q | data acquisition module | | ^ Q | data acquisition module | | ||
- | |||
==== Generic NAK responses (shared by all modules) ==== | ==== Generic NAK responses (shared by all modules) ==== | ||
Line 93: | Line 92: | ||
* low level communication with devices on I²C bus | * low level communication with devices on I²C bus | ||
==== Commands ==== | ==== Commands ==== | ||
+ | ^ c | calculate CRC checksum for given data | | ||
^ C | configure communication parameters | | ^ C | configure communication parameters | | ||
^ d | get date and time | | ^ d | get date and time | | ||
Line 101: | Line 101: | ||
^ i | read data from I²C device | | ^ i | read data from I²C device | | ||
^ I | write data to I²C device | | ^ I | write data to I²C device | | ||
+ | ==== Calculating CRC checksum ==== | ||
+ | <code> | ||
+ | Query | ||
+ | ---------------------------------------------- | ||
+ | | SOF | P | c | TYPE | P1..P4 | D1..DN | EOF | | ||
+ | ---------------------------------------------- | ||
+ | </code> | ||
+ | where | ||
+ | ^ TYPE | 1b | s - 16-bit CRC-CCITT calculated by software (only P4 used); d - CRC calculated by DMA module | | ||
+ | ^ P1 | 1b | 0 - input data not reflected (MSB first); ≠0 - input data reflected (LSB first) | | ||
+ | ^ P2 | 1b | length of CRC polynom (1..32) | | ||
+ | ^ P3 | 4b | CRC polynom | | ||
+ | ^ P4 | 4b | CRC seed | | ||
+ | ^ D1..DN | Nb | data in form of ASCII HEX | | ||
+ | <code> | ||
+ | Response | ||
+ | ------------------------------------------- | ||
+ | | SOF | P | 00 | CRC | TIME | CHSUM | EOF | | ||
+ | ------------------------------------------- | ||
+ | </code> | ||
+ | where | ||
+ | ^ CRC | 4b | calculated CRC | | ||
+ | ^ TIME | 2b | time in μs the calculation process took | | ||
+ | Error codes | ||
+ | ^ N02 | Invalid parameters provided | | ||
==== Configuring communication parameters ==== | ==== Configuring communication parameters ==== | ||
<code> | <code> | ||
Line 207: | Line 232: | ||
where | where | ||
- | ^ TTTT | 4 chars | temperature coded as two's complement (see packet format below) | | + | ^ TTTT | 2b | temperature coded as two's complement (see packet format below) | |
Format of TTTT packet: | Format of TTTT packet: | ||
Line 216: | Line 241: | ||
Error codes | Error codes | ||
^ ?? | ?? | | ^ ?? | ?? | | ||
+ | ==== Reading from I²C device ==== | ||
+ | <code> | ||
+ | Query | ||
+ | -------------------------------------------- | ||
+ | | SOF | P | i | A1 | A2 | LN | CHSUM | EOF | | ||
+ | -------------------------------------------- | ||
+ | </code> | ||
+ | <code> | ||
+ | Response | ||
+ | ---------------------------------------------- | ||
+ | | SOF | P | 00 | D1 | ... | DN | CHSUM | EOF | | ||
+ | ---------------------------------------------- | ||
+ | </code> | ||
+ | where | ||
+ | ^ A1 | 1b | I²C device address | | ||
+ | ^ A2 | 1b | register address | | ||
+ | ^ LN | 1b | number of bytes to be read (0..255) | | ||
+ | ^ D1..DN | Nb | data | | ||
+ | |||
+ | Error codes | ||
+ | ^ ?? | ?? | | ||
+ | ==== Writing to I²C device ==== | ||
+ | <code> | ||
+ | Query | ||
+ | ------------------------------------------------------- | ||
+ | | SOF | P | I | A1 | A2 | D1 | ... | DN | CHSUM | EOF | | ||
+ | ------------------------------------------------------- | ||
+ | </code> | ||
+ | |||
+ | where | ||
+ | ^ A1 | 1b | I²C device address | | ||
+ | ^ A2 | 1b | register address | | ||
+ | ^ D1..DN | Nb | data to be written | | ||
+ | |||
+ | Error codes | ||
+ | ^ ?? | ?? | | ||
===== Carmon logger ===== | ===== Carmon logger ===== | ||
Carmon logger module provides API for | Carmon logger module provides API for | ||
* configuring operating mode of Carmon logger device | * configuring operating mode of Carmon logger device | ||
+ | * determining last sector written by Carmon logger | ||
+ | * reading sectors from the log device | ||
==== Commands ==== | ==== Commands ==== | ||
^ C | configure the module | | ^ C | configure the module | | ||
+ | ^ l | get number of last sector written by Carmon logger | | ||
+ | ^ R | read blocks from the log device according to provided parameters | | ||
+ | ^ r | read subsequent blocks from the log device according to parameters previously set via 'R' command| | ||
==== Configure the module ==== | ==== Configure the module ==== | ||
<code> | <code> | ||
Line 237: | Line 303: | ||
| SOF | L | A | CHSUM | EOF | | | SOF | L | A | CHSUM | EOF | | ||
----------------------------- | ----------------------------- | ||
+ | </code> | ||
+ | ==== Read sectors from the log device according to provided parameters ==== | ||
+ | <code> | ||
+ | Query | ||
+ | -------------------------------------------------------- | ||
+ | | SOF | L | R | CONF | SECSTART | BLKNUM | CHSUM | EOF | | ||
+ | -------------------------------------------------------- | ||
</code> | </code> | ||
+ | where | ||
+ | ^ CONF | 1b | configures how sectors are transfered to the master | | ||
+ | ^ SECSTART | 4b | number of 1st sector to be read | | ||
+ | ^ BLKNUM | 4b | number of blocks to be read | | ||
+ | Format of CONF word: | ||
+ | ^ bit# ^7^6^5^4^3^2..0^ | ||
+ | ^ | NA | NA | NA | 1/0..binary/ASCII mode | 1/0..block is/is not compressed | number of sectors in block (1-8) | | ||
+ | <code> | ||
+ | ACK response - standard ASCII mode | ||
+ | ----------------------------------------------- | ||
+ | | SOF | L | A | SN | B1D1..B1DN | CHSUM | EOF | | ||
+ | ----------------------------------------------- | ||
+ | ----------------------------------------------- | ||
+ | | SOF | L | A | SN | B2D1..B2DN | CHSUM | EOF | | ||
+ | ----------------------------------------------- | ||
+ | ... | ||
+ | ----------------------------------------------- | ||
+ | | SOF | L | A | SN | BMD1..BMDN | CHSUM | EOF | | ||
+ | ----------------------------------------------- | ||
+ | ACK response - binary mode | ||
+ | --------------------------------------------------- | ||
+ | | DLE | STX | SN | B1D1..B1DN | CHSUM | DLE | ETX | | ||
+ | --------------------------------------------------- | ||
+ | --------------------------------------------------- | ||
+ | | DLE | STX | SN | B2D1..B2DN | CHSUM | DLE | ETX | | ||
+ | --------------------------------------------------- | ||
+ | ... | ||
+ | --------------------------------------------------- | ||
+ | | DLE | STX | SN | BMD1..BMDN | CHSUM | DLE | ETX | | ||
+ | --------------------------------------------------- | ||
+ | </code> | ||
+ | where | ||
+ | ^ SN | 1b | sequence number (01-FF); incremented with each packet; useful for detection of packet loss | | ||
+ | ^ BxD1..BxDN | Nb | Xth data block (CONF[2..0] sectors) | | ||
+ | note: When operating in binary mode, each DLE data byte is replaced with sequence of two DLE bytes. | ||
===== RFID module ===== | ===== RFID module ===== | ||
RFID module provides API for | RFID module provides API for |