Connect with us

Motor Project

Discussion in 'Sensors and Actuators' started by Integrator741, Nov 19, 2014.

Scroll to continue with content
  1. Integrator741

    Integrator741

    125
    4
    Jun 16, 2013
    Hello,

    I got a little project going on and a part of this project includes a small DC motor with a small fan stirring some liquid of unknown density at 500 to 1500 rpm. The motor must be controlled with some computer code. Now I am not really sure how is it possible to control a simple DC motor from a microprocessor? What sort of motor should I buy? And how can I see the motor's speed when it is spinning in the liquid of unknown density?

    Thank you in advance,

    :)
     
  2. BobK

    BobK

    7,680
    1,685
    Jan 5, 2010
    There are several ways you could go.

    In order of increasing expense:

    If you use a simple DC motor you will need some kind of rotary encoder to give feedback about the speed. And optical encoder, or hall effect sensor are typical. In this case you would modify the power to the motor until the desired frequency was read from the sensor. The motor power would be controlled by PWM. At the very simplest, if you need only one direction, you could control it with a single MOSFET and a microcontroller.

    A a stepper motor can be controlled to very high precision because you move it in precise steps. The timing between the steps determines the rotation speed. PWM may still be needed to vary the power with liquid density. The controller for stepper motors is typically an H-bridge (4 MOSFETs) per winding, typically two of them. You can buy controller boards that take 2 inputs, for direction and step, that you would interface to the computer.

    Then there are variable frequency AC motors, and brushless DC motors (which actually run on AC, go figure) which are a bit more difficult to control, but in this case you would buy a ready made controller that could set the RPM directly. You would need one with a computer interface.

    Hope this helps.

    Bob
     
    Gryd3 likes this.
  3. BobK

    BobK

    7,680
    1,685
    Jan 5, 2010
    Here is a picture of my robot vehicle with DC motors and an photo-interrupter to get feedback of the wheel speed.

    Interrupter.jpg

    The toothed wheels and the little black U's behind them are a photo-interrupter, which sends a pulse each time a tooth interrupts a light beam going across the U. You may notice the black paint on the teeth. The photo-interrupter is made of translucent red plastic, which is, apparently quite transparent to IR light from the interrupter! The black paint fixed it.

    Bob
     
    Arouse1973 and Supercap2F like this.
  4. Colin Mitchell

    Colin Mitchell

    1,418
    314
    Aug 31, 2014
    All motors produce electrical noise and the frequency of the noise depends on the RPM.
    Use a simple PWM circuit to produce the RPM, pick off the noise across the brushes and feed it back to the micro to give you a readout on a 4 digit display. .
     
  5. Integrator741

    Integrator741

    125
    4
    Jun 16, 2013
    Thanks for the reply.

    I just found out that I am going to be using MSP430. I want to keep this as simple as possible, so I am thinking of using a MOSFET for one direction spinning. Now I tried to google how to actually hook up a simple DC motor to MSP430 but not much came up. Maybe you can help me with this?
    And also about absolute encoder. Should I think about this before hooking up the motor or can I do it afterwards when the motor is nice and running?

    Thanks
     
  6. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,267
    Nov 28, 2011
    The MSP430's I/O is no different from that of other microcontrollers. But what voltage will it be running at?

    Is there a supply rail available with higher voltage than the MSP430's VDD rail? What voltage is it?

    You could use a MOSFET that is specified to turn on heavily with a low VGS voltage (e.g. 3.3V if that's the MSP430's operating voltage). Alternatively you can use a level shifter (one or to transistors and a few resistors) to convert the logic-level signal to a higer voltage to ensure that the MOSFET has enough gate-source voltage to turn ON fully.

    Most MSP430s have PWM output capability but you should check to make sure.

    Why are you not considering using a stepper motor? It would be easier to control.
     
  7. Integrator741

    Integrator741

    125
    4
    Jun 16, 2013
    Well, I was thinking about using two 1.5v batteries. So if I would use a stepper motor, what would be different? Would I be able to connect it straight to the controller? How would the connection look like?
     
  8. Integrator741

    Integrator741

    125
    4
    Jun 16, 2013
  9. Frenoy Osburn

    Frenoy Osburn

    64
    24
    Nov 20, 2014
    If you can increase the voltage to at least 6V, 9V would be ideal, then you can use a DC geared motor. It will give you much more torque then the small (BO) motors shown in post #3.

    To control it:

    For uni-directional control:
    Take a look at this page, check the circuit at the bottom. Do a similar thing with the MSP430
    http://www.bristolwatch.com/picaxe/adc_pwm_demo.htm


    For bi-directional control:
    You can use an L293D (H-Bridge chip) for currents up to 600mA, or else you could go for the L293N for currents up to about 1A. There are numerous examples with the same chips and if you can't seem to understand something, feel free to contact me. I've used these chips a lot. You basically generate a PWM signal from your MCU, which controls the voltage applied to the motor. Higher the voltage applied to the motor, faster it rotates (until it eventually burns out :p)

    To determine the RPM, you'd have to use an encoder. Again, plenty of material already exists.

    To give you an idea about pricing (I'll convert local prices here to US $): the motor should cost you about $3-4, the drive $1 (L293D) or $2 (L293N)

    Stepper motors are nice, but the only reason I would not recommend them are:
    1. You would need a stepper driver, something like a A4988 or DRV8818 or DRV8825
    2. The stepper itself is usually bulky and heavy.
    3. You would need more wires to connect everything (not sure how compact and *clean* your setup needs to be)
    4. The cost would be higher, about $8 for the drive and $15 for the stepper.

    If you know what would be the maximum torque that the motor would have to deliver, then by using a stepper you would not need any position encoder as the step signals would determine the speed. You need to ensure that the stepper motor will not slip or else your step signals will not give you a true indication of the speed.

    Hope that helps!
     
    KrisBlueNZ likes this.
  10. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,267
    Nov 28, 2011
    You would need some kind of buffer between the micro's I/O and the stepper motor. The details would depend on the stepper motor, as there are several kinds.

    3V is a pretty low voltage - both for the motor, and for the drive circuitry. No doubt there are stepper motors designed to run at 3V and ways to drive them, but most of the material you find will be designed assuming a higher supply voltage and may require several changes to run properly at 3V.

    Here are some good resources on stepper motors:

    https://en.wikipedia.org/wiki/Stepper_motor
    http://www.freescale.com/files/microcontrollers/doc/app_note/AN2974.pdf
    http://homepage.cs.uiowa.edu/~jones/step/an907a.pdf
    http://homepage.cs.uiowa.edu/~jones/step/

    I have no experience with steppers myself, but there are plenty of folks here who do.

    The reason I suggest stepper motors is that speed control is automatic. There is no need to monitor the speed and implement feedback to control the motor voltage to achieve the desired speed, the way there is with brushed DC motors.

    Another option that BobK mentioned is a brushless DC motor. A BLDC motor is actually just a type of stepper motor that's designed for continuous rotation. This is the type of motor used in 3.5" floppy drives (if you've ever looked inside one of those).

    https://en.wikipedia.org/wiki/Brushless_DC_electric_motor
    http://electronics.howstuffworks.com/brushless-motor.htm
     
  11. Frenoy Osburn

    Frenoy Osburn

    64
    24
    Nov 20, 2014
  12. Integrator741

    Integrator741

    125
    4
    Jun 16, 2013
    Sorry but I still don’t really get it.
    Like I said before, I want to make this as simple as possible, so that means stepper motor is out, because that would require additional stuff. So if I use a plain DC motor I understand that they move very fast right? If I use it with gears, I can somehow control the speed right?
    To make it spin only in one direction I understand I need to connect the motor through MOSFET, one leg of MOSFET to the MSP430, other to ground and other to the motor, then other part of the motor would be connected to my power supply (probably some batteries). Also a diode for protection right? So what voltage should I use then? Because I need to produce 500 to 1500rpm. And I still don’t really get the relationship between MSP430 and batteries. For example if I connect my motor to 9v battery, then other wire to MOSFET, would that affect MSP430?
    Thank you for your patient.
     
  13. Frenoy Osburn

    Frenoy Osburn

    64
    24
    Nov 20, 2014
    Ok let me break it down. And don't worry, we are here to learn and teach.

    Consider the image below (from my earlier link)

    [​IMG]

    1. You see the circle with M? That's where you will connect the DC motor.
    2. The diode 1N4001 is for protection. Yes you need it (Answer to query)
    3. The line marked 5-12V is your motor supply voltage. You should apply the full voltage your motor needs. If it's a 9V motor apply 9, 12V then 12.
    4. The line marked B.3, is your input or control signal.
    5. Generally, the MSP430 will be powered by 5V while your motor will need a higher voltage. Thus you have 2 voltage sources in your project. Agree? The 5V for MCU and the other being the motor supply voltage,
    6. 0V is GND. Please note the ground for both your supplies need to be connected together. (Answer to query)

    With all the connections in place, if you place 5V on your control signal (B.3) the MOSFET will switch ON and current will flow from the motor supply voltage, through the motor, through the MOSFET to ground. If you remove the 5V signal (remove 5V signal = connect it to GND), the MOSFET is turned OFF and the motor stops spinning.
    If you reverse the motor wiring, the motor will spin in the opposite direction.

    You should test this first, before connecting the MCU, to make sure everything is ok.

    Now what's happening here is when the MOSFET is ON, the entire motor supply voltage (there will be some small drop, ignore it for now) is applied across the motor and hence it spins at full speed.

    If we vary this motor supply voltage, the speed will vary. If I apply a square wave (50% duty cycle), the MOSFET will be ON for 50% of the time and OFF for the other. So the motor will be ON for 50% of the time and if you measure the voltage across, it would be 50% of the motor supply voltage.

    Can you see the relation? 50% duty cycle = 50% voltage. 25% duty cycle = 25% voltage.

    Thus, by varying the duty cycle, we can vary the voltage applied to the motor and hence the speed. This is nothing but PWM.

    The job of the MSP430 is to generate a PWM signal which is connected to the control signal (B.3). When the MSP430 varies the PWM duty cycle, the speed should vary.

    I hope this gives you an overview about what the thing will look like. Please read further on this matter and if you have any doubts, feel free to ask them here.

    Sorry for a long post. I thought taking it step by step would help.

    Cheers!
     
    Integrator741 likes this.
  14. BobK

    BobK

    7,680
    1,685
    Jan 5, 2010
    If you went for a pre-made stepper controller board, a stepper motor would be simpler to control as Kris suggested. The software to control a stepper motor to run at 1500 RPM would be as simple as putting out 5000 pulses per second. (1500 RPM is 25 revolutions per second, and a typical stepper takes 200 steps to make 1 revolution)

    If you are going to build all the hardware yourself, a DC motor with an encoder would be simpler hardware, but more complicated software. The software would have to continually monitor the speed and adjust the power up and down to make it constant. That is what my little robot vehicle that I posted does.

    Most of the motors on the page you pointed to are not appropriate because the have geared down the speed to below the range you want. If you want to the top of the range to be 1500 RPM I would go with a motor that is geared to a bit above that speed, say 3000 RPM at full voltage because these speeds would be unloaded, and loaded they will be lower. You can lower the speed by PWM, but not raise it.

    And, as someone already pointed out, these motors would not run on 3V. In fact, you will probably have a difficult time finding a motor designed to run on 3V that will have the power you need. Not to mention that a small battery will probably not cut it.

    Bob
     
    Integrator741 likes this.
  15. Integrator741

    Integrator741

    125
    4
    Jun 16, 2013
    Thank you very much. This is really helpful.
     
    Frenoy Osburn likes this.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-