Thank you, Andy. May I ask you how you are processing the picture, mean- adding such a cute red, please.
how you are processing the picture, mean- adding such a cute red
it has since been acquired by Corel, and is now: https://www.paintshoppro.com/en/
This 21 year old version does all I need - so I see no reason to "upgrade".
(the joys of software you actually get on physical media - not tied to some cloud subscription)
It was shown rightly here:
Servos work, so it’s time for summary.
I started this thread from one of my projects - 3Servos + 2Potentiomwters + 1Pushbutton:
My MCU is ATmega328p, and my project used 4 cases of 2 peripherals – Time/Counter and ADC:
Time/Count_0 for 1 servo, Timer/Counter_1 for 2 servos;
ADC channel 0 and 1 for 2 potentiometers.
At first, only servo used Timer/Counter_0 worked correctly, so I opened this thread. Inspired by the comments here, I modified my code, and tested it by example in Arduino IDE, I’m sure configuration for Timer/Counter_1 was OK, then is the ADC.
I listed the suggestions valuable here, the ones with flag “(Tested)” were tested and adopted in my project, the ones without it haven’t been tested and accepted due to the lower requirements and primitive components.
* use “=” instead of “|=” (Tested)
* read the entire ADC value all at once into an integer variable (Tested)
* starting the ADC conversion and waiting for it to finish before reading the ADC results (half Tested)
* power supply goes directly to the servos
* Remove any connections shared between the pots & the motors
* (do not)use such(22kΩ) a weak switch pullup in a noisy motor situation
* POWER CAPACITORS FOR MOTORS(should be large like 330uF, 470uF, 1000uF, etc)
You see, I have just used suggestions for software and the motors run rightly, avrfreaks.net is really a website could get some solutions, I appreciate all the responses for this post.
Special thanks to david.prentice and avrcandies:
I have to say:
You know ADC
You know AVR
You know Servo
The last and the first,
You know “|=”.
Jolly good. You have addressed all the important lessons.
Regarding starting the ADC conversion and waiting for it to finish. You can either wait for ADSC to clear or for ADIF to set.
ADSC is easier because it just reflects the conversion state.
ADIF sets when conversion has completed but you must clear ADIF manually. (read the note in the datasheet)
It is reasonable to just poll for completion. You might use interrupts in busy applications.
use interrupts in busy applications.
OK, I will try interrupt in this project, and I would ask you for break through when I met blocks.
© 2022 Microchip Technology Inc.