PDA

View Full Version : bit, byte or word?



peterdeco1
- 5th December 2004, 12:31
Hello Everyone. I thought I had this figured out but someone's post has confused me. At the top of my program I put:
x var byte

now, any reference to the adcin command reads back to me a number from 0 to 255 when I put it into x. It works perfectly. Now, if I put:
x var word

what number will it read to? I thought is was 0 - 1023 but someone's post refers to the number being 65535.

One more - what will x var bit read to? - Thank you.

Melanie
- 5th December 2004, 12:56
A word is 16 bits...

16 bits gives you a range from 0-65535

The internal ADC in most PIC's is 10 bits...

10 bits gives you a range from 0-1023

You need a WORD variable if in PBP you want to play with numbers bigger than 255 (a BYTE). When reading from your ADC, your WORD variable will acquire a value in the range 0-1023... the upper bits will be zero.

peterdeco1
- 5th December 2004, 13:07
Thank you Melanie. And how about a bit variable? What does that count up to? Thank you.

Melanie
- 5th December 2004, 13:24
I never thought I'd find myself answering this one but...

A bit is the smallest variable you can have... represented by one wire, one pin, one-eighth (1/8) of a byte... in the Digital world, this can only be Zero (0) or One (1)... there is no other state.

So the variable range for a BIT is 0-1. It's either a Zero or a One, that's it...

Like I always say to everyone... if you can count to ONE, you're a computer expert, because that's all ANY Digital computer does... it just might happen to do it damn quick, but basically if you can understand that concept, then that's all there is to computers... micro, mini or mainframe... if you can count to one (or have an IQ equal to or greater than a BIT), you too can earn big bucks...

peterdeco1
- 5th December 2004, 13:49
Thank you Melanie. My IQ = a bit but I don't make big bucks.

Melanie
- 5th December 2004, 14:04
Life isn't so bad... it still rates you over the average Politician, Lawyer, Real-Estate Agent...