MegaMUX - 32 Channel Multiplexer Board and Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

You’re a good teacher Sean, keep it up. Have you ever done a video working with optocouplers?

👍︎︎ 2 👤︎︎ u/alifeinbinary 📅︎︎ Jun 07 2018 🗫︎ replies
Captions
hey everyone how's it going my name is Sean Hodgins and welcome back to my channel so usually when I'm doing a new project that involves circuits or components that I've never used before I'll make a small demo circuit board with just that component to test it out so that I don't build some giant thing that doesn't end up working and it's usually a good thing to do so my upcoming project is no different I'm actually going to be doing a project that involves sampling over 500 analog sensors so I found this cool multiplexer that actually does 32 channels to one so in the future project I'm going to be using two of them to do like a matrix but right now I designed this simple board that just takes that chip and allows you to collect data from or send data out of 32 other channels from one line on the microcontroller whatever you're using it's just gonna be a really simple quick project just to test it out but I think people may find it useful let's go [Music] so as you can see this is called the mega MUX that's what I called it anyways the way it works you have five digital pins connected to your microcontroller and then the pin you want to control for the 32 inputs or outputs and what you do is you set those five pins either high or low and that selects which pin is selected on this chip so theoretically you can connect up to 32 things and have it be read by just one pin on the microcontroller of course it does take more than just one pin I think this one requires eight plus the pin you're reading so you need eight to control the data lines and then the one to read in then it saves you another 24 on the microcontroller so if you're trying to like I said read 32 sensors on one pin this is how you do it so I'm gonna make a quick program wire this up and test it out okay so basically what I have put together here is I've got an Arduino and I've got the mega mocks connected to 32 LEDs 69 each side and they're all going through one pin and one single resistor into one pin on the Arduino and then I've got the rest of the pins which I'll show you in the program connected to the Arduino to select which painters output so let's go through the program I'll show you how it works okay so to start off we've got the pins for the selection so selecting which pin on the MUX between 1 and 32 is going to be selected and tied to the output the Arduino so digital pin 13 12 11 10 and 9 Arduino are connected to those they're labeled as a 0 to a 4 on here I've called them s then we've got chip select which we're just gonna leave low for this program but if you have multiple ones you can actually choose which one you want to change so if you have multiple muxes you don't want to change them all if they're tied to the same digital pins which is pretty cool we have WR you have to set that low to be able to change the pins and then when you set it high it latches them all so they can't be changed so no matter what you do it'll be the same then enable that's just enabling this chip you said it low it works you set it high it doesn't do anything and then in pin that's the input or output that we're using in this case because we've got the LEDs we're using it as an output so right from the get-go we set all the pins low just because when we set them all to outputs and low and we enable a serial so we can debug if there's any issues which there won't be from there I've made a subroutine called pin select which just takes a number between 0 and 32 and it sets WR low which is needed to do to write the new configuration then it has a for loop for the 5 different to the five pins so state one this little function called bit read in Arduino will take the integer that you have and it will read the bit of this integer in this bit starting from the least significant bit to the most significant bit so if this for loop is zero this is gonna read the first bit which is going to change the first pin it's going to read all five so this says one if it's integer of one it's gonna be zero zero zero zero one if this is 32 or 31 I should say it's gonna be one one one one one and that is going to change the state of the multiplexer and then after that state has changed we set W our high and when we set that high that latches all the pins it's good to go and it will output and then in the for loop we run this subroutine inside of a for loop from 0 to 31 so it's gonna pick it's just gonna cycle through all the pins it's what's gonna do is it's gonna select the pin it's gonna set that pin high so the LED goes high and it's gonna wait 100 milliseconds then it's gonna set it low again so if we plug it in and we program it okay now it's dimmed but you can see it's cycling through all the LEDs and if we open the serial monitor you can see that it's displaying the binary output just based on this little loop we have here and you can run these really fast if we change this to 100 milliseconds to 10 which means it'll take 20 milliseconds to do all of the lights then you get a really fast light display and you can select any one at any time how cool is that so let's throw some photo resistors in here and we'll measure a couple them I don't know how many I have but maybe I'll do like 16 and see what happens okay now managed to scramble together 16 of these photo resistors I've got them connected in a voltage divider so I modified the program slightly and now it reads the analog voltage of one side of the 16 of them and I'll go through the program so again just like last time same inputs all this stuff this is going to be an input because we're reading the analog voltage of the voltage divider so now we have this as an input that's what's different and we're not doing any averaging or anything so it's gonna be really really noisy so now everything is the same except we're doing an analog read and we're just printing it out so I've got a program down here now so if we look at the numbers they're not too amazing they don't really mean much right now but they're all taking in light and it's going through each one of them displaying the number so like 0 to 15 it's displaying the analog read of each one so if we go to the serial plotter which is a interesting tool so we can see lots of noise looks really noisy it's just going through them some 0 16 so if we cover the first 3 you're gonna see a pattern as it goes through them the first 3 are seeing a shadow right now if we move that to the last 3 you'll see looks the same but now it's at the end of the cycle and I could put like a step in there so you can see where the cycle begins and ends but we're just demonstrating right so it works and this is exactly what I need you to do so pretty cool glad everything's working which means I can move on to the new project so as usual this project this small simple project is open source so if you would like to recreate it or use these boards for your own testing they'll be available on github and I'll probably even have a link to my PCB waste or where if you order them through there it actually gives me like a percentage of the sale or something like that it's kind of cool so you can find that down below and also I have to give great thanks to my patrons on patreon they will be receiving one of these boards as well as a few other boards that I just ordered and that's one of the benefits if you become a patron you help me do these projects the simple ones the big ones all of them I can't thank you enough so anyways everyone as usual if you like this video hit that thumbs up and be sure to subscribe so that you can see what project is coming up it's really cool and I'm gonna be giving some hints to my patrons as well they'll actually know exactly what it is because I'll tell them so anyways everyone you know the deal be good have a good day [Music]
Info
Channel: SeanHodgins
Views: 24,492
Rating: undefined out of 5
Keywords: SeanHodgins, sean, hodgins, seanhodgins.com, timelapse, diy, make, build, electronics, arduino, raspberrypi, 3dprinting, idlehandsdev, pcbway, circuit board, open source, multiplexer, analog signals, analog, learn electronics, pcb design, kicad, oshw, open source hardware, hackaday
Id: e4h7akFXovM
Channel Id: undefined
Length: 9min 53sec (593 seconds)
Published: Wed Jun 06 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.