#72 Arduino controlled Dual PWM controller & Timer thoughts

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ก.ค. 2024
  • New! ralphbacon.blog
    PWM is easy to do on the Arduino, but flawed in its native implementation. Thank goodness we have a brilliant PWM library to help us out. Flawed? Help out? Why do we need helping out? Watch the video and find out!
    Here's how to control TWO PWM motors independently with a single rotary potentiometer (resistor) and a switch to tell the Arduino which output you're currently controlling.
    I also show you why the three independent timers on the Arduino are so useful but why you should never adjust the Timer Zero if you want your sketches to run without potentially weird results.
    This is a personal project that implements several of the techniques I've described in my previous videos and demonstrates I really do what I say in those videos. It's not just theory, it's real life implementation. You might want to do something similar to control two motors on a robot arm, car, tank or something else.
    Oh, there's a short clip in the video of me constructing this on my workbench - please forgive the total chaos there as I was in the middle of another project when I decided to complete this one. I'm ashamed of the mess shown there! But you do get to look at the "Strange Third Hand" unit which I'm finding invaluable when building projects like this.
    ---------------------------
    DOWNLOAD
    ---------------------------
    The PWM library, the project (demo) sketch and anything else I can find that might be useful can all be found here on GitHub. Just click the "Clone or Download" button to download a zipped file which Windows or Mac will unzip for you.
    github.com/RalphBacon/Dual-PW...
    If you like this video please give it a thumbs up, share it and if you're not already subscribed please do so :)
    My channel is here:
    ------------------------------------------------------------------
    / ralphbacon
    ------------------------------------------------------------------
    How can I remember this? Memory tip: "See" Ralph Bacon, geddit?
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 117

  • @VasilisKarastergios
    @VasilisKarastergios 6 ปีที่แล้ว

    You are the best at explaining how things are working, thank you for sharing your knowledge with us.
    Merry christmas & happy new year!

    • @RalphBacon
      @RalphBacon  6 ปีที่แล้ว

      You're very kind to say so, Vasilis, I'm glad your knowledge is increasing as a result of my videos. And a Merry Christmas to you too.

  • @danljohnston
    @danljohnston 7 ปีที่แล้ว +1

    Thanks Bennie for keeping this video up to your high standards. Oh, and thanks Ralph for operating the cameras.

    • @RalphBacon
      @RalphBacon  7 ปีที่แล้ว

      Yes, Danny, you got that right! Benny's my mentor and knows everything about Arduinos. As you say I just press 'Record' and blag it.

  • @simonbancroft8579
    @simonbancroft8579 6 ปีที่แล้ว +1

    Wonderful tutorial thank you Ralph. I purchased these 12 months ago and failed. Added the adapter plates, failed. Tried every library i could find , failed. Put them away at the back of the drawer. Until yesterday. I have been a fan of your work for some time and needed a refresher on relays for a new project. Happened across this tutorial and naturally had to give it a go, despite a lack of confidence, but it worked first time straight off the bat. Brilliant. I now need to re-visit some old projects to re-vamp them and suddenly a whole host of new ideas are fighting for precedence. Thank you again.

    • @RalphBacon
      @RalphBacon  6 ปีที่แล้ว +1

      OK, so you're talking about the nRF24L01+ modules from video #73, right? So glad they worked for you, and glad also that you had the adapter plates which really do make a difference.
      Yes, now you have the basics working you can think about sending more data (max 32 bytes in one "burst") for all manner of projects.
      Thanks for posting and your kind words about my videos, happy you (re-)joined our Arduinite journey.

  • @smithjonathan
    @smithjonathan 6 ปีที่แล้ว +1

    Another great video. I’m picking up lots of tips going through your channel.
    Somebody already mentioned a rotary encoder, but another simple change I might make would be to mount the switch sideways so it pointed to the related port. I’m old and I’d never remember is up was fan or mitten 🙂

    • @RalphBacon
      @RalphBacon  6 ปีที่แล้ว +1

      Frankly, BaselBantam, I just put some emblems on the front panel (oh, alright, I just wrote on it with a thin Sharpie in my best handwriting) and it looks OK, a bit retro, in fact! As the cold mornings start (sometimes it's just 14 degrees in my dayjob office!!!) my mitten will be put to good use. Glad to hear you're picking up tips, that's the idea of this channel! Thanks for posting, nice to hear from you.

  • @DrexProjects
    @DrexProjects 7 ปีที่แล้ว

    As usual, you are a wealth of information. Thanks

    • @RalphBacon
      @RalphBacon  7 ปีที่แล้ว

      "A wealth of information" you say Darrell? Wow! You are too kind sir, I just show Arduinites the basics really. Glad you liked it though :)

  • @willofirony
    @willofirony 7 ปีที่แล้ว

    Excellent video, Ralph. To paraphrase a song that was popular in the 50s: "There's a house loose around this mouse" . I always want to switch my soldering iron on when I watch I watch your vids. So, I guess you are hitting 'em (and me) were it counts.

    • @RalphBacon
      @RalphBacon  7 ปีที่แล้ว

      Hey there Michael, good to hear from you. That "moose hoose" is doing sterling service keeping my hand warm (now wonderfully controllable) except that the 7805 voltage regulator is overheating when on 100% power and shutting down! So I will have to fit a heatsink as I alluded to in that video.
      An if I can get you (or any viewer) excited enough to get out a soldering iron (or breadboard, I'm not fussy) and actually experiment a bit then my job here is done! For the week, anyway. Always more to discover and learn!
      Thanks for posting Michael, good to get feedback.

  • @danljohnston
    @danljohnston 5 ปีที่แล้ว

    Watching Ralph re-runs. Benny stole the show. Ralph and Benny=Team Genius!!

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      You are too kind, Danny, but Benny is purring now that I've told him that! Good to hear from you.

  • @tomgeorge3726
    @tomgeorge3726 7 ปีที่แล้ว

    Good informative video Ralph, sat back with cup of coffee and Anzac biscuits to dunk.

    • @RalphBacon
      @RalphBacon  7 ปีที่แล้ว

      I hope you didn't run out of biscuits before the video was over Tom!
      You've raised a very serious point there, inadvertently perhaps. There is much discussion on the TH-cam forums how TH-cam is changing from "Look at this 3 minute video of my dog doing funny things" to "Let's watch this 20 minute 'TV program' video teaching me how to do ..." And of course, I fit into that last category with my longer videos! I must try and get them down to the magic 20 minute mark though, so that will be a challenge for my next video.
      Glad you liked it, and I'm pleased you posted how you 'consumed' my video (along with the biscuits), it's all great feedback, thanks for posting.

  • @javierpallalorden
    @javierpallalorden 7 ปีที่แล้ว

    Nice video Ralph.

    • @RalphBacon
      @RalphBacon  7 ปีที่แล้ว

      Hi Javier! I'm really glad you liked the video, I nearly didn't make it but now I'm glad I did as it has some useful stuff in there. Don't forget to check out the other videos I have on my channel, something for everyone I hope! Thanks for posting your supportive comment, great stuff!

  • @robertpatton6700
    @robertpatton6700 7 ปีที่แล้ว

    Good job, I learned things. Thanks

    • @RalphBacon
      @RalphBacon  7 ปีที่แล้ว

      And we are all learning in the Arduino arena I feel, so that's great. Keep watching the videos, you might learn more things too!

  • @chrisarmstrong8198
    @chrisarmstrong8198 4 ปีที่แล้ว

    Another great video. Mounting the switch so that it toggles horizontally (i.e. toward the USB socket that it is selecting) may be more ergonomic. Also, since the MOSFETs switch the current on and off very rapidly, it's surprising that you got away without any snubbers or spike protection across the loads, especially the fan which is likely to be inductive.

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Interesting observation, Chris. I'm not sure whether I added (at the very least) a reverse biased diode across the output to prevent back EMF damaging the MOSFET. As it happens it ran well for a couple of years but I don't use it any more (I change my job). But whether I "got away with it" or not, you are correct that some sort of suppression should be on the PWM output MOSFET.

  • @LauwersFreddy
    @LauwersFreddy 7 ปีที่แล้ว +2

    Hi Ralph, great video, as always. I was wondering if using a rotary encoder instead of the potentiometer would have been a better choice. When you change the position of the switch, the position of the pod would overwrite the current value of the selected usb port, right? You could just decrease/increase the stored value of the selected usb port by turning the rotary encoder left or right without changing the previous values I think. In my last project I used a little buck converter instead of the 7805 because these are much more efficient (and run cooler), plus the output voltage can be changed and I can use the same model for every voltage I need. Love these! Looking forward to more video's. Thank you.

    • @RalphBacon
      @RalphBacon  7 ปีที่แล้ว

      Well, Freddy, hindsight is a wonderful thing, and if I did this project again I would choose a Rotary Encoder like a shot. And, in case you missed the update, I have already replaced the Linear Voltage Regulator in this box with a buck converter, as I could fry an egg on the old 7805 (even with a modest heatsink) but the buck converter runs cool (no heatsink required). I should have followed my own advice from video #21 (embarrassed face).
      You have immediately grasped the sub-optimal design here inasmuch that the following happens:
      1. I set the Mouse House to 75% output.
      2. I flip the switch and set the fan to 10% output.
      3. I then flip the switch back to Mouse House and guess what? Yes, it detects that the pot has now changed and reduces the output to 10% from the previous 75%, when really I wanted to increase the value to 90%
      The use of a Rotary Encoder (which I had thought about but too late) would make this ideal, as it is the relative increase or reduction of the power of each PWM channel that matters. Come to think of it, I might even have included a small, 2-digit LED to display the current power output (as the pot knob would no longer indicated the power level).
      That all said, it's working (well), it does the job, and the fact that is could be better, well, I'll chalk this up to experience. To be totally honest I also wanted this to be quick and clean for a video, and including a Rotary Encoder in with the design might have made it "a step too far" for some to grasp, whereas a good old analog reading from the pot is easy to understand.
      Good to hear from you, Freddy, and thanks for highlighting the sub-optimal design (er, I think... ;), others reading this may be encouraged to experiment with Rotary Encoders, fully described, and easy to use, in video #19.

    • @LauwersFreddy
      @LauwersFreddy 7 ปีที่แล้ว +2

      I really appreciate you for taking the time to answer my comment (in length). There's always version 2.0 ;-) but if this does the job for you, why should you? Have a really nice day!

  • @MUHAMMADYAWARIFRAHEEM
    @MUHAMMADYAWARIFRAHEEM 4 ปีที่แล้ว

    Very informative video

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      Glad you liked it, Muhammad, thanks for posting although TH-cam keeps putting your posts in my "Likely Spam" folder!!!

    • @MUHAMMADYAWARIFRAHEEM
      @MUHAMMADYAWARIFRAHEEM 4 ปีที่แล้ว

      @@RalphBacon TH-cam hates me😂

    • @MUHAMMADYAWARIFRAHEEM
      @MUHAMMADYAWARIFRAHEEM 4 ปีที่แล้ว

      @@RalphBacon sir you have pwm video with 2 push buttons?

  • @TechMan-sl5gf
    @TechMan-sl5gf 7 ปีที่แล้ว

    I've been looking at these timers myself as it will be used in the very first project. The project to create a actual MPPT charge controller that will accept 150vdc and at 4000w. Then convert that to 12/24/48 volt going to the batteries. As we know once the batteries are topped off and don't require additional charge they just float. On smaller MPPT's they have a load output for some circuit or whatever. What am thinking of is to via relay transfer power from the battery to it which will feed some supercap that is connected to a GTI. So, we aren't wasting the invested money in panels that are really just sitting there. The PWM from the two timers which will be out of phase for the most part and will run a dual channel buck converter. At least from the timing bit.

    • @RalphBacon
      @RalphBacon  7 ปีที่แล้ว

      You definitely have some meaty projects in mind, TechMan, that's for sure. Certainly, ensuring that your solar panels don't fry your batteries on a sunny day is imperative but there are several commercial MPPT modules out there you might be able to use, I'm sure. With those voltages and wattage you won't want to skimp on quality. Let us all know how it proceeds, this looks interesting.

    • @TechMan-sl5gf
      @TechMan-sl5gf 7 ปีที่แล้ว +1

      Not really mate. My problem is time. I work a job where they want more than 8 hours a day. Wrote my first OS when I was 28 where I had lots of time but little funds. Lost the lot when the HD failed and all of the backups were trash. Never wanted to pick it up again. Now, I work as a software analyst. More money and less time. I do have a number of projects like a greenhouse monitor for my wife whom is of course British. She hates tech and of course I think if a computer can do it better then let it. I come from an electronics background where one of my first jobs was working on RDF and INS, worked in a component repair depot, and did on paper designed a new style of computer but at the time hardware was expensive, not available and the CAD programme to aid me in the PCB design cost an arm and a leg.

  • @NeonblueIndustries
    @NeonblueIndustries 5 ปีที่แล้ว

    Hi Ralph. You may want to try an INfra Red Panel under you desk too. You can control it via PWM signal going to a Solid State Relay. Cheers!
    and yeh, Linear Voltage Regs Suck. I always put a 3A Buck converter along side my nano in my projects.

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Although I've just been told by a very experienced engineer that a linear converter works great outdoors (and he deliberately uses them in such cases) because the extra heat keeps things warmer and dryer than if no heat were present. Who knew? Thanks for your post, appreciated.

  • @hydroalternation
    @hydroalternation 5 ปีที่แล้ว

    where did you find the switch box with 4 panels great idea to make modular projects

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว +1

      Now you're asking. A British supplier, for sure. It's a standard double socket back plate (pattress) with a standard modular face plate normally used for ethernet sockets, tv sockets and so on. I can't remember where but try CPC to get an idea then buy locally if you are not UK-based. I hope this helps.

  • @randyhaun9127
    @randyhaun9127 ปีที่แล้ว

    Hi Ralph, I've found your videos very helpful -- especially to someone like myself trying to learn circuitry from the ground up. Following your example, I've tried to set the frequencies of the various PWM pins on an Arduino, but only pins 3, 9, and 10 are successful. The other PWM pins return FALSE after SetPinFrequencySafe(). Is this expected?
    More importantly, I've tried to adapt your circuit using a PWM pin (one of the above three pins that worked) to send a signal to the MOSFET you used in your circuit to drive a Peltier element with an external 5V supply (higher current). Although this circuit worked (i.e., the voltage to the Peltier increased with higher PWM values), when I checked the voltage being supplied to the Peltier I noticed that at HIGH (PWM = 255) the Peltier was only getting around 4V rather than the 5.3V of the power supply. The gate voltage is 5V from the Arduino, so I expected the Peltier should be getting the full 5.3V from the power supply (or something at least close). I'm always unsure about whether to connect the power supply ground to the common ground of the rest of the circuit (i.e., the Arduino ground) or not. Currently, I do have everything in the circuit connected to the same ground rail on a breadboard; but, perhaps that's not the issue. Any thoughts about expected voltage drops?

    • @RalphBacon
      @RalphBacon  ปีที่แล้ว

      On the Arduino, PWM pins are 3, 5, 6, 9, 10 and 11, although the frequency of pins 5 & 6 is just under 1kHz (980Hz); the others are about 490Hz. This is all too slow to control motors / fans because you can _hear_ the buzz. Very annoying.
      To overcome this I used the technique described, I believe, by Nick Gammon (no relation): see th-cam.com/video/e2CPnmLmSws/w-d-xo.html which is a _very_ old video of mine but describes the issue and solution.
      Regarding your lack of voltage at the Peltier element there are couple of things to check:
      Is the MOSFET you are using one with a "logic level gate"; that means it will switch FULLY on at 5v (which is what you are sending from the Arduino's GPIO pin)? If you are using a MOSFET that requires 10v gate voltage you have your answer. Spec sheets will tell you this.
      Also, Peltiers take a lot of current. If you short the gate of the MOSFET to +5v do you still have the same problem (ie voltage sag due to too much current being taken)? Your power supply must be able to cope.
      Finally, all power to the circuit MUST have their ground connections connected together (known as Common Ground). Amazingly the current from each PSU flows back to the correct source but only if the grounds are commoned.
      Let me know!

    • @randyhaun9127
      @randyhaun9127 ปีที่แล้ว

      @@RalphBacon Thanks for your reply Ralph! To change the PWM frequencies I was using the pwm.h library and the SetPinFrequencySafe() command. I tried to set the frequency of each of the PWM pins (3,5,6,9,10,11) on an UNO using this command and had the script report whether the command returned a TRUE or FALSE to a 'success' variable. On the UNO, only pins 3, 9, and 10 returned TRUE. After watching the video you previously made I decided to do the same exercise with a MEGA 2560 and found that pins 3, 5, 6, 9, and 11 were successful, but not pin 10. So, it appears the SetPinFrequencySafe() command is processor dependent (perhaps not surprisingly).
      As to the MOSFET, I am using the logic-level on you referred to in your video (RFP12N10L), so it should be fully on at 5V.
      Rather than use a PWM pin I also tried to supply 5V to the gate directly from the 5V pin on the Arduino, but I still see the voltage difference between the power supply output and the input voltage at the peltier element, with a current of ~350 mA.
      So, perhaps I shouldn't be concerned about the drop in voltage since the peltier element is heating adequately for my purposes.
      I noted in your earlier PWM video (#15) that you included a diode and capacitor between the +/- terminals of the motor (to prevent voltage spikes in the circuit?) between the motor and drain. Would similar protection be advisable in general before the MOSFET in a circuit or is it more of a concern with motors?
      Thanks again!

  • @midnightrizer
    @midnightrizer 4 ปีที่แล้ว

    what can you tell me bout the 8 segment display with the usb connect did you build or buy it that way?

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      So long ago, Eric... but I'm pretty sure it was a USB current/voltage display that you just plug in. I've replaced it now with one that displays both volts and current simultaneously instead of flipping between the two every few seconds although I still use both. See:
      New one: www.banggood.com/USB-Detector-Current-Voltage-Tester-Double-USB-Row-Shows-p-973712.html?p=FQ040729393382015118&
      Old one: www.banggood.com/Bakeey-USB-Charging-LED-Display-Current-Voltage-Tester-Adapter-Detector-USB-Voltmeter-Ammeter-p-1620203.html?p=FQ040729393382015118&

  • @ShaunDobbie
    @ShaunDobbie 7 ปีที่แล้ว +2

    You could have used a buck converter instead of a linear regulator. Far more efficient and can supply much more current.

    • @RalphBacon
      @RalphBacon  7 ปีที่แล้ว +3

      Could have, Shaun, should have, and after 24 hours did so. Yes, the 7805 was a rubbish decision based purely on the desire to "get it done". After 24 hours with a box hot enough to cook a family dinner on, I ripped it out and put in a lovely little variable voltage buck converter which has done wonderful service ever since (and runs cool). Lesson learned: don't rush a project, you'll only have to rework it anyway! Ironically, I describe the merits of a buck converter in video #21 yet failed to follow my own advice! Doh!

    • @ShaunDobbie
      @ShaunDobbie 7 ปีที่แล้ว +4

      I learned this from my first car phone charger which used a linear regulator. It got very hot.

  • @mustafaglnr8780
    @mustafaglnr8780 5 ปีที่แล้ว

    TO drive the MOSFET GATE Driver, SetPinFrequencySafe(); is enough for that purpose on Arduıno.
    OR ı have to add another parameter as a code or wiring a component?

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      You need to add two parameters, Mustafa: the first for the pin number, the second for the frequency.
      Look at the sketch I use in the demo: github.com/RalphBacon/Dual-PWM-Controller to see an example of how I do this.
      I also recommend you put a small (eg 180 ohm) resistor between the Arduino pin and the gate of the MOSFET, to protect the Arduino.

    • @mustafaglnr8780
      @mustafaglnr8780 5 ปีที่แล้ว

      @@RalphBacon ,
      ı will use the gate driver to run the MOSFET at 50kHz, to gate Driver IC
      I have to get PWM signal from ARduıno.
      Your described way above is the correct way for that?

    • @mustafaglnr8780
      @mustafaglnr8780 5 ปีที่แล้ว

      @@RalphBacon
      which pin is the best for 50kHz frequency PWM?

    • @mustafaglnr8780
      @mustafaglnr8780 5 ปีที่แล้ว

      void setup() {
      Serial.begin(9600);
      // We will only play with timers that do NOT affect Timer 0 (millis and delay)
      InitTimersSafe();
      // Set the frequency of the PWM pins
      SetPinFrequencySafe(pwmPin, 50000);
      }
      void loop(){
      if (newMarkSpace != oldFanMarkSpace) {
      // Output the frequency with the mark/space ratio
      pwmWrite(pwmPin, newMarkSpace);
      oldFanMarkSpace = newMarkSpace;
      }
      pwmWrite(pwmPin, 0);
      delay(50);
      }

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Use one of the pins I use in the demo code, it's not critical.

  • @michaelstevens630
    @michaelstevens630 5 ปีที่แล้ว

    The obvious answer was to fit a Velux Window - so when the Mouse House got too hot flip the window open. That is problem solved, next case please :-)

    • @RalphBacon
      @RalphBacon  5 ปีที่แล้ว

      Of course, how silly of me not to spot this easy solution. Great to hear from you Michael, just keep taking the tablets, OK?

  • @scottmitten2248
    @scottmitten2248 6 ปีที่แล้ว

    Hi Ralph,
    I know you're a busy guy, but is there any chance you could give more detail on your "One size fits all Serial Monitor debugging messages"?
    I'm not an advanced coder by any means, and never really learned C++ - I'm more of a C guy. I DO get what your function(?) is doing, but I'm not getting HOW it does it.
    I've tried looking up the template & typename stuff, but I can't get my head around it.
    Thanks!
    PS - To help reach more people with your channel ... EEVBlog is doing a bunch of guest videos right now to help get exposure for some smaller channels.
    I've watched a few and think your content is much better than some of the ones he's put up so far. Maybe you can get in the mix there?

    • @RalphBacon
      @RalphBacon  6 ปีที่แล้ว

      Hey Scott! What a question! How long have you got? Here goes...
      The Serial Monitor debugger function works (in a simplified explanation) by telling the compiler that we don't know what the variable type will be until we call that routine.
      The *compiler* than figures out that you're calling it with an integer, string, float or what have you and decides whether that's a valid call. It saves having to define all the signatures with individual (strongly typed) parameters. Your code won't compile if you try and call that function with a type of type which does not make sense in the body of that function (eg subtracting strings won't work).
      So:
      template int addUp (T firstVal, T secondVal) {
      return firstVal + secondVal;
      }
      will let you add up just about any 2 values that can be added, and will return an int, but won't do it for strings, such as addUp("Hello","World")
      will give you an error similar to error: invalid operands of types ‘const char*’ and ‘const char*’ to binary ‘operator+’ (in other words you can't do arithmetic on strings ).
      Does this help you any?

    • @scottmitten2248
      @scottmitten2248 6 ปีที่แล้ว

      Thanks Ralph,
      That part makes sense, I think. :) (Thanks)
      Originally, when I copied your code into my sketch it wouldn't compile. (I had pasted it onto the bottom of the sketch like another routine.)
      I eventually tried moving it above my first routine (SetUp) and it started compiling.
      Therefore, I've deduced that:
      - 'Template' is a CPP declaration that I don't understand yet and
      - 'Typename' is the part that allows the ambiguity
      Does that sound right?
      Would 'typename' work within a regular routine, or is it specific to using the 'template' class?
      'Class' is still fuzzy to me for some reason - I think because most of my formal code training was in C, & lower level languages. Don't get me wrong - I'm happy not to have to bit-bang everything. Too tedious!
      (Virtually everything else seems fairly straightforward, but I can't get my head around classes.)
      In the program memory, Does the compiler allocate the largest variable memory unit (4 Bytes?), or does it place a larger amount aside incase something like a string is passed?
      Not that at matters at this point in my current project, but I assume this could eat away a lot of memory during development.)
      Ane one more, if you don't mind -
      (I'm not at home and unable to run anything that isn't web based from the computers I have access to, so I'm limited to the Arduino web editor. I can write code and do a compile check, but no uploading or testing for the time being.) Unless you know of a free, web based Arduino simulator I can try this out on:
      When using printMe() ... if x = 12 & y = 3
      printMe(x);
      printMe(y);
      Serial monitor would show: 123
      printMe(x);
      printMe(" & ");
      printMe(y);
      Serial monitor would show: 12 & 3
      printMe(x,1);
      printMe(y);
      Serial monitor would show: 12
      3
      and in all cases, any further printMe() call would continue on the same line.
      Do I have that right?
      Thanks Again!
      Looking forward to your next video.
      Cheers!

    • @RalphBacon
      @RalphBacon  6 ปีที่แล้ว

      Last question first, then, Scott. Yes, that is exactly how it would print.
      Previous question: Typename doesn't allow the ambiguity, its the that does that. Any letter can be used, but by convention T for Type is usually used. Typename describes the type of variable, such as Integer, Float, Long, Char and so on. We're saying here, the typename is unknown at the time of writing that function, but we will know when we call that function - and the beauty is that we can call the function with all types of parameter.
      First question: a function template allows us to work with generic (ie unknown) types. It's how we get to the use the in the actual function without the compiler complaining that it doesn't know what a T is! By using the template the compiler understands that T stands for whatever typename we call that function with.
      If you have not yet learned Object Oriented Programming (OOP) then 'class' will indeed be hazy, but if you follow my video #71 How to create an Arduino Library, you will get exposed to the concept - I try very hard not to mention the fact we are actually creating a class (a blueprint) and from that an actual instance of that class (an object). You will learn more if you actually do the demo, line by line, with my video, pausing it as required. Have a go!

    • @scottmitten2248
      @scottmitten2248 6 ปีที่แล้ว

      That helps quite a bit! Thanks for taking the time.
      So, Typename is literally a placeholder for the variable type (int, long, etc), and "T" is the function's name for that passed variable's data of unknown type. (Like a normal function declaration.
      "Template" is the key to allowing the ambiguity, because it's what lets the compiler knows you could send it anything.
      I'm getting there!
      I've been exposed to the general concepts of Objects and classes before - just didn't really need them, so It didn't stick in my head.
      (I have watched the Library making video (I've actually watched all your videos over that last couple of weeks) and had already marked it for reference later)

    • @RalphBacon
      @RalphBacon  6 ปีที่แล้ว

      Yes, you pretty much got it. It will take a little time but it sounds like you are putting in the time to master this. Keep going and keep watching the videos too!

  • @j1952d
    @j1952d 3 ปีที่แล้ว

    Re. your 7805. You probs know this anyway, but if you've got 9V in and 5V out at 0.5A, the power the 7805 has to lose is (P=I x V) = 0.5 x (9-5) = 2W, and that all goes to heat. Thermal resistance of TO220 package is at least 20degC per W, so that's a 40 degree rise (above ambient!). No wonder it burnt your thumb.

    • @RalphBacon
      @RalphBacon  3 ปีที่แล้ว

      Not just burnt my thumb, John, hot enough to cook an egg on it I reckon! Thanks for the formulae, appreciated.

  • @kennmossman8701
    @kennmossman8701 4 ปีที่แล้ว

    I live in a tropical country.....is there a hand cooler? ;)

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      YES! If you were to use a Peltier device the cooling side could be above your hand and the fan-cooled "hot" side on the other side of any housing with the heat being removed. Or just switch on the A/C?

    • @kennmossman8701
      @kennmossman8701 4 ปีที่แล้ว +1

      @@RalphBacon LOL I just 'up' the fan speed. BTW the Peltier would create a cold spot - need to have the cooling effect around my hand - maybe a glove with plastic tubing - filled with coolant- and that being cooled by a Peltier with a water pump

  • @julienmina7276
    @julienmina7276 4 ปีที่แล้ว

    👍⭐🥇❤

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Wow! Thanks for the great emojis!

  • @stevec5000
    @stevec5000 6 ปีที่แล้ว

    Yes there are other videos that cover this but their sketches won't compile so it doesn't work! I'd like to find someone showing this where it's not a fake!

    • @RalphBacon
      @RalphBacon  6 ปีที่แล้ว

      Well, you've found a channel that has no fakes, Steve! This particular fan unit is on my desk and in constant use, and the double unit is on my desk at work and also in regular use (especially during the cold weather that mouse house heater is great!). Note that I did replace the 7805 regulator (which was hot enough to cook eggs on) with a tiny buck converter that runs really cool. No fire risk at work now!

    • @stevec5000
      @stevec5000 6 ปีที่แล้ว

      Ralph, if you are familiar with Arduino sketch code can you tell me why the other videos using this PWM sketch won't compile? It doesn't seem to like the InitTimersSafe and pwmWrite commands they used but I can't figure out why. All it says is "Error compiling for board Arduino Nano" but I'm using the same kind of board used in the videos.
      th-cam.com/video/gMB88fXOZ-g/w-d-xo.html
      storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/arduino-pwm-frequency-library/Arduino%20PWM%20Frequency%20Library%20v_05.zip

    • @RalphBacon
      @RalphBacon  6 ปีที่แล้ว

      I use the same library in this very video, Steve. And I use use InitTimersSafe() in the setup() routine. Are you sure you are including the library in your sketch? And have you placed said library in the correct 'libraries' folder within your Arduino workspace? What's the exact error message you're getting? Before you next build, set 'verbose' messages on by going to the Arduino IDE, then File > Preferences and then find the checkbox that says "Show verbose output during" and tick the checkbox for 'compilation' and 'upload'. That way you'll get all the errors in the console.

    • @stevec5000
      @stevec5000 6 ปีที่แล้ว

      I'm trying to use the example sketch from the above referenced Google code archive and it has the library already included in the sketch! That doesn't seem to be the problem though. If I turn on verbose output I get several pages of stuff but the main problem in red seems to be: "utility/BTimerDefs.h: No such file or directory". It seems to be wanting another library that's not even mentioned anywhere! The Arduino stuff doesn't even have a folder called "utility"!
      I'm a network administrator not a programmer and I hate software! This kind of stuff that never works just gives me a headache! LOL

    • @RalphBacon
      @RalphBacon  6 ปีที่แล้ว

      Let me see if I can grab a couple of minutes tonight (GMT) to try this out. From the information you've supplied it seems to be a Bluetooth related library that is missing - possibly in a sub-folder of that library. I shall have a quick look...

  • @MUHAMMADYAWARIFRAHEEM
    @MUHAMMADYAWARIFRAHEEM 4 ปีที่แล้ว +1

    That gian claw Did steel from your kids room 😂😂

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว +1

      No, no, that giant bear claw/hand is made by someone in China with a heated pad inside - all very commercial! Works great but now I don't need it as my (new) workshop is warm!

    • @MUHAMMADYAWARIFRAHEEM
      @MUHAMMADYAWARIFRAHEEM 4 ปีที่แล้ว +1

      @UC8Ob-HnnmhlgSv5Vs_i32TQ ok😂

  • @fozlurrahman7052
    @fozlurrahman7052 7 ปีที่แล้ว

    Ralph do you have email would like to send you a PWM module for review...

    • @RalphBacon
      @RalphBacon  7 ปีที่แล้ว

      Sure Drake, if you go to my channel and click on the About tab you'll see a way of contacting me.

  • @fozlurrahman7052
    @fozlurrahman7052 7 ปีที่แล้ว +1

    How to do this with a 4 pin 48v fan

    • @RalphBacon
      @RalphBacon  7 ปีที่แล้ว

      Hello there, Drake Summer! Without knowing your fan I can only hint at what you can do. I'm assuming (dangerous) your fan is a DC fan (not AC). Your four connections are then probably:
      +ve (48v)
      GND
      PWM
      TACHO (speed sensor)
      Computer cooling fans with 3/4 pins are designed so that in the absence of a PWM input they run at FULL power. If you connect your fan to +ve and GND and disconnect all other leads does it do this?
      If it does then all you need supply is a PWM signal to that input lead. It very much depends on whether you can identify the leads / connections and what the PWM signal is expected to be (5v? 12v? higher?)
      Google may be your best friend in determining the exact fan you have - the rest is straightforward.

    • @fozlurrahman7052
      @fozlurrahman7052 7 ปีที่แล้ว +1

      Ralph S Bacon hi ralph thanks for reply. No spec sheets on this im afraid even contaced sanyo denki in japan. If at all possible would you mind if i posted you 1 of the fans and you can have a go at it? im also in UK, of course would pay for your time.

    • @RalphBacon
      @RalphBacon  7 ปีที่แล้ว

      Hi Drake, if you want to send me HD pictures first (taken with your phone, for example) from many angles, ideally with shots of any labels on the fan I'll see whether I can identify it first. Measurements are always good too. Put the pictures in this DropBox folder and let me know: www.dropbox.com/sh/qi4u7r0w4k4g493/AAA4VW04etgG7hrkRXRzbXp5a?dl=0
      Note: link expires in 7 days, if this is not long enough also let me know!

    • @fozlurrahman7052
      @fozlurrahman7052 7 ปีที่แล้ว

      Ralph S Bacon Ebay listing that i bought if from m.ebay.co.uk/itm/351346830279?_mwBanner=1

    • @fozlurrahman7052
      @fozlurrahman7052 7 ปีที่แล้ว

      Ralph S Bacon glad to send you pictures if needed.

  • @simonbancroft8579
    @simonbancroft8579 6 ปีที่แล้ว

    Sorry Ralph, I was talking about nRF24L01's and have put my comment on the wrong video.

    • @RalphBacon
      @RalphBacon  6 ปีที่แล้ว

      Got it, no problem.

  • @garymetheringham4990
    @garymetheringham4990 6 ปีที่แล้ว

    not being picky, but why would anyone want a hand warmer AND a fan on at same time? 😂😂😂😂

    • @RalphBacon
      @RalphBacon  6 ปีที่แล้ว

      Not at the same time (necessarily), Gary. Just independently controlled. But I COULD have my handwarmer on, with a very gentle breeze aimed at my face (like your car's ventilation system). But mainly they are used independently and not concurrently, I admit.

  • @MUHAMMADYAWARIFRAHEEM
    @MUHAMMADYAWARIFRAHEEM 4 ปีที่แล้ว

    😂😂😂

    • @RalphBacon
      @RalphBacon  4 ปีที่แล้ว

      Glad you liked it, Muhammad!

  • @pekkagronfors7304
    @pekkagronfors7304 7 ปีที่แล้ว

    First! :-D

    • @RalphBacon
      @RalphBacon  7 ปีที่แล้ว

      Hello Pekka! Thanks for your support for my video and I hope that my channel will be useful to you, plenty of things to explore. Thanks for posting I love hearing from my Arduinite viewers.

    • @pekkagronfors7304
      @pekkagronfors7304 7 ปีที่แล้ว +1

      A usual I picked up some good tips 'n trick in this video. Keep posting! Thanks.