Shop OBEX P1 Docs P2 Docs Learn Events
Radio control reviever pwm to step/dir — Parallax Forums

Radio control reviever pwm to step/dir

MeistroMeistro Posts: 12
edited 2008-11-27 18:53 in BASIC Stamp
Hi everyone, I need some advice. I'm trying to use my bs2 to convert the pulsin pwm train from my RC reciever to step/dir signals my stepper board will understand. Also looking to ramp up, ramp down those steps too. Any help in pionting me in the right direction would be much appriciated.

thanks!!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-26 15:14
    The PULSIN statement would be used to measure the width of the RC receiver output PWM pulses. Any pulses less than 1.5ms should cause motion in one direction and pulses greater than 1.5ms should cause motion in the other direction. Pulses that are 1.5ms in width (and maybe in a very small band around that) should cause no motion at all. The difference between 1.5ms and the pulse width would indicate the number of steps needed in a period of time (like the 20ms between RC PWM pulses).

    The details of how to do this depend on what kind of step rate you would need to produce equivalent movement to a servo motor and you haven't described that. Do you need 50 steps per second to get full speed or 5000 or more? The higher the step rate needed, the more likely you'll need some kind of external circuitry to provide it with the Stamp controlling the rate.
  • SRLMSRLM Posts: 5,045
    edited 2008-11-26 16:31
    Take a look on the stepper motor product page in the Parallax store for code on how to control a stepper (with a driver, L296 if I'm not mistaken)

    Edit: Okay, the official parallax documentation uses the ULN2803 driver chip, and the chip that I was referencing before (see the N&V article "Stepping Out With Spin") is the L293D.

    Post Edited (SRLM) : 11/26/2008 4:39:36 PM GMT
  • MeistroMeistro Posts: 12
    edited 2008-11-27 04:41
    I already made the stepper controller that I use on my mill. I made another one for this new project since that one works so well. It runs in full step, 1/2, 1/4, 1/8, 1/16 step mode. I just feed it the step pulses and dir high or low and the stepper drive does the rest. I will most likely use 1/2 or 1/4 step because of the torque output and smoother operation.

    So basically, to provide more info on what I'm looking to do:
    If I use 1/2 stepping, I will need 2000 steps per sec.
    If I use 1/4 stepping, I will need 4000 steps per sec.

    I have no clue what the BS2 is capable of producing. Or if it can process that fast.

    So, I need to:

    constantly read the PULSIN from the radio receiver

    based on the varied input, produce steps, and a high or low pin output(DIR signal)

    use constants to make adjustment variables easier

    The steps output needs to vary along with the value of the input pwm. meaning for an example, if I have a rc car radio controller, and I apply throttle forward slowly, the step out pulses ramp up to speed gradually. Full throttle will mean 4000 steps per sec. Half throttle would be 2000. Same concept in reverse, with the exception of only requiring 3000 steps per sec.

    Oh, :| and I'm trying to control 2 steppers with channel mixing from another receiver channel. One direction on the other channel slows down the step rate of one of the steppers.

    Channel 1 travel in either direction (without input from channel 2)will run the steppers syncronized. Introduce channel 2 and depending on how far away from center, will reduce the amount of steps to either stepper depending on which direction off center chan. 2 is moved.

    I'm sorry about my explaining, not to good at it. Actually as I stare at SRLM's avatar, its controlling a tank drive with steppers instead of the standard H-Bridge DC motors. lol
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-27 05:14
    Practically, you won't be able to do this nicely with a BS2, partly because the Stamps are single task devices. While the Stamp is waiting for the next receiver pulse, it can't be doing any stepper pulses. You will need some kind of external hardware If I were going to do something like this, I would use an SX or Propeller. Either one can handle multiple tasks. The SX does it with precisely timed interrupts while the Propeller does it with multiple processors. Both are also capable of much higher speeds than the Stamps. Both also have tools to help with the conversion from Stamps to an SX (the SX/B compiler) or a Propeller (the BS2 Compatibility Library).

    The BS2e Motherboard (www.parallax.com/tabid/528/Default.aspx) has a BS2e Stamp with two peripheral processors. The standard firmware for these processors doesn't have a convenient function for controlling a stepper motor, but it does handle PWM and that routine could be modified to produce a specified number of step pulses at a particular rate, then stop.
  • MeistroMeistro Posts: 12
    edited 2008-11-27 16:41
    Thanks Mike.
    I was afraid you were gonna say something like that [noparse]:)[/noparse] I will probobly splurge for this... http://via-itx.com/via-artigo-builder-kit.html And use embeded Linux. That should more than handle what I need to do [noparse]:)[/noparse] I can still use my stamp to collect data so it won't go to waste.

    Thanks for all your help
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-27 16:55
    Your VIA-Artigo-Kit will not help you very much with the low level I/O like timing R/C receiver pulses or driving your stepper controller. It doesn't have the I/O for it. Even if you use the Stamp for this, you will run up against the same single-thread execution limitation.
  • MeistroMeistro Posts: 12
    edited 2008-11-27 17:47
    Hmm, Isn't there some kind of usb to serial adapter steup I can find? Happ thanksgiving by the way if your in the US [noparse]:)[/noparse]

    Probobly a better question would be, what type of platform would you concider if you were doing a project similar to mine? I have some PIC16F84A chips that I can use.

    I am having a very hard time finding circuit or code info about driving stepper motors by control of a RC model receiver. I might just have to wipe that idea and go with dual DC motors and dual H-bridge pwm driven. I like the stepper idea since I already have lots of stepper hardware and some 305oz unipolar steppers that have unbelievable torque.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-27 18:53
    1) FTDI has some USB to "serial" adapters that have an 8-bit parallel FIFO for input/output. They look like serial ports to the PC, but have the parallel FIFO interface to the external logic. The FT245R has a "bit-bang" mode where the I/O pins are continuously updated as data is received. At higher Bauds (like 130KB), you would be able to toggle a bit at about 4000 steps/second. You can have some I/O pins act as outputs and some as inputs with the inputs sampling the receiver outputs. I don't recommend this sort of thing since it's a lot of work on the PC end to get the throughput high enough and to try to keep the timing correct.

    2) I'd use a Propeller. You've got several tasks here (timing R/C pulse widths, generating stepper control information, and interfacing the two) and the Propeller is naturally suited for multiple tasks in a straightforward manner. It can provide real-time debugging information via a TV video output that you can disconnect, but otherwise leave in place, running, with no significant overhead other than one cog (processor) and some I/O pins. You could even dispense with the stepper controller and substitute just the coil drivers if you want. There's already contributed code for controlling 3 steppers (for X,Y,Z for CNC), see: http://forums.parallax.com/showthread.php?p=609066

    You could certainly use some PIC16F84A chips, but a Propeller would be easier.
Sign In or Register to comment.