I am using a standalone Atmega328 circuit without serial communications and USB connection.or just send them out Serial instead of to the LCD?
I am using a standalone Atmega328 circuit without serial communications and USB connection.or just send them out Serial instead of to the LCD?
ok , well let us know how this turns out.I am using a standalone Atmega328 circuit without serial communications and USB connection.
void setup ()
{
Wire.begin();
Wire.setClock(400000L);
analogReference(INTERNAL);
oled.begin(&Adafruit128x64, I2C_ADDRESS);
oled.setFont(Callibri15);
oled.setLetterSpacing(2);
oled.clear();
selftest();
}
void loop()
{
selftest();
delay(1000);
}
void setup ()
{
Wire.begin();
Wire.setClock(400000L);
analogReference(INTERNAL);
oled.begin(&Adafruit128x64, I2C_ADDRESS);
oled.setFont(Callibri15);
oled.setLetterSpacing(2);
oled.clear();
selftest();
oled.println("1");
delay(1000);
selftest();
oled.println("2");
delay(1000);
selftest();
oled.println("3");
}
void loop()
{
selftest();
delay(1000);
}
Maybe, but not necessarily. Is it that a second call is necessary, or is a time interval from setting Vref that is necessary?I have modified the code like this:
That means, there must be an initial analog to digital conversion to sort thing out...
See post #25Anyway this thread was very useful for me personally... Thank you for all the input.
I have cancelled the internal reference and I am now using the Vcc as reference. The very first measurement is always incorrect. The second one is almost OK. The subsequent ones are OK. For the new problem, I am afraid I have to contact an exorcist!!!
Already seen! Thank you very much.See post #25
No, it can’t. Did you read my link?This analog read issue can be fixed, and should be fixed, by fixing the connection between the battery and analog input.
The original code does not read the voltage too often. The above code is meant only for testing purposes. But even if I read the voltage infrequently, I want to be sure that the result is somehow correct.Just a side note here... I read through and I'm sorry if this was mentioned.. Your potential divider is to the tune of 110k... This will slow down things considerably.. I struggled with a 22k divider.. If you need to use the 110k for "battery saving" purposes then your read will have to be very few and far between... You do not need to check the battery every cycle.... I would put a cycle clock and check it once a second...
Yes. The default for Arduino IDE is that the analog reference is Vcc. In my circuit the Vcc is adequately stabilised and I think I can use it for reference.I read somewhere that you are referencing Vcc on the ADC...This will not work as the ADC will read ratiometrically... I use a 2.5Vref so I can get a good battery voltage reference... I would read ADC 4 times then / by 4 with at least 1mS between reads... You are best to up your ADC TAD to the maximum.. I must emphasise that I predominantly use PIC's but I know the procedure is the same..
As long as you load the ADC cap for long enough, your readings should be stable enough..
Yes I do!Are you still seeing demonic activation of the motor? Which GPIO is it on?
JUST FOR ILLUSTRATION:Yes I do!
The MOSFET driving the motor is connected to PD6 (Atmega328 pin 12). As you can see I didn't declare this pin as OUTPUT in the test code but the motor keeps running.![]()
Sorry!I wrongly assumed the Battery was the Vcc… If the Vcc is regulated, then all's good.Yes. The default for Arduino IDE is that the analog reference is Vcc. In my circuit the Vcc is adequately stabilised and I think I can use it for reference.
You are right. I have omitted the pull down resistors. In this case if I declare the PD6 as OUTPUT I shouldn't have this behaviour. In the final circuit I will use those pull down resistors. Yhank you.JUST FOR ILLUSTRATION:
![]()
Do you have a pull-down R as you see here as R2? [from Gammon.com] I realize that you have not shown the schematic for your driver, but a missing R2 could, conceivably to me, cause such "possession".
Great advice. I will try it. Maybe not 24 samples but at least 5 - 6 samples... Thank you.Sorry!I wrongly assumed the Battery was the Vcc… If the Vcc is regulated, then all's good.
Just for information... When I need a stable reading I oversample 24 times with a 1mS delay between samples...But I work on cranes, and they are noisy little b***ers…
| Thread starter | Similar threads | Forum | Replies | Date |
|---|---|---|---|---|
| S | Boss DM-2 PCB problem | PCB Layout , EDA & Simulations | 6 | |
|
|
Filter problem | Analog & Mixed-Signal Design | 8 | |
| T | Arduino AnalogRead noise in voltage reading | Microcontrollers | 3 | |
| T | Adafruit Trinket m0- AnalogRead | Analog & Mixed-Signal Design | 5 | |
| R | Setting a timer to count analogRead input for 3 seconds | Microcontrollers | 2 |