How to use a LM393 IR Speed sensor with an Arduino - Tutorial

Sdílet
Vložit
  • čas přidán 25. 06. 2024
  • Let's see how to connect and use a LM393 Speed Sensor to calculate the speed of a DC motor.
    Check out our tutorials page at : brainy-bits.com/tutorials/ to get the schematic and more information on this tutorial.
  • Věda a technologie

Komentáře • 78

  • @BrainybitsCanada
    @BrainybitsCanada  Před 9 lety +1

    +Neil Kolban Thanks for watching and your comment! And I will work on my pronunciation of "potentiometer" in my next videos! :)

  • @naboulsikhalid7763
    @naboulsikhalid7763 Před 2 lety +1

    your tutorials are always detailed, informative. thank you for making me better.

  • @BrainybitsCanada
    @BrainybitsCanada  Před 9 lety

    Thanks for watching Mike!

  • @BrainybitsCanada
    @BrainybitsCanada  Před 8 lety

    +Max Tubbs Also make sure that you closed and restarted the Arduino IDE software after you extracted the files.

  • @KR0tG5fk
    @KR0tG5fk Před 9 lety

    Your video’s and web site is very nicely done, you have me hooked.

    • @BrainybitsCanada
      @BrainybitsCanada  Před 9 lety

      Ron Henderson Thanks for watching and your comment! Always great to hear that the videos are interesting, and it encourage us to make new ones!

  • @thomasbaars5948
    @thomasbaars5948 Před 3 lety +2

    Amazing tutorial, very informative.

  • @BrainybitsCanada
    @BrainybitsCanada  Před 8 lety

    +Max Tubbs Hi, make sure that the folder that has the TimerOne files in your Arduino Libraries folder is named: TimerOne and not TimerOne-r11. Not sure if that's the problem but it's worth a try. Let me know if that doesn't fix it, then we'll try something else :)

  • @user-ux9rj9hm4z
    @user-ux9rj9hm4z Před 8 lety +8

    this is a nice high level explanation.
    I'd be careful in the way you handle the math --> as your rotation variable is an integer and integer math are trunking results - what you get when you divide by 20 is highly approximative( but it makes nice for display). In practice with your code, if counter is 20 or 39 you'll show 1 Revolution per second which is correct for 20 but almost way off when counter is 39.
    Also, while by defaults lower level interrupts do not stop the execution of an interrupt callback, it might be good practice to call noInterrupts(); and interrupts(); at the beginning and end of your timerIsr function.
    Also because it's not a great idea to have long running interrupts (where you do all the printing - that skews timing functions and your main code might need accurate millis() for example) best would be to limit what you do in the timerIsr function. For example you could have a global volatile variable lastMeasuredRPM which you would calculate in timers and do the printing in your main loop function (checking millis() - startmillis) and print every second for example)

  • @CidaLunacorteecostura
    @CidaLunacorteecostura Před 8 lety

    Hello, I'm making a line following robot and I want to know I can connect 04 motors DC (3-6v) in brigde l298n? And how to control the rotation and speed of the motors(02 motors by connecting in series) ?
    Thank you.

  • @EdgarasArt
    @EdgarasArt Před 9 lety

    Great tutorial, really useful.

    • @BrainybitsCanada
      @BrainybitsCanada  Před 8 lety

      +Edgaras Art Thanks for the comment and for watching of course :)

  • @bahargungor
    @bahargungor Před 6 lety

    very nice, thank you very much

  • @sreeharihunnithan
    @sreeharihunnithan Před 7 lety

    I was working on a project with your code as the base where the rpm is displayed on an LCD screen, however, these weird characters are also getting displayed along with motor speed .

  • @LSUtiger607
    @LSUtiger607 Před 6 lety

    I have basically replicated your project here but using a hobby airplane electric motor. The difference for me is I'm dealing with much faster RPMs. Using your code above with the interrupts, I can only sense a maximum of 240 "counts" per second. Anything faster begins to drastically corrupt the reading. Is that a limitation of the interrupt itself or of this sensor (LM393)? I have it plugged into the interrupt 21 (2) pin of my Arduino Mega. What would you suggest if I wanted to increase the counts per second? Thanks in advance.

  • @user-ux9rj9hm4z
    @user-ux9rj9hm4z Před 8 lety +1

    While this code is simple so it does not really matter much, to be accurate and safe, your counter variable should be declared as volatile ( volatile keyword should be used in the definition of a variable when there's a chance that the variable's value could change outside the normal flow of execution of the program - which is the case here as you use it in an interrupt).

  • @jimmy2times
    @jimmy2times Před 5 lety +1

    Well explained!

  • @justkeen18
    @justkeen18 Před 9 lety

    is it possible to use this system with a 220v pwm speed controller? I want to make a speed controller for a 220v router motor on a cnc machine for mach3, im just worried about the higher voltage frying the rest of the circuit. maybe there is buffer circuit or something i need to put between the dc and ac parts?

  • @rashiidsherif9222
    @rashiidsherif9222 Před 8 lety +1

    Would it work if your encoder plate has say 4 holes? You would just divide the counter by 4?

  • @webslinger2011
    @webslinger2011 Před 5 lety

    Has it been uploaded? Can't find this tutorial on your site.

    • @BrainybitsCanada
      @BrainybitsCanada  Před 5 lety

      Here it is: www.brainy-bits.com/speed-sensor-with-arduino/ Thanks for watching!

  • @rapunzeleh546
    @rapunzeleh546 Před 5 lety

    could i use that lm393 to make my own wind sensor? doesnt have to be very precise, just want to pull down a solar tracking panel if the wind is too strong.

  • @MrCesarios23
    @MrCesarios23 Před 8 lety

    Hello! Can i print the disc with a 3D printer? Do i have to have the exact number of slots you had on your disk?

  • @mahdikhalil2026
    @mahdikhalil2026 Před 8 lety

    Hello, can we set the timer to a higher value like 15 mints? and how? thank you.

  • @emmanuelbabu2215
    @emmanuelbabu2215 Před 8 lety

    hi...what is the maximum allowable cable distance between sensor and the UNO??

  • @sitinurshazwaniemohamadjas9908

    hi I m basically in making of project by using adruino to test the rpm and output voltage from the 24v dc generator of wind turbine can you help me with the coding?

  • @adedotunowojori7296
    @adedotunowojori7296 Před 3 lety

    pls kindly share the link to the forum, I would like to join. Thanks for the tutorial

  • @TruKleenable
    @TruKleenable Před 8 lety

    sketch_nov05a.ino: In function 'void timerIsr()':
    sketch_nov05a:14: error: 'Timer1' was not declared in this scope
    sketch_nov05a.ino: In function 'void setup()':
    sketch_nov05a:30: error: 'Timer1' was not declared in this scope
    I get the above error message.
    I have extracted the TimerOne-r11.zip file into libraries file where all my other libraries work fine for other sketches.
    So WHY won't it recognise this, or am I mistaken?
    Many thanks

  • @kevteg05
    @kevteg05 Před 8 lety

    Hello there, great tutorial!. It should work with any ir sensor right?. Thanks

    • @BrainybitsCanada
      @BrainybitsCanada  Před 8 lety +1

      +kevteg05 The module used is basically an IR emitter and IR receptor. If you have an IR sensor then all you need is an IR Led to make sort of like the same thing. Of course it is easier to use the module, but it's possible :) Thanks for watching!

  • @MrAutospec
    @MrAutospec Před 5 lety +1

    How can I use that sensor to set speed on 230 volts motor with brushes? Can arduino rule the triac driver? Please answer )
    Sorry for my english )

  • @duncpoly236
    @duncpoly236 Před 8 lety

    Nice video. Is encoder disk included when you buy LM393? Where could I find any?

    • @BrainybitsCanada
      @BrainybitsCanada  Před 8 lety

      +Dunc Poly The ones we sell in our store at: brainy-bits.com/shop/modules/speed-sensor-module/ come with the encoder disc. Unfortunately we don't sell them separately. Thanks for watching!

  • @nektarioskourakis8331
    @nektarioskourakis8331 Před 4 lety

    inside interrupt mode rising - lose a slight mm from one hole to another..maybe you must change the mode rising to change and replace 20 to 40

  • @MyDesignerTV
    @MyDesignerTV Před 8 lety

    perfect for beginners! exactly what i was looking for. thanks! which language is the code in .. C ?

    • @BrainybitsCanada
      @BrainybitsCanada  Před 8 lety

      Arduino uses a C++ type of language structure. They are some restrictions of course because of the little available RAM on the Arduino hardware, but it's very similar. Thanks for your comment and watching btw :)

  • @jaimecortesvillagra5994

    Do exactly the same, and it works well, thank you very much, but only works correctly up to 10 Volts, after that, the speed decreases. Please help.

  • @wisdom_wellness365
    @wisdom_wellness365 Před 7 lety

    Awesome!

  • @mike_x48954
    @mike_x48954 Před 9 lety +1

    Yay, I'm the first to like this video.

  • @altheasarahapeta1846
    @altheasarahapeta1846 Před 4 lety

    hello, can i get the program? just need it for the thesis thank you!

  • @triyapol7780
    @triyapol7780 Před 8 lety

    can u tell me how i can show rps in lcd.

  • @ndindandi
    @ndindandi Před 7 lety

    i used stepper motor with tb6600 driver and i also use your encoder coding. but when i combine your coding with my motor stepper coding, the serial monitor shows value 3000 but i didn't let anyting through sensor... how come it could happend:( please help:(

  • @windybintang
    @windybintang Před 7 lety

    i cant found the library. please give me the link :(

  • @rohanverma6058
    @rohanverma6058 Před 3 lety

    Thanks

  • @arulkalai8854
    @arulkalai8854 Před 7 lety

    which sensor is used to measure the speed of the vehicle

  • @daiasoftener4558
    @daiasoftener4558 Před 3 lety

    Very useful video 👍🏻, automatically susbcribing the channel.

  • @asyrafshahrom9896
    @asyrafshahrom9896 Před 7 lety +1

    how to change output pin from speed sensor (pin 2) to another pin ?. Currently im using arduino mega.

    • @shahirburd
      @shahirburd Před 7 lety

      can you show me exmple sketch to change the digital pin.?

    • @asyrafshahrom9896
      @asyrafshahrom9896 Před 7 lety

      how..can you show me..because i cannot define pin at my coding

    • @LSUtiger607
      @LSUtiger607 Před 6 lety

      I've been using pin 21 (interrupt 2) on my Mega and it works.

  • @mdnouman771
    @mdnouman771 Před 8 lety

    can u tall me how can use to count the pules to rotate the motor to a particular position. like a stepper motor. plz hlp

    • @BrainybitsCanada
      @BrainybitsCanada  Před 8 lety

      +md nouman You can count the pulses and stop the motor at a specific one, but it will never be precise since there is no encoder on these motor to keep track of their position. For accuracy you want to use a stepper motor.

  • @OregonDARRYL
    @OregonDARRYL Před 5 lety

    You can control a DC motor as if it was a stepper motor, except you also get feedback with these...

  • @khairulhafiz3016
    @khairulhafiz3016 Před 8 lety

    guys, how do i wanna measure the speed underwater? it is for my final project, can u help me, what sensor should i use, help me plis....

  • @rutwijjoshi7578
    @rutwijjoshi7578 Před 7 lety +2

    what is the maximum rpm that can be measured using this module ?

    • @mixtermuxter8602
      @mixtermuxter8602 Před 7 lety

      i would love to know that too.
      like how many holes per second are the limit for the arduino and sensor?

    • @cool-cj3gh
      @cool-cj3gh Před 7 lety

      It depends on the processing speed of the Arduino

    • @LSUtiger607
      @LSUtiger607 Před 6 lety +2

      I have been using this same setup on a Mega and can achieve a max of 240 "counts" per second (see code in video) before the reading starts to degrade. With a 20 hole disk, that means a max RPM sensing of 720. You can increase the rpm reading capability by reducing the number of holes, at the cost of sample time.

  • @lionconvoy8622
    @lionconvoy8622 Před 8 lety

    why 680 value? i dont understand why maping this value

  • @jesuishalil
    @jesuishalil Před 9 lety

    Shouldn't the Ground of the motor driver be connected to the arduino's Ground in order to have signals travel to the motor driver?

    • @BrainybitsCanada
      @BrainybitsCanada  Před 8 lety +1

      +Flo wey You are correct. You should always have ground referenced to the Microcontroller. In this instance it still worked fine, but as good mesure you should do it! Thanks for the observation and for watching!

    • @jesuishalil
      @jesuishalil Před 8 lety

      +Brainy-Bits thanks for clearing that up, had my mind boggled. :P

    • @BrainybitsCanada
      @BrainybitsCanada  Před 8 lety

      ***** You are welcome :)

  • @dalexz4316
    @dalexz4316 Před 8 lety

    i had a problem with this sensors. how the speed sensors will get the rpm data ? all i know.. we put the rotation thing between the two little cube things that allready in the sensor modules. im a correct ? because i didnt see how you put the rotation things in this video.
    sorry for my bad english btw :)

    • @BrainybitsCanada
      @BrainybitsCanada  Před 8 lety

      +darren alex You are right, you put the sensor wheel that's on the gearbox motor between the two cubes thats on the speed sensor. There are holes in the sensor wheel that will let the infrared led on the speed sensor shine through and that's how it detects rotation. Hope that helps. Thanks for watching!

    • @dalexz4316
      @dalexz4316 Před 8 lety

      +Brainy-Bits thanks! its very difficult to find this kind of sensors in my place... so i dont have any idea to use it :)

  • @muhamaditaqilah764
    @muhamaditaqilah764 Před 4 lety

    50/5000
    can it be used on a motorcycle vehicle?

  • @wojciechpvb7132
    @wojciechpvb7132 Před 9 lety

    Will it work with stepper motor ? and not connected to PC ?

    • @BrainybitsCanada
      @BrainybitsCanada  Před 8 lety

      +Wojciech PVB To use a stepper motor you would need a motor controller like the EasyDriver board. I did some videos using the EasyDriver, you can check this one here: czcams.com/video/dQuTgngoFPQ/video.html Hope that helps! Thanks for watching!

  • @nagvarma3178
    @nagvarma3178 Před 6 lety

    can u send u circuit.....

  • @user-wl7qn7ry9f
    @user-wl7qn7ry9f Před 6 lety

    can you give me coods for ardueno
    and map

  • @afcce.u.6514
    @afcce.u.6514 Před 3 lety

    danke sehr hilfreich!
    a new precisely and fine resolution speedsensor 0-70m/s ; Company AFCCe.U.

  • @PiefacePete46
    @PiefacePete46 Před 7 lety

    Very useful, Thank you. Liked. :o)

    • @BrainybitsCanada
      @BrainybitsCanada  Před 7 lety +1

      Always nice to hear that the videos are helping others. Thanks for watching and the Like :)