I have a unique delima to sort out. I am trying to us my Arduino to detect movement past a magnet that will, in turn, cause an easydriver stepper board driver to turn a stepper motor for a specified distance either forward or backwards depending upon it's location and previous movement. I am not much good at programming so this is becoming a bit of a headache for me. If anyone can come up with a solution I would be much appreciative. My setup is this. I am an inventor of sorts, and I just finished a project where I automated my wife's quilting machine with computer control, stepper motor movement in the X and Y axis, and now I need to automate the takeup roller to roll up and move forward and reverse as the quilter moves in the same direction, I have a basic idea using the Arduino as noted above, interfaced with an easydriver 4.3 to drive the motor. I want the hall sensor to detect the presence of a small magnet placed strategically under the carriage of the quilter, and upon detecting the magnet, move the stepper on the take up roller to a position of rotatio of approximately 2.5 inches or one revolution either forward or backward depending on the direction of travel of the carriage. I hope this makes sense.
I'm not sure I follow what you are trying to do. My wife has a long arm quilting machine to, so I'm familiar with the setup. The only take-up roller I know of is the one that the finished quilt is rolled up on. There is a fair amount of tension on the material between that roller and the feed roller, where the un-quilted material is staged.
The feed roller and takeup roller do not move while the quilting is being done. Only after a section is quilted are the locks released and the takeup roller turned to roll up that just quilted material.
However, there are 4 wires from the Arduino to the EasyDriver, and one from the hall effect sensor (though it seems that a simple pushbutton switch would work as well).
Read from the sensor. When the value is sufficiently high, or low, tell the stepper to step the required number of steps.
I'm not sure how you can tell something to rotate 2.5 inches, any more than you can move a linear actuator 45 degrees.
First, thanks for answering so fast. Let me explain a bit more about what I have done. I have automated the carriage with stepper motors of sufficient strength, to move the carriage and sewing machine along two axis, x=length of table, and y=carriage movement across the table. Basically, the movement of the carriage would control the movement of the upper roller. This is a concept used by a system called Max-Throat, which, using the movement of the carriages y movement, allowed magnets and hall sensors mounted in the carriage, controlled the take-up roller, causing it to move forward and backward with the movement of the carriage, all the while rotating the roller either forward or backward either releasing or rolling up the quilt. actually a pretty simple concept when you stop to think about it. My problem is the programming of the sketch, which I have partially completed. I'll include the programming so that you can look at it. I am using two easydrivers connected to one arduino, but right now the sketch only shows one easydriver setup.
Here is the sketch so far:
/*
Hall switch test/stepper test.
Turns on and off an LED connected to pin 13 when passing a magnet by the hall switch connected to pin 7
Also controls the direction of the stepper. Thanks to Daniel Thomas for the idea and some of the sketch.
*/
int ledpin = 13; //Pin for LED
int hallpin =7; //Pin for Hall switch
int val = 0; //Integer for reading Hall status
int dirpin = 3; //pin for DIR
int steppin = 2; //pin for STEP
void setup()
{
Serial.begin(9600);
pinMode(ledpin, OUTPUT); //Declare LED pin as output
pinMode(hallpin, INPUT); //Declare Hall pin as input
pinMode(dirpin, OUTPUT); //Declare dirpin as output
pinMode(steppin, OUTPUT); //Declare steppin as output
}
void loop()
{
int i;
val = digitalRead(hallpin); //Read Hall pin status
if (val == HIGH){ //If there is A magnet infront of Hall switch...
digitalWrite(ledpin, HIGH); //Turn LED ON
digitalWrite(dirpin, HIGH); // Set the direction pin to move forward
delay(1000); //Give it some time
Serial.println("Forward"); // Print Forward to the terminal window
for (i = 0; i<1600; i++) // Step Forward 1600 steps
{
digitalWrite(steppin, LOW); // Start out with step pin low
delayMicroseconds(500); // Delay controls speed and Torque. I originally had these at 100 that was too short
digitalWrite(steppin, HIGH); // Now switch it high
delayMicroseconds(500); // Delay controls speed and Torque you need at least a 500 delay
digitalWrite(ledpin, LOW);
/* }}else{ // this is where the program splits to go into reverse, and also
val = digitalRead(hallpin); //Read Hall pin status
if (val == LOW){ //If there is A magnet infront of Hall switch...
digitalWrite(hallpin, LOW);
digitalWrite(ledpin, HIGH); // Turn LED oFF
digitalWrite(dirpin, LOW); // Change direction to reverse
delay(3000); // Give it some time
Serial.println("Reverse"); // Print Reverse to terminal window
for (i = 0; i<1600; i++) // Step in Reverse 1600 steps
{
digitalWrite(steppin, LOW); // Start out with step pin low
delayMicroseconds(500); // Delay controls speed and Torque you need at least a 500 delay
digitalWrite(steppin, HIGH); // Now switch it high
delayMicroseconds(500); // Delay controls speed and Torque you need at least a 500 delay*/
}
}
}
As is stands, you seem to be missing something to tell you the direction of the carriage. You're using the hall sensor to trigger the stepper motor, but also using it (in the commented out code) to tell you which way to turn. Is there another sensor that gives direction?
Yep, you are right. I do have another Hall Sensor that can worked into the equation to control the reversal, but I also believe I can do it with software control using an IF ELSE or Do While to handle the interrupts to turn it around. The remarked out portion does a reversal, but it is in a loop that is endless at this point in time. This is the portion that I got from Dan Thomas software that gave me the idea for the project.