Click here to Order!

CANPIC Home
Up
CANUSB
CANPIC PIC18F258 Project
More Information
Custom Work

CANPIC ASCII Commands
CANPIC Binary Commands

CANPIC

 

CANPIC CAN232 - ASCII Commands

The CANPIC CAN232 processes commands to configure the network, send messages, and monitor messages. Each are explained in detail in the following sections.

OFFLINE

The offline command, F, disables communications. This command does not require the carriage return to terminate the command.

ONLINE

The online command, O, enables communications. This command does not require the carriage return to terminate the command.

BAUD RATE

The baud rate command is used to view or set the baud rate. The following table lists the available built-in baud rates and the format of the command. Custom baud rates are available by selecting baud rate 19 and using the T command.

B[cr] displays current baud rate
B0[cr] = 1 mbps
B1[cr] = 889 kbps
B2[cr] = 800 kbps
B3[cr] = 727 kbps
B4[cr] = 666 kbps
B5[cr] = 500 kbps (default value)
B6[cr] = 250 kbps
B7[cr] = 167 kbps
B8[cr] = 125 kbps
B9[cr] = 100 kbps
B10[cr] = 83.3 kbps
B11[cr] = 62.5 kbps
B12[cr] = 50 kbps
B13[cr] = 41.67 kbps
B14[cr] = 33 kbps
B15[cr] = 31.25 kbps
B16[cr] = 25 kbps
B17[cr] = 20 kbps
B18[cr] = 10 kbps
B19[cr] = Custom (use T command for custom baud rate configuration)

 

CONFIGURE MESSAGE OBJECT

The configure message object command sets the direction, type, length, and id for a message.

Cobj,dir,type,len,id[cr]

obj specifies one of 20 message objects from 0 to 19
dir specifies the direction, either R for receive or T for transmit
type specifies either S for standard 11 bit identifiers or E for extended 29 bit identifiers
len specifies the message length for 0 to 8 data bytes
id specifies the 11 or 29 bit identifier

For example:

C0,R,S,8,0x100[cr] specifies that message object #0 is a receive message, standard 11 bit ID, 8 data bytes and id=0x100(hex).

C1,T,S,5,50[cr] specifies message #1 is a transmit message, standard 11 bit ID, 5 data bytes, and id is 50 (decimal).

C2,T,E,4,0x10000[cr] specifies message #2 is a transmit message, extended 29 bit ID, 4 data bytes, and id is 0x10000(hex).

C19,R,E,8,0x1aa55[cr] specifies message #19 is a receive message, extended 29 bit ID, 8 data bytes, and id is 0x1aa55(hex).

DISPLAY MESSAGE OBJECT CONFIGURATION

The message object configuration is displayed using the M command.

For example:

M[cr] displays all the message configurations.

M1[cr] displays the configuration for message object #1.

SET MESSAGE DATA (with echo)

Message data is set using this command.

For example:

S0,0,0,55,0,0xaa,0,0,1[cr] sets all 8 data bytes for message object #0.

S1,0,2[cr] sets only the first 2 data bytes for message object #1. The remaining 6 are left unchanged. Each character received is echoed back to the sender. 

Note: To set individual bytes use the Set Message Data Byte command.

SET MESSAGE DATA (without echo)

Message data is set using this command without echoing characters back to the sender. This command is available with version 3.7 and later.

The first byte is the + (plus) character.

For example:

+2,0,0,55,0,0xaa,0,0,1[cr] sets all 8 data bytes for message object.

+1,0,2[cr] sets only the first 2 data bytes for message object #1. The remaining 6 are left unchanged. Each character received is echoed back to the sender. 

Note: To set individual bytes use the Set Message Data Byte command.

DISPLAY MESSAGE DATA

Message data is displayed using this command.

For example:

D1[cr] displays all 8 data bytes for message object #1

 

SEND/RECEIVE MESSAGE

The ASCII characters 0 through 9 can be used to send or receive message object 0 through 9. In order to perform the operation on message object 10 thorugh 19, the dot qualifier is used ( .5 sends message object 15). If the message has been configured to transmit then the message will be sent. If the message has been configured to receive then CAN232 will display if the message is new and will also display the data bytes.

