Pages: [1]   Go Down
Author Topic: Question about hex codes  (Read 801 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys,

I'm needing to convert some IR codes to use with arduino. The codes that I normally use
are in Hex format like this:

0000 006a 002d 0001 000a 001e 000a 0047 000a 001e 000b 001e 000a 001f 000a 001e
000a 0046 000b 001e 000a 001e 000a 0047 000a 0047 000a 0046 000a 0047 000a 001e
000a 001f 000a 06a2 000a 001f 000a 0046 000b 001e 000a 001f 000a 001e 000a 0047
000a 001e 000a 0047 000a 0046 000b 001e 000a 001f 0009 001f 000a 001e 000a 0047
000a 0046 000b 06a2 000a 001e 000a 0047 000a 001f 000a 001e 000a 001f 000a 001e
000a 0047 000a 001e 000a 001f 000a 0046 000a 0047 000a 0047 000a 0046 000a 001f

but I need to convert this to something like this:

0x02FD48B7

I don't have any idea how to do this, I don't know if is a base conversion, or
some conversion of type, if anybody can help me, I will be very grateful.
Logged

Offline Offline
Edison Member
*
Karma: 32
Posts: 1387
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just put '0x' in front of your numbers, that signals the compiler to treat it as hex, not decimal.
Logged

ivrea (to)
Offline Offline
Faraday Member
**
Karma: 77
Posts: 4645
miaaao ^-^
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your codes are printed using the example sketch IRrecvDump.ino   ?
The raw rappresentation of IR code? What type of code the sketch give you, "unknow" or one like NEC?                             
« Last Edit: July 26, 2013, 01:47:49 am by nid69ita » Logged

my name is IGOR, not AIGOR

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1257
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The numbers you have listed are all 16 bit integers. The number you showed separately (0x02FD48B7) is a long value (32 bits).

Each hex digit takes 4 bits (0-F), so it is easy to work out the data types you need to store the values. Up to 2 hex digits fits in a uint8_t, up to 4 in a uint16_t and up to 8 in a uint32_t.
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The numbers you have listed are all 16 bit integers. The number you showed separately (0x02FD48B7) is a long value (32 bits).

Each hex digit takes 4 bits (0-F), so it is easy to work out the data types you need to store the values. Up to 2 hex digits fits in a uint8_t, up to 4 in a uint16_t and up to 8 in a uint32_t.

Marco_C thanks for answer. Can you tell me how do I convert it? If you could give me an example would be very usefull, because there is about a month that I'm looking for a way to convert them, and I still don't know how.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25782
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
0000 006a 002d 0001 000a 001e 000a 0047 000a 001e 000b 001e 000a 001f 000a 001e
000a 0046 000b 001e 000a 001e 000a 0047 000a 0047 000a 0046 000a 0047 000a 001e
000a 001f 000a 06a2 000a 001f 000a 0046 000b 001e 000a 001f 000a 001e 000a 0047
000a 001e 000a 0047 000a 0046 000b 001e 000a 001f 0009 001f 000a 001e 000a 0047
000a 0046 000b 06a2 000a 001e 000a 0047 000a 001f 000a 001e 000a 001f 000a 001e
000a 0047 000a 001e 000a 001f 000a 0046 000a 0047 000a 0047 000a 0046 000a 001f

but I need to convert this to something like this:

0x02FD48B7
It isn't clear (to me anyway) how to compress all the data in the table you showed (a total of 1536 bits) down to a single 32 bit value.

On the other hand, your final example "0x02FD48B7" could be expressed as 0x02FD and 0x48B7, or 0x48B7 and 0x02FD, depending on endianess.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1257
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Without knowing more about the data it is not clear how you would be able to compress this large amount into 32 bits.

What are you actually trying to do?
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Without knowing more about the data it is not clear how you would be able to compress this large amount into 32 bits.

What are you actually trying to do?

What I know is that the first type of hex is knows as Pronto Hex format, and your type is .CCF. I'm trying to do this because I'm developing a project about Home Automation, I already have some experience in this area, and I have a huge list of codes in this format that I spent years collecting, so I need use this codes in arduino, I found this sketch to  use Pronto Hex in arduino, but I didn't understand what I should modify in the sketch, or to be clear, where I should put the hex codes in the Sketch.

The link to the Sketch:
https://github.com/probonopd/arduino-infrared-pronto

thanks for your help
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25782
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What I know is that the first type of hex is knows as Pronto Hex format
"Pronto" as in the old Philips Pronto universal remote?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What I know is that the first type of hex is knows as Pronto Hex format
"Pronto" as in the old Philips Pronto universal remote?

Yes, those codes came from Philips Pronto.
Logged

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1257
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks like the current sketch takes its input from the serial monitor. So you need to cut and paste the data to the serial monitor input section at the top of the window.

If you want to hard code it into the sketch then you need to modify the sketch to be triggered by something like a digital input instead of reading the data from the serial line. Then just send the array of data the way that it would be handled at the moment.
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Québec
Offline Offline
God Member
*****
Karma: 16
Posts: 660
What ever! I'm gonna do what I want. Screw you guys! I'm going home. And other Cartman stuff. ;)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That simple

Make a routine that transform your number into a string then add "0x" in front of it. Then make it do it over and over again.

The form 0x*** is necessarily a string any way. I would use a For() and put every thing in a array of string to make it easy.
« Last Edit: July 27, 2013, 01:28:20 am by Frederic_Plante » Logged

Words cannot express how much I hate you guys. As we fight our way northward into the great unknown, only that one thing remains certain...

Pages: [1]   Go Up
Jump to: