Go Down

Topic: Adding a leading 0 to incoming HEX data for conversion to binary (Read 3192 times) previous topic - next topic

Delta_G

You're still talking about converting a binary number to decimal to do some math. That's where you misunderstand.  A computer CANNOT do math in decimal. They only understand binary.  You can display a number however you want but the numbers themselves are all represented in binary for the processor.  You don't need to convert anything to do math with it.  Math is the same in any base anyway.  The only time comverting bases comes into play is when you want to display a number for a human.
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

PaulS

You have 64 bits of data. Use a little math, to determine which byte the data is in, and bitRead() to read the bit from the byte. Do that as many times as needed to get all the bits that make up a value. Then, just use the value. Do not concern yourself with whether the bits represent a binary value, a decimal value, or a hexadecimal value.

aarg

Hi all!
Thanks a lot for your help.

@aarg: What I doing it reading CAN-Bus Data from a Car. I get 8 * 8Bytes of Data, saved in an Array "rx_frame.dada.u8"

So in total, I receive 64 Bits of information.

But as others have pointed out, you are not receiving CAN data as a string of binary characters. You are receiving it as a series of bytes, which have all 8 bits, not just the bits that happen to get printed by the Arduino binary print method.

The real answer to my question, which is what are you doing with the binary string, is "nothing except looking at it and being confused". Because, the binary string is just one of many ways of printing it.

You may find this function useful: BitRead
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

Go Up