For example:

5      Entering just the ASCII character 5 wil cause message 5 to be sent (if configured)

.4     Entering the period followed by an ASCII character 4 wil cause message 14 to be sent (if configured).

PUT INDIVIDUAL MESSAGE DATA BYTE (with echo)

The P command allows writing an individual data byte in a message.

Pobj,b,d[cr] where obj is message object 0 to 9, b is the data byte location in the message from 0 to 7, and d is value to write to the data byte.

For example:

P1,0,10[cr] writes decimal 10 to the first data byte of message 1

P9,7,0xa0[cr] writes hexadecimal a0 to the last data byte of message 9

PUT INDIVIDUAL MESSAGE DATA BYTE (without echo)

The - (minus) command allows writing an individual data byte in a message without echoing characters back to the sender.  This command is available with version 3.7 and later.

-obj,b,d[cr] where obj is message object 0 to 9, b is the data byte location in the message from 0 to 7, and d is value to write to the data byte.

For example:

-1,0,10[cr] writes decimal 10 to the first data byte of message 1

-9,7,0xa0[cr] writes hexadecimal a0 to the last data byte of message 9

 

 

GET INDIVIDUAL MESSAGE DATA BYTE

The G command allows reading an individual data byte in a message.

Gobj,b[cr] where obj is message object 0 to 19 and b is the data byte location in the message from 0 to 7. The value is returned as a decimal value terminated with a carriage return.

For example:

G1,0[cr] reads the first data byte of message 1

G16,7[cr] reads the last data byte of message 16

 

MESSAGE SEND TIME

Message objects can be configured to be transmitted periodically.

Qobj,b[cr] where obj is message object 0 to 19 and b is the number of milliseconds from 1 to 65535. A value of 0 disables the feature.

Q[cr] returns a list of all the values.

For example, set message 2 to send every 50 milliseconds then display all the message send times.

Q2,50[cr]

Q[cr]

Message send times

0: 0
1: 0
2: 50
3: 0
4: 0
5: 0
6: 0
7: 0
8: 0
...
...
18: 0
19: 0

 

SAVE SETUP

The CANPIC CAN232 allows the following configuration items to be saved to onboard non-volatile memory;

Message objects 0 to 9 configuration (direction, type, data length, ID)
Message objects 0 to 9 message send times
Baud Rate
Autostart configuration

The format for this command is as follows;

Y0[cr]              Command sent to the CANPIC CAN232 device

Saving ...         Response from CANPIC during the operation.
Complete[cr]    When completed.

RESTORE SETUP

The CANPIC CAN232 allows the stored configuration items to be recalled from onboard non-volatile memory. The items recalled are listed in the SAVE SETUP command.

The format for this command is as follows;

Z0[cr]              Command sent to the CANPIC CAN232 device

Restored[cr]    Response from CANPIC.

SET BIT TIME REGISTERS

The SET BIT TIME REGISTERS command allows a user to setup the registers that control the baud rate to values other than the standard values set using the BAUD RATE command. Refer to the PIC18F258 data sheet for more information. This command is for advanced users and will not be needed in most cases. A T[cr] will display the custom settings.

Tbrgcon1,brgcon2,brgcon3[cr]

READ CAN REGISTER

The READ CAN REGISTER command allows a user to read the value of one of the PIC18F258 CAN registers. The registers start at address 0xf00 in the PIC and the command uses the offset from the base to address the register.

Rreg[cr] where reg is the 8-bit address offset of the register from 0xf00.

WRITE REGISTER

The WRITE REGISTER command allows a user to write a value to one of the PIC18F258 CAN registers. The registers start at address 0xf00 in the PIC and the command uses the offset from the base to address the register.

Wb,d[cr] writes the 1 byte value d (range 0 to 255 or 0 to 0xff) to CAN register b (0 to 255 or 0 to 0xff).

VERSION

This command displays the version information, terminated with a carriage.

V No carriage return is needed.

 

 

 

 

 

 

   

Copyright © 2002 Embedded Micro Software  |   Site Map  |  Contact Us