Troubleshooting - What to do when it won't work!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today in the workshop will be discussing troubleshooting what to do when your project doesn't work I'll show you how to diagnose and repair both hardware and software problems we're staying out of trouble today so welcome to the workshop [Music] well hello and welcome to the workshop and today I've got a bit of a different episode for you it's different in the way that I'm not going to be explaining the use of a new component and although we are going to build a project the reason we're going to build it is so we can break it and why I'm doing this is because today we are going to talk about a very important skill and that is troubleshooting what to do when the stuff doesn't work now I'm sure everybody has experienced this I know I have many times I put something together following something I saw maybe on a video or on an article or it may be something I got out of github or maybe just something I've conceived myself and I figured hey this thing is gonna work it's gonna be wonderful I put it together and it doesn't work so what do you do at that point well what you don't do is panic because that isn't going to resolve anything what you should do is troubleshooting now troubleshooting is actually a process it's a process of going step by step to figure out what is working what isn't working and eventually it will lead you to what the problem is now I want to be clear that what I'm talking about today is troubleshooting projects that we build ourselves and so I'm not talking about troubleshooting problems that you would have let's say with your television or with your toaster oven or something like that although a lot of the principles that we're using applied to troubleshooting everything including your car but we are going to focus on troubleshooting stuff that we build now one difficulty in troubleshooting the projects we make is that we make use of a lot of things like arduino x' raspberry pies and vidya Jetsons and because of that sometimes we aren't even certain whether we might have a hardware problem such as a bad component or a wiring error or maybe it's a software problem maybe there's something that's wrong with our code and I'm going to cover both of those and also how to try to determine which is which and I'm also going to show you how because we are using micro controllers and microcomputers we can use them to our advantage when we are troubleshooting so it's a two-way street another thing is that some of you may be thinking oh yes but you're in a workshop you've got a Silla scalp signal generators all kinds of wonderful test equipments what do I do if I don't have that well actually you do not need to have that it is of course something wonderful to have but you can do basic troubleshooting and solve most problems with just a multimeter I'm going to show you another piece of test equipment that you might want to pick up that'll set you back all of maybe twenty-five dollars and that you could even build yourself but it's optional a multimeter would be really all you would need for the hardware troubleshooting and as for the software troubleshooting all that you are going to need is your brain so let's start off by taking a look at what a troubleshooting process involves I'm going to show you a trouble cubing process that is kind of a standard is called the compte iead process and it's a standard certification process and will kind of build upon that to troubleshoot our stuff after that I'm going to build a circuit and then I'm intentionally going to break the project and we will see how we could troubleshoot that so let's get going Copts EIA is an international computer technician certification organization and they've developed a six step process for troubleshooting that they teach to their technicians and we can learn from it now the first step in the process is simply to identify the problem I say simply but actually in some cases people do not do this correctly they only identify one of the symptoms of the problem and not all of them you need to fairly look at the problem and see what is working and what is not working the second step is to establish a theory of probable cause I'll use a car as an example if the engine won't start it's very unlikely that it's being caused by poor tire pressure similarly in an arduino circuit you can establish whether the cause is hardware or software and i will be showing you in this video how we can determine that the third step is to test the theory to determine the cause again you'll have to establish the theory and then go through and run a test if it is a hardware problem you can test with test equipment or by substituting components if it is a software problem you can test by injecting different code into your code changing the value of variables or monitoring things with your serial monitor again we will go over those steps in this video the fourth step is to establish a plan of action to resolve the problem this is a very fancy way of saying just go and fix it if it's a hardware problem replaced a defective part or correct the incorrect wiring if it's a software problem do what is necessary to resolve it and make the software work correctly the fifth step is to verify full system functionality the key word over here is full quite often when we solve a problem we will ignore the fact that our solution may have caused another problem we need to verify that everything is working correctly to make certain that it is indeed repaired and the final step is to document the findings actions and outcomes now this is something that most of us seldom do but it's a very good idea after all you could run into a similar problem down the road and by having documentation as to what caused the original problem and what actions you took to resolve it you could resolve the problem much quicker and we'll apply these six steps in all of our troubleshooting efforts so as you can see from the CompTIA a method troubleshooting can be broken down into a fairly methodical process but one of the key parts of troubleshooting is your own knowledge knowing how a device is supposed to work and knowing how it works internally those are critical to being able to troubleshoot as a former bench technician we used to get a lot of things in that we're actually working just perfectly they had nothing at all wrong with them it was just simply that the individual who sent us the device either didn't know how to operate it correctly or they were trying to use it for something that it was never designed for and therefore it couldn't do so you need to know how your device works well that you probably know because if it's a Raspberry Pi or Arduino project you're building it in order to do a specific thing but you also need to know how the circuitry works and how the code works how it really works now if you're taking a project that you found on the internet or on YouTube and you're building it and you're disc copying the code and it's wiring things as per instructions and it doesn't work and you don't really know why you're hooking things up or why this code does does what it does or why they used a specific statements they do then you're not in a good position to troubleshoot it you really need to know how it works internally so if you are in that position what you need to do is sit back and read the code understand what it is supposed to do look at the hook-up why are things hooked up the way they are all of that will assist you in troubleshooting so having said that let's go on to our troubleshooting example now for our experiment you're going to require an Arduino Uno a linear potentiometer I used a 10k pot but any value of 5k upwards would suffice a small servo motor an ST 90 is the best type to use for this a couple of LEDs I use the yellow one and a red one but of course any two colors would work too dropping as resistors for those LEDs I use 220 ohm resistors but any value from 150 to 470 would work fine and a separate power supply for the servo motor now it's critical that you don't power this from the Arduino I used a 6 volt supply consisting of four double A batteries as this is what the servo was actually rated to use we begin by connecting one side of the potentiometer to the 5 volt output on the Arduino the wiper of the pot is connected to the analog a 0 input and the other side of the potentiometer is connected to the Arduino ground next we connect pin 12 of the Arduino to one of the dropping resistors and then to the anode of the red LED pen 11 goes through a dropping resistor and is connected to the anode of the yellow LED we then connect the ground to the cathode of both LEDs now we connect the ground of the servo motor to the negative side of the power supply this is usually a brown wire on most small servos the power or red wire from the servo is connected to the positive side of the servo power supply and the servo control line which is generally orange is connected to pin 10 of the Arduino finally we connect the ground of the Arduino to the negative side of the power supply and this completes the wiring of our circuit this is a sketch that we're going to be using for our demonstrations today and it's a very simple sketch really we're going to start off by using the servo library and including it in our sketch now the servo library is part of your arduino ide so you won't need to download any external libraries it's already there for you next we create an object to represent our servo motor and I'm going to call the object servo motor the next thing is a variable that represents the position of the servo motor now the servo motor can travel anywhere from 0 to 180 degrees and it's going to be represented by an integer we call angle we're also going to need an input for the potentiometer I'm going to call that s RV control and that's on a zero because her pots connected to analog pin a zero we also define a couple of integers for the LEDs so he got LED red on pin 12 an LED yel on pin 11 now in the setup we attach the servo motor to the pin on the Arduino that we're using and so since we're using pin 10 we attach the pin 10 we also initialize the LEDs both as being outputs and now we go into the loop we start the loop off by reading the value from the servo control connected to a zero and assigning that to the angle variable now that value is going to be a value from 0 to 1023 because the 10 bit analog to digital converter in the arduino is going to give you that value we need to map it to a value of 0 to 180 so we're going to use a map command to change that now we're going to use the LEDs we're going to light one of the LEDs if the value is above 175 so we're going to check to see if the angle is greater than 175 and if it is we're going to turn the red LED high to illuminate it if it isn't we're going to keep it off we also want the light the yellow LED on the opposite end of travel if the value is below 5 degrees so if the angle is less than 5 we're going to light the yellow LED and we're going to turn it off if the value is greater than 5 and then after that we're going to write that angle to the servo motor in order to move the motor into that position we'll apply a very short delay of 5 milliseconds and then we'll start the loop over so again this is a pretty simple sketch so let's go and take a look at how it works right now with a fully working sketch and then we'll go ahead and break it so here's our test circuit and you can see all the various components obviously my Arduino is over here and I'm the solderless breadboard about the potentiometer mounted I've got the two LEDs you can sort of see them buried behind the wires when they glow you'll see them better here is my 6 volt supply for my servo motor and here's the servo motor itself now on the solderless breadboard I've taken these two supply rails at the top and used them for the six volts and I've taken the two supply rails at the bottom and I have used them for the five volts from the Arduino and the dropping resistors for the LED are probably a little difficult to see but they're back over here so this is running right now I've loaded my sketch up to the Arduino and as I move the motor you can see the servo move now if I move to one extreme you will see the yellow LED so right now the value has dropped below five degrees and if I move all the way up to the other extreme you'll see that the red LED is illuminated indicating I've gone above a hundred and seventy five degrees and so there's really not much more to it I can manipulate the servo that seems to work and as I go end to end the indicators are telling me that I've reached the end of travel and so this is our working circuit now let's go and see what happens when the circuit doesn't quite work the way we want it to now this is a flowchart that represents the test circuit that we've constructed we start of course in the start box and in the start we load the servo library we create an object for the servo we define the LED pins we define the potentiometer pin and we create a couple of variables then we move into the setup and in the setup we attach the servo to the Arduino pin we defined and we set the LEDs as outputs then we move down and read the potentiometer with the value that we read from the pot we rotate the motor to a specific position and then we kept that value in a decision box that's this triangular box if the value is greater than 175 then the red LED is illuminated and we go back up and read the pot again if it isn't greater than 175 the decision box answer is no and we move into another decision box where we kept to see if the value is less than 5 if the value is less than 5 then we illuminate the yellow LED and go back up and read the pot again if it is not less than five then we exit the box on the nose side and go back and read the pot the stages from repot on are the loop in our program so you can see how this flow chart corresponds to the code that we wrote well now we've seen our simple test circuit and it seemed to work pretty well so it is time to break it now I'm going to induce a problem into this circuit and the problem I'm going to add to it is actually a fairly common problem I've seen it before I've even been guilty of it myself and so let me go and just do something sneaky to this circuit we'll run it again see what isn't working and then we'll see how we can troubleshoot the problem all right well I've gone and done something nasty to our circuit over here and at the moment it's not doing exactly what it should be doing now I'm going to move the pot and as you can see nothing is happening on my servo motor so that's not a good thing now I do still have all the batteries in I didn't just go and reverse one of the batteries to mess up the power supply and I'll tell you right now the servo is still connected I haven't changed any of its connections whatsoever now let's move the pot to one extreme of travel and you'll notice that the LED is coming on the yellow LED which is the correct operation and if I move up over here you'll notice the red LED is coming on so that's operating correctly but the servo is not moving right now and so there are a number of things that I'm going to need to test in order to determine why the servo isn't working so let's go through the troubleshooting process right now well as you've probably already surmised I'm looking at a hardware problem in this particular example after all when I turned a potentiometer I can see an LED illuminate when I get to one extreme and I turn it all the way the other end I can see the other LED illuminating so we're obviously picking up the movements of the pot and we are reading them enough to know which is the low end which is the high end but let's imagine for a moment that we didn't have those LEDs so we had no indication that the pot was working we were turning it and nothing is happening to her servo motor we could be looking at hardware or software in this particular case obviously hardware it could be a bad connection or a defective component like a defective pot or a defective servo motor but we could also be looking at a software problem perhaps our logic is incorrect perhaps we're never actually driving the servo motor correctly or perhaps we're not reading the value from the potentiometer in the first place how do you determine if your problem is hardware or software well one easy way to do that is through software by using the serial monitor by using the serial monitor you can place snippets inside your code in order to print out the value of variables to the monitor and then you can go and move the pod etc and see if the values changed the way that you think they should and this is a very valuable technique for any troubleshooting now if you're not working with an Arduino if you're working with let's say a Raspberry Pi and Python you can use the same technique by printing out to the console and again printing out the value of specific variables to see if your code is operating the way that you should so before we go and troubleshoot some hardware let's go and take a look at the serial monitor with our circuit to make sure everything is working behind the scenes now using the serial monitor is an excellent technique for troubleshooting code because you can place statements at various points in your code and examine the value of variables now I've taken our sketch and I've added the serial monitor to it so what I needed to do in the setup was set the serial monitor up with a serial dot begin command and you pass to it the speed that you want the monitor to go out I'm using 9600 baud but you can use a different speed providing you set your serial monitor to the corresponding speed and then you simply place statements within your program now we only have one very we're really interested in so over here after I've determined the value of angle I print out the value of angle using a serial dot print Ln and the println as opposed to a print we'll create a line feed after the statement so everything will appear in a different line if you just use print they'll all appear one after another and in some cases that's what you want but over here we want each value on its own line so I've already uploaded this to the Arduino and so what we'll do is we'll go into our tools and we'll run our serial monitor and as you can see the serial monitor is displaying a value right now now notice down in the corner I've got it set the 9600 baud which matches the rate that I had specified in the serial begins statement so now let's go and dis turn to potentiometer and see what happens on our serial monitor and as I turn it up I'm getting values up to about 179 which is my maximum range and as I turn it down I'm going down to zero so it does look like this statement is working in fact it looks like the code is working correctly and if that's the case that our problem is indeed a hardware issue so now that we've confirmed our initial suspicion that this is a hardware problem it's time to bring out some test equipment now of course there is a lot of test equipment you can purchase some electronic workshops have thousands and thousands of dollars of test equipment I have test equipment like the Scylla scopes and frequency counters and signal generators that you probably do not have especially if you are starting out and you don't need test equipment like that indeed there is one piece of test equipment that you can buy that'll satisfy most of your needs and it is this it's a multimeter now as its name implies it's a meter that does a number of different things that can measure voltage it can measure resistance this one can measure capacitance it can check transistors you can their current with this you can measure continuity the thing that I'd use this for the most is measuring voltage and checking continuity I use the other functions occasionally but those are the two most common ones and they're the only ones that we're going to need to troubleshoot the problem that we have right now a multimeter is an essential piece of equipment for anyone experimenting with electronics and they aren't expensive this is like a twenty five dollar multimeter there's a number of different types of course you can spend hundreds and hundreds of dollars on a calibrated meter that has several digits but you probably don't need that level of meter when you're just starting out if you are already in possession of a multimeter that's wonderful in fact I have a couple of multimeters and there are times when I use more than one of them but if you don't have one right now just go and pick one up they're very easy to find you can get them on Amazon you can get them on eBay I got this at one of my local hardware stores now there's another piece of test equipment you might want to consider adding to your arsenal that is also not very expensive and it is this this is a logic probe now you may have seen me use this before a logic probe certainly is not a substitute for an oscilloscope but in a lot of cases it'll make do when you're not trying to make a measurement but when you simply want to know is something going high is something going low or is there a pulse over here a logic probe is an ideal tool for that now this probe lets you tell what the state of logic is that you're touching with it both by lighting up a couple of LEDs and also making a rather irritating sound and while that may be irritating it's a useful thing because you don't always have your eyeballs on the probe so you can just hear the results as you're poking around so I'm going to show you how we can use both of these pieces of test equipment in order to troubleshoot the problem that we have with our little circuit and so we've brought out the test equipment to test our circuit now the first thing we have here is a multimeter and this multimeter is an auto-ranging multimeter which is actually rather nice because all I need to do is what the function like AC volts or DC volts or ohms or capacitance frequency etc and I don't need to worry about setting range I've got another multimeter over here I'll just show you and this one is similar to that multimeter except it's not Auto ranging so for example for DC volts I would need to actually set the maximum range it has a range of 200 millivolts 2 volts 20 volts 200 volts and a thousand volts in the case of this circuit I would probably set it for 20 because I'm dealing with 5 or 6 volts in this circuit right now so that would be within range the auto-ranging ones are a little easier to use and they're not that much more expensive now let's go and turn our meter to the DC volt position right now and there's a couple of voltages we can measure obviously we'd like to know if these batteries are working if the batteries are dead then that could be the reason that the circuit isn't working and I've connected a couple of leads to the breadboard to facilitate that it's a little hard to sometimes get the probe into the breadboard connections so here's the ground and here is the positive lead and I've got 5 point 1 3 5 volts right now and 5 point 1 3 5 volts is not bad it should be around 6 volts but these batteries are probably a little low and the motor is connected as well - it's probably drawing a slight bit of current although not much because it's obviously not moving okay the other voltage I can check is the 5 volts coming from the Arduino to make sure that that's working and I've brought that out over here onto these connections and the main reason for doing that as you'll see soon as for my logic probe so let's just try to quickly check that voltage four point eight to one which is pretty close to the 5 volt logic that we need over here so I believe that our voltages are correct now another thing that you can do with a meter like this is check continuity and you'll go into the ohms scale for that now if I touch the leads together of course it should go down very close to zero ohms and at zero ohms but what is useful on this meter and on many meters is that you can also do an actual continuity function if I press this button here first it goes to a diode test function which is a very useful function as well it lets you see the voltage drop across a diode and lets you see if that's working this function is the continuity one so if I put the leads together I get that annoying beep sound and while that may indeed be an annoying sound it's very useful because then I can focus on where I've got the test leads without having to keep my eye on the meter I can hear it when I have continuity so I use that function a lot especially when I'm soldering things maybe some perfboard and trying to figure out if my connections are all good or if anything shorted I can use that and I'm not going to go over the board with that although if I would I think I'd probably solve our problem to be honest but you can do that to Kent to check your connections just if you're not sure about a connection place to meter on one end and the other take the power off of it in that particular case and then go and check for continuity and make sure you've got all your connections correct now we'll put this aside now and look at our logic probe now as I showed you this is a logic probe it's a very simple probe it's got lights for high and low as well as another one for pulse you can also set it for different levels I've got it set the TTL which is transistor transistor logic and that's the type of logic that we generally use with these circuits it's the 5-volt logic we're used to now the pulse one is very useful and we should be getting a pulse going out to this servo motor if the circuit is working if it's not we won't be and that should be the orange lead down here so I'm just going to try to touch that if I can and as you see over here I think I've got a bad connection there you are getting a pulse over here so indeed we are getting a pulse and you can also check this for high and low like if I go over here to where this LED connection is down here it's low right now if I bring it up it goes high and so you can check all the different logic levels you're getting out with this and it's a lot cheaper of course than an oscilloscope and in some ways it's handier because you don't really need to know the actual level of the actual pulse width you just simply know that pulse is there or that a level is high a level is low so it's a very useful piece of equipment and these are the two pieces of test equipment that if you haven't bought any test equipment I believe you should buy them first definitely the multimeter first but then consider a logic probe with these two devices you'll be able to do a great deal of troubleshooting so let's see what we know about our problem right now we know that when we turn the potentiometer we are getting the two lights to light the only issue is that the servo is not working right now we also know that through software that the servo should be working because we're getting a different value as we turn the pot which we should indeed be passing to the servo motor and we've even determined with our logic probe that we are getting pulses sent out to the servo motor so we might have a bad servo motor and the way to find that out the easiest way would be to simply put another servo motor in there and see if it works so if you have another servo that would be a great way to do it and that's an excellent troubleshooting technique in general substitution if you have another part you can just put the part in and see if that fixes the problem quite often it's as simple as that in this case it's not and I'll tell you right now that our servo motor is perfectly fine so what we are looking at is most likely a wiring error now let's go and take a look at the schematic right now and see what kind of a wiring error we could have in order to cause this problem now we could go through with our meter over here in continuity mode like this and buzz out every single connection but that's rather tedious and it's not really that necessary because we already know we're getting power connections from the Arduino we know that the connections to the LEDs are obviously working and the other connection to the servo seems to be working because we're getting pulses on it right now so we must have some other wiring error right now or potentiometer and the analog side is obviously fine perhaps the servo isn't wired correctly and we can go and double-check our connections to make sure that we're going to power and ground and then to the servo control line and those all seem to be correct you can go through and check it yourself but that actually seems to be correct so what else could be missing over here well the key to our problem right now is to know how this circuit works and the way that the circuit works it is of course sending pulses to a servo motor but those pulses need to have a reference and the reference is the ground now remember we're using two different power supplies this is supplying the servo and the Arduino is supplying our logic circuit and so those two grounds need to be connected together ground is actually a reference signal it is called ground because traditionally we used to actually physically connect that to the earth ground you would drive a stake into the ground and that would be the ground line and indeed you will find that in your home there's a good chance that the ground lead on your power connection is connected to the cold water pipes that you have in your home this is a typical arrangement and the cold water pipes run underground so they're indeed connected to earth ground well we don't have to worry about earth ground right now but we do need to know if our two grounds are connected together so I've got the power disconnected right now and I've got my meter in continuity mode and this black lead here is the ground from my Arduino and this green lead over here is the one that I brought out to test voltage it is essentially the ground or the negative lead from the battery and they should be connected together but when I put this together they are not connected together and that seems to be the problem I've neglected to connect the two grounds together in this case actually what I did is I sneakily took the ground wire and I put it in the wrong place Noddy me I will put it back and we'll now check and we do have continuity right now and so I think we've solved our problem let's get rid of all these spurious leads because they're causing noise back to our original circuit which we will power up and it looks like it's working right now and so our issue was we did not tie the ground of the two power supplies together and so although these pulses were going to the servo they had no reference the servos reference is the ground on this side the reference from the Arduino is the ground on this side and they need to be tied together so that connection was omitted and that is the problem with our circuit which we have now succeeded in troubleshooting and so we finished their first bout of treble shooting and as it turned out we had a hardware problem and I hope you can see how we determined that that was a hardware problem just with some logic and common sense so what I'm going to do right now is expand upon the code in our circuit I'm going to keep the circuit the same but I'm going to add some additional code so that we can flash the LEDs a few times before everything starts and of course I'm going to do something to it so that it doesn't work exactly correctly and we will figure out how to troubleshoot that and how to get it working correctly so let me go and write a bit of additional code and then we will go and take a look at our next troubleshooting problem now for our next demonstration I've enhanced the sketch that we've been using what I wanted to do was I wanted to flash the LEDs when the sketch was first turned on when the Arduino was first reset in other words and so I want to flash one of the LEDs five times wait a second and then flashed the other LED five times and then go into the sketch and have it operate the same way that it did before and so in order to facilitate that I've created a function that I called flash LED and I'll show you that function that's right at the end of my sketch now this is flash LED which of course its purpose is to flash in LED and it's got three input parameters the first one is led pin and that is which LED do I want the flash what pin on the Arduino is it connect to the next integer is the flash numb how many times do I want the LED to flash and the third one is flash delay what is the delay in milliseconds between the on and the off period for the LED and so we can take a look at the function itself and basically what I've done is I've taken the blink sketch and I've placed it inside a for loop and so I will flash at that number of times the LED pin and the delay on it instead of specifying a fixed number is flash delay and so in order to use that function I'm put it into my setup because remember I only want the LEDs to flash when the program starts so something you want to only happen once you put in the setup something you want to happen over and over again you'll put that into the loop so the setup is essentially the same as it was before with the addition of the flash LED command so I flashed the LED the red one five times and I'll leave a 500 millisecond delay between flashes I then apply a one-second delay over here and then I go and flash the yellow LED five times at the same parameter 500 milliseconds between flashes and I could vary those parameters if I wanted the flash them a different number of times or if I wanted to make the delay different between the two LEDs and so now that you've seen this sketch let's go and see if it actually works all right so I've uploaded our sketch to the Arduino I've temporarily disconnected the power because the sneaky problem that I induced into it is actually something that you're going to see once the circuit is started so let's put some power on and see what happens now as you recall what is supposed to happen is I'm supposed to flash the red light five times then the yellow like five times and then we'll go into the sketch that we had before where we simply can move the motor using the potentiometer and get the lights illuminating at the end of travel so let's put some power on this there we go and a red light is starting to flash and it's supposed to flash five times its flashing more than five times in fact it's still flashing it won't stop flashing and of course our potentiometer isn't working all that is happening as the red light is flashing essentially what we've done is we've just built a different version of the blink sketch it would look like so obviously we have something wrong over here and so let's go and see what we can do in order to figure out what that is now I think it's fairly obvious that what we have here is a software problem after all we had a working circuit and we added some extra code to it and now it is not doing exactly what we wanted it to do however don't overlook the fact that you could have more than one problem with the circuit there could indeed be another hardware problem over here with the potentiometer or with the servo motor that we haven't seen just because the code hasn't got to the point where we can test those things but first we have to resolve the software issue with the code that we added so likely the function that we created has an error in it or the way we're calling this function may have an error or the fact that we're calling it into setup and not the loop may be part of the issue so let's go and see how we can troubleshoot this as a software if you okay let's try and troubleshoot our code we'll go down into the setup will recall our flash LED because this is likely where a problem is going to be now one technique you can use when you're troubleshooting your code is to not run a specific line and you can kind of remark the line out by just putting a couple of slashes in front of it now you'll notice this line has now simply become a comment so the code will ignore this line completely it'll do the delay and it'll go to the yellow LED flash so let's just see if there's something specific about the red LED that's causing our problem well upload that to the Arduino and now we see the yellow flash and the yellow keeps flashing so obviously this problem is not specific to the red LED I didn't actually think it would be and so let's go back in the code and undo what we just did and let's experiment now now this is the flash LED and we're passing at the LED pin which is LED red in this case the number of times we want to flash which is five and that's what it's not doing and the delay of 500 milliseconds and by the look of the flash it probably is 500 so this is where the problem seems to be let's just tell it to and see if that makes a difference and we're flashing to red again and it still keeps flashing so obviously that number isn't making a difference let's go back into our code and change that back to what it originally was and go down to the flash led function which obviously is the source of our problem right now let's examine this function a little more closely now we have the parameters the LED pin the flash num and the flash delay we know that these two are working we know LED pin is working because when we changed from red to yellow it indeed flashed a different LED and we're pretty sure flash delay is working we could have added a longer delay to make certain that it changed but it looks like it's about 500 and so it's flashed numb that is the problem and over here we've got what actually happens now flash numb is used over here so for the integer equals 0 to the integer is less than or equal to flash numb we will go and execute this loop over here and the loop is basically the blink sketch with all these parameters inside it but there's actually something we are not doing over here we forgot to increment so after it finishes over here it just keeps going on and on because the value of I is never going to be less than or - flash numb it's going to stay at zero all the time we're not incrementing I at all and so let's do hi to increment I put a space there to make it look nice and now let's go and send that and see what happens that looks a little bit better doesn't it it does indeed okay now that I've made my code fix let's try this again now I've uploaded it again to the Arduino and I'm going to give it a bit of power and we'll see what happens and so there goes our red light flashing again and stopped and now the yellow light is flashing again so it looks like we've had some success over here and it stopped and now it seems that we can move our motor to the extremes and get the light so it does look like it's fixed although actually it's not 100% fixed let me reset this because the problem here is a bit subtle but you may catch it so remember what's supposed to happen the red light supposed to flash five times wait a second the yellow light is supposed to flash five times and then we'll be able to use the potentiometer like normal so let's just reset this there goes the red light there goes the yellow light but that's actually not correct did you see the problem I'm going to reset it one more time and this time I'll show you what the problem actually is I'm going to count the flashes 1 2 3 4 5 6 1 2 3 4 5 6 I want to delight the flash 5 times it's actually flashing 6 times so it almost works but we still have a slight code problem let's go in and see if we can figure out what's making it do this now the issue we're having obviously has to do with our flash LED function so we can ignore the rest of the code and concentrate on that now one simple way of fixing it of course would just be changing these fives into fours and since we know it's flashing one more time than we want it to that would probably work but it's not the best way to fix it because the flash LED function if it were working correctly would be a useful function that we could reuse in some other code so let's go and see if we can fix that now let's take a look at flash LED we take the LED pin we know it's working with that and the flash delay we know it's working with that and flash numb it's sort of working with but it's flashing one more time than we need it to and so flash numb is only used in this particular statement here at the beginning of the for loop and so this has to be where our problem is and if you think about it that is the problem it's going from I to 0 to I is less than or equal to flash numb and in this particular case we're starting at 0 and so since we start at 0 we're counting 0 1 2 3 4 5 as opposed to starting at 1 so there are two ways that we could fix that one way would be to make I equal 1 at the beginning another way in the way that I'm going to fix that is to change the less than or equal to to just a less than because equal to will make it too large if it's less than that's fine because we are less than five which is a number or passing but if we say equal to we also run the statement one more time because it will be equal to five and so in order to make this correct I'm just going to take this out and I'm gonna load that up and see what happens all right I've uploaded our code change with the equal sign missing and I'm just gonna reset this so you can see what the results are 1 2 3 4 5 and it stops 1 2 3 4 5 it stops and now we can move the motor and of course get the LEDs illuminating when we reach the end of travel and so it appears we now have a working circuit thanks to our brilliant troubleshooting techniques now before we go today I wanted to mention a few other things about troubleshooting these are things that didn't really fit into any of the previous categories but I think they are important to mention because sometimes when you check everything it still doesn't seem to want to work and you're scratching your head there are other reasons that things will not work now the first one is a software thing let's say that you are putting together a project from something you saw perhaps from me perhaps from another YouTube video or an article or something on github and the project involves a library which you downloaded and installed or you got off of the Arduino IDE library manager directly and you put it all together and it just doesn't work and you don't understand I mean you've got the wiring double-checked triple-checked everything is fine you've gone through a lot of troubleshooting techniques everything seems ok the code that you've got is the code did you directly got off of github or off of the articles so you know it should work you even saw someone in a video make this work and yet it doesn't work well one of the problems could be if it's an older project that you're looking at it might have used an older version of a librarian sometimes features and libraries get downgraded and you may have installed the newest version of the library which has downgraded the feature and it's no longer available so check version numbers of libraries that can sometimes throw a little loop to you because everything seems fine but the version number is the issue another if you is something that you run across when you're working with electronics and working with things that work with high frequencies I've had a lot of people write me about the nrf2 4l zero ones for example those are the little RF modules that you can buy for next to nothing and use with your Arduino or Raspberry Pi in order to make a wireless device and they're great little modules but they can be difficult to work with because they're RF modules now radio frequencies are actually sensitive to things like the length of wires the proximity of components and a lot of times when you put something like that on to a solderless breadboard the breadboard itself the length of your jumper wires you're working with a tuned RF circuit and it'll throw everything off sometimes you'll pick up power supply noise as well now in the case of the nrf2 for l01 there's actually a pretty simple solution and I showed it in the video that you did about those things is that there is a little carrier board that you can buy it's only cost about a dollar and it has a voltage regulator on it to make the supply voltage good because supply voltage through those things is quite often the problem it also has a capacitor to decouple the power supply and since it's on a printed circuit board all of the wiring is very small and it's already been made for the nrf2 for l01 and i find most of the time you can just solve those problems just by using something like that so keep that in mind if you're working with radio frequency circuits also audio circuits you'll sometimes get funny noises and things like that in audio circuits that do breadboard and again you're picking up external interference sometimes you can cut it down by putting in power supply capacitors but sometimes you really just have to build your project either on to a printed circuit board or a perf board inside a shielded enclosure these the kind of things again that you can go through the troubleshooting chart and everything seems to work right but it won't a third one and a final one that I want to mention is one that I ran across about a year or two ago and it was when I was doing the project for a drone lot workshop video it escapes me which project it was but I remember the situation there was an LED that was supposed to light and it just would not light so of course I checked my wiring I had it connected to the correct pin I checked my code it seemed to be fine I checked the LED itself it wasn't put in backwards I could take it out and I could you know put current across it and make it glow and yet this didn't seem to work well there was a fellow called Sherlock Holmes fictional character art Sir Arthur Conan Doyle wrote about over a hundred years ago that I'm sure we're all familiar with and one of Sherlock's sayings was that when you eliminate all of the other possibilities the remaining one no matter how impossible it seems is going to be the answer and this was actually the case it wasn't the jumper wire the jumper wire looked perfect but inside there was a break on the jumper wire and I took the wire out an old meter across it no it was broken another jumper wire in the circuit was fixed so little gotchas like that you got to watch out for it because they do happen in the real world your songless breadboard too if you've used it a lot sometimes the pins don't make correct contact and just moving it over a couple of spaces will solve your problem and also indicate that you probably should purchase a new solderless breadboard so at any rate I hope you enjoyed this video on troubleshooting it's just sort of the tip of the iceberg there is a lot of techniques that I haven't covered today but I think this should get you started and so the next time you're building a circuit and it doesn't quite work the way you want to don't panic just do some basic logical troubleshooting techniques and I'm sure you will make it work correctly and you will also learn a lot more about your circuit at the end so I hope you enjoyed the video if you haven't subscribed to the Channel please do I really love getting new subscribers if you'd like to discuss some of this stuff check out the general workshop comm forum at forum dr. BOTS workshop calm and there's a lot of great people on there having a lot of great discussions and I would love to have you join us and also check out the drone bot workshop website for all sorts of articles and projects and so until the next time we meet please take good care of yourself I hope you can get your circuits working and I will see you very soon here in the workshop good bye for now [Music]
Info
Channel: DroneBot Workshop
Views: 38,484
Rating: 4.9476695 out of 5
Keywords: troubleshooting, electronics, multimeter, logic probe, test equipment for electronics, troubleshooting electrical circuits, dronebot workshop
Id: v7NFNSbvCRE
Channel Id: undefined
Length: 53min 33sec (3213 seconds)
Published: Sun Jan 05 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.