Author Topic: Need example on how to properly send multiple can packets  (Read 11732 times)

techn0

  • Guest
Need example on how to properly send multiple can packets
« on: October 24, 2016, 04:25:40 PM »
New to guide.  I'm learning.  I am able to use a single CAN_Tx and CAN_Rx to send and receive a single can packet without a problem but as soon as I try to configure a second CAN_Tx the data gets mixed at times.  I think it is trying to send them right on top of each other.  I have tried different oscillator values to step the sending of the packets with no success.  Eventually I am going to need to send and receive multiple packets in both directions from dp700 display and mc038 controller.  Manual and examples I have seen so far are great to get started but lacking for more complex CAN comms.

Any assistance would be greatly appreciated. Thanks

Offline FluidPowerTom

  • PLUS+1 Guru
  • *****
  • Posts: 363
  • Karma: +33/-0
Re: Need example on how to properly send multiple can packets
« Reply #1 on: October 24, 2016, 05:22:47 PM »
The oscillator values won't be the issue.  If they did try to send at the exact same time then CAN has a way of arbitrating that.  It sounds like you might have the same CAN ID for multiple messages being sent.  You want to have separate CAN ID for each message.  You might want to post an image of your program.
Controls Engineer
Hydra-Power Systems

techn0

  • Guest
Re: Need example on how to properly send multiple can packets
« Reply #2 on: October 24, 2016, 05:30:59 PM »
I am using different IDs  The data gets parsed properly on the other end but sometimes the values are interpreted by the wrong CAN_Rx ID.  Figured it was because the packets were getting sent at the same time.

See pics.

Offline Loader

  • PLUS+1 Expert
  • ****
  • Posts: 50
  • Karma: +3/-0
  • If something can go wrong, it will!
Re: Need example on how to properly send multiple can packets
« Reply #3 on: October 25, 2016, 11:25:13 AM »
They seems properly managed...maybe the problem is in rx data....? You can control with CAN King if the data are correct on bus?
regards

Offline FluidPowerTom

  • PLUS+1 Guru
  • *****
  • Posts: 363
  • Karma: +33/-0
Re: Need example on how to properly send multiple can packets
« Reply #4 on: October 25, 2016, 05:39:41 PM »
Agreed - that all looks correct unless you've got some data type issues.  Are any of those signals using a Signed data type before you split them into U8 types?  My guess though is also that there's something on the receiving end that is mixing things up.
Controls Engineer
Hydra-Power Systems

Offline jashom1

  • PLUS+1 Expert
  • ****
  • Posts: 78
  • Karma: +6/-0
Re: Need example on how to properly send multiple can packets
« Reply #5 on: October 26, 2016, 02:05:59 AM »
Have you got a screenshot of your RX block?  Are you using ID filter mask?  Are you using multiple RX blocks to receive the same message ID?  You can use multiple Tx blocks with the same ID, but you can only use one Rx block (with no data or ID filtering) as one of them will be ignored.

Hope this helps :)

John.

techn0

  • Guest
Re: Need example on how to properly send multiple can packets
« Reply #6 on: October 26, 2016, 03:41:51 PM »
Here is the Rx program.  Keep in mind that I have now changed the IDs to 0x001 and 0x002 respectively.  It did not change anything.  I also posted a video so you can see what is happening.  Look at the section where there are 6 u16 variables grouped together.  Occasionally it will display zeros.  That should not happen.  When there are values in all 6 spots it is working as expected.

Also I have examined the data with can King and it checked out as one would expect.
« Last Edit: October 26, 2016, 03:44:25 PM by techn0 »

techn0

  • Guest
Re: Need example on how to properly send multiple can packets
« Reply #7 on: October 26, 2016, 03:46:51 PM »
Here is a screen shot of Can King

techn0

  • Guest
Re: Need example on how to properly send multiple can packets
« Reply #8 on: October 26, 2016, 04:32:51 PM »
I changed the CAN_Rx2 id to 0x003 and nothing changed even though Tx2 is still set at 0x002.

Seems to receive the packet no matter what I have the rx id set to

Why would that be?


Offline FluidPowerTom

  • PLUS+1 Guru
  • *****
  • Posts: 363
  • Karma: +33/-0
Re: Need example on how to properly send multiple can packets
« Reply #9 on: October 26, 2016, 05:31:36 PM »
The problem you're having is because your mask is set to 0.  If you want you can read up on logical masking, but for what you're doing you'll want to set that mask to 0xFFFF
Controls Engineer
Hydra-Power Systems

techn0

  • Guest
Re: Need example on how to properly send multiple can packets
« Reply #10 on: October 26, 2016, 05:45:24 PM »
I changed Rx masks to 0xFFFF and it works exactly as expected now.  I don't think I would have ever figured that out. 

Thank you immensely