I have an issue with the Can Crusher software. When I set the steps beyond 20,000 steps the motor reverses direction. I am using a cork screw gear so it doesn't need to be super accurate. I have to run the code twice in both directions to get the results of 40,000 steps to make the Can Crusher work. Here is the code. Also I want to be able to turn off the motor once it has completed.Β
// NEMA-23 Motor with DM542T Controller const int STEPS_PER_ROTATION= 800; //800 Steps per full rotation // DM542T Stepper Controller pinouts const int INPUT1 =2; //PUL+ To Digital pin 2 const int INPUT2 =3; //PUL- To Digital pin 3 const int INPUT3 =4; //DIR+ To Digital pin 4 const int INPUT4 =5; //DIR- To Digital pin 5 const int INPUT5 = 6; //ENA- To Digital pin 6 const int Input6 = 7; //ENA+ To Digital pin GND //Initialize the stepper library to stepper motor controller Stepper myStepper(STEPS_PER_ROTATION, INPUT1, INPUT2, INPUT3, INPUT4); void setup() { // put your setup code here, to run once: myStepper.setSpeed(100); // Default speed 100 RPM // Set the rotation myStepper.step(20000); //Set Delay for 2 Second delay(2000); // put your setup code here, to run once: myStepper.setSpeed(100); // Default speed 100 RPM // Set the rotation myStepper.step(20000); // Set return on motor myStepper.setSpeed(100); // Default speed 100 RPM // Set the rotation myStepper.step(-20000); // Set return on motor myStepper.setSpeed(100); // Default speed 100 RPM // Set the rotation myStepper.step(-20000); delay(2000); pinMode(6,OUTPUT); pinMode(7,OUTPUT); digitalWrite(6,LOW); //Turn off Motor digitalWrite(7,HIGH); //Turn off Motor while(1){} }
Β
It's great to tip your server unless you work in the Server Room!
Where's the rest of the code ? This sketch will not compile.
You have no #includes listed despite the fact that you're used a Stepper class and there is no loop() method.
I'd suggest that you switch to AccelStepper library., more modern and way more features.
Anything seems possible when you don't know what you're talking about.
@will Here is the rest of the code. I tried using theΒ AccelStepper library last night and was not able to find any example code to get it to work. I didn't use a void loop since I want it to stop after just one cycle. Here is the updated code.Β
#include <Stepper.h> // NEMA-23 Motor with DM542T Controller const int STEPS_PER_ROTATION= 800; //800 Steps per full rotation // DM542T Stepper Controller pinouts const int INPUT1 =2; //PUL+ To Digital pin 2 const int INPUT2 =3; //PUL- To Digital pin 3 const int INPUT3 =4; //DIR+ To Digital pin 4 const int INPUT4 =5; //DIR- To Digital pin 5 const int INPUT5 = 6; //ENA- To Digital pin 6 const int Input6 = 7; //ENA+ To Digital pin GND //Initialize the stepper library to stepper motor controller Stepper myStepper(STEPS_PER_ROTATION, INPUT1, INPUT2, INPUT3, INPUT4); void setup() { // put your setup code here, to run once: myStepper.setSpeed(100); // Default speed 100 RPM // Set the rotation myStepper.step(20000); //Set Delay for 2 Second // delay(2000); // put your setup code here, to run once: myStepper.setSpeed(100); // Default speed 100 RPM // Set the rotation myStepper.step(20000); delay(2000); // Set return on motor myStepper.setSpeed(100); // Default speed 100 RPM // Set the rotation myStepper.step(-20000); // Set return on motor myStepper.setSpeed(100); // Default speed 100 RPM // Set the rotation myStepper.step(-20000); delay(2000); pinMode(6,OUTPUT); pinMode(7,OUTPUT); digitalWrite(6,LOW); //Turn off Motor digitalWrite(7,HIGH); //Turn off Motor while(1){} } void loop() { // put your main code here, to run repeatedly: // put your setup code here, to run once: //myStepper.setSpeed(20); // Default speed 20 RPM // Set the rotation //myStepper.step(500); //Set Delay for 1 Second // delay(2000); }
It's great to tip your server unless you work in the Server Room!
Anything seems possible when you don't know what you're talking about.
@will The motor is not moving at all. The code compiled successfully however. π
It's great to tip your server unless you work in the Server Room!
In case you get bored easily, here's a modified version of one of Bill's sketches from using big steppers which doesn't require any stepper library at all.
You'll need to verify that the pulse and direction pins match your drive pins and that the goForward and goBackward variables are the right way around.
Currently the step time is 1 ms (500 micros with pulse on and 500 micros with pulse off).
Currently the target distance is et at 40000 steps. Since you're having some trouble now, this might need to be changed.
Β
Anything seems possible when you don't know what you're talking about.
@will The motor is not moving at all.
I was afraid of that, I don't use the expensive drivers so I don't know which of the set and direction pins to use.
Maybe-try it with PUL- and DIR- ?
Anything seems possible when you don't know what you're talking about.
The code is working, I made some modifications since I am using pins 2-5 as outputs. Also it seems to be running a lot faster. Thank you for the code! π
It's great to tip your server unless you work in the Server Room!
The code is working, I made some modifications since I am using pins 2-5 as outputs.
Excellent !
Also it seems to be running a lot faster. Thank you for the code! π
You're welcome, but you should thank Bill, I just made some mods to one of his sketches to make it more applicable for your use.
You can change the speed by adjusting pd (pulse delay) making it smaller will mane the move faster and making it larger will slow it down. That's because this value is the time in microseconds that the pulse is sent and the slack time afterwards. Since it's starting at 500 microSeconds, that means that the motor pulses for one step in 1 milliSecond and 1000 steps in a second.
So, making pd smaller means it takes less time for a step, so more steps per second (faster) and making it larger means that takes more time to complete a step (slower).
Anything seems possible when you don't know what you're talking about.
@will That is the next experiment, I'm going to do is see if I can speed it up with it still crush the cans. From what I have read the NEMA 23 produces 60 pounds of force and it takes 20 pounds of force to crush a can. Here is the video of the can crusher in action.Β
Β Β
It's great to tip your server unless you work in the Server Room!
@will Got the level converter and Raspberry Pico today. Wired it up and the level converter seems to be working, haven't sent a signal through it yet however.
Β
It's great to tip your server unless you work in the Server Room!
Another easy improvement that could easily be made is to increase the motor speed on the return trip because there won't be any real drag on the stepper motor then except for the friction of dragging the jaw back to the edge. This should be negligible compared to the load of crushing the can.
Anything seems possible when you don't know what you're talking about.
@will @clark77494 Does it help to think of it as you need more torque going forward to do the crushing while needing more speed to re-position the jaws for the next can. What I am getting at is what are the laws of physics involved here that cause torque in one direction and speed in the other. We all know what that means in transmissionsΒ or pulleys, but what is the equivalent in electronics. Is torque a greater number of short duration pulses in time T and speed is fewer pulses of longer duration in the same time T. I am certainly not positive, as it's been decades since I studied this stuff but that sounds right to me and yet could be total poppycock.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.
You (Ron) mentioned earlier about power being the area under the curve (of the oscilloscope trace).
Consider that more power is required crushing the can than is required dragging the jaw back to its starting point. So, if you consider the power as a function of step times, slower steps means more power, faster steps mean less power.
So we can afford to return the jaw much faster than we can crush with it because it requires much less power. (However, we don't HAVE to move it faster, it's just an available option).
Anything seems possible when you don't know what you're talking about.
@will Only if the voltage is the same, what if it's more short steps but higher voltage thus increasing the area under the curve. Again, just theorizing, I am hoping someone who knows the physics for sure will pipe up.
First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.