Jump to content

Counting in Hex & Bin


Recommended Posts

Hi,

I'm trying to build a MidiboxSid controller in my Clavia G2 - so far so good. But I'm having problems understanding the following from the CC-implementation:

LFO1 Mode                                 

Bit 0: Enable LFO                         

Bit 1: Sync with assigned note events     

Bit 2: Sync with all note events           

Bit 6-4: Waveform                         

           0: Sine                           

           1: Triangle                       

           2: Saw                           

           3: Pulse                         

           4: Random                         

           5: reserved                       

           6: reserved                       

           7: reserved                     

Example: 11h = 17 = Enable & Triangle Wave   

                  15h = 21 = Enable & Triangle & Sync

I don't understand the "bit 6-4" concept, and I can't seem to figure it out backwards since only Tri waves are mentioned in the example.

It should be stated that I really haven't done much Hex/Bin calculations... ever!  :-\

Any help would be appreciated!

Cheers,

Mikael

Link to comment
Share on other sites

Edit: ***PLEASE IGNORE THIS POST***

See below!

And get sleep or you make silly mistakes which can fry your stuff sometimes!!!!!!!

One other way you could read it is this:

LFO1 Mode                                 

Bit 0: Enable LFO                         

Bit 1: Sync with assigned note events     

Bit 2: Sync with all note events           

Bit 3: Sine                           

Bit 4: Triangle                       

Bit 5: Saw                           

Bit 6: Pulse                         

Bit 7: Random     

15h  = 10101000 = 21  = Enable & Sync & Triangle

11h  = 10001000 = 17  = Enable & Triangle

other eg:

C2h = 11000010 = 194 = Enable & Sync Assigned & Pulse

1h    = 00000001 = 1 = Disable & Random

I was thinking the other day that it would be really nice if there was an app that had three text boxes, one for binary, one for hex and one for decimal... And if you type a number into any box, it converts the other two boxes as you type... I thought a +/- box would be good too... And bit shifting (left/right)...And an option with the binary to type from right to left like you read it....

Of course, it's very simple to program, I just dont have visual C on this machine... Isn't there an open-source c++ IDE/Compiler on sourceforge?

Anyway there's this: http://www.aquariussoft.com/downloads/pc-binary-conversion-downloaded.asp .... it's nagware though, $14 to buy

There's this freebie, very nice and simple, but no shifting, and rather limited: (also note the LCD character generator there, look familiar? :) ) www.everydaylogic.com

There's some code here:

http://www.marston-home.demon.co.uk/Tony/uniface/tip32.html

And some theory here:

http://www.janeg.ca/scjp/oper/binhex.html

Google is your friend, this is everywhere...

Hope this helps

Link to comment
Share on other sites

bit 6-4 means bit 4,5 and 6 together can form a number 0-7 selecting one of the options listed. It is written backward (6-4) because the high value of those three bits need to go into bit 6.

So;

Bit

654

000 Sine  (== 0+0+0 = 0)

001 Triangle (== 0+0+1=1)

010 Saw (== 0+2+0 =2)

011 Pulse(==0+2+1=3)

100 Random (==4+0+0=4)

101 Res ...

110 Res

111 Res

Of course the bits have pos 4, 5 and 6 so the actual values when put into this cc value are 16, 32,64.  (So pulse is 48)

Note that when writing a value bitwise you should (as with all numbers) start with the highest value bit. (Bit 7 in this case)

So 1000 0010 = (128 + 2) = 130.

bit 7654 3210

You can do also sorts of conversions with windows calculator, just put it into scientific mode.

Link to comment
Share on other sites

That is so funny, I went to adjust the post and I even said in there:

And an option with the binary to type from right to left like you read it....

Notice C2 was correct, but 1 was not?

LOL!  :D I converted it from 5 bit to 8 bit by tacking the 000 on the *end* for some strange reason hahahahaaaa

*slaps himself*

I didn't even notice it said 6-4, i just assumed it was 3-7 for some fricken weird reason.

Regarding windows calculator, you can do that, but you have to make too many clicks to get a quick answer. There's calculator.org too for that kinda thing.

Anyway, just to clear it up, here it is, correctly this time! (with examples to clear it up for those new to binary, which you'd think I was today!)

XXXXX001 = Enable

XXXXX010 = Sync assigned

XXXXX100 = Sync all

X000XXXX = Sine

X001XXXX = Triangle

X010XXXX = Saw

X011XXXX = Pulse

X100XXXX = Random

00010001 = Enable & Triangle

00010101 = Enable & Sync & Triangle

00010011 = Enable & Sync Assigned & Triangle

00110001 = Enable & Pulse

01000011 = Enable & Sync Assigned & Random

Note bit 3 & 7 (read from the right)never get used

Just to show how tired I am, in this tiny post, I have made over 32 typing errors!!! 6 in this sentence alone! I'm really sorry if I've caused any confusion. If I get it wrong this time, someone pelase shoot me so I get some sleep for a change!

Link to comment
Share on other sites

Exactly. Because the highest bit is never used, there are only 7 bits used.

in binary, the most you can you can have is 1111111

The way it works is this...

If the byte is all 0's, that's 0. Thats nice and easy :)

The 1st bit, from the right hand side, is equal to 1 in decimal when it is set, or on, or a '1'. However you like to say it

The 2nd bit, from the right hand side, is equal to 2 in decimal

The 3nd bit, from the right hand side, is equal to 4 in decimal

The 4th bit, from the right hand side, is equal to 8 in decimal

The 5th bit, from the right hand side, is equal to 16 in decimal

The 6th bit, from the right hand side, is equal to 32 in decimal

The 7th bit, from the right hand side, is equal to 64 in decimal

The 8th bit, from the right hand side, is equal to 128 in decimal

So you see, the decimal value doubles each higher bit

You then add up the value of any bits that are 'set' - the one's.

So

00000001 is 1

00000010 is 2

00000100 is 4

...

10000000 is 128

but in this case we don't use bit 7 -

and

00000101 is like 4 AND 1 (see just above), so that's 5

00000111 is like 4 AND 2 AND 1, so that's 7

00010001 is like 1 AND 16, so that's 17

10000000 is 128

10000001 is 129

10000010 is 130

Maybe this helps...

So anyway, because this is a computer not a human, the counting starts with 0, not with 1.

As you know, we don't use bits 7 or 3. This is counting from 0. So we never use the 8th bit from the right - bit7, or the 4th from the right, bit 3. The far right bit, the "1st" bit, is called bit 0, because we're counting from zero, not one.

so this means that the highest you can go with 7 bits is like this:

01111111

If you grab the calculator of your choice, and convert from binary to decimal, you will find that this is 127 decimal. This allows 128 different settings, including zero.

I hope this helps, and doesn't confuse matters further. I have had alcohol to drink for the first time in years tonight, so this may be completely incomprehensible!

More sake and moet please!!  ;D  ;D

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...