Hi
I've got a project the has a attiny linked directly to a vid29 stepper motor and there is a lot twitching on the needle. There is no noise on the pin of the tiny that senses the voltage but there is noise on the 4 pins that control the motor.
Is there anything that i could try to rectify this issue
The analogRead() result is never perfectly stable. It will often vary +/- 2. Taking 32 or 64 samples and averaging the total works wonders to get it more stable.
When i scope the input voltage it is pretty stable. The needle on motor is jumping around more than 5v volts at time. Without the needle on the motor the motor can turn 360° which it's not suppose to do
Are you sure your wiring is correct - your voltage input not only connected to A1 but with an actually working wire? (do measure the voltage at the pin - where it's soldered onto the PCB of the Arduino itself - to confirm).
Another thing you should do is print the analog readings to the Serial console, to see whether the values you see there make sense. When you're at it, also print the values of pos and target.
I've read the analog input values on pin A1 and everything is stable and as expected.
I changed the program to use the map function and the motor moves stable but is not accurate.
So the question is what could be causing the problem in the code and how would the rest of you have wrote the code as this is the limit of what i have learned so far
Why is there a second order equation to go from ADC reading to motor/needle position in your original code? What does the map() purport to do instead?
Did you already try to look at the actual, continuous stream of values for both the target position of the motor and the actual position, and if so what does it look like?
In order for me to look at serial data i need to remove the motor. I'm using a attiny85 and all pins are used on the micro.
The equation was what i had previously used on another project for reading analog input reading and it worked very well. It was worked out by another forum user.
DrDiettrich:
I still don't understand anything, what "needle on motor", what "accurate" motor...???
The vid29 is a precision stepper designed for moving a needle on an analog gauge, such as you may find on the dashboard of a car. OP could have posted some images to make that clear.
Code is apparently updated but OP didn't post it; still no schematics; oh well. Wild guesses can be fun, too.
wvmarle:
Code is apparently updated but OP didn't post it; still no schematics; oh well.
I posted the schematic in a pdf file with my original code.
I've not updated the code. I'm still stuck with the code i posted. All I've done is added software serial to read the analog input on pin A1 but to do that i had to remove the output to the stepper motor.
From all my testing in seams the motor moving randomly is something in the code.