EmbeddedRelated.com
Forums
Memfault Beyond the Launch

HCS12 and CAN Bus

Started by hc08jb8 February 12, 2004
Hi Folks

I am trying to use CAN bus as a communication link in a project. I
have a CAN 'Master' connected to the PC and several CAN 'Nodes'.
These nodes are based on Motorola HCS12C32 MCU with CAN. I have got
the communication working however I find the default maximum transfer
of 8 bytes per transaction somewhat limiting.

When searching for higher level protocol layers, most of them seem to
be quite expensive or complex. I would like to find out if there is
any simple low cost higher level layer that could handle messages and
so forth greater than 8 bytes?

Another question is, the MCU i use has a Identifier Acceptance
Register and a Identifier Mask Register, I am a bit confused as to
which should I set if I need to filter only one ID, say for example:
accept only messages with ID of 0x105.

Regds
Jay



Hi Jay

checkout MILCAN at www.milcan.org
you can download the specs for free

Regards

Tony White


Hi Jay,

You can also find inofrmations on www.can-cia.de



Hi Jay --

Here are a couple more sources.

www.microcanopen.com

www.micromessaging.com

The micro messaging effort seems to still be in birth, but looks quite
interesting. 607-656-2597 -----Original Message-----
From: hc08jb8 [mailto:]
Sent: Thursday, February 12, 2004 10:52 PM
To:
Subject: [68HC12] HCS12 and CAN Bus Hi Folks

I am trying to use CAN bus as a communication link in a project. I
have a CAN 'Master' connected to the PC and several CAN 'Nodes'.
These nodes are based on Motorola HCS12C32 MCU with CAN. I have got
the communication working however I find the default maximum transfer
of 8 bytes per transaction somewhat limiting.

When searching for higher level protocol layers, most of them seem to
be quite expensive or complex. I would like to find out if there is
any simple low cost higher level layer that could handle messages and
so forth greater than 8 bytes?

Another question is, the MCU i use has a Identifier Acceptance
Register and a Identifier Mask Register, I am a bit confused as to
which should I set if I need to filter only one ID, say for example:
accept only messages with ID of 0x105.

Regds
Jay

--------------------To learn more about
Motorola Microcontrollers, please visit
http://www.motorola.com/mcu
o learn more about Motorola Microcontrollers, please visit
http://www.motorola.com/mcu

Yahoo! Groups Links


Here's how I see it...if you are thinking about creating your own CAN
protocol you need to consider the following (first, study as many of the
other CAN protocols as you CAN)
You are going to have to consider three areas
1) How to define the CAN ID's to transfer data to and from your node
2) How are you going to define the packet data to transfer data in
a standardized method
3) How are you going to handle the flow of data with respect to nodes
communicating on their own, in response to polls and in response to
emergency or unexpected events.

For 1) this can be as simple as each node getting a node number and
that is used in its ID. Any messages sent to that node are sent to that
ID. The problem is that if you have more than one node sending to
the same node, you'll have a problem with the ID's being the same
and they might get sent at the same instant. So, the easiest is to add
the senders ID to the ID so that the ID is based on some number of
bits making up the sender address and some number of bits making
up the receiver ID. The receiver uses its filters to except any message
that is addressed to it without regard to the senders address. Now,
you could also take this one step further and instead of just sending
to and from the node in general, you could add devices within the
node. You could use the CAN ID to encode a 7 bit sender node address,
a 7 bit sender device, a 7 bit receiver node address and a 7 bit
receiver device. (assuming 29 bit ID is used) This would give your
network 128 nodes with each node having 128 unique devices, being
whatever you want, motors, switches, outputs, etc etc. Keep in mind
this is just one method and other protocols like CANOpen and J1939
have different methods. Also, you can reserve the node address zero/
device address zero for anybody that wants to broadcast data to
everybody in general. This means if you have a switch that changes
state and you don't know who on the network cares about it, you
broadcast it to mynode/mydevice/zero/zero and it is up to the reciever to
know to look
for that node/device packet.
2) Ok, so now you can send data to and from any node on the network,
now you must define what the data looks like. For a simple protocol,
you can just define that the first byte of the protocol is a command byte
and that this defines how the rest of the data is organized. For example,
define the command value of one to mean "send my your value" and
two to be "Here is my value". You could leave it up to the receiver
to know that a particular node/device will be sending data in a particular
format, with regards to the rest of the packet or you could define a
second byte to be a data type identifier that defines the following data
to be 1 bit, 1 byte, 2 bytes, 4 byte floating point etc. If you are sending
data that spans more than one packet, than you need to define a command
for multipacket data and a byte or two to define the index number of
the packet currently being sent. With one command byte, a two byte
index, this leaves 5 data bytes*0xFFFF(index) for 320K of data. Again,
this is a simple method for a simple protocol.
3) OK, this is turning into a novel...actually, I think I'll leave it here
for now, I've
covered some of point three already anyway.

