Mecanum Wheel Robot Car & ESP-NOW Remote

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today in the workshop we're building a robot car using mechanim Wheels you'll see how mechanim Wheels work and how we can write code to manipulate them we'll also use a cool esp32 module to build a remote control with a joystick and a TFT display we're moving in every direction today so welcome to the workshop [Music] well hello and welcome to the workshop I should say welcome back to the workshop it's been a while since we've had a video but I'm hoping that today's video will more than make up for that Gap in material now today we're going to be building a small robot car and as you've already surmised from the introduction and the title of the video the car uses some very special wheels wheels called mechanim Wheels and if you're not familiar with the Canon Wheels I think you'll find them pretty fascinating not only can they move backwards and forwards like normal Wheels but they can also move sideways and at a bunch of different angles but aside from fancy Wheels I think this project is really cool because it incorporates a lot of the technologies that we've already looked at here in the dronebot workshop plus a couple of new ones that we haven't seen yet our car is based around an esp32 and of course we've built several esp32 project index it also uses a number of neopixel LEDs addressable RGB LEDs and we've talked extensively about those before as well the car has a separate controller unlike other esp32 designs where you'd use a phone or a tablet to control it we've got a separate physical controller with a joystick and a really neat esp32 module that includes an integrated TFT display plus Provisions for connecting a small LiPo battery that can be charged from the module and so it makes for a great remote control now the remote control and the car are going to communicate with one another using ESP now protocols so they're going to set up a peer-to-peer Network between them you won't need an external router or anything they can just talk to one another and they can send data back and forth and so we're going to use the TFT display on our remote the display data that comes from the robot car so there's a lot of interesting technologies that work today but of course one of the more interesting ones is the wheels that we're using so let's go and learn a little bit about mechanim Wheels a mechanim wheel is an omnidirectional wheel that can Propel a vehicle in any direction the mechanim wheel was invented and patented in 1972 by banked Ireland Island it was named after mccannum a b the Swedish design firm that Mr Island worked for the McAdam wheel is sometimes called a Swedish wheel or an island wheel Mr island sold the patent to the U.S Navy in 1980. in 1997 the U.S Navy released the rights to the mccannum wheel so you can use them in your design without worrying about violating any U.S Navy copyrights the mechanim wheel should not be confused with the Omni wheel the Omni wheel is indeed an omnidirectional wheel but it can only Propel a vehicle in a forward Direction it cannot Propel it sideways the rollers on the McCannon wheel are tapered to provide a smoother ride and a single point of contact there are also two styles of mechanum wheel that are used in the same vehicle one of these has the rollers at a 45 degree angle toward the axle line whereas the other one has them at a 45 degree angle as compared to the plane of the wheel these wheels are arranged in a vehicle as shown here by moving all of the wheels in the same direction the vehicle will be propelled in a straight line moving the wheels in the direction shown here will propile the vehicle sideways reversing the direction of rotation on all the motors will send the vehicle toward the Other Side by only using two of the wheels you can have the vehicle move diagonally you can change the wheels to change the angle and you can change the direction of rotation as well rotating two wheels on one side will cause the vehicle to Pivot if you drive two wheels on one side of the vehicle in the same direction and the other two wheels in the opposite direction the vehicle will rotate and by driving the front two wheels in opposite directions you can make a pivot sideways McCannon Wheels have found many unique applications industrial forklifts and lifting platforms robotics of course and the Canon wheel wheelchairs which can offer the user a great deal of flexibility of movement today we're going to use a simple mechanum wheel robotics platform for our experiments there are many of these available on eBay and Amazon to choose from and they're not that expensive you can also buy the wheels individually and just adapt one of your own four-wheel robotics platforms to it so now let's take a look at the platform that I'm using to experiment with the mechanim wheels now here are the contents of the mechanim wheel robot car kit that I purchased from one of my local Distributors and I was actually kind of surprised pleasantly surprised to see that this seems to use aluminum instead of the acrylic that we normally see otherwise we've got four of the standard yellow Motors I'm sure that we're all familiar with and we've got a bag full of Hardware which I suppose can put everything together here there were no instructions whatsoever these appear to be hubcaps that would fit onto the mechanim wheels and then we have the four mechanim wheels themselves and as we went over there are actually two different types of wheel if I bring them up over here you can sort of see that one wheel has the rollers going in One Direction and the other one in the opposite direction and there are two of each of those and so I'm going to throw this kit together and we can start experimenting with our mechanim Wheels so now that we know the theory behind mechanim wheels and that we've taken a look at the wheels that I'm going to be using in my project it's time to get working with them so what we're going to do is Mount four of the motors and four of the wheels onto the chassis I'm going to put it up on blocks so to speak so it doesn't run around on my workbench and then we'll see what it takes to code for these wheels and make the move in the correct directions and so here's how I've rigged up my Macadam wheels so we can give it some basic tests before we actually build the complete robot and you'll notice I've got the four wheels mounted onto the base now before you start making comments about it in the comments you'll notice I still have the blue plastic on over here and that's intentional because I actually still have some work to do on this base I need to drill some more holes in it so I can mount the circuit board for our final robot car design and it's better to keep the plastic on while you're doing the drilling so you don't scratch up the aluminum and so the motors are just temporarily mounted over here but you'll notice that I've got the mechanim wheels angled up correctly so that these two Motors are basically using the same wheel and these two Motors here are using the same style of mechanum wheel and that of course refers to the angle that the rollers are on the wheel now I'm powering everything up with an esp32 and I'll show you the hookup for that in a moment I've done something over here that I suggest that you do and that is just to map out the connections to all of your wheels so you know which is positive and which is negative and when I say positive I'm referring to the fact that if I hook the motor up this way the car goes forward and as for forward I drew on the blue plastic and arrow over here to indicate what forward is because of course with this car base it's kind of hard to determine what is for there really is no front or back on this style of design but this is what we're going to be using to do a few tests on the mechanim wheels before we act to go and build our robot car so now let me show you how I hooked up the esp32 and the motor drivers now here's how we're going to hook up our mechan wheel test bed we're going to be basing everything around an esp32 and for my experiments today I'm using an esp32 dev kit C module you could use a different esp32 module providing that it had the same pin outs now we need a couple of dual motor drivers because we have four Motors and I'm using the tb6612fng which is pretty well my favorite h-bridge module you could also use an l298n if you wanted to and you can see my previous videos and articles about motor drivers to let you know how to wire that up instead I've got the motor drivers divided as a front and a rear one and of course they're going to be driving the four Motors my right front left front right rear and left rear motor we also of course need a power supply for our Motors and I'm just using a six volt battery pack which works pretty well with the kind of Motors I have on my test bed if you're using different Motors you'll of course need a different voltage power supply just remember not to exceed the ratings on the tb6612fn key now we'll Begin by connecting the positive side of the motor power to the VM pin on both of the motor drivers we'll connect the negative side of the motor power to one of the ground pins on each of the H Bridges 3.3 volt output on the esp32 is connected to the VCC on both of the H Bridges we'll also connect one of the grounds from the esp32 to one of the grounds on each of the H Bridges the 3.3 volts from the esp32 is also run to the standby pins on each of the driver modules you need to bring these pins high in order to take the modules out of standby mode now we'll wire up all the input pins on the h-bridge modules to the esp32 i o pins we're going to start with the front module and we'll wire its pwma pin to the esp32's gpio 19. we'll run ai2 to gpio 23 ai1 to gpio 32 bi1 to gpio 33 bi2 to gp25 and the pwmb pin will run the gpio pin 26. now we'll do the other module where the pwma pin goes to gpio pin 27 on the esp32 the ai2 input goes to GP of io14 ai1 to gpio12 bi1 to gpio 13 bi2 to gpio2 and pwmb is run all the way to the gpio4 PIN the last thing we need to do is connect up our Motors we'll connect the right front motor to the motor driver's a01 and a02 outputs the left front motor will be connected to the modules b01 and b02 outputs note the positioning of those outputs on the module and how they're essentially a mirror image of each other we'll do the same thing for the rear Motors so the right rear motor will go to the a01 and a02 outputs on the second H bridge and the left rear motor will go to b01 and b02 and that completes the wiring now let's go and take a look at a sketch we can use to move our Motors around now the first sketch that we're going to run on our mechanim wheel base is a very simple sketch but it will test the operation of all four of the motors and this will let you know that you've got all of the motors hooked up correctly that you've got the polarities of the motors correct that you've got all the inputs to the motor drivers correct so it's a good thing to run for test purposes now we're going to start off by defining all the connections we have to the four different motor drivers and so that's these over here and then we Define a couple of preset speeds and you can change these if you want to we're going to call the slow speed a value of 100 and a fast speed a value of 250 and you can go from anything from 0 to 255 although if you go below 100 you'll find that a lot of Motors will be very very sluggish so you can modify those if you need to in setup all we do is we basically set up all those pins that we defined earlier as being outputs and then we go into the loop and the loop is very basic we're just going to go motor by motor and run it at a slow speed in the fast speed forward and then we're going to stop and then reverse it fast and slow and stop again and so we do a number of digital rights and analog rights we're doing digital rights to the two input pins to set the direction and we do an analog right to set the speed we start off with the slow speed and then we go to the fast speed and we put a delay in over here now I should make note that analog right is not the only method of doing pulse width modulation on an esp32 and in fact it's not the best method for doing it and in the sketches that we're going to be proceeding into after this we're going to be replacing analog right with something else but I just wanted to use it right now because it's a very basic sketch and most people are familiar with the operation of analog right as you can use it in the Arduino as well and so anyway we just cycle things through we set it up for forward we do it analog right then we change the speed fast it's still going forward so we don't have to manipulate these bits we'll do that for two seconds we'll stop for a second by selecting the speed to zero and then we'll reverse it by doing the digital rights over here do our analog right at a fast speed for two seconds and then we'll reverse to a slow speed for two seconds and then we'll stop for a second and we go and do that for the left motor then the right rear motor and the right and the rear left motor and so basically we go through all four motorcycling back and forth so it's a pretty basic sketch but again it's very good for testing purposes so let's load it up and take a look at it in action and so I'm ready to begin testing all of our Motors up now one thing I wanted to mention before I got going is that one thing that I found handy when I was developing this was a logic probe and the reason I found it handy is I actually did have a wiring issue that I was able to troubleshoot quite quickly with something like this probably even quicker than I could have used in oscilloscope and I just wanted to mention that this is a very handy thing to have around it'll let you know whether the level is a zero or a one or whether it's pulsing and they're very inexpensive so they're certainly a lot cheaper than a scope so if you want to move your test equipment game up Beyond a multimeter I would suggest that be your next purchase at any rate logic probes aside we're ready to begin now you can see I'm using a six bolt battery pack over here to power everything up and everything's all hooked up all I have to do is actually connect the USB cable so Excuse me while I do that and there we go and it's cycling through all the Motions with each of the wheels and they all seem to work although the 100 value for pwm is actually very very picky on this wheel over here and as we're going to see in a bit there's an issue with these motors that we're going to try to resolve but otherwise we can see that they're hooked up correctly and so we can move on to actually making the mechanim wheels move in the various directions that they're capable of earlier on we saw that there were different modes that you could run the mechanim wheels in these modes depended upon which Wheels you had activated and what direction they were spinning it now we of course have four Motors one attack to each one of the wheels and we can represent them as the motor front and the motor rear Motors both left and right the motor drivers driving these motors have two channels an A and B Channel and it has two inputs in i1 and an I2 for each Channel these two inputs determine the direction that the motor will rotate and we can see the truth table for that below now as we have four Motors and two inputs per motor that means eight bits would describe every movement that we need to make and eight bits of course is a byte and so let's take a look at the straight mode now you can see from the truth table below that we have the eight bits that we'd have to activate to go straight and there are two different modes here because we can go forward or backwards in a similar fashion this is a sideways mode and there are two modes here again to go sideways to the right or sideways to the left there are four diagonal modes because there are four different directions we can go in now I should point out right now that this does not mean that our car is restricted to only going 45 135 to 25 and 315 degrees you can go any angle you want by varying the ratio of the speed between the wheels however at this point we're only concerned with Direction there are also four different methods of pivoting depending on whether you pivot on the right or pivot on the left we can Define two different rotations a clockwise and a counterclockwise rotation and there are four sideways pivots as well pivots from the front and pivots from the rear you can combine all of our data into this table which will show you that with 18 bytes we can represent every different mode that our mechanim Wheels can use so let's go and see how we would code something using these 18 bytes now here's the sketch that we're going to use to put the mechanim wheels through their paces and it's a fairly simple sketch but it has something different as far as the pwm goes and so we'll take a look at that in a moment now we're going to start off the same as we did before by defining the connections to the two motor controller modules and so that's the connections over here we've also got some variables for the speed which are in this sketch but an actual fact for only keeping one speed for this demonstration but this is actually for future purposes because as we develop sketches we'll be making more use of these variables now here's where we Define the individual bytes the 18 different bytes that represent the different mechanum wheel modes and so each one of these is a byte constant and it's got a name to it and then a byte value and this B over here tells us that we can use binary numbers over here to represent the byte and when you highlight it over here with the IDE 2.0 it also shows you the decimal number so for this first one for example it's got a value of a high 170. okay here's a variable just for a time delay that we're using within our test and now some parameters for our motor control and this is a bit different than what we used before now we want the frequency that we're going to use the pwm at and I'm using a kilohertz the resolution of 8 Bits and we're defining a pwm channel for each motor now what's that all about well let me explain on the esp32 there are actually some dedicated registers for performing pwm operations there are two dedicated registers for doing it for Motors and 16 for doing it for LEDs now just because it's called an LED register doesn't mean it's restricted to LED use it can be used for a number of different purposes for pwm including Motors and as there are only two motor channels on the esp32 we're going to be using the LED ones instead so these are the four different channels that I've defined line now you could Define any four you want they go from 0 to 15. and here is a function to move all of our Motors and so we have five inputs to the function the speed of the individual Motors and the byte that represents the direction control now for each of the motors we do the same thing for the right front motor for example we write to the two different bits the i1 and the I2 inputs and we use bit 7 and 6 from our Direction control byte the bit read function lets you get the individual bits in the byte and this is how we are writing to our Motors we're going to do an ledc right and that is the pulse mod with modulation LED function we're going to write it to a specific pwm Channel and we're going to write the speed to it and we do that for all four of the motors now here's another function to stop the motors and to stop the motors again we just write zeros to all of those channels and then we set all all the bits to zero for the inputs for the motor control modules now in the setup you can see the rest of the LED parameters and we start off with the serial begins because we want to use our serial monitor pin mode as we did before just to set everything as an output now here we come to the pwm for the LEDs now first of all we do an ledc setup and this sets up each one of the channels so we match a channel and its frequency and its resolution and then we attach those channels to the pins that we had so we attach it to the pin in this case the pwma pin is going to this particular channel so we've attached all four channels to our pins and that's how that works and here we're setting the test speed to set all the 200 but you can vary this a bit to see what happens when you change the motors make different speeds and now the loop we're just going to go through a bunch of the functions we start with a three second delay and then we print out to the serial monitor to let us know what function we're into and then and we'd call move Motors we passed the four speed parameters and then we call the control byte which in this particular case is Max straight forward and we call that up we do a time delay to run it for a specific time right now time delay is set to 2000 so it'll run for two seconds we stop the motors and delay for half a second and then we go through the other operations and we step through a number of them now I'm only doing eight of them just the ones that move forward backwards sideways and at an angle but you can add the other ones in if you wish just to see how your Motors move so that's the sketch we're going to use let's load it up and take a look at it in action and so we're going to put the car through the paces we've got the mccannum wheel demo sketch running and as you can see the wheels seem to be going through the correct motions you can watch the serial monitor to see what phase we are in and that should be the end of the cycle it'll wait three seconds and go over it again so that does indeed demonstrate that our code works but what we really want to do of course is see how the vehicle moves using the mechanum wheels in these different modes and for that we're going to have to put it down on the ground so let's see if we can do that now so in order to put the car down on the floor and still keep my circuitry on the subtlest breadboard I decided to extend the motor wires and the easiest way that I could think of doing that was to use an ethernet cable because it has the eight conductors that I required and is quite flexible in order to make the connection simple I use the SparkFun RJ45 breakup box on each end now as you can see the car is going through the motions and I have to admit when I first started seeing it go sideways it was pretty impressive now it isn't perfect with the code I wrote the car should end up back in the same point it started from and it clearly doesn't however this discrepancy is because of a number of things the surface that I'm driving on and also speed differences between all four of the motors unfortunately I can't do much about either the surface is what it is and as for the speed differences I don't have a speed sensor on the high speed side of the motors the best I could do is to be putting one on the low speed side and that that isn't a good way of regulating speed nonetheless I think it's a good design and so we'll continue building our mechanim robot car now before we start building our car I want to address another aspect of its design and that's the neopixel displays that I'm using I'm using five individual neopixel LEDs four of these LEDs are going to be used to indicate the direction that each of the motors is traveling in and the fifth one is a status LED now neopixels have a number of different advantages over regular RGB LEDs and I did an entire video about RGB LEDs it included neopixels so you might want to take a look at that but essentially these are addressable LEDs and they are Daisy chains so instead of needing a whole bunch of i o ports I would normally need 15 i o ports to drive five RGB LEDs neopixels can be driven with just one i o Port so it really is a savings there however there are timing considerations with neopixels and as you're going to see also considerations about using specific needle pixel libraries so let's go and take a look at our colorful neopixels we're going to be making use of five Adafruit eight millimeter neopixel displays and they conveniently come in packages of five Adafruit also makes five millimeter versions of them as well now these LEDs may look like regular RGB LEDs but they aren't they're addressable and the pin outs are quite different you can identify the pin outs by looking for the flat side on the LED and if the LED is brand new you can also look at the length of the leads going from left to right the first pin is the data input pin this is a 5 volt data input for driving the led the next pin is the 5 volt power supply and the pin beside that the longest lead is the ground lead the final pin is the data out pin neopixels or Daisy chains so you'll connect the data out from one neopixel to the data in on the next one we're going to keep the same wiring that we have for our Motors so don't get rid of that I'm just going to get rid of it from our diagram to make it a bit easier to see things now to our circuit we're going to be adding five eight millimeter neopixel LEDs this will be the status led the right front left front right rear and left rear LEDs I'm also using a two channel logic level converter to convert the 3.3 volt logic of the esp32 to the 5 volt logic required by the LEDs you could also use a bipolar transistor to do this as well we'll require a 330 ohm resistor and we'll need 5.1 microfarad capacitors and physically you want these capacitors to be quite close to the individual LEDs we'll Begin by connecting the 5 volt output of the esp32 to the 5 volt pin on all of our neopixels we'll also connect the 5 volts to the 5V connection on the logic level converter the esp32's ground will go to the ground side of all of the neopixels I'll also send the ground to the two ground leads on the logic level converter in actual fact you only need to connect one of them up as they're internally tied together we'll connect the 3.3 volt output of the esp32 to the 3.3 volt input on our logic level converter and we'll connect all of our 0.1 microfarad capacitors across the power supply for each of the LEDs we'll then connect gpio pin 5 of the esp32 to the logic level converters 3A input we'll connect the level converters 5A output through a 330 Ohm resistor to the input on the status LED this will be our first led we'll connect the output of the status led to the input of the right front LED and will continue to daisy chain the rest of the LEDs there's no final connection to the left rear LED of course because it's the end of our daisy chain and this completes our wiring now here's the sketch that we're going to use just to check out our neopixel connection and this is just an adaptation of the sketch that we used earlier to check out all the mechanum movements of the motor and so I've just added the neopixel components to that same sketch so the first thing that I added was to include the Adafruit neopixel library now if you don't have that of course you can install that through your library manager and this library has a number of dependent libraries and if you don't have those the library manager will offer to install those as well and you should take it up on that offer because you're going to need those after that we go through the same things we've seen before with the motor connections and the motor speed and defining the constants we use for the motor movement and motor control so we won't go through that we'll get down to our first neopixel related thing which is this one over here we're going to define the pin that we've connected our neopixels to in our case it is pin number five and we need to know the number of neopixels that we have and we have four of them now you can address the neopixels with their actual address which in our case would be zero one two and three however I find it a lot easier to read the code if I give them names so I just Define names for all of our neopixels so here we are at the right front left front right rear and left rear neopixel and in a similar fashion I want to use four different colors in this demonstration and you could just input the RGB values they could also be inputted as hexadecimal values but again I find it easier to read when we just Define constant so here's red green blue and yellow and of course if you wish you could change it to different colors you don't have to use the ones that I used now this is the part where we create an object called pixels with the neopixel library so we're going to create this pixels objects and the parameters we need first of all are the number of pixels which is not phases for the port that we're going to in our case is five we need the mode that we're going to run the neopixels in and this is a very important parameter different styles of neopixels can run in different modes some of them for example also have a white component to them ours are Neo RGB and that's the only kind that you can use with the discrete neopixel so it's a very important parameter and this is the frequency that we're going to be addressing the neopixels at 800 kilohertz now this is the function for moving the motors that we've seen before the stopping the motors now we're down to another neopixel function and this is the LED motor status so this is what's going to give you the status for all four Motors when they're moving and we're going to input the same control byte that we used earlier so the bytes we defined are going to be inputted into here and that will determine which neopixels we're going to light and what color we're going to light them in so first of all we're going to check the right front which if you recall is bits number seven and six so we go through to three different cases first of all with the first bit being high in the second bit being low that means we're moving that particular motor forward and we want to use blue to indicate forward so we do a set pixel color and we Define which pixel we're doing the right front pixels and then we're going to do pixels color and then the LED blue is the color we've defined zero zero two five five over here if we're going in reverse then it's the opposite thing the high bit will be a zero and the second bit will be a one and so we're going to move in reverse and we do the same thing except this time we set it yellow to indicate we're going in reverse any other condition which would be either zero zero or a one one which is actually a breaking condition although we're not using that but they both indicate that the motor would have been stopped so in that case we're going to set our neopixels red now one important thing to note is that we're going to go through this and do this for all the different Motors but this doesn't actually set the color at this point at the very end you need to do pixels.show so after you set the colors nothing will change until you do pixels.show neopixels retain their previous state until they are refreshed with this okay a couple of other neopixel functions written over here we've got the LED turn off and this just turns off all of the neopixels so we do a pixels clear and again we have to do pixels.shell or else this will be an effective then we do an LED all stop is the other one that I created and this just turns all of the neopixels red and we would do this in the case where we're just stopping all the motors if we don't do that the neopixels just retain the last state that they had so we're going to clear all of our pixels set them all to red and then we'll do a pixel shell now in setup there's only one thing that we need to do for the neopixels and we need to initiate them so we do pixels.begin here and then we'll go through the loop and the loop is basically the same as what we saw before with the mechem test with the addition of some neopixel things so at the very beginning we're going to stop all the motors we're going to put the LED all stop function on so that'll Turn All the Lights red delay for about 3cm seconds and then we're going to go forward we do the same thing we did before with moving the motors forward and we passed the mech straight forward constant we also now will do LED motor status and packs it the mech straight forward and that will light up the LED in this particular case blue because we're going forward will run for the time delay which I believe I defined as being a second and then we'll stop the motors and do LED all stop which will turn all of them red and delay for half a second and we go through all the various iterations and do exactly the same thing and so this is basically just in addition to the previous sketch with the neopixels let's load it up and take a quick look at it running all right I've got everything hooked up and ready to test as you can see I've mounted my LEDs onto a second solderless breadboard along with the logic level converter and the car of course is still up on blocks and it's still connected with the ethernet cable because I've been doing tests on the floor as well so all I need to do is plug the USB in to get this thing going we start off all red and blue for forward green for reverse and then we exchange colors to indicate the direction of the motor now of course in the final design I intend to mount the LEDs very close to the motor that they're driving so that at a glance you can see which direction the motor is spinning in and learn a little bit more about mechanum Wheels [Music] well after putting everything together with my neopixels and my Motors and my ESP now that I'm going to be using for communications I found out that I had an issue there is a conflict between the espnow library and between the Adafruit neopixel library and while there are ways of resolving that conflict I resolved it in the simplest method possible I used a different neopixel Library I chose the neopixel bus Library by Michael C Miller and I'm going to be using that in the final design of the robot so I just wanted to let you know that although we've done our demonstration with the Adafruit Library it's not the one that we're going to use in the final design so now that we've seen how all the various components in our robot work it's time to actually put it together now I showed you the chassis that I'm using earlier in the video and you may indeed be using the same chassis but you're probably using a different one so I'm not going to dwell too much on the hardware assembly but I will show you how my final build looks electrically we have already seen the circuit we've seen how to hook up the motors and we've seen how to hook up the LEDs all that's missing is a power supply we're going to need to have power for both the motors and for the esp32 slash LEDs and so we'll cover that in a few moments now as you're building the circuit permanently I used perf board I used a perf board for most of the circuitry and little tiny pieces of perf board to hold the LEDs and that's a good construction technique you could use it on a solderless breadboard but solderless breadboards are a little bit fragile for something like a robot that gets bumped around a lot one nice compromise is to use one of those circuit boards that emulate a songless breadboard to solder your components onto that so there's a number of different ways you could do that as well so let's go and take a look at my robot build and so here's the robot car assembled except it doesn't have its circuit board mounted on it and I just wanted to show it to you before I put the board onto it and also show you the circuit board now we'll start by flipping it over to the bottom and we'll take a look at the motor assembly I just wanted to show you that I've added a few capacitors over here and these are across the motors just to try to reduce some of the EMF from the motors when they're running now if we go on to the middle section of this car because it's got two layers the middle section seems pretty sparsely populated but there's a reason for that I've got these I've got these little sensors and these are the speed sensors that you can use for these motors along with the discs and they mount over here now I haven't used them in this design yet but I'm preparing to use them in an update to the design so I wanted to leave space for those another thing that's mounted on the main layer over here on the bottom layer are all these little LEDs and these are the neopixels the eight millimeter neopixels and on each one of them it's a little hard to see but there's a little capacitor across the power leads and that's kind of a requirement for the neopixels there's also a neopixel mounted here in the top along with a power switch and the power switch runs down to a voltage regulator and if you look inside there it's a little hard to see you'll see the voltage regulator now that's a buck converter that I'm using and I toyed between using a buck converter and a load Dropout analog voltage regulator I was concerned the buck converter might have a bit too much noise on the line for the esp32 but it seems to be fine I can always replace it but it's mounted under there and so it provides the five volt Supply and the two batteries the 18650s will mount in holders over here on each end now if we look at the top we can see a lot of the wiring these are all the LED wires the wires came from the LEDs and over here we've also got a number of wires these are wires that came from the motors and they're going to go through the circuit board which is going to mount over here I've left this end over here free and there's enough space to add another circuit board or even a single board computer so again this design can be updated now uh let's just take a look at the circuit card itself now here's the card that I wired for it and it's just done on perf board it's not a difficult wiring job we've got of course the esp32 and the two motor driver chips and they're all in female sockets so they can be removed and replaced this is the logic level converter over here and these are the connections that go to the LEDs and the daisy chaining is already done on the board over here and I've got them color coded so I know which way they go this is the input for the power and so I've got the the high voltage the battery voltage the ground and the 5 volts over here this connector is just a ground connector and I've got a few ground wires mounted over here on the robot to go over to there so that we can also ground the chassis to perhaps reduce a bit of electrical noise and the only thing that you'll notice on here that you didn't see in the original circuit is a number of capacitors and these are just filtered capacitors I've got them across the motor voltage line on each of the motor drivers another one across the motor voltage here and these two are across the five volt line and I wired this up this by hand is quite a simple wiring job really it only took maybe about two hours and you'll note I used different gauges of wire I used a heavier gauge for the power and ground as well as for the motor connections and then I used a 30 gauge wire to do all the logic connections and so that went together pretty easy so all I need to do is now Mount this board onto here and I'll have completed the construction of the robot car now here's the schematic of the power supply that I used for my robot and as you can see it's a pretty simple power supply I use two 18650 batteries in series and that provides enough power for my Motors I also feed that into an lm2596 buck converter that I've preset for a 5 volt output and I feed that 5 volt output to the 5 volt pin on the esp32 now you could use the same power supply I used you could make a few variations on it such as using a linear voltage regulator instead of the lm2596 however you'd have to use a low Dropout linear voltage regulator because a regular one like a 7805 is going to drop out too soon and you won't get a lot of battery life a simpler power supply might be just to use four double A cells to power your Motors and then use a 5 volt USB adapter to power the esp32 so there are many options you have for powering up your robot so now that we have the car constructed we have to turn our attention to the remote control and our remote control is based upon a really neat esp32 module it's made by a company called lilygo and it's called the TT go t display this module has an integrated TFT display as well as Provisions for charging a lipo battery and we're going to be using both of those features in our design now this is a great module and you can get it at Amazon you can also get it at Alibaba they have a number of really great modules at Lily go however one thing they don't seem to have is a lot of great documentation the documentation is very sparse for these modules however there is an excellent source of documentation for this particular module for the TT go module and I want to point that out to you it is another YouTube channel called volo's projects and he has done some amazing things with this module he's created little games little calculators all sorts of designs in his style of explaining how the code works is absolutely excellent so you can learn a lot about this module by watching the videos on his channel and I'll leave a link to his channel in the description of this video so let's grab our TT go display and start building our remote control in its native form our joystick is going to be reading numbers from 0 to 255 on each of the potentiometers however to make things easier we're going to convert that range from a range of negative 255 to positive 255 for both the X and Y axis potentiometer this will make our coding a lot easier so in this scenario when the joystick is in the center position both X and Y will be equal to zero and all Motors will be stopped if we push the joystick forward our y value will have a positive value whereas the x value will remain at zero and this is the max straight forward operation we'll be using pulling it backwards will cause the opposite effect X will still be zero and Y will be a negative value and this will be the max straight backwards if we push our joystick to the right the x value will become positive while the Y value will become a zero and this will be the sideways right operation sideways left is the opposite in which the x value is negative and the Y value will remain at zero if we put our joystick up diagonally at a 45 degree angle both X and Y will be positive the mech diagonal 45 will be used note that we can get angles other than 45 degrees by changing the ratio of the speed between the X and the Y motor in a similar fashion if we push it off to the other side x will be negative and Y will be positive and this is the mech diagonal 135 constant pulling it down to the left will cause both X and Y to be negative and will invoke the mech diagonal 225 constant and finally pulling it down to the right will cause a positive value for x a negative value for y and we'll call the mech diagonal 315 constant now here's a chart that summarizes all of the various joystick conditions and the constant that we'll need to call within our code we can use this chart when we're developing our code now this is the TT go module that we're going to be using for our controller and it comes in this nice little plastic case and I'm going to actually use the plastic case as the case for my controller the module comes unsoldered so they give you all the DuPont pins that you need to solder onto it it also comes with a connector wire for the battery and that's a good thing because it's very tiny jst connector that they have is a bit hard to find and so you can use that to connect to the onboard battery now they pack a lot of different things into this module over here you can see the display takes over most of the surface here there's also a couple of push buttons and these are connected to two of the gpio pins and you can use those just as part of your circuit this is the USBC connector of course for both power and data this is a reset button on the side over here and it's very convenient place for it now if you flip this over you'll see there's components on the back over here as well this is the connect for the battery and down over here it's difficult to see but one of these components here is an LED and that's the built-in LED so when you have this on a subtle as breadboard it's a bit difficult because for one thing this battery connector prevents you from going to insert the thing all the way down on the breadboard so you'll have to put this module at the very edge of your subtle as breadboard and the built-in LED will then be facing down so they did pack a lot of things onto this and I'll give them credit for that now it comes already with a demo software on it so let's just hook it up right now and take a look and it says TT go and we get a couple of colors and then we get a menu I'm going to pull the plastic protector off so we can see that a little better and as you can see the left button does a Wi-Fi scan so we'll do that and we'll scan our Wi-Fi networks and here's all the local Wi-Fi networks that can pick up the other button is a voltage measurement and so that measures the voltage now right now of course that's the voltage from my USBC but you can measure the battery voltage as well and you can use those sketches as examples of course for your own sketches but it's a really neat little compact module it's very well priced I picked mine up on Amazon they also have them in Alibaba and it's going to be great for building our remote control our remote control is going to be constructed around the Lilly go TT go t display this is a small esp32 module with a lot of features to it it has a 1.14 inch IPS display at the bottom we can see that it has a USBC connection for both power and data there's a very convenient reset button on it and there are two push buttons internally connected to two of the gpio pins on the esp32 kpio0 and dpio35 if we flip the board over we'll see that there's a battery connector on the bottom for a lipo battery the charging is also built into the board the board also has a built-in LED that's in the corner of the board on the bottom the Lily go TT goatee display is based around an esp32 240 megahertz 32-bit MCU there are two versions one with a single core and one with a dual core the two versions have either four megabyte or 16 megabytes of flash Ram both versions of 520 kilobytes of static Ram it has of course Wi-Fi and Bluetooth capability and its most prominent feature is an st-7789v IPS display which is internally connected using the SPI bus the battery charge current is 500 milliamps which is rather high for some small cells you'll need to use a battery that has a capability of at least 800 milliamps in order to use this device our hookup is very simple in addition to the TT go module will require a standard analog joystick the ground of the joystick will be connected to the ground of the TT go module the joysticks VCC will be connected to the 3.3 volt output of the TT go note that on many joysticks this is labeled 5 volts but as these are just resistive elements they'll really work at any voltage the joysticks x-axis output will be connected to gpio pin 32 and the joysticks y output will be connected to gpio 33 note that on some joysticks the X and Y axis have been reversed so it might be possible that you'll need to reverse these two connections you can also do that just in the code and finally the joystick switch output will be connected to gpio pin 27. and this completes the wiring of our remote control and here's the controller that we're going to be building as you'll notice I've got mine mounted in the plastic case that the TT go module came in I just cut the lid off the plastic case and found it to be a convenient way of doing it I've just wired it up on perf Board of course the wiring is very very simple for this it's just simply connecting a joystick up to a couple of the i o pins on the TT go module and that was it I also added the battery and if we flip it over you can see the battery inside there and that battery is connected to the battery connector on the TT go module through this little slide switch over here so I can turn the power on and off now of course I've got the module mounted so it's sticking out over the edge and that allows me to get access to the battery underneath here I also can see the built-in LED although it serves no real function in our remote control thing and here of course are the USB connection I can use to both power and add data to it so so it's a pretty simple piece of construction and it's going to be great for controlling our mechanum wheel robot so now we've got all of our Hardware built both the robot car and the remote controller it's time to focus now on the software on the sketches that we're going to need to run in order to make everything work but before I can show you the sketches for the robot car and for the controller we're going to need one piece of information and it's going to be a unique piece of information to the two esp32 boards that you're using and that is we need each board's Mac address a Mac or media Access Control address is a unique address assigned to every Network device on the planet and your two esp32 boards have these addresses we're going to run a very quick script so that we can get the MAC address because we're going to need these the controller is going to need the MAC address of the robot and the robot's going to need the MAC address of the controller and this is so the ESP now protocol can set up a peer-to-peer Network between the two so let's look at a quick sketch that we can run in order to get our Mac address and then we'll move on to the sketches for both our robot car and for its controller here's the sketch that we're going to use to get our Mac address and as you can see this is a pretty simple sketch I hardly even have to scroll over here essentially all that we do is we include the Wi-Fi Library we set up our serial monitor in the setup we put our Wi-Fi into station mode and then we print the MAC address it's really as simple as that so everything runs in the setup and there is nothing in the loop and what we'll get as a result is the MAC address itself so I've already run this so let's just go and take a look at it now I know the font is very small here I apologize for that but the MAC address is this address at the very beginning over here and I've actually got this already done so I've run it and put the MAC address for both of my esp32s into a text file so that I can get at it very easy when I code because you're going to need to use this of course in the final code and each unit it's going to have to carry the other unit's Mac address so this is the MAC address for my car esp32 and this is the MAC address for the esp32 that I'm using for the remote control and of course if one day you decide to exchange your esp32 for another one you're going to have to do this again because the MAC address is unique to the esp32 now here's what we're trying to accomplish with the sketches for both the controller and the car the controller and car will communicate with each other via ESP now the controller will be sending out data for the X and Y positions of the potentiometers inside the joystick it'll also send out the switch state of the joystick I.E whether it has been pressed or not the car will return data to the controller and it will return the motor mode byte that's the bite we've been working with to tell us which directions to turn the motors the mechanum mode there are several different modes we can put the car into and it'll return back the mode it's currently in it'll also return back data for all four of the pwm signals that it is sending to the motors and this will be sent to the controller so it can be displayed on the display so now let's go and take a look at those sketches now we'll Begin by looking at the code that we're using for the robot card as you might imagine the code has gotten to be quite long in order to make it more understandable and even more importantly easier to modify for your own purposes I've divided the code up into a number of different files other than the main Ino file this is a technique that you can use with the Arduino IDE both the current one and the previous one with the current IDE you hit these three dots in the corner and go to the new tab give your file a name and it will create a file with that name and an Ino extension and it'll keep it in the same folder as your program file the compiler knows this file as part of the program and it'll compile it for you you can also Force the order of compiling by alphabetically naming your file so you'll notice that I've got these all alphabetically named starting with an a then a b etc etc but this file here of course is always processed first because it's the main file now I'm not going to go over every line of code with you we already have a very long video and it'll be twice as long if I did but we've seen a lot of this code anyway and there's a lot of repetition over here first I'll go over what all these different files are this of course mech-robot.car.ino is the main file and we'll go over that in some detail in a moment the next file is the car functions file and we've actually seen pretty well all of this before these are the functions for both moving the motors and for setting the LEDs to the correct color and so this is basically a repeat of what we've done before the Callback section is part of the espnow protocol a callback is issued every time something is received or transmitted and it creates two different functions on data set and on data received and these functions are dealt with over here as you can see we don't do anything when we send data but there is stuff we do when we receive it and I'll go over that in a moment the mechanim functions let you know what mechanum mode you're in our car uses a number of different modes the standard mode is the one where you can go backwards forward sideways and at Angles and then we have different modes for all the different rotations and pivots this is the section with selects which mode that we are going to be in these final three files are the modes themselves mode 0 is the standard mode and this is the longest one and it's basically what we have seen before going diagonally or forward or backward or sideways mode one is a rotate mode so it's just basically a smaller version of that previous file and mode and the f file is modes two to five and these have all the different pivot modes inside them but these functions are basically the same they just call a different motor control byte and they also move the the y-axis and the motor is a little bit differently depending upon which mode you're in so let's go back to the main file over here now we start off by including some libraries the first three libraries you would be familiar with of course but this fourth Library you might not be and what this is is a watchdog timer Library I've implemented a watchdog timer on this now a watchdog timer is something that looks at your code and if it sees the code isn't responding after a preset period of time it'll perform an action in my case it'll restart the esp32 I've done this so that if the car happens to lose a signal or something goes wrong and it's still running it'll turn itself off and reset now we start off The Code by defining a timeout period and that's in seconds so I've got a three second Watchdog timer if it doesn't see a response within three seconds it'll reboot now over here we've just defined all the motor connections as we've done before the parameters for the pwm as we've done before the neopixels and the neopixel LEDs these are the colors that we're going to be using for the neopixels again we've seen all this stuff before we create a neopixel bus object which is how we work with this library and this is also where we enter the MAC address of the other responder which in this case would be the remote control now remember every esp32 has its own Mac address so this will be unique to mine you will need to change this in your code now this is a very important part over here now this is the data structure for both the received and sent data and this is how we communicate over ESP now so in receive data we've defined a structure that has the x-axis the y-axis and the push button switch because that's the information that we are going to be getting from the controller on the send one the transmit one these are the items we're going to send back to the controller to display on its display the motor mode which lets you know what the eight bits that we have to control the motor the mechanim mode and this tells us which of these modes the standard mode the rotate mode the pivot modes that we're currently in and then the pwm speeds of the four different Motors and this will go back to the controller so we can display it on the display and now that we've done all that we create a timeout value for the esp32 I've set it to 500 milliseconds and this last received time is this the marker that we set so that we can time that time of value these you've seen before the different bytes that Define the mechanum modes and uh here's the meccanum mode itself where we put it into whether standard rotate pivot right pivot left these are the values that this mechanim mode will have for those different modes some variables for the motor speed for the joystick values and for the push button and then we go into our setup we've got a Serial monitor set up just for troubleshooting of course in normal operation we don't use it and we also remark out all the serial print commands because they're inefficient if we keep them in there we set the esp32 up as a Wi-Fi station and we put it we disable the Wi-Fi sleep these are two requirements for ESP now this one isn't necessarily a requirement but if you don't do that you can have intermittent issues so I found this really helped a lot now we'll initialize the ESP now or register both of those callback functions so basically as I said earlier we have a callback function whenever we receive or send data and those are the functions in the B section over here we'll register our peer and add it then we go through the pin modes that our connections up as outputs the pwm frequency we've seen that before here's where we enable the Watchdog timer and we enable it to that timer which we've set to three seconds and true and what true is is it puts the Watchdog timer into panic mode and in panic mode it'll just restart if it times out and we're adding the current thread to the Watchdog timer you can monitor whatever we want but if we add a null value here it'll just monitor the current thread which is exactly what we want now these commands are for our neopixels it works a little bit differently than the Adafruit library but it's pretty simple we're going to begin and show and that'll clear the whole display we'll call a function called LED all stop which is a function inside car functions we'll go to that right now just to show you that and there it is and basically this is how we work with these LEDs we set the pixel color and we'll tell it what led and what color we're going to use and then we do a show and so this sets all of our pixels red so it's pretty easy to see how the work with that new neopixel library we stop all Motors as a function in there again we've seen that before and we'll delay for a second now inside the loop we'll check to see if we're still getting a signal so we set a variable called now which is the Millis value the Millis value is the number of microseconds that the processor has been running for now we take a look to see if the last Millis value and this one exceed the timeout and if they do the signal is lost we'll stop the motors we'll put everything into an error state but if it isn't we'll actually go through the loop we'll set the LED status to the mechanim mode value so that basically sets our status led to tell us which mode we're in we'll drive the car in this mode we'll take the data that we're getting right now the motor mode mechanum mode value Etc and we're going to assign it to these variables here these are the variables that are part of our structured data so this is what we're going to be sending back to the controller and then we're going to send that back to the controller we'll call this to reset the Watchdog time and let it know that we're still alive put a short delay and finish the loop so that's really the main functionality the car functions as I said you've seen these already these are basically just to control the LEDs and to control the motors the callbacks we'll take a look at now there is nothing that happens when we send data on this when we send data we just send it this callback is issued but it doesn't do anything when we receive data however it's a bit different first of all we're going to check the length of the data if it is a zero we haven't received anything there's some kind of a problem so we'll stop everything put everything in them into an error mode and set the joysticks and switch back to the default positions however if we have got data than what we're going to do is pass that data on to our local variables over here and you can see over here I've rammed out a number of Serial prints that you can use when troubleshooting just to make certain you're getting data back from your controller now we're going to check this the mechanim mode to see if that button's been pressed and if it's true we're going to toggle the Macadam mode to the next mode so every time we press the joystick down we'll change modes and then we update our counter for the last receive time so that this variable at the beginning has something to work with now mechanim functions as I said just figures out what mode we're going to be in so this is the toggle mechanum mode and it'll toggle through all the different mode values there are from zero to five drive mechanum mode will tell us what mode value that we're in right now so we can go to the correct function to drive the motors and all those Motors are all those functions excuse me for the motors are over here so we're just going to call a motor control mode zero for example if the case is zero and we're going to pass it to there and for motor control zero we have to pass both the X and Y axis but everything else just needs the y-axis because for the rotating pivot modes the x-axis has no function so again it's a pretty complicated bit of code but when you divide it up like this it's not too hard to understand or modify so now let's go and take a look at the code that we're going to be using for our controller and now we'll look at the sketch for the remote control and as with the sketch of the car I've divided it up into a number of different files we have the main files remote functions which really only has one function in it called convert joystick values and that just simply converts our joystick values to the positive to negative 255 that we talked about earlier the callbacks of course are the ESP now callback functions graphs are the two different graphs that we have on our display our display can have two different graphical displays the first one which I call graph motor speed is a display of bar graphs and it has four bar graphs one representing each of the motors the bar graphs will show you the speed of the motors and they'll change color from blue to green depending on which direction the motor is going in the background of the graph will be the color that indicates the mechanim mode we're in and that color will match the LED on the car now if we go down here down down down down we'll see the next one and that's display motor speed now with this display I have a little icon that's supposed to look like a car with four wheels the wheels will change color depending on what direction they are traveling in and the speed of the wheel will be written beside the wheel and the same deal with the background color it will be changed to the same color as the LED that is on the car now this screens one only has one function in it called splash screen the splash screen is displayed both at the very beginning when we boot up the remote control and if we have any error conditions so we're going to send it both a message to display and an error state which we'll talk about in the moment and if the error State happens to be high and we're in error that will change the color of the splash screen to red now let's go and start with the first file you're going to need to add a library for the TFT display it's this Library over here and you can get that in your library manager by typing in TFT underscore espi and install this TFT underscore espi by bodmer into your Arduino IDE otherwise the libraries are all pretty standard the SPI library of course is being used because the display internally is connected using the SPI bus now we Define the inputs for the joystick and also the connections for the internal push buttons on gpio pin 35 and xero now there's an object we create for our display over here for our display and Sprites Sprites being the area that we're writing into on the display these are the colors we're using on the display note that these aren't RGB but they are a different method of displaying colors I talk a bit more about this in the article it accompanies this video in case you want to change these colors the MAC address of the responder in our case the responder is the car and this is the area of code that you will definitely need to change for your operation to put in the MAC address of the esp32 in your own car the two data structures are the same as we did before in the car except it's backwards R receive is the send that we had in the car and our send is the receive so we're going to receive data from the car the motor mode which is that byte that tells us which way the wheels are moving mechanim mode which tells us whether we're in standard mode rotate or one of the pivot modes and then the speed of the four different Motors we can use that for our displays and on our sent data we're sending the X and Y axis values from the potentiometer converted from values to negative 255 to positive 255 we're also sending the state of the push button switch so we know if it's been pressed now the esp32 sorry the ESP now stuff that we've seen before is all over here the peer information the byte for the motor mode here's a variable for the mechanum mode for the pwm speed through the joystick values for the joystick push button now here's our connect error variable we set it low normally but if it goes High we are in an error State and connect status is a string that we are going to display on our splash screen and we start off by saying we have no information and this is the display select byte and basically if it is at zero we're going to display the bar graph one we're going to display what I call the speed display which is a display that has a little car icon now here are two interrupt service routines one for each push button switch because pushing a switch is going to create an interrupt and all the switch needs to do is tell us which display we're selecting so if we press the top switch we're going to select that to a zero and display the display with the four bar graphs if we select the bottom switch we'll display the other display by setting display select 201 now we'll go into setup serial monitor pretty standard we're going to set a pin mode for the switch pin and the two built-ins and we're going to use the input pull-ups and so basically they'll always be held high until their respective switch has been pressed attach those interrupt handlers notice that we do it on falling so that when we go from high to low we'll trigger the interrupt and then the esp32 setup as we did before initialize it as we did before only this time we're sending the status over to our connect status and connect error we're setting those and so that can be used to display things on the screen so something does go wrong we will get an ESP now error and it'll be a red screen because connect error will be high register the Callback functions we've seen this before register the peers this is all the ESP now stuff we've seen before we'll select the analog the digital resolution of 12 bits as opposed to the default 10 so we can get a bit more accuracy out of it here's where we initialize a TFT display and we'll set its rotation into landscape mode we create a Sprite and a Sprite is an area on the display that we're going to be working with and ours is the entire 320 by 170 display and now we go and display the splash screen so we'll call the splash screen function the one that lives in the screens over here we'll pass it our connect status and whether or not we're in an error mode and that basically whether we're in an error mode will change the background color of that screen we'll show that for two seconds and then we'll change connect status to waiting for car we'll end we'll display everything again so that displays for two seconds as well and over here is something you might find odd but this is just to make the display not flick quicker when we first start up we set our connect error to high now that actually isn't true of course generally if the car is already on that should be a low but it doesn't matter it's only going to be one cycle of the loop and will prevent us from jumping into that screen and then jumping out of it when we find out the car isn't actually there now in the loop we kept that connection status if it's low it means everything's okay so our display we're going to select which one we'll take a look at the display select value and display either the graphic or the car one accordingly we'll get our joystick values and convert them with the converged joystick values function that we looked at over here and we're going to finish that now the else over here is for this so if the connect status was high where we have an error remember when we come in off of setup we're going to have an error we're just going to set our splash screen up with the connect status we'll set it high so that it's red because the connect status will basically say that the car hasn't been found yet and we'll set these joystick accesses to their standard default values of in the middle now after that in the loop for both of them we'll go and check the status of the switch and so basically this is the joystick switch if it has been pressed then we'll set the state to true if it hasn't been pressed we'll set it to false now here we format the data that we're going to send out to the car so this is our structured data here and we'll send it to the car here and then at the very end of the loop we add a short delay the period of the delay depends on whether or not the joystick has been pressed if it hasn't been pressed we're going to delay for 50 milliseconds but if it has we're going to delay for 200 and that's a form of debouncing it now as I said remote function simply has a convert joystick values and in convert joystick values you're going to see two different values remember we're going from 0 to 40 95 because we have a 12-bit converter 2200 and 1800 these are the thresholds for a zero so anything between eighteen hundred and twenty two hundred is going to be considered a zero and this is because joysticks aren't exactly perfect so we can't expect it in the middle to be at the actual value that we want now you can of course if you want change those values you can make this eighteen hundred higher and the 2200 lower to reduce that range and maybe get a bit more movement out of your joystick I found these values worked for me but you can play with them yourself now let's look at the callbacks in this case we actually have one when we send the data we didn't in the car but we do here we take a look to see the status to see if it was a successful send and if the status is successful great we'll keep connection error at low and the connect status is car found but chances are we're not even displaying that screen at the point at this point anyway however if we don't get anything that says that this connect status was successful that will print car not found and set connect error to high so in the loop when we go and check that we're going to run the the section of the loop which brings up the splash screen displays car not found and passes the connect error of high which will turn our splash screen red now here's the Callback function that's executed when the data has been received and there's not really much to do we basically just get the data and pass it to a number of different local variables over here now these are the functions for the two different graphs as I said we have display motor speed and at the top over here we've got graph the motor speed now this basically just goes through we'll set the background color depending on to what the operation mode is and so that color is going to match the color of the status LED on the car and then we're going to fill the Sprites with a couple of rectangles this basically draws our screen we'll draw the text through the screen this routine over here and this is actually some code I got from Volvo's project is is quite easy to do and I just modified a bit this this displays the labels on the left sidebar and it's a it's an easy way of doing it you could also do it discreetly if you want here's a text for the bottom in this case is the bar graph so we're doing rfl and LR to indicate our different Motors and the bar graph values we're going to get over here and we're going to map those results and then I want to set the bar graph Colors by the motor Direction and so we'll get the motor Direction and we'll also fill the rectangles according to the bar graph value and so that actually moves the bar graph up and down so that's pretty cool we do that for all four of them over here at the very end when you finish these commands it's important to do this you have to do a Sprite put Sprite and push it to the corner because we're going to do the whole display and we're going to paint the display motor speed does a similar thing again we set the background colors over here we set up a couple of of different rectangles and that just to basically look like a car we'll get the motor speed values again we'll set the wheel Colors by motor Direction This is similar to what we do with the bar graphs except we also now have a red color and if it's red we'll also set this value to say off it could say zero but I thought off looked better if you'd rather have zeros you could just eliminate these in the four different ones we have right front left front right rear and left rear and then at the end of that we'll display the speed values we'll draw a string right beside all of the wheels and we paint the display now screens over here just basically uh is the splash screen and the splash screen will get the message at an error State and basically if the error state is high we are going to make everything display color 6 which is going to turn it all red and uh well basically just set some text on it and over here it's the same thing except display color 2B which is green and we set some text on the display and at the very end whatever we've done we push it over to the display and so that's basically the code for our remote control again you can go and modify it you could add more functions more screens Etc if you wanted to but I'd suggest you start off with it this way so now let's load everything up and see if everything works and so everything's been built the wiring's been checked the code has been uploaded to the esp32s on both the car and the controller All That Remains right now is to turn everything on and give our robot car a test drive okay I'm ready to test the car I've got it on the workbench it's up on blocks at the moment I've got both the remote and the car turned off I'm going to turn the remote on first and you see it goes through its splash screen waits for the car and it says the car isn't found which of course makes sense because the car isn't on at the moment so let's turn the car on and the car boots up its top light is light blue which is also the same as the background on the remote right now and we're in standard McKenna mode and we're in the graph mode so if I move it up we'll go forward to move it here we'll go backward we'll do those sideways and to the other side and you'll notice that the lights on both the car and the display colors on the graph match each other now I can put the display into the other mode and we can lock it over there and we can see the various speeds of the wheels those sideways go and see that we can also change mode so over here I'm now in rotate mode and you'll note that the car's LED on the top also change the same green so in rotate mode to be going opposite directions as indicated here we'll flip through some of the pivot modes through the front pivot mode for example if we change the graph mode here you can see only two of the motors are driven in front pivot mode here's the pivot rear mode and we're back to the standard mode again now if I turn off the remote the car status lights goes red and the other LEDs are Violet and that indicates I've got no connection and if I connect the remote back up we're back in business so it looks like the car is working and the next test of course would be to put it down the ground and drive it around okay I've got the car on the floor I'm going to put it through some of its basic moves so we'll just go forward now we don't have a lot of areas so we'll have to do it slowly and reverse let's do a sideways movement the other side and we'll bring it back let's put it into another mode now we're in rotate mode we're going to rotate the other direction as well now here's the right pivot let's do a left pivot the front pivot and of course the rear pivot so we'll put it back into standard mode maybe rotate it a bit back all the way to standard again and it looks like the car can go through all the basic motions and of course if I had more space I could really have a lot of fun with it but as you can see we seem to have a working mechanim robot car so as you can see a mechanon wheel robot is both a fun project to play with and an educational one to build and I do hope that you take the time to put one of these together now this is the end of the video but it is certainly by no means the end of this robot project I've already left space as I've shown you for speed sensors on it and there is some space on the front of the chassis that says dying for more Electronics or maybe even a single board computer so I'm sure you'll be seeing this robot again here in the dronebot workshop now if you want to build the robot that I built today or if you want to build something similar to it you'll find the information that you need plus all the code that you need in the article that accompanies this video on the dronebotworkshop.com website and there's a link to that right below the video now while you're on the website if you haven't yet please consider signing up for my newsletter it's not a sales letter it's just my way of keeping in touch with you to let you know what's going on here in the workshop and if you want to discuss this project a great place to do that is on the dronebot workshop forums you'll find a dedicated thread to this video there's one for every one of my videos plus you can discuss General topics with a bunch of like-minded individuals who are happy to answer your questions and you might even be able to answer a few of theirs so it's free to sign up for the Forum as well and finally while you're in a signing up mood if you haven't done so already please subscribe to the YouTube channel I make videos about electronics and microcontrollers and about Little mechanum Wheel robots and it's really easy to subscribe just hit that red subscribe button and also click on that Bell notification and assuming that you've enabled notifications on your YouTube you'll get notified every time that I make a new video so until the next time please take care of yourself stay safe out there enjoy your mechanim wheel robot and I'll see you again very soon here in the dronebot workshop goodbye for now bye [Music] [Applause]
Info
Channel: DroneBot Workshop
Views: 61,475
Rating: undefined out of 5
Keywords: mecanum wheels, mecanum wheel robot, esp32, esp32 projects, esp-now
Id: dZttHOxIoek
Channel Id: undefined
Length: 86min 38sec (5198 seconds)
Published: Sun Dec 04 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.