Can bus configuration

General discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
amfortas
Posts: 212
Joined: 18 Feb 2010 18:10

Can bus configuration

#1 Post by amfortas » 17 Jan 2015 12:27

Hi,

I am wishing to use a CANSPI module and EasyPic 6 as a prototype data logger served by around 100 nodes collecting weight data from animal feeders.

I am inexperienced in CAN BUS but have read extensively. I am not clear how best to get the single central node(data logger) to accept messages from
up to 100 sensor nodes.

My first plan is to set the arbitration message I.D. on all sensor nodes to a common I.D. say I.D.=999 and to identify the individual node sensor data(weight)
using 2 bytes of the data array.

I think there may be arbitration problems with the identical priority of all nodes ?

The sensor nodes will use a can bus to can bus WLAN to the data logging node.

Alternatively I could give each sensor node its own transmit I.D, but with a common segment of bits to be isolated by the data logger node using the masking
function.

I feel that this simple situation of a central node reading many sensor nodes should be simple and possibly either of these suggested methods might work ?

I am trying to stick to the ME Pascal CAN BUS tools,

I would welcome a comment from anyone who is experienced in CAN bus.

Very many thanks,

amfortas

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: Can bus configuration

#2 Post by dejan.odabasic » 19 Jan 2015 14:02

Hello,
amfortas wrote:I am not clear how best to get the single central node(data logger) to accept messages from
up to 100 sensor nodes.
Central node will call-out the weight-measuring(WM) nodes(each with different address) and WM-nodes will reply only when they receive message from central node.
When central node receive reply, it can continue with calling out the next WM-node.
amfortas wrote:My first plan is to set the arbitration message I.D. on all sensor nodes to a common I.D. say I.D.=999 and to identify the individual node sensor data(weight)
using 2 bytes of the data array.
At my opinion addressing each WM-node with specific address is better approach.

I suggest testing the CANSPI example projects and then try adding nodes to network with similar configuration (with different ID_2nd).

Best regards.

amfortas
Posts: 212
Joined: 18 Feb 2010 18:10

Re: Can bus configuration

#3 Post by amfortas » 19 Jan 2015 16:13

Many thanks Dejan,

Yes,

I am rigging up three nodes to experiment with.

What I did not mention was that I am needing an event driven process where the sensor nodes send weight when an animal leaves its feeder and fires this
event when its access gate closes and changes the state of its hinge switch.

The sensor messages will occur randomly and there will be occasions where two animals withdraw at the same instant but given the speed of the CAN bus
transaction, this collision will be rare - but it will occur,

The requirement is therefore that the instant an animal withdraws, the weight data is sent after a processing time of maybe 1 second, To this is added
the SPI time and the controller processing time. But these times do not slow down the CAN bus speed so the collision window remains very short.

It would maybe be possible to make the data logging node a listen only mode but obviously it would be useful to delegate all sorts of configuration
tasks to the central controller.

I simply cannot quite make out from the Microchip data sheet whether there is anything against the central controller handling random messages from
around 100 nodes.

Very many thanks Dejan all very helpful. Looks like the proof of the pudding will be in the eating !

Regards,

Amfortas

amfortas
Posts: 212
Joined: 18 Feb 2010 18:10

Re: Can bus configuration

#4 Post by amfortas » 20 Jan 2015 17:39

Hi Dejan,

Yes, I now understand that CAN bus arbitration/prioritisation cannot accept duplicate I.D. and that use of the masks cannot
enable acceptance of part of an I.D. to enable multiple node reads.

So it looks as though event triggering cannot be made to work. It looks therefore that I must transmit from the central node
and try to accommodate the scan time latency. This may be possible if I can keep the 100 sensor node transactions in under 2 secs.

Pity but reality is reality !

(I will see what happens when I set the RXBn.CNTR mask control bits to 11 on the basis that I could accept the Central Node as read only and the sensor
nodes as send only using different I.D.s Not a normal option but maybe acceptable in this simple data collection task. Not optimistic
but if CAN monitors use this to see every bus transaction it might work.)

Thanks

Amfortas

amfortas
Posts: 212
Joined: 18 Feb 2010 18:10

Re: Can bus configuration

#5 Post by amfortas » 27 Jan 2015 13:37

Having travelled the CAN bus learning curve, the problem which was concerning me, I find does not exist.

My need to use a central node as a data logger from some 100 sensor nodes has resolved into masking out
the unique sensor I.D. bytes, thereby ensuring the CAN bus carries the required unique arbitration frames
whilst the RX buffer accepts all sensor nodes.

This has been tested very easily by connecting a CANSPI module to my EASYPIC6 in communication with
two of my prototype sensor nodes.

It was important that my solution used formal CAN bus methods so that system access to commercial CAN bus
products further down the line is achievable.

The MikroElectronica CANSPI module made life very easy whilst exploring CAN bus as a novice. I can now
confidently purchase a bus analyser in order to document performance as the bus traffic is increased however
there should be no nasty surprises considering the random and one way flow of data during routine
animal feed consumption monitoring. It looks like all my Pascal CANSPI services will be easily
met by the CANSPI library services.

Many thanks

Amfortas

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Can bus configuration

#6 Post by filip » 28 Jan 2015 12:59

Hi,

Thanks for sharing your experience with us, I'm sure you will advance quickly in implementing CAN networks. :)

Regards,
Filip.

amfortas
Posts: 212
Joined: 18 Feb 2010 18:10

Re: Can bus configuration

#7 Post by amfortas » 28 Jan 2015 18:42

Thanks Filip,

I am now designing a local control unit for the sensor nodes using the PIC18F458.

I can find the MikroP CANSPI tools but not the direct CAN tools to use when the CAN controller is within the PIC.

No great problem but there appear to be MikroC tools utilised by Dogan Ibrahim in his
book Controller Area Networks which I found helpful.

Regards,

Amfortas

amfortas
Posts: 212
Joined: 18 Feb 2010 18:10

Re: Can bus configuration

#8 Post by amfortas » 30 Jan 2015 01:17

O.K. I see the Library changes with the processor - stuck to one processor for too long !

Amfortas

Post Reply

Return to “mikroPascal PRO for PIC General”