Это видео недоступно.
Сожалеем об этом.

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

Поделиться
HTML-код
  • Опубликовано: 15 авг 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.co... to get the schematic and more information on this tutorial.

Комментарии • 79

  • @naboulsikhalid7763
    @naboulsikhalid7763 2 года назад +1

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

  • @user-ux9rj9hm4z
    @user-ux9rj9hm4z 8 лет назад +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)

  • @KR0tG5fk
    @KR0tG5fk 9 лет назад

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

    • @BrainybitsCanada
      @BrainybitsCanada  9 лет назад

      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 3 года назад +2

    Amazing tutorial, very informative.

  • @user-ux9rj9hm4z
    @user-ux9rj9hm4z 8 лет назад +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).

  • @rashiidsherif9222
    @rashiidsherif9222 8 лет назад +1

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

  • @MrAutospec
    @MrAutospec 5 лет назад +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 )

  • @BrainybitsCanada
    @BrainybitsCanada  8 лет назад

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

  • @BrainybitsCanada
    @BrainybitsCanada  9 лет назад

    Thanks for watching Mike!

  • @BrainybitsCanada
    @BrainybitsCanada  8 лет назад

    +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 :)

  • @sreeharihunnithan
    @sreeharihunnithan 7 лет назад

    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 .

  • @jimmy2times
    @jimmy2times 5 лет назад +1

    Well explained!

  • @emmanuelbabu2215
    @emmanuelbabu2215 8 лет назад

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

  • @jaimecortesvillagra5994
    @jaimecortesvillagra5994 6 лет назад

    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.

  • @rapunzeleh546
    @rapunzeleh546 5 лет назад

    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.

  • @nektarioskourakis8331
    @nektarioskourakis8331 4 года назад

    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

  • @mahdikhalil2026
    @mahdikhalil2026 8 лет назад

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

  • @MrCesarios23
    @MrCesarios23 8 лет назад

    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?

  • @ndindandi
    @ndindandi 7 лет назад

    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:(

  • @adedotunowojori7296
    @adedotunowojori7296 3 года назад

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

  • @justkeen18
    @justkeen18 9 лет назад

    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?

  • @TruKleenable
    @TruKleenable 8 лет назад

    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

  • @muhamaditaqilah764
    @muhamaditaqilah764 4 года назад

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

  • @sitinurshazwaniemohamadjas9908
    @sitinurshazwaniemohamadjas9908 6 лет назад

    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?

  • @khairulhafiz3016
    @khairulhafiz3016 8 лет назад

    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....

  • @arulkalai8854
    @arulkalai8854 7 лет назад

    which sensor is used to measure the speed of the vehicle

  • @CidaLunacorteecostura
    @CidaLunacorteecostura 8 лет назад

    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.

  • @LSUtiger607
    @LSUtiger607 7 лет назад

    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.

  • @EdgarasArt
    @EdgarasArt 9 лет назад

    Great tutorial, really useful.

    • @BrainybitsCanada
      @BrainybitsCanada  8 лет назад

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

  • @altheasarahapeta1846
    @altheasarahapeta1846 4 года назад

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

  • @daiasoftener4558
    @daiasoftener4558 3 года назад

    Very useful video 👍🏻, automatically susbcribing the channel.

  • @windybintang
    @windybintang 7 лет назад

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

  • @triyapol7780
    @triyapol7780 8 лет назад

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

  • @rutwijjoshi7578
    @rutwijjoshi7578 7 лет назад +2

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

    • @mixtermuxter8602
      @mixtermuxter8602 7 лет назад

      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 7 лет назад

      It depends on the processing speed of the Arduino

    • @LSUtiger607
      @LSUtiger607 7 лет назад +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.

  • @OregonDARRYL
    @OregonDARRYL 5 лет назад

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

  • @lionconvoy8622
    @lionconvoy8622 8 лет назад

    why 680 value? i dont understand why maping this value

  • @duncpoly236
    @duncpoly236 8 лет назад

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

    • @BrainybitsCanada
      @BrainybitsCanada  8 лет назад

      +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!

  • @asyrafshahrom9896
    @asyrafshahrom9896 7 лет назад +1

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

    • @shahirburd
      @shahirburd 7 лет назад

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

    • @asyrafshahrom9896
      @asyrafshahrom9896 7 лет назад

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

    • @LSUtiger607
      @LSUtiger607 7 лет назад

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

  • @mdnouman771
    @mdnouman771 8 лет назад

    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  8 лет назад

      +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.

  • @kevteg05
    @kevteg05 8 лет назад

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

    • @BrainybitsCanada
      @BrainybitsCanada  8 лет назад +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!

  • @webslinger2011
    @webslinger2011 5 лет назад

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

    • @BrainybitsCanada
      @BrainybitsCanada  5 лет назад

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

  • @bahargungor
    @bahargungor 6 лет назад

    very nice, thank you very much

  • @rohanverma6058
    @rohanverma6058 3 года назад

    Thanks

  • @dalexz4316
    @dalexz4316 8 лет назад

    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  8 лет назад

      +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 8 лет назад

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

  • @jesuishalil
    @jesuishalil 9 лет назад

    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  8 лет назад +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 8 лет назад

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

    • @BrainybitsCanada
      @BrainybitsCanada  8 лет назад

      ***** You are welcome :)

  • @MyDesignerTV
    @MyDesignerTV 8 лет назад

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

    • @BrainybitsCanada
      @BrainybitsCanada  8 лет назад

      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 :)

  • @BrainybitsCanada
    @BrainybitsCanada  9 лет назад +1

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

  • @wojciechpvb7132
    @wojciechpvb7132 9 лет назад

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

    • @BrainybitsCanada
      @BrainybitsCanada  8 лет назад

      +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: ruclips.net/video/dQuTgngoFPQ/видео.html Hope that helps! Thanks for watching!

  • @wisdom_wellness365
    @wisdom_wellness365 7 лет назад

    Awesome!

  • @mike_x48954
    @mike_x48954 9 лет назад +1

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

  • @nagvarma3178
    @nagvarma3178 7 лет назад

    can u send u circuit.....

  • @user-wl7qn7ry9f
    @user-wl7qn7ry9f 6 лет назад

    can you give me coods for ardueno
    and map

  • @afcce.u.6514
    @afcce.u.6514 3 года назад

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

  • @PiefacePete46
    @PiefacePete46 7 лет назад

    Very useful, Thank you. Liked. :o)

    • @BrainybitsCanada
      @BrainybitsCanada  7 лет назад +1

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

  • @markkornytchuk7847
    @markkornytchuk7847 Месяц назад

    That was the most useless video I've ever seen in my