Shop OBEX P1 Docs P2 Docs Learn Events
using multiple frequencies to control a stepper motor. — Parallax Forums

using multiple frequencies to control a stepper motor.

bbrienbbrien Posts: 561
edited 2020-11-29 05:37 in Propeller 1
I have a functioning program that controls two DC geared motors with PWM. I am using a UDN2993 motor controller. I am building a new program which controls also two motors, one DC geared motor and one geared stepper motor. the stepper motor is controlled by a MC3479 motor controller. It uses a enable line which uses a PWM at 50% duty cycle and a phase line(0, or 5 volts) which sets direction.Telescope%20mount%20dh12.spin
«13

Comments

  • What I would like to do is replace the RA motor and function lines to use the stepper motor which uses adjusted frequency to set the speeds of the RA motors. Would I need to use a separate cog to do this.
    bbrien
  • bob_g4bbybob_g4bby Posts: 440
    edited 2020-11-29 11:28
    That's an interesting project. Tell us a bit more:-

    1. Why do you want to change from the existing setup? What problem(s) are you seeking to fix?
    2. What I would like to do is replace the RA motor and function lines to use the stepper motor which uses adjusted frequency to set the speeds of the RA motors Do you mean a stepper will be moving the telescope via a gearbox instead of a DC motor or something more complicated?
    3. Are you the programmer or has the program been written for you?

    Whether you need more than one cog probably depends on whether one cog is likely to run out of time to do all the task or that too much jitter in control is occurring due to 'multi-tasking'. On some programs, it's possible to measure cog spare-time using the system clock-cycle counter.

    I bought a job lot of small worm-wheel gearboxes off ebay. One of them has a ratio of 2304:1 which may be of interest.

    Cheers, Bob SW U.K.
  • A stepper motor does not use PWM to work. A stepper motor is just that, it steps each time a pulse is generated on the pulse line. The direction pin tells the MC3479 what direction the motor should step in.

    So to use a stepper motor for this application you need to know how many steps to generate to get the movement you need.

    Look at this project to see three stepper motors in action. They control the X, Y, and Z access of the robot based on the angle that is needed to place the arm in the correct position. SCARA Robot.

    Mike

  • bob_g4bbybob_g4bby Posts: 440
    edited 2020-11-29 15:15
    Mike is right - and direct pulsing of the stepper motor would cure the problem you may be having with the PWM driver and DC motor at the moment - the rate of turn is not precise and thus the star field may be drifting out of view sometimes more sometimes less, session to session - due to friction in the reduction drive varying with temperature, lubrication etc.

    So you would control the stepper directly by sending 1's and 0's to the propeller pins that connect to the stepper controller or even just via power transistors. This means you know exactly how many steps you've sent and thus control the rate of turn exactly. Once tuned so that star field drift is minimised, then it should always maintain that performance - IF that's your problem at the moment.

    Your project caught my eye because I like to program the propeller in tachyon forth. You'll probably know that forth was (is?) very popular for big telescope control. I'm not suggesting switching languages, though - stick with what you're most familiar!
  • Stepper motors do use PWM when they're being microstepped. Microstepping gives a smoother motion than on/off stepping and may be desirable when controlling a telescope drive.

    -Phil
  • Further to what Phil said, I’ve used a PWM strategy when not actually stepping in order to reduce the holding current on a stepper. It reduces heating at the expense of holding torque. With the Prop and a FET driver, its pretty simple to do it all in code and it doesnt have any undesireable effects on the motor or position as long as you are PWMing all the windings that need current at the same rate/phase.
  • bbrienbbrien Posts: 561
    edited 2020-12-01 02:39
    By using the MC3479 to step the motor you can get precise control. I've used it on other devices with good results. Data sheet included. The chip wants a pwm pulse with a 50% duty cycle
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2020-12-01 02:43
    That is a very old and very limited chip for small motors so it depends upon the motor you are using. As for a "pwm pulse with a 50% duty cycle" I'm not sure where you got that from, it's not in the datasheet and a 50% duty cycle is a clock pulse, not PWM. I guess you found that out from "the interweb thingy". Just tell use the motor you are using and how fast it needs to step, and also the supply voltage. In general, a higher voltage is better and a stepper driver that internally PWMs to control the current is much better than a simple driver like the MC3479. Then there are drivers that use PWM to microstep between phases by carefully balancing the current in each winding and with these you can achieve a smooth motion rather than a jerky step that may affect the viewing. I know even just the slightest vibration on a mount is amplified.
  • bbrienbbrien Posts: 561
    edited 2020-12-01 04:47
    the motors that I am using are from an orion a dual axis drive kit powered by a four pack of D batteries(6volt @ 2200ma).The circuit sets with a variable resistor which changes the frequency generated by the 74hc00.I will send a copy of the circuit. Refer to first post #2020-11-25-183244.
  • Just keep the DC and use the L298. You can buy on amazon for $6.
  • I don't get it. We are talking about my other telescope. It is a 10 diameter neutonian reflector. The RA drive module has a stepper motor in it. I have to use what I have.
  • bbrienbbrien Posts: 561
    edited 2020-12-03 02:36
    The telescope in question is my 10 inch diameter Newtonian which is equipped with a stepper in the RA module. Circuit is already built with plug-in for the processor board. Also can someone recommend a OBJ for the stepper.
    thanks
  • Dave HeinDave Hein Posts: 6,347
    edited 2020-12-03 02:56
    It looks like there are 8 different stepper motor objects in the OBEX on GitHub at https://github.com/parallaxinc/propeller/tree/master/libraries/community/p1/Motor Control . I don't know which one is best for you. Maybe somebody can recommend one of these.
  • I looked but I don't know how to download, couldn't find a download button.
  • I know that github isn't very friendly for individual files but please just try clicking here and there because I tried and I can view the file and then click raw and download that text page etc or go back to the root directory and download the whole 112MB shebang, or install a git client but then you'd also have to learn how to use that etc. Everything in life requires an effort which we are accustomed to ourselves. You only need to put in a little bit of it yourself.
  • In that case I would go with a $10-$12 Amazon step driver . I've used those before. You need to dedicate a few pins for fwd/rev, enable , clock etc. you'll have to drive those opto''s in the step driver with +5V. So prop pin to 2N3904 etc. I'll look for my spin driver. My last stepper project was a two phase A/C .
  • Would that be one of the ULN2003 chips or what. The MC3479 has a enable(clk) a phase( cw/ccw) full/half and bias pins
  • I have looked at the information and I don't think I need to have a special obj to run the chip, I will experiment a little and let you know.
  • If you look at your data sheet it's high or low on all control pins and clock is your pulse rate for speed. So clock is a steady pulse rate at a set frequency, low hz for slow higher hz for fast. Or click in a single pulse to nudge the stepper.
  • DigitalBob wrote: »
    Just keep the DC and use the L298. You can buy on amazon for $6.

    Is that stuff reliable, Bob?
    I need some 18200 devices which are $13 whereas I can get complete motor control modules for $5 😮
  • So far none have burnt up. And they say ST micro on the package. Some of these Amazon modules can be purchased cheaper than buying the component from mouser or digikey. Like a AD9850 module is cheaper than the part itself.
  • bbrienbbrien Posts: 561
    edited 2020-12-03 19:50
    I know. This is my first experimental version.
  • Dave, the first attempt failed so I tried another approach but I get an error at motor.start(RA_SPEED,......)"expected ")"
  • You have an extra set of parentheses. The line
    motor.start( -1, RA_SPEED, RA_DIR, PWM1_FREQ,( -1, DEC_SPEED, DEC_DIR, PWM2_FREQ ))
    
    should be
    motor.start( -1, RA_SPEED, RA_DIR, PWM1_FREQ, -1, DEC_SPEED, DEC_DIR, PWM2_FREQ )
    
    However, if one of your motors is a stepper motor you don't want to you use that object for that motor. Which motor controller did you decide to use for the stepper motor?
  • bbrienbbrien Posts: 561
    edited 2020-12-04 04:31
    Haven't any as yet but since only two outputs like the UDN2993 don't really know if need one.
    I tried what you suggested and I get an error " expected an expression term" at PWM1_FREQ.
  • My suggestion about removing the parentheses was just to fix the obvious syntax error. I hadn't realized you added an extra calling parameter also. The original call in DH12 was
    motor.start(-1, RA_SPEED, RA_DIR, -1, DEC_SPEED, DEC_DIR, PWM_FREQ) 
    
    You can't just add another calling parameter without changing the method that you're calling. How would the method possibly know what to do with the extra parameter you added?

    You have to first figure out what controller you're going to use to control the stepper motor. You then either need to write a method, or find one in the OBEX, that interfaces with the controller you selected. Your call to motor.start should only use one of the channels, since only one of your motors will be controlled by pulse-width modulation. You should pass values of -1 for the channel you are not using.
  • If one looks at the inputs of the UDN2993 and the inputs oif the MC3479 they are almost the same as the clk pin is alike to the enable and the phase and cw/ccd are alike too. I am thinking that the dual motors object can handle the stepper controller. Maybe I need two motor .start(...), one for RA and one for DEC. will try it out.
  • bbrienbbrien Posts: 561
    edited 2020-12-04 21:19
    more errors, take a look at current attempt and correct if possible The error is "expect byte,word,long"
  • Dave HeinDave Hein Posts: 6,347
    edited 2020-12-04 22:02
    @bbrien, you have an interesting approach to programming. When you call a method in another object you must call it using objectname.methodname. The object name is declared in an OBJ section as follows
    OBJ
      objectname : "filename"
    
    The filename contains only the root of the filename without the .spin extension.

    By convention, an object normally has a method called start that is used to initialize the object. The top object calls the start method using the syntax objectname.start(...). As with all methods, the calling arguments must match the parameters that are define when the method is declared in the object. The compiler will issue an error if the number of parameters don't match. You should look at the start method in the object to see what the parameters are.

    If an object requires starting a new cog it must be done within that object. When you start a new Spin cog you need to provide a pointer to the stack. In the case of the PWM object that you are using, the PWM object provides the stack. The top object does not provide the stack. If you need more than one instance of the PWM object you would declare it twice in the OBJ section using two unique names. Alternatively, you could define it with one name, but as an array of two objects.

    However, ....................................... You do not need two PWM objects. The one you are using support two PWM outputs. But,.......... you only need to use one of the PWM outputs. The other motor is a stepper motor, so it needs a different way to control it. That different way is not PWM. I have no experience with stepper motors, but I'll study the devices you listed to see if I can help you. Maybe somebody else has some code they can provide to control the stepper motor.
  • bbrienbbrien Posts: 561
    edited 2020-12-04 23:02
    I am going to backtrack to DH12 . Most all of the stepper controllers that I have studied have two inputs plus an enable per channel but the MC3479 uses only one enable and a cw/ccw pin. Bias and full/half step are controlled by the 74hc00 and a switch. Step delay is done by chip internally.
    What I need is PWM on one counter and a freq. pulse on the other(square wave train with 50% duty cycle)
    post # 2020-11-30 18:18:49 See also SMD1 page 13 "External clock input"
Sign In or Register to comment.