Processing to Stepper

henhen
edited October 2013 in Arduino

Hi,

I have been working with a piece of colour tracking code. I have manipulated it to work out a difference in previous and current angle with the view to sending the difference to my arduino which will then send the difference to the stepper.

I have got to a stage now where I have a variable 'tempAngle' which returns a value + or -, which corresponds to the difference in angle.

I believe it is now just a case of converting the angle in to steps (200 steps = 360 degrees so 1 degree is 0.55555 steps)

Once this simple function is done the number of steps needs to be sent to the arduino.

Using firmata I think I have established a serial link by using the serial library in the processing reference, Serial.list() and so on.

How do I then bring this number of steps in to arduino? Is it going to be a problem that the number of steps is going to be a weird, possibly recurring decimal?

Thanks.

Answers

  • You need to use something like the lerp() function to calculate the number of steps output to the stepper. You cannot output a half step or fraction of a step. It is either on or off with the output. Some controllers can do "micro-stepping", like a half-step, but you would then be calculating for 400 steps instead of 200. If you want to stick to the 360 degree idea, you will need a different stepper and/or controller with that capability.

    If you do try to change the pulse length as is, i.e. do a half-step, you will more than likely cause harmonic issues with the stepper (it will hum and groan) and you will lose steps and the motor location. This may happen anyway if you send steps faster than the controller can digest them. It is possible send shortened pulses, but they must be balanced on all of the windings of the stepper with a somewhat complicated ramping algorithm.

    A home switch or encoder is good to help the motor find its location if it gets lost.

Sign In or Register to comment.