Go Down

Topic: Stepper motor control via Processing Firmata (Read 7832 times) previous topic - next topic

joshuakoomen

Dear all interested readers,


I want to make a penplotter using an old plotter. I will use steppermotors for the movement.


How can I send commands via Processing to the arduino to make a stepper motor rotate?


I found this example:

http://arduino.cc/en/Tutorial/MotorKnob


... but I want to use Firmata. Is that possible?


Thanks in advance.

Kind regards,


Joshua

PaulS

Quote
... but I want to use Firmata.

Why?

What Arduino do you have?

There is a Firmata sketch that works with servos, if you set Processing up right.

joshuakoomen

I thought that Firmata is also capable to run stepper motors. Okay, so not Firmata then, but what's the best way to run it then?

joshuakoomen

I found this link:

http://www.instructables.com/id/Control-a-RepStrap-RepRap-CNCCartesian-Bot-usi/step10/Doing-it-with-Firmata/

It sets the direction, but I also want to be able to control the steps.

PaulS

The best way is for you to define what information Processing needs to send to the Arduino, to "control" the stepper motor.

How is the stepper motor connected to the Arduino? What does it need to do, in response to some input from Processing? Turn a fixed number of steps? Turn a number based on what Processing says? In which direction? At what speed?

Once you can answer those questions, sending the required data from Processing to Arduino is simple. Defining how to send that data in a way that the Arduino can store and parse it is relatively simple. Storing and parsing the data is trivial. Using the parse data is trivial.

joshuakoomen

Yes, I want to plot graph. Values from 0 to 100. I want my motor to move at a range from 0 to 100. The value comes from a float.

joshuakoomen

connected like this:

http://arduino.cc/en/Tutorial/MotorKnob

PaulS

Quote
I want my motor to move at a range from 0 to 100. The value comes from a float.

So, you want the stepper motor to step 4.7 steps?

Perhaps you don't understand how a stepper motor works.

joshuakoomen

I do understand how a stepper motor works. The range is an example. A range from 0 to 100. Where 100 could mean I want to rotate it 9 times to the right.

PaulS

The values that you say you want to send all fit in a byte. Have Processing send one byte for each movement needed.

Have the Arduino determine if there is at least one byte to read, and, if there is, read that byte and do something.

Serial.available() and Serial.read() on the Arduino side, and Serial::write() on the Processing side.

You are still to vague on what you want to do to offer any more help. How does the value 100 translate into 9 turns? How many steps is that? How do you expect to rotate the other direction?

joshuakoomen

I have a number from 0 to 100 in processing. 100 means that the pen of the plotter (it's like a plotter device) should be 100pct to the right. 0 means it should be left.

PaulS

Quote
I have a number from 0 to 100 in processing. 100 means that the pen of the plotter (it's like a plotter device) should be 100pct to the right. 0 means it should be left.

The advice in the previous reply holds, then. All that the Arduino will know is what percentage of the total travel the stepper motor should be at. You will need to maintain a current step count, and know how many steps are required to travel from one limit to the other. Given the last directed percentage, the last step count, the total step count, and the new directed percentage, you can work out how many steps to step, in which direction. Then, all you need to do is step that number of steps.

joshuakoomen

#12
Dec 18, 2011, 03:37 pm Last Edit: Dec 18, 2011, 03:40 pm by joshuakoomen Reason: 1
Thank you for your advise. Can you describe what my code should look like? Like: How to send a step and also send the speed.

PaulS

Quote
How to send a step

With the wiring that you have, you have to set the state of 4 pins in the correct order to step. Which pins, and which order, depends on where the motor is now.

Using a stepper driver makes stepping a lot simpler, since it keeps track of which pins to activate next.

Presumably, the code that went with that wiring defines how to make the stepper step. Hopefully in a way that is easy to use.

Quote
and also send the speed.

The speed of a stepper motor is controlled by the delay between steps. Use smaller values to step more often. The limit is a function of the voltage that the motors are operating at and the current capacity of the power supply. Stepper motors need a lot of current.

Go Up