PC joystick to (Servo or Stepper) STEP/DIRECTION


Closed Thread
Results 1 to 24 of 24

Hybrid View

  1. #1
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231

    Default PC joystick to (Servo or Stepper) STEP/DIRECTION

    I have found a need to read an old PC joystick and generate some movement commands.
    The joystick is the older type with a 15 pin DB (DA actually) connector. Mine makes 3) 20k to 80k pots and 4 switch contacts available at the connector

    My purpose is to drive a CNC gantry using servo or stepper motors (STEP and DIRECTION signals, not pulse length on hobby servos). The basics of manipulating the readings would be the same for use with a game or hobby servos and this may be useful to others.

    Thd PIC will output X and Y movements based on the distance from center on the joystick with a small null in the center to prevent creep.

    I have been unable to find anyone working on this with a search, so I will make a go of it and solicit any suggestions.

    Since my joystick has 3 pots (X, Y, and trim) and 4 switches that can be read , the goal is to
    grab the analog and determine if the X and Y are above or below center and set a direction pin to 1 or 0. Then the magnitude of the signal from center (minus the dead zone) will determine the number of pulses generated. The trim pot will modify the number of pulses and act kind of like a speed control or limit to tune the movement of the device. The switches will be used to activate extra functions on the device.

    Reading the A/D should be straight forward, but I mulling how to control 2 pulse streams and adjust them using a third. Current target is a 18F2331 or 18F4431 and I'm going to see if I can get the PWM outputs to do what I want.

    So far this is preliminary, so I'm just fishing to see if there is any interest. If there is, I will post my progress.

    Bo

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Hey Bo,

    Not sure if you saw this one. It is to drive an x/y table with two stepper motors. May be of some help if you choose steppers.

    http://www.picbasic.co.uk/forum/content.php?r=223

    Walter
    http://www.scalerobotics.com

  3. #3
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default

    Thanks for the hint Walter, After some sleep, I will study it and see what I can learn. I remember seeing that post once, but didn't study it or think to apply his solution to my problem. He's using Step/Direction, so I'm sure there some answers there.

    After a few hours of looking at my original problem, it became apparent that I was going to have to find out how to generate 2 independent pulse trains that had variable frequency in order to move the motors in two axises. I am currently looking at the timers, CCP's, and the HWPWM for a clean way to do that. At first glance, I overlooked that it was considerably different than varying the width of pulses over a constant period (ie.. PWM). I seem to remember where someone did the calculations with a formula on the fly. I'm going to see if I can do that with the PR2 register and get somewhere with 2 timers.

    I will keep this post updated as I learn more.

    Bo

    BTW, better up your sampling rate, you're not even near Nyquist!

  4. #4
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    Some prelimary questions: How fast do you want max jog to be? how many steps per rev? This info will drive how you toggle the output pins for the steps. My first thought is intrupt based toggle. But it really depends on the speed you want to achieve, and how precise you want that speed.

    If you think about the a/d answer being the modifer for a delay between toggles, I am not sure you have much math to do.

    Lets assume 10 bit A/D, with 24 bits of dead band. so you have 500 possibilties for the speed. So 0 max, and 500 is stop. This is because 0 delay would be full speed.

    Now we just need to know osc speed for the rest of the math

    If you use 2 counters as the delay, your A/D answer can change the count needed to toggle. Then establish a duration for what a count represents and load that into the timer. when the timer rolls over, update both counters. If either or both have reached their count, toggle the pin for that motor.
    Last edited by cncmachineguy; - 28th October 2010 at 15:53.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  5. #5
    Join Date
    Feb 2008
    Location
    Michigan, USA
    Posts
    231


    Did you find this post helpful? Yes | No

    Default

    I'm coming up with about 6000 pulses per second for max travel speed (2.375" travel/rev, 360cpr encoder X 4, 10"/sec Max jog), so that is about 167uS as the quickest pulse repetition.

    That helps me focus on a target. I'm going to see if I can monkey poke tonight and come up with something.

    Thanks for helping me clarify my thoughts.
    Bo

  6. #6
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default

    are you using steppers with encoders?
    the step/dir implies using steppers, the 360 cpr x 4 encoder suggests encoders. I ask for 2 reasond, 1 just because its pretty cool if you are closing the loop, but more important is if you are reading the encoder for 2 axis and generating the steps for 2 steppers, timing will become important. how fast is your pic running?

    If you are using steppers, how many steps per rev are they? Is your drive running full step, half step,...

    I'm actually very intrested in this concept. I never thought of a joystick for a jog control
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts