1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Speed control of a fidget spinner

Discussion in 'Electronic Projects Design/Ideas/Reviews' started by Beets, Nov 1, 2017.

  1. Beets

    Beets New Member

    Joined:
    Nov 1, 2017
    Messages:
    6
    Likes:
    0
    Hello, anyone good with sensors, robots and control sytems help me with this question. (not neccesarily a robot question)

    I am trying to find a way of capturing the speed of a rotating fidget spinner using a micro-controller (the pic18f45k20). The method I am using to make the fidget spinner run is as shown in this link (It also has a video and how it is done including a circuit diagram).

    link: http://www.instructables.com/id/Electromagnetic-Fidget-Spinner-Accelerator/

    My main aim is to control the speed using the micro-controller (pic18f45k20).

    Anyone please advise me on how I can do this and which sensors to use in order to capture high speeds that can vary between 500rpm and 1000rpm .

    Thank you.
     
  2. dr pepper

    dr pepper Well-Known Member Most Helpful Member

    Joined:
    Oct 6, 2008
    Messages:
    4,708
    Likes:
    255
    Location:
    North west UK
    If you've seen the 80s gizmo 'power ball', well it has a magnet in the ball and a magnetic reed switch in the rev counter display, simple and measures up to 15k rpm.
     
    • Informative Informative x 1
  3. JonSea

    JonSea Well-Known Member

    Joined:
    Oct 1, 2012
    Messages:
    1,159
    Likes:
    98
    Location:
    Seattle, WA
    ONLINE
    An easy way to measure speed would be an IR optical sensor like this one from Elecrow Electronics. This type of sensor will generate a pulse each time a piece of reflective tape passes in front of it. The detection range between tape and sensor is a few cm to half a meter.

    These sensors are commonly used to measure the speed of rotation for machinery.
    SmartSelectImage_2017-11-02-03-18-16.png
     
    • Agree Agree x 1
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Beets

    Beets New Member

    Joined:
    Nov 1, 2017
    Messages:
    6
    Likes:
    0

    Dr Pepper, thanks I'll look into that. I'll be back because I still have to learn how I can vary and stabilize the speed.
     
  6. Beets

    Beets New Member

    Joined:
    Nov 1, 2017
    Messages:
    6
    Likes:
    0
    Jonsea, Thank you. I also found many other types of this IR sensor on google. I guess what remains is trying to program it together with a micro-controller
     
  7. dr pepper

    dr pepper Well-Known Member Most Helpful Member

    Joined:
    Oct 6, 2008
    Messages:
    4,708
    Likes:
    255
    Location:
    North west UK
    • Like Like x 1
    • Agree Agree x 1
  8. Beets

    Beets New Member

    Joined:
    Nov 1, 2017
    Messages:
    6
    Likes:
    0
    Thanks Dr Pepper. That link will actually help because my design already includes PID tuning, even though am using matlab to design the circuit specifications and some op amps for building the circuit. If the PID circuit works then, I will try to incorporate it with a micro-controller. Am not yet sure how that will work. And for the speed sensor, I suggested a photo-transistor (that will measure how many times the light is blocked by the spinner in a second), which i am not sure will work fine. I intend to replace it with an IR optical sensor as suggested by JonSea.
    This is my design so far.
    link : https://drive.google.com/open?id=0B8fxRqAjEVYeRC10VTdzVUxid3M
     
  9. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    5,979
    Likes:
    510
    Location:
    Cleveland, OH, USA
    ONLINE
    Your lower speed is 500 rpm, which equates to 8.3 Hz. Rather than measuring pulses per second (assuming one pulse per revolution), I would measure the time between pulses and "calculate" speed from that to get more timely control. I put calculate in quotes as your control system may be based on time alone and not actually do that calculation.

    John
     
    • Thanks Thanks x 1
  10. Beets

    Beets New Member

    Joined:
    Nov 1, 2017
    Messages:
    6
    Likes:
    0
    okay, that sounds more accurate.
     
  11. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    5,979
    Likes:
    510
    Location:
    Cleveland, OH, USA
    ONLINE
    You chip has one or more 16-bit timers. The first is Timer 1; the others will have sequential odd numbers. Timer 1 types can be set to trigger on either, both, or alternate edges of a pulse. You probably just want to pick either a rising or falling edge. Since your MCU will be running very fast relative to the pulse, you also need to pre-scale the counter (or its trigger) so you do not overflow more than once during a count. As 16-bits give you more than enough precision for your project, I would set the pre-scale fairly high.
     
    • Agree Agree x 1
  12. dr pepper

    dr pepper Well-Known Member Most Helpful Member

    Joined:
    Oct 6, 2008
    Messages:
    4,708
    Likes:
    255
    Location:
    North west UK
    Good idea from Jp.
    I cant open your link however if your using an arduino as the processor there is a pulse library which is meant for such an application.
     
    • Like Like x 1
  13. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,080
    Likes:
    326
    Location:
    Brisbane Australia
    To add to what John already said, if you use the ccp (PWM) module you can capture timer1 on each rising edge. Subtracting current from previous will give you the period.

    Mike.
     
    • Thanks Thanks x 1
  14. Beets

    Beets New Member

    Joined:
    Nov 1, 2017
    Messages:
    6
    Likes:
    0
    Thanks guys, I appreciate. Currently I only have access to a micro-controller. By the way, which of the two is easier to use, a micro-controller or an arduino?
     
  15. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,080
    Likes:
    326
    Location:
    Brisbane Australia
    If your Micro is a pic then most newer ones have a PWM/CCP module built in.

    Mike.
     
  16. dr pepper

    dr pepper Well-Known Member Most Helpful Member

    Joined:
    Oct 6, 2008
    Messages:
    4,708
    Likes:
    255
    Location:
    North west UK
    An arduino is a micrcontroller, with a board and an Ide and a range of libraries.
    The arduino is a good platform to prove your concept or for a one off as the range of libraries is extensive.
    The ide is free and dead easy, and the 'duino itself is also cheap.
     
    • Like Like x 1

Share This Page