8/10/2023 0 Comments Arduino pro mini 5v outputInt getBandgap(void) // Returns actual value of Vcc (x 100)Ĭonst long InternalReferenceVoltage = 1059L // Adjust this value to your boards specific internal BG voltage x1000 Int battVolts // made global for wider avaliblity throughout a sketch if needed, example a low voltage alarm, etcīattVolts=getBandgap() //Determins what actual Vcc is, (X 100), based on known bandgap voltage Thanks to "Coding Badly" for direct register control for A/D mux Now works for 168/328 and mega boards. This demonstrates ability to read processors Vcc voltage and the ability to maintain A/D calibration with changing Vcc Function created to obtain chip's actual Vcc voltage value, using internal bandgap reference The bandgap waries a bit from chip to chip, so the sketch provides for a way to calibrate for a particular chip. The ADMUX register is described in detail in Section 24.9.1 in the datasheet for the 328P. It should work for the 328P in the Pro Mini. I don't know of a library that includes this option, but below is an example sketch that produces the value of the Vcc voltage based on the bandgap reading. The ADMUX register selects the reference for the measurement, which will be Vcc, and channel of what is being measured - that will be channel 14, the internal 1.1V bandgap voltage. A P channel to shut off the divider at the high side and an N-channel to control the P channel.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |