hi
i have a bipolar stepper motor what i need to controlon my ardiuno im trying to control it with a 10k temperaturometer so basically the stepper motor reanacts what the pot is doing but i need to be able to set a amount of degrees the motor will rotate eg 180 degrees
i have no idea how to program this so any help would be appreciated
How to read the temperature sensor? How to convert the temperature sensor value to a stepper position? How to make the stepper motor step the required number of steps? All of the above?
sorry my bad spelling i meant potentiomenter theres no temperature sensor
basically how to do the programming for all of it i find it hard to get the programming round my head lol
There is a Stepper library that can easily be use to drive the stepper motor. You tell it haw many steps in a complete revolution. Then, tell it to step the motor.
Since you want the stepper motor to act like a servo, you will need to keep track of where it is, and whether the motor should step forwards or backwards to get from the old position to the new position.
Closer inspection of your picture leads me to think that you have a L239D H bridge chip.
Assuming you have then try running the MotorKnob example bundled with the Arduino IDE, you might need to change some of the pin bindings. If this works then replace the code in setup() and loop() with this:
watch your motor turn, if it goes more than one turn, then reduce the number of steps set by #define STEPS on line 13. If it goes less then a turn then increase the number of steps. Once you have found the number of steps per turn then you can follow the code suggested by PaulS
the chip in the picture is H-bridge sn764410NE Can you make the motor do anything?
yes I have had it working on the arduino with the coding on the arduino software under stepper what makes the motor rotate backwards and forwards but cannot control it. It does what it wants to do are there any numbers on the motor?
16hy0417n
Date 03 01 23
yes I have had it working on the arduino with the coding on the arduino software under stepper what makes the motor rotate backwards and forwards but cannot control it. It does what it wants to do
It does not do what it wants to do. It does what you told it to do.
Apparently, what you told it to do, and what you wanted it to do, are not the same thing.
Post that code that does something, and describe what it does, and what you want it to do instead.
Something else to keep in mind, which PaulS hinted about...
Even if you are counting steps to get to the angle you want, those will ONLY be referenced to the starting position of the motor. Should the motor slip or mis-step, or should something force the shaft to rotate (or stop it from rotating), the count the system has for the position will not be the same as the rotational position of the shaft.
In order to obtain the positional information of the shaft, you need to implement an absolute position encoder scheme; if you are limited to only a certain set of angles less than 360 degrees, you can use a potentiometer (multi-turn if you can get by with a few full rotations or need 360 degrees). If you need full and continuous rotation, then you will need a binary encoder of some sort (works like any optical encoder, except that it outputs a binary number indicating its position - and typically does not have rotational limits - but they don't tend to be cheap, either, depending on the required resolution).
Either of these options will give you the ability to monitor the shaft of the motor for positional information to a fixed angle.
// change this to the number of steps on your motor #define STEPS 100
// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
Stepper stepper(STEPS, 8, 9, 10, 11);
// the previous reading from the analog input
int previous = 0;
void setup()
{
// set the speed of the motor to 30 RPMs
stepper.setSpeed(30);
}
void loop()
{
// get the sensor value
int val = analogRead(0);
// move a number of steps equal to the change in the
// sensor reading
stepper.step(val - previous);
// remember the previous value of the sensor
previous = val;
}
when using this code it will rotate but it rotates even when your not touching the pot and it will randomly change direction on its own.it will sometimes shudder backwards and forwards.If you rotate the pot it may sometimes change direction heading in the opposite direction but if you wind the pot from one end to the other you can hear the motor change the tone as well
thanks for that information cr0sh the motor is opperatinga spring loaded device so when power is lost it should return back to the same position as started but trail and error will prove that fact lol
hi been tring to have a bit of a play with my arduino and it woat let me down lode to it, it some's up with this:
avrdude: stk500_paged_write() : (a) protocol error, expect=0x14, resp=0x64
avrdude: failed to write flash memory, rc=4
avrdude: stk500_disable () :protocol error, expect=0x14, resp=0x51