Extracting data from CAN message

Excuse me Sir , can i ask you a others questions very similar to the project ... ?

I need to turn on a certain number of helpers in relation to data transmitted by my CAN bus.

In my previous project I had only one CAN but now I want to read only the next one:

I have identified the ID in hexa is : 321 , a lenght of 16 bits , I want to read from 8 th to 24 th bytes and I have an Offset of 0.1

I realized the following code but I'm looking for how to modify the beginning of my VOID loop to read only the desired ID...

Do you know a way to do that simplely ?

This has nothing to do with replacing dots by commas…

In the future You need to create your own post for this. I’m moving this to a new thread

1 Like

Damn right I'm not familiar with the forum rules yet :slight_smile:

can you help me?

Most CAN controllers have filters, use one of them and your code will not have to process all the unrelated stuff.

1 Like

i try my code today but idk why i'm stuck at

 if(!digitalRead(CAN0_INT))   

I correctly connect my Can bus on my Arduino

show what you tried.
what do you receive? if you don't want to use filtering, store the payload in a buffer and parse it.

1 Like

that implies that NO MESSAGES are being received then!

did you check if your CAN wires are connected the right way and not inverted?

1 Like

does the receive example from the library work?

is CS connected to pin 10 or 53?

1 Like

What are helpers in relation to data transmitted. How did you get your previous project work with only one CAN module? The reason I ask it needs an acknowledge generated by any module other then the transmitter.

Since you are using Cory Fowler's library I have something for you to try to check the hardware. Leave all the hardware connected. In the library there are two samples one called send the other called receive. Load send into one module and receive in the other and validate it works, if so reverse send and receive and see if that works. If not is is something in hardware. This gets us past the hard part.

You state: I have identified the ID in hexa is : 321 , a lenght of 16 bits , I want to read from 8 th to 24 th bytes and I have an Offset of 0.1 That does not sound correct. A CAN base frame supports a length of 11 bits for the identifier, and the CAN extended frame supports a length of 29 bits for the identifier, made up of the 11-bit identifier ("base identifier") and an 18-bit extension ("identifier extension"). So 16 bits is confusing.

Since the CAN Protocol itself is limited to a maximum payload of 8 bytes you cannot read the 8th through 24th bytes. The byte count is 0-7. By definition you cannot send a payload greater than 8 bytes in one frame while working with CAN Protocol .

You mention an offset of 0.1, that is impossible as everything is either a zero or one and normally referenced in bytes. 0.1 is a floating point number and can be processed in a binary representation.

I would suggest you rework your question and try using better terms and keep all the numbers in one radix, hex prefered (0X) as the prefix and some of us oldtimers remember it as an H suffix.

1 Like

Hello everyone after many tests and verifications there were many connection problems.

I receive on my computer
Standard ID : 0x321
with a frame with which I get my value 0x373 --> 883 --> 88.30 ( in % )

But I have a problem with the display of my leds.
For 88% I'm supposed to have leds 1 to 17 on, but here all my leds are on except LED3.

It seems that on the one hand the leds are reversed (LED 3 LED 17) and on the other hand that the lighting according to the thresholds does not work here ...

for 88% I would like all the leds below LED 17 On and the rest above until the 20 OFF but how to do it simply?

Thank you for your help and your patience

CAN only transmits and receives 8 bit binary data (bytes) up to 8 per message. You need to find out the format of the message. Post that frame in HEX, include the identifier. Where is this message coming from?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.