Steve Steven D. Letkeman BSc.
President - Zanthic Technologies Inc.
403-526-8318
www.zanthic.com Embedded micro-controllers and CAN interfaces
www.brightan.com Automated lighting systems ----- Original Message -----
From: "hc08jb8" <>
To: <>
Sent: Thursday, February 12, 2004 8:52 PM
Subject: [68HC12] HCS12 and CAN Bus > Hi Folks
>
> I am trying to use CAN bus as a communication link in a project. I
> have a CAN 'Master' connected to the PC and several CAN 'Nodes'.
> These nodes are based on Motorola HCS12C32 MCU with CAN. I have got
> the communication working however I find the default maximum transfer
> of 8 bytes per transaction somewhat limiting.
>
> When searching for higher level protocol layers, most of them seem to
> be quite expensive or complex. I would like to find out if there is
> any simple low cost higher level layer that could handle messages and
> so forth greater than 8 bytes?
>
> Another question is, the MCU i use has a Identifier Acceptance
> Register and a Identifier Mask Register, I am a bit confused as to
> which should I set if I need to filter only one ID, say for example:
> accept only messages with ID of 0x105.
>
> Regds
> Jay >
>
> --------------------To learn more
about Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu
> o learn more about Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu
>
> Yahoo! Groups Links >



Hi Steve,

> 3) OK, this is turning into a novel...actually, I think I'll leave it here
> for now, I've covered some of point three already anyway.

..and you have covered it VERY WELL!

Thanks,

Bob Furber

__________________________________________________________

Connect your micro to the internet the easy way
www.microcommander.com

Microcontroller with an obscenity of I/O & features
..in a small footprint www.steroidmicros.com
__________________________________________________________


--- In , "Steve Letkeman" <hc12list@z...> wrote:

> Here's how I see it...if you are thinking about creating your own CAN
> protocol you need to consider the following (first, study as many of the
> other CAN protocols as you CAN)

You are opening a CAN of worms here...



thanks Bob, most of what I was describing comes from the
protocol I designed for the HC12+CAN based lighting
system I've been developing. The protocol is designed to
be used for lighting commands plus the ability to add other,
yet to be defined, equipment (alarm systems, temp sensors,
weather station, music control, etc etc) without getting so
complex you need months to understand the protocol and
a megabyte to implement. The newest version allows
firmware to be downloaded across the CAN bus as well.

Steve Steven D. Letkeman BSc.
President - Zanthic Technologies Inc.
403-526-8318
www.zanthic.com Embedded micro-controllers and CAN interfaces
www.brightan.com Automated lighting systems

----- Original Message -----
From: "Bob Furber" <>
To: <>
Sent: Friday, February 13, 2004 10:10 AM
Subject: RE: [68HC12] HCS12 and CAN Bus > Hi Steve,
>
> > 3) OK, this is turning into a novel...actually, I think I'll leave it
here
> > for now, I've covered some of point three already anyway.
>
> ..and you have covered it VERY WELL!
>
> Thanks,
>
> Bob Furber



Hi Steve

> ..most of what I was describing comes from the
> protocol I designed for the HC12+CAN based lighting
> system I've been developing.
>
> www.brightan.com Automated lighting systems

Impressive!

Your Yacht?

What do you use as the USB4CAN device? Did you roll this yourself? Or, is it
an off-the-shelf item?

Bfn,

Bob Furber

__________________________________________________________

Connect your micro to the internet the easy way
www.microcommander.com

Microcontroller with an obscenity of I/O & features
..in a small footprint www.steroidmicros.com
__________________________________________________________


Ya, that's my $15 mil yacht I earned doing embedded processor
work, doesn't everyone have one? The CAN-4-USB is an interface
that I've designed and have been selling for a number of years now.
http://www.zanthic.com/can4usb.htm
(thanks for asking and sorry for the blatant plug)
S

> Hi Steve
>
> > ..most of what I was describing comes from the
> > protocol I designed for the HC12+CAN based lighting
> > system I've been developing.
> >
> > www.brightan.com Automated lighting systems
>
> Impressive!
>
> Your Yacht?
>
> What do you use as the USB4CAN device? Did you roll this yourself? Or, is
it
> an off-the-shelf item?
>
> Bfn,
>
> Bob Furber
>
> __________________________________________________________
>
> Connect your micro to the internet the easy way
> www.microcommander.com
>
> Microcontroller with an obscenity of I/O & features
> ..in a small footprint www.steroidmicros.com
> __________________________________________________________ >
> --------------------To learn more
about Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu
> o learn more about Motorola Microcontrollers, please visit
> http://www.motorola.com/mcu
>
> Yahoo! Groups Links



Memfault Beyond the Launch