I have an RC remote and receiver. I want to use the remote to control a stepper motor. The receiver outputs PWM which normally would control a servo or ESC.
Well what I'm doing is I'm trying to read PWM from my receiver with the arduino, then using the value to put a stepper motor in a specific position. For thoughs who know how RC car PWM work I plan on having every .01 ms equal 7 steps in the stepper motor.
I'm a hardware guy not a software guy so I know very little about C. With the research that I have done I know you can read PWM(but can't find the code) with the arduino and I know you can control a stepper motor. I was thinking once I figure out how to read PWM I would use part of the code from MotorKnob to do the rest of the work.
For thoughs who know how RC car PWM work I plan on having every .01 ms equal 7 steps in the stepper motor.
Do you plan on having an encoder or potentiometer in there somewhere so you know your actual position?
Based on your description, it sounds like you are planning on doing "open loop" control, which even with a stepper will not necessarily be accurate (unless there isn't going to any load on the shaft of the stepper, or whatever load there is can't backdrive it).
If you need to have the stepper start and stop in certain absolute positions, you are going to need an encoder. If, however, you are planning on something like an x/y/z table (like for CNC), where the table can't backdrive the steppers (because of the leadscrew mechanism that would generally prevent it), then it will probably be OK (although you would still want end-stop switches for homing).
I understand the type of set up I'm talking about would cause the motor to start at a random position every time it would be turned on. I had planed to center the wheel before turning on the motor but you gave me a good idea. The stepper motor turns 3.5 times so at start up I should have it turn left or right 1.75 time left or right to hit a switch so it will know where center is.
Unfortunately since I don't know much about C I'm working on the pwm to serial first. I'm assuming when you say encoder your talking about a device that interprets pwm into something that C understands. I was kinda hoping that the arduino would be able to interpret pwm into some type of variable in C that I could play with. Would anyone know if that's possible?
I'm assuming when you say encoder your talking about a device that interprets pwm into something that C understands.
No, I am talking about a device which can tell you how much a shaft has turned.
Most encoders you are likely to find will only give you speed (single) or speed and direction (quadrature); neither or these can give you an absolute position (the shaft is facing this angle/direction). These kind are sold by various vendors; you can also find small ones in older non-optical mice.
There are encoders that can give you this information; binary-coded decimal (BCD) encoders are available that can output a digital value that represents the angle the shaft is at (to varying degrees of precision) - sometimes you see these on high-end stepper and industrial servo motors. There are also analog versions that output either a voltage or a changing AC-signal phase angle.
One way you can homebrew such an encoder (though it won't be very accurate) is to print on a transparency sheet or clear label a filled-in circle in which the sweep line around the circle changes density by a set amount per degree of sweep, so that it starts dark at 0 degrees, and ends up clear at 359 degrees, so there is a smooth gradient around the area of the circle. Then, you use an LDR or phototransistor with an LED opposite (plus light-blocking baffles) and read the change in light level via an analog input (essentially a 360 degree optical potentiometer).
If you only had to spin one way or another by so many turns (and you wouldn't exceed those number of turns), there exist devices called "multi-turn" potentiometers; they are essentially potentiometers that can be rotated multiple times 360 degrees (some even have dials and counters built in); they use gearing and such to move the actual slider by small increments for each full turn of the knob.
Thanks for your responses. At the moment I have a stepper motor driver program with a 10 turn potentiometer. It works just fine I can turn it left right and it's very precise for what I'm doing. Anyways my main question is how can I make the arduino read PWM on one of it's input pins? Like for example the arduino will see that it's at, let's say a 1.50 ms high and in the C program will tell me the pwm's position.