Notifications
Clear all

Large Stepper Code does not work

119 Posts
5 Users
10 Likes
8,377 Views
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2534
 

@ralphxyz 

Yes, definitely put in some Serial.print statements to display the values of direct and pulseDelay inside the loop. That'll slow down the motor (which will get the pulse commands slower) but it'll help see what the controls are doing (if anything).

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@ralphxyz)
Member
Joined: 4 years ago
Posts: 61
Topic starter  

This is what I am seeing:

 

1394 2
1392 2
1330 2
1444 2
1284 2
1465 2
1301 2
1423 2
1354 2
1356 2
1410 2
1303 2
1457 2
1288 2
1452 2
1330 2
1402 2
1392 2
1337 2
1444 2
1293 2
1471 2
1301 2
1434 2
1352 2
1370 2
1411 2

 

pulseDelay = map(analogRead(revPin),0,1023,2000,50);
digitalWrite(dirPin,direct); // Set direction

Serial.print(pulseDelay,DEC); // prints a tab
Serial.print("\t"); // prints a tab
Serial.print(dirPin,DEC);
Serial.print("\t"); // prints a tab
Serial.println(); // carriage return after the last label


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2534
 

@ralphxyz 

Very strange. Please show me your wiring for both the switch and the pot.

Also, you'll need to use at least a 5K linear potentiometer.

Can you run that test again while turning the pot through its entire range and back please ? I want to see what effect changing the pot has over its whole range.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@ralphxyz)
Member
Joined: 4 years ago
Posts: 61
Topic starter  

I was turning the pot and pushing the button but neither seemed to effect the motor.

Pot and Arduino

Microstep Driver

Ralph

 


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2534
 
Posted by: @ralphxyz

This is what I am seeing:

pulseDelay = map(analogRead(revPin),0,1023,2000,50);

My error, that should read 

pulseDelay = map(analogRead(spdPin),0,1023,2000,50);

i.e. AnalogRead(spdPin) not revPin.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@ralphxyz)
Member
Joined: 4 years ago
Posts: 61
Topic starter  

Should lastInt = millis(); show a value for lastInt?

Serial.print(lastInt,DEC); shows nothing.

 

Ralph


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2534
 

@ralphxyz 

try Serial.println(lastInt);

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@ralphxyz)
Member
Joined: 4 years ago
Posts: 61
Topic starter  

I corrected the spdPin error.

Here is video of the motor turning:

The pot is certainly working

Turn up your speaker volume to hear the motor.

Ralph


   
ReplyQuote
(@ralphxyz)
Member
Joined: 4 years ago
Posts: 61
Topic starter  

Serial.println(lastInt); still shows 0

 

Ralph


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2534
 
Posted by: @ralphxyz

I corrected the spdPin error.

Here is video of the motor turning:

The pot is certainly working

Good, then we're making at least some progress 🙂

Is your switch reversing properly ? You'll need to look up what pins on your Arduino are interruptible and use one of those. I chose pin 5 for use but it may not be appropriate for your Arduino model.

Bt the way, please use the Reply icon at the bottom of the message box. That sends me an email telling me that I have a reply, otherwise I just check randomly depending on which computer I'm using for what.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@ralphxyz)
Member
Joined: 4 years ago
Posts: 61
Topic starter  

Yes we are making good progress!

No the switch does nothing.

As you could see in the video the motor is just barely turning even though the pulseDelay 

goes from @50 to @2000.

Ralph


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2534
 

@ralphxyz 

What model Arduino are you using and how is your switch wired ?

What level of micro stepping are you using ?

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@ralphxyz)
Member
Joined: 4 years ago
Posts: 61
Topic starter  

I am using a Adafruit Metro, which I believe is 386 based so it should have a lot more interrupt pins.

I cannot find any documentation on which pins are interrupt enabled.

I am using a Momentary On/Off switch.

Ralph


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2534
 

@ralphxyz 

Which Metro ? Mini, M4, M0, ... ?

How is your switch wired (to what pins are the ends connected) ?

What level of micro stepping are you using ?

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2534
 
Posted by: @ralphxyz

I am using a Adafruit Metro

So, back a couple of days ago, when I asked you "Which part of your setup doesn't exactly match Bill's setup ?", it didn't occur to you to mention that you weren't using an Arduino ????

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Page 3 / 8