Posts: 375
Threads: 53
Joined: Jun 2013
Location: Jonesborough, TN
I'm confusing myself with posts on 2 forums about this.
I got my meter out and in trying to set the 4x4 keypad sketch to step in one direction or another, I discovered that the driver board has 5vdc on the dir pin with nothing connected. Evidently the Dir output from the Arduino is not changing or sinking the current on the driver Dir pin.. If I force the driver Dir input low, by connecting it to ground from the Arduino, the direction reverses. The sketch is having no affect on direction.
I verified this by putting my meter on the dir pin output of the Arduino and running the sketch without the driver connected. The output does not change from .001vdc with either choice of direction.
Just to reiterate, I use the driver board with another Arduino running Chuck F's sketch from his post on HMEM with no changes. I am trying to add the ability to enter # of divisions from a 4x4 keypad rather than X # of button pushes for X # of steps.
Chuck
Micromark 7x14 Lathe, X2 Mill , old Green 4x6 bandsaw
The difficult takes me a while, the impossible takes a little longer.
Posts: 8,860
Threads: 319
Joined: Feb 2012
Location: Arizona/Minnesota
Chuck,
Is the code in your first post still the code you're working with?
Ed
Posts: 2,620
Threads: 100
Joined: Dec 2014
Location: Michigan
Sounds like he'll need a pull up on the arduino to make this measurement. Ed, didn't you use the same code?
Posts: 8,860
Threads: 319
Joined: Feb 2012
Location: Arizona/Minnesota
(04-06-2015, 03:47 PM)Vinny Wrote: Sounds like he'll need a pull up on the arduino to make this measurement. Ed, didn't you use the same code?
He shouldn't need a pullup. The Arduino outputs are not open collector and they're capable of driving 40mA. The input to the driver is about an 18mA load.
I did use mostly the same code. I had to strip out all of the LCD and keyboard stuff and do some hard coding of variables.
Ed
Posts: 8,860
Threads: 319
Joined: Feb 2012
Location: Arizona/Minnesota
Chuck,
Try this code as a test.
Code:
/*
Test that turns the stepper motor in one direction for about 3 seconds and then reverses it for 3 seconds in a continuous cycle. Digital pin 12 is the step signal and 13 is the direction signal.
*/
#include <Wire.h>
//setup vars
const int stp = 12; //connect pin 12 to step
const int dir = 13; // connect pin 13 to dir
const int StepsPerRotation = 200; //Set Steps per rotation of stepper
const int TableRatio = 90; //ratio of rotary table
const int Multiplier = (StepsPerRotation * TableRatio)/360;
const int stepdelay = 1;
float Degrees = 0; //Degrees from Serial input
float ToMove = 0; //Steps to move
int Direction = 1;
int repeat = 0;
void setup()
{
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);
}
void rotation(float tm, int d)
{
if(d == 0)
{
digitalWrite(dir, LOW);
}
else
{
digitalWrite(dir, HIGH);
}
for(int i = 0; i < tm; i++)
{
digitalWrite(stp, HIGH);
delay(stepdelay);
digitalWrite(stp, LOW);
delay(stepdelay);
}
}
void loop()
{
if(repeat == 0)
{
Degrees = 30;
}
Degrees = Degrees * Direction;
if(Degrees < 0)
{
ToMove = (Degrees*Multiplier)*-1;
rotation(ToMove,0);
}
else
{
ToMove = Degrees*Multiplier;
rotation(ToMove,1);
}
if (Direction == 1)
Direction = -1;
else
Direction = 1;
}
All it does is to turn the stepper motor in one direction for about 3 seconds and then reverses the direction for about 3 seconds and repeats the cycle until power is removed. Digital pin 12 is the step and 13 is the direction.
Ed
Posts: 2,620
Threads: 100
Joined: Dec 2014
Location: Michigan
So the output puts out 5v when hi?
Posts: 8,860
Threads: 319
Joined: Feb 2012
Location: Arizona/Minnesota
(04-06-2015, 05:41 PM)Vinny Wrote: So the output puts out 5v when hi?
Yup, they're push/pull outputs.
Ed
Posts: 375
Threads: 53
Joined: Jun 2013
Location: Jonesborough, TN
Spins in one direction continuous, Ed. I did change the output pins to 2 and 3, as that is how it was currently wired. But. I will set it up with 12 and 13 if you want. I think the main idea was to test if Dir was effecting a change, yes?
Chuck
Micromark 7x14 Lathe, X2 Mill , old Green 4x6 bandsaw
The difficult takes me a while, the impossible takes a little longer.
Posts: 375
Threads: 53
Joined: Jun 2013
Location: Jonesborough, TN
I hope you guys don't think I'm jerking you around, I'll post pics if necessary. I can't do video.
And yes, I'm still working with the original code of this thread, with the keypad.
Chuck
Micromark 7x14 Lathe, X2 Mill , old Green 4x6 bandsaw
The difficult takes me a while, the impossible takes a little longer.
Posts: 375
Threads: 53
Joined: Jun 2013
Location: Jonesborough, TN
04-06-2015, 06:07 PM
(This post was last modified: 04-06-2015, 06:11 PM by chucketn.)
I did set the connections for step and Dir to 12 and 13 as your code said, and results are the same. Spins continuously in one direction. Just to show I'm doing what you suggest. I also put my multimeter on the Dir input to the stepper driver. It read 4.40 vdc.
Chuck
Micromark 7x14 Lathe, X2 Mill , old Green 4x6 bandsaw
The difficult takes me a while, the impossible takes a little longer.
|