Hello,
I use an Arduino Uno with Python and Py2duino. For now, I want to control a nema23 stepper motor with a TB6600, but when I want to control the step with a limit switch, it becomes slowly
this is my code :
When i use this, the stepper is moving fast.
MonstepperX.move(2000,0.8)
But When i put't in for bocle the stepper move quite slowly.
def stop_x():
for i in range(1,50000):
MonstepperX.move(20,0.8)
i += 1
if limitswitchX.read() == 0:
break
Now, my question is: is there any way to make the stepper go faster using Python?
I really need to use Python instead of using Arduino's IDE directly. think for help.
saadtarres:
Where I insert the limitswitchX.read() == 0: condition I got this error
""Erreur de transmission ou bien le pin digital n'a pas ete bien assigne au prealable avec arduino.pinMode"
Maybe you would find it easier to use the French section of the Forum?
If you wish to continue with English then you have not yet posted your Arduino program.
Looking at the Python program in Reply #5 I have the following questions ...
What is the Python program running on?
What is it trying to do?
I am not familiar with py2duino (though I use Python with my own Arduino boards) but it seems as if the Python program is trying to do stuff that should really be done on your Arduino.
saadtarres:
i alrady put the link of the arduino code
Help us to help you. Post your code here so we don't have to go chasing after links.
i want to run cnc mahcine with an arduino uno from a python code interface,
It would be a good start if you tell us what the CNC machine is and what software it is using. The GRBL program is an obvious candidate and you can use the "Universal GCode Sender" program to control a CNC machine that uses GRBL.
On the other hand if you have written your own CNC control program you need to provide details of the commands it expects to receive.
You should NOT be expecting a Python program to do low-level control of a CNC machine - the link between Python and the Arduino is just not fast enough. The Python program should send a message to the Arduino telling it how many steps to move and how fast and then let the Arduino do the detailed stuff.
In addition to what Robin2 wrote, your Arduino program should keep track of how close it is to the limit switch by adding and subtracting steps. The first thing the Arduino program must do is find the limit switch and set your counter to zero. Then any movement of the stepper means add/subtract from that counter.
A program may be slow because it is doing something to test for a limit switch, rather than using a step count.
Paul