Go Down

### Topic: Accurate voltmeter (or could be renamed : uC's ADC ... State of the art) (Read 4671 times)previous topic - next topic

#### retrolefty

#15
##### Apr 27, 2014, 10:20 pm

Quote
As I said, I don't know how to "read" :
"BV" means "bit value", so given a bit position as a number (LSB is zero), it turns that into a bit mask.
BV(2) is the same as 1 << 2, which is same as 4.
"|=" says bit wise OR the variable on the left with the mask on the right, and assign the result to the variable on the left.

So can I say :
is equivalent to :
is equivalent to :
is equivalent to :
is equivalent to :
is equivalent to :

Mmmm ! So many writting to say the same thing ! No wonder why a beginner can't understand !

I think what you may be missing is that by using the _BV(ADSC) method that the function will work correctly for the different AVR chips versions that the IDE supports that otherwise if you used fixed values like 64 it might work correctly on a 328P chip but not a 2560 chip. Same goes for using register names like ADCSRA where the actual physical address of that register might again be different for the different AVR chips used in the Arduino world. They are pretty cryptic to read, at least for me also, but there is a method to their madness.

#### retrolefty

#16
##### Apr 27, 2014, 10:21 pm

What chance has the beginner (or indeed anyone) if you just wrote
Code: [Select]
At least the BV form gives an idea what is going on.

(BTW, you realise ADCSRA is a macro too, don't you?   . )

Is it a macro, or a defined constant that can change with AVR chip type?

#### hary

#17
##### Apr 27, 2014, 10:22 pmLast Edit: Apr 27, 2014, 10:38 pm by hary Reason: 1
I'm now wondering if using 1024 or 1023 in the calculation of VCC !

What chance has the beginner (or indeed anyone) if you just wrote
Code: [Select]
At least the BV form gives an idea what is going on.

(BTW, you realise ADCSRA is a macro too, don't you?   . )

ADCSRA ? A macro ? I don't see what you mean.

This topic  is really leading me to deep. Somebody to help stay tuned on the most important things ?
Properly using uC seems to be quite difficult indeed ! Interesting, but a little bet hard for a beginner !

#### AWOL

#18
##### Apr 27, 2014, 10:28 pm
Quote
I'm now wondering if using 1024 or 1023 in the calculation of VCC !

Ask yourself why semiconductor manufacturers like TI or National would go to the trouble of designing and marketing reference voltage devices with strange, non-physical constant (like band gap voltage) voltages, like 1.024V.

"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.
I speak for myself, not Arduino.

#### AWOL

#19
##### Apr 27, 2014, 10:33 pm

What chance has the beginner (or indeed anyone) if you just wrote
Code: [Select]
At least the BV form gives an idea what is going on.

(BTW, you realise ADCSRA is a macro too, don't you?   . )

Is it a macro, or a defined constant that can change with AVR chip type?

Of course it is a macro.
How could you have a constant on the left-hand side of an assignment?
"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.
I speak for myself, not Arduino.

#### retrolefty

#20
##### Apr 27, 2014, 10:50 pm

What chance has the beginner (or indeed anyone) if you just wrote
Code: [Select]
At least the BV form gives an idea what is going on.

(BTW, you realise ADCSRA is a macro too, don't you?   . )

Is it a macro, or a defined constant that can change with AVR chip type?

Of course it is a macro.
How could you have a constant on the left-hand side of an assignment?

Hell I don't know, solder it in?

#### Robin2

#21
##### Apr 27, 2014, 11:22 pm

This topic  is really leading me to deep. Somebody to help stay tuned on the most important things ?
Properly using uC seems to be quite difficult indeed ! Interesting, but a little bet hard for a beginner !

As with every area of expertise (lawyers, doctors ....)  people who know stuff like to talk about the things they know.

The trick is to take what you need from the arcane discussions.

You seem to have it figured out when you listed all the options. Just use the system that will best help you to know what your code means when you come back to it after a 6 month break.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up