Previous Blog |
---|
Project R.A.G. - Blog #6 - Mechanical Build P1 - Robot On Rails |
Blog #7 - The Mainframe - P1
1. Introduction
Hi! This will be my 7th for the 1 Meter of Pi - Design Challenge. In the last blog I covered the first part of the main mechanical build where I built the rail system on which the robot will ride on. That blog is linked at the top and at the bottom of this blog. For this blog, I will focus on making the enclosure and surroundings for the "main box" which I nicknamed The Mainframe because this box will hold the main computer for this project, the Raspberry Pi 4. All other modules will be connected to this box, but I'll get into my idea now.
2. Idea
To explain my idea for this part of the project, let's take a look at the diagram above. This is something similar that I showed in some of my previous blogs, but some of the things & ideas changes a bit, so this is my final setup for the main box. Let's first take a look what will be outside the box. We will have 5 separate modules, of which, 2 are completed for now and one of them is the Enviro Hat Mini, and 2 independent power supplies. Because I will have motors on both the 5V rail and on the 12V rail I thought it would be better to go with 2 supplies, rather than use a buck/boost converter.
We can see that both power supplies are connected to something I called a 5V/12V PSU switcher. My idea was to have a small circuit there which would switch automatically between those 2 power supplies if one went out. I want to use the 5V power supply to power the Raspberry if possible, because I don't have to drop down the voltage twice, and lose on efficiency, but, if the 5V PSU goes bad, I would still have the 12V system which can power the Raspberry and everything else except the Robot Subsystem (We can still have all of the sensor data, lights & watering).
Besides that we have the breakout board that is connected directly to the Raspberry, this will be essentially a board with all of the needed wires coming out of it. The connection is much more secure when we have a board like that, rather than having all of the wires individually plugged in one next to the other. This is the board in question.
The I2C breakout board will be just a convenient way to connect multiple I2C slaves to the Raspberry, while I will be using a single 4 channel relay module. My plan in the beginning was to use 2 of the 4 channel modules, but I've reduced the overall number of modules by combining the functionality of some into single modules like we have the Sensor & Light module or the Water & Rail module. As you can see by looking at the diagram, 4 channels will be the perfect number that we will need.
3. Plan
There won't be a ton of design work like in some of the previous blog, but there will be a need for a lot drilling and tapping. For all of the modules I will be using the 3D printed connectors I covered in my second blog for this competition: Project R.A.G. - Blog #2 - Strapped In For Launch - Connectors . To not mess up along the way while working, I decided to a bit of color coding since I already have different colored filaments. For the 12V systems power supply connectors, I will use yellow filament, while for the 5V system I will use white. Same things goes for the communication protocol, for I2C I will use yellow filament on the connectors, while for the serial I will use white. I may add additional colors for motor connectors and stuff like that, but I will look into that when I get to it.
The breakout board will just need 2 sided perfboards and a few pin headers and a bit of soldering to make it work, same goes for the I2C breakout board. As for the PSU shifter circuit, I'll cover it's design in the next section. Besides that, I only have a few mounts for various components to design and assemble the 12V power supply. I will go for the same style as I did for the 5V PSU:
4. Design
To begin the design process, I will start with the enclosure. This of course means that we will have some 3D modelling to do, but this time, nothing complicated and not a lot. While I have all of the connectors designed that I will be using for this build, there will be a total of 10 of them on this box. To make it easier to know what is what, I decided to design small panels that will go before the connectors with signs as to what connector goes to what Subsystem and what is the connector designed for, is it power or data. Another thing I need is a mount for the Enviro Hat Mini. This box will probably get more features in the future, but these are some of the essential things that we need for the first time assembly. To design these components I will be using Fusion 360 and for printing, I will be using my Ender3 Pro and printing everything out in PLA. For slicing I'm using Cura 4.6 currently and will be printing everything you will see at standard settings meaning, 205C nozzle, 60C bed, 0.4mm nozzle, 0.2mm layer height. You will find the link with all of the 3D models that are needed for this part of the build at the end of this part. You are to download and do with those models whatever you want!
Enclosure
There will be 3 different types of panels for the connectors and 1 mount for the Enviro Hat Mini. Besides the models you can see below, I've also included blanks for all of the panels, without any signs on them, so you can customize them more easily. You will find STL and STP files for all of the models you see below, on the following link: Main Box 3D models. Let's get to designing.
{tabbedtable} Tab Label | Tab Content |
---|---|
Power In Panel | This will be the first out of the 3 panels. I will use this panel to explain the design process and just show the others, since they are the same thing essentially. The goal is to make a panel with signs for the 3D printed connectors I showed before. The first thing we need to look at is what connectors we want here, in my case, I want 2 connectors here, one for 12V and the other one for 5V. I had dimension the outside of the panel so that it can fit on the plastic box I was going to use as an enclosure. Make sure you have some thin markers (0.3-0.5mm) for coloring in the letter later on. Another thing you can do to make these look even better is to enable ironing in your slicer and get a really nice and smooth surface, just know that that will increase the print time a lot. Here is the printed out version. |
Bottom Panel | Just like the last one, let's first take a look at what connector we need for this panel. This panel will have 4 connectors in a 4x1 configuration. This panel will cover the Sensor & Light module as well as the Robot Subsystem. We need 2 connectors for each module, one going for power and one going for data. This one took longer the print of course, but I love how it turned out. As the name suggests, this panel will go on the bottom of my main box, |
Side Panel | Now we have the last of the 3 panels, the side panel. This panel will be for the Water & Rail module and for the LAB module. Just like the bottom panel, it will need 4 connector slots, 2 for power and 2 for data, but instead of a 4x1 configuration, this will have a 2x2 configuration. Again, as the name suggests, this will be mounted on the side of the main box. |
Enviro Hat Mount | The last 3D model I will be designing is a mount for the Enviro Hat Mini. As I've already covered in my third blog, the Enviro Hat is affected by the heat of the Raspberry CPU a lot, so I want to mount it at the front of the box (on the lid). I designed the mount to be simple and will use 4 screws to be mounted together with the Enviro Hat at once. After printing it out, here is how it turned out and how the hat fits into the mount. |
3D Printed Locking Connectors
The connectors are something I covered in detail in my second blog: Project R.A.G. - Blog #2 - Strapped In For Launch - Connectors . I will just show the versions I have designed for now here and share the link for them if you're interested in downloading them. All of the 3D models for the connectors can be found here: 3D printed locking connector. I have 3 different versions of the connector so far, one being the 3.5mm jack, one being the 5.5/2.1mm barrel jack and the USB port jack. Here are the pictures of those:
If you're interested in more details about the connectors or the wire side connector, you can check out the blog linked above, and if you are interested in the 3D models, you can check the GitHub link as well where you can download all of the models.
Electronics
With the mechanical design aspect sorted out, we can look at electronics now. There are a couple of perfboards that I'll need to solder for this board. A Raspberry Pi breakout board, an I2C breakout, a common GND breakout and a 12V/5V switcher. 3 out of 4 of these are literally just soldering connectors to a perfboard with a few wires, the only one that needs some actual electronics is the 12V/5V switcher as I call it. Let's tackle it first since it is the most of the whole bunch.
12V/5V switcher
As described above, the idea for this circuit is to seamlessly switch between 2 power supplies. Let's analyze that sentence a bit. The main box will be powered by 2 separate power supplies, one being a 5V power supply, while the other one is a 12V one. This switcher is supposed to power only the Raspberry and nothing else, which doesn't consume that much current. The function of this box is to keep the main computer running, in our case, the Raspberry, if there is a fault with one of the power supplies. Of course, one of the power supplies going out will shut off the rest of the system running on that voltage, but we will still have a live computer to hopefully analyze what happened. There's another part of the sentence and that's seamlessly. By seamlessly I mean without a power down time, in other words, we have to assure that there isn't a big voltage drop which would reset our computer. Here are the circuits I tested.
Relay circuit
My first idea and the first thing I tried out was a relay circuit. My basic idea being having the common pin of the relay on the output and having the 5V direct input and input of off a linear regulator on the normally open and normally closed pins. You can see what I mean on the schematic below.
While making this circuit, I suspected what was going to be the main issue with it, but I wanted to try to see if I can maybe rectify it a bit and that is the relay switching time. This being a standard electromechanical relay, it's not the fastest thing in the world when switching from one state to the other. For a lot of cases where we just need to turn something on or off this is more than good and is a great component to use, however, for something like this, the switching time is too long. Before we get to that, let's look at the other components first. You'll notice that there's a Schottky diode in parallel with the relay coil and that's because of the huge spikes that occur when powering down the coil. Here is a picture of that happening.
On the second channel (green) which was my trigger you can see the massive spike when powering down the coil of the relay. Over time this can damage the power supply and it would for sure damage a microcontroller if we only tied a digital pin directly to the coil of the relay. Here is how it looks when we put a Schottky diode across.
As you can see from the picture, we lost the huge negative spike, so our solution with the diode worked great. On the picture above you can see the downtime on our first channel. That is the time we have between the one power supply being active and the other. This was the test without the capacitor at the output, so we can pretty much see the time it took for the relay to switch between the 2 states, which in this case was 5.69ms. For testing purposes I put an Arduino Nano as load at the end because I could see if it resets because of a voltage drop by looking at it's LED-s.
On the 2 pictures above, we can see what happens when we put a capacitor at the end. We don't have the sharp drop like we did in the circuit with no capacitor, but rather, we have a slow drop. There are 2 pictures for 2 different values of capacitors, one on the left being 100uF and the one on the right being 330uF. I tried more values but nothing really helped.
Here I tried a circuit where the cap at the end could discharge through a Schottky diode directly, but in the downtime would have to charge up over a 10k resistor. My idea was to not waste the current from the power supply trying to charge the capacitor if it already dumped out all of it's energy into the circuit, but rather more current going to our load, in our case the Arduino Nano. This circuit could work great for a high power system because of the relay if we besides the power supplies had a small backup battery. So with these few tests done, I went online and started looking at different designs, with the 2 catching my eye mostly, those being the MOSFET circuit and the Schottky diode circuit.
Schottky circuit
I decided to go with the Schottky diode circuit because it was much more simple than the MOSFET one. The idea behind this circuit is really simple, having a Schottky diode tied to both the 5V input as well as the 12V input and connecting those outputs together. It's a really neat and easy way of doing this. There are problems however of a voltage drop across the diode and the efficiency, but that's why I went with Schottky diodes instead of regular diodes, because of the lower voltage drop on them. Here is how the circuit looks like.
I've put 2 diodes in parallel for each of the power supplies since we will be having a Raspberry Pi 4 as a load. Each of these diodes can handle 1A current looking at the datasheet and looking online a bit at the power consumption levels of the Raspberry Pi 4, this should probably be enough. In this configuration, the leading power supply will be the 12V because of the small voltage drop because of the diodes on the 5V rail. Here are the test results for this circuit:
Here is the picture of what happens when we disconnect the 5V system. As predicted, the leading power supply was the 12V since it didn't have the voltage drop like the 5V one because the Schottky diodes were before the 7805 linear regulator, which again, dropped the 11 point something voltage down to 5V exactly. Let's see what happens when we disconnect the 12V rail while the 5V rail is connected.
On this picture here, we can see that something actually did change when it comes to our supply voltage for the Arduino. But unlike the relay circuit, there are no voltage drops that would reset our Arduino, which proved correct during my testing. To finalize the design for this board, I came up with this schematic and wired it up:
This schematic, except the components we saw on the last one, has additional voltage dividers and OpAmp buffers. I wanted to have a small circuit which would have output signals for both power supplies if they were on or not. This would enable us to track what is working and what is not on our Raspberry Pi later on. As you can see glowing in the pictures, I put some LED-s on as indicators.
One thing to be wary about is that the logic level on a Raspberry Pi is 3.3V and a 5V input to one of the digital pins can damage the board. The pins on the Raspberry are directly connected to the microchip, so be careful when you're playing around to not damage the board.
Looking online I came across this website: GPIO Electrical Specifications, Raspberry Pi Input and Output Pin Voltage and Current Capability. There, we can find some details about the digital pins on the Raspberry. Reading through confirms that we must not deliver more than 3.3V to any of the pins or we will cause damage, also we can look at the lowest voltage we can deliver to the pin and still be registered as HIGH. That voltage would be somewhere around 2.3V. In other words, to know we won't damage anything and that the Pi will correctly read our value, we need a voltage between 2.3V and 3.3V. With the voltage dividers chosen as shown on the schematic, this is where we are standing at:
As you can see, we are in the sweet spot with both voltage dividers. I added an OpAmp buffer at the end to keep the voltage stable and a pull down resistor to always have a defined state on our pin, without having to add anything on the Raspberry side. To properly test out this circuit with the Arduino I wrote a short code that would turn on one of the LED-s depending on/off the LED-s based on the voltage that was coming from the power supplies. The reason I did it this way and not hardwire everything, is because if there easy any kind of a voltage drop, the Arduino would reset, which we would see by the LED-s turning off as well as the red LED blinking on the Arduino. Here is the short code I wrote for this test:
#define Pin_5VIn 2 #define Pin_12VIn 3 #define Pin_5VOut 4 #define Pin_12VOut 5 void setup() { // put your setup code here, to run once: pinMode(Pin_5VIn, INPUT); pinMode(Pin_12VIn, INPUT); pinMode(Pin_5VOut, OUTPUT); pinMode(Pin_12VOut, OUTPUT); } void loop() { // put your main code here, to run repeatedly: if(digitalRead(Pin_5VIn) == HIGH){ digitalWrite(Pin_5VOut, HIGH); } else{ digitalWrite(Pin_5VOut, LOW); } if(digitalRead(Pin_12VIn) == HIGH){ digitalWrite(Pin_12VOut, HIGH); } else{ digitalWrite(Pin_12VOut, LOW); } }
The code is extremely simple, it just turns on an LED based on the value of the digital pins that we defined as input. Voltage needed for the digital pin on the Arduino to be surely high is 3V, but there is a gray zone between 1.5V and 3V where we don't have a guarantee if it will be detected as HIGH or LOW. Since both of our voltages are above 2.5V the Arduino seemed not to mind that they were under 3V so everything worked out in the end. Here is a short video demonstration of this circuit working.
Soldering the perfboard
I took a small leftover piece of perfboard with lines on the bottom that I had laying around and started populating it with components. The input connectors will be the screw terminals, while the output connectors will be a female USB type A connector and screw terminals for the signals that will show us if the given power supply is on or not. I made a few mistake along the way, but I managed to correct them along the way, here is the end result:
Besides the mentioned connectors, you can also see a white nylon connector as well as heatsink on the 7805IC, but more on that heatsink later... You can see that the connector is currently shorted out, but the goal is to use that connector to connect a power on/off switch for the mainframe, or in my case, a mushroom safety switch. With the soldering complete, let's test out our board.
Testing with Arduino
First, here is a short video test of the circuit working with the Arduino, which still has the same sketch uploaded as it had for the first test. For powering the 5V rail I used a phone charger, while the for the 12V system I used a 12V power supply which I assembled, which you can see later in this blog. Here is that test:
As you can see in the video, the circuit is working exactly as I wanted. The Arduino isn't resetting as I'm switching between the 2 power supplies. But all of this works great with an Arduino Nano, which in all honesty, isn't that big of a load. Let's see what happens when we try it with a Raspberry Pi 4.
Testing with the Raspberry
Here is where we get into some issues. I was worried about this part for multiple reasons. In my experience with using the Pi, not just the 4, but the previous versions as well (2 & 3, can't really speak for the 1 and 0), they really love a lot of power and aren't really happy with any kind of under voltage. This would be an issue on our 5V rail, since we had a drop of voltage over the Schottky diodes. Another issue is the standard 7805IC, looking at the datasheet, it's rated for up to 1.5A. I tried testing this circuit and I managed to get the Pi to boot to the desktop screen by blowing air onto the 7805 to keep it a bit cooler. I added a heatsink, but since the size of it was so small, there wasn't really much use. Here are the cozy temperatures I measured on the 7805.
Unlike the fun news from the ISS trend I've kept through my blogs, I really hope this trend doesn't extend into the next blog as well... Since everything is pretty much closed or on big delay with the deadline coming in a week. I'll have to resort to the components I have at home. While this circuit is working great for what it is, it will find it's use for some other project of mine that will use an Arduino or something like that, I'll need something a bit more beefy for this. For dropping down the voltage I'll have to go and look for some buck converters and voltage regulators I have lying around, as for the circuit itself, I will have to find a different design that will work for the Pi. I will conduct a few experiments for some of my ideas, as well as for the MOSFET circuit and other I find online. I'll post that update in one of the next blogs, so I can get this blog posted and continue with the essential work. If all else fails, the relay circuit will work for sure, though, we will have a reset if there's a fault with one of the power supplies. To finish of this segment, here is one of my favorite quotes that can be applied for this for sure:
Adam Savage: "Failure is always an option"
While the board turned out to not to work in the end, I still learned quite a bit and had fun while experimenting with it and, as I've said previously, the board will work great for some other project where I won't necessarily need to power something power hungry like a Raspberry but rather something like an Arduino or some other module.
I2C breakout
The 2 boards I will be covering here will be simple screw terminal breakout boards. Their purpose is to let me connect multiple devices to the same thing. This one will be for the I2C communication. The I2C communication uses 2 wires, SCL & SDA. I'll need connections for the master and 5 other devices.
Common ground breakout
All of the power connectors will have one of the wires going to the relay, which will the 5V/12V wire, but we still need to connect all of the ground wires together. This is where this second mini board comes in, even simpler than the last.
5. Assembly
With all of the prototyping and testing completed, we can now assemble everything. There are 2 things that we need to design, one is the main box of course, and the other one is the 12V power supply. This power supply will be used for powering all of the 12V systems in the project, which are all of them except the robot. That includes, the lights, the rail mechanism, watering and so on. I'll assemble it into a neat little package and then focus on the main box.
12V PSU
For this power supply, I went with a Meanwell power supply like I did for the 5V power supply as well. This is a 12V 6A power supply, with the code name LRS-75-12. Here are some relevant links for this power supply, where you can get buy it, as well as the datasheet for it:
- https://www.meanwell-web.com/en-gb/ac-dc-single-output-enclosed-power-supply-lrs--75--12
- https://www.meanwell-web.com/content/files/pdfs/productPdfs/MW/LRS-75/LRS-75-spec.pdf
- https://export.farnell.com/mean-well/lrs-75-12/power-supply-ac-dc-12v-6a/dp/2815997?scope=partnumberlookahead&ost=LRS-75…
As the enclosure for this power supply, I will be using another electronics box. They are a perfect fit for this kind of thing, robust, cheap and come in various shapes and sizes. I will be using one that is 150x110x75mm. On the font there will 2 3D printed locking connectors, one the back there will be an AC input plug, switch & fuse and I will mount the power supply itself to the lid of the box. The power supply is pretty big for this box, it's a really snug fit, it would interfere with the connectors if I mounted at it at the bottom.
If you're planning to follow along for this part and build a power supply, please note that you are working with high voltages that can seriously harm you or kill you if mishandled. If you're doing this, you are doing it at your own risk. I know a lot of people reading this will have had a lot of experience with this kind of stuff, but if you are younger and reading this, please be careful and get some help!
For all of the wires Inside I used 16AWG wires, the switch breaks both the live and the neutral wire. As you can see from the pictures, I also put small labels on each of the wires to not mix them up and also crimped on some wire ferrules to make the connection in the screw terminals more secure. All that's left now is to screw on the lid and power it up to see if we're getting the expected voltage at our connectors.
We are getting the expected voltage on the cable and with the correct polarity. The switch on the back has a built in LED, so I will be using that as an indicator if the power supply is on or not. With that, this part of the build is complete and we can go towards assembling the main box which will have a bit more work than this power supply.
Main box
Now it's time for the main build for this blog, assembling the main box. We have to mount the panels on first, mount the connectors to them, mount some additional outside components. Then, on the inside, we need to mount in all of the electronics and wire everything up in such a way that we know what's going where, which means, more label making. It's really simple method but I found it to work great. Let's begin by mounting all of the outside components first and then we can get to the inside bits.
Panels, connectors & outside components
For mounting everything on the outside I will be using M3 screws and M2.5 screws for the Enviro Hat Mini. Since there are already a lot of screws used for this part of the build, I wanted to to evade using nuts for those screws if I could somehow. So I went and tapped all of the holes that I drilled out. I could have printed the connectors and panels as one piece, and mounted them with many less screws, but I love the idea of modularity, where if something gets damaged or broken, you can just replace a single connector, rather than the whole panel with 4 connectors. Here are the links where you will find the files I've printed out:
I printed one each out of those panels from the second link and one mount for the Enviro, I went with white color for that, because it's a neutral color. As for the connectors, I had to print 10 of them in total. 6 out of those 10 are the ones for the barrel jack and the other 4 are for the 3.5mm connector. I printed these in 2 different colors, 2 power connectors and 1 3.5mm connector in white and the rest in yellow. The white connectors are for 5V power and serial communication, while the yellow connectors are for 12V power and I2C communication.
On the picture above you can see the 2 side panels, the first one takes care for all of the power going to this system, that being the power supply input for the whole project, while the other one covers 2 of the modules, the LAB module and the Water & Rail module.
On these 2 pictures we can see the rest of the components that I've mounted. In the first picture we have the last panel with connector that goes on the bottom of the box. It covers 2 of the modules as well, the Robot module and the Sensor & Light subsystem. On the second picture you can see my mounting of the Enviro Hat Mini and the safety switch. I love how the mount for the Enviro turned out and that it uses only the screws that the Enviro uses as well, it's mounted on the lid which will face the center of our project when the box is mounted, so we get relevant measurements. As for the safety switch, this will be my way of turning on and off the project, while it also gives me an easy way to stop everything if I see something going wrong.
Mounting the electronics
Now I need to mount the electronics inside the box, this will include only mounted the few board that I've covered during this blog, the Raspberry and the relay module, sadly, this won't include the 5V/12V power switcher board for now, but I will mount it at a later date. Let's begin with mounting the Raspberry.
I mounted the Raspberry onto the lid of the box, a bit underneath the Enviro Hat which you can see in the background. This way I can easily connect them 2 together and have the whole box dedicated for all of the wiring and other boards. I've used 20mm hex spacers for mounting the Raspberry with a M3 thread on the inside. I just screwed them in with cone head screws and countersunk the holes to make everything flush. Now we can fill the box with all of our boards.
For mounting all 3 boards I used more of those spacers. I had 4 shorter ones with a threaded part sticking out, I used those to mount the relay module. The spacers are great for mounting stuff like this, because they are really sturdy when tightened properly and also give us an option of routing some of the wires underneath the boards if we so desire. In the P2 of this, I will cover all of the wiring that went into this.
6. What's next?
With this semi-completed, I will focus on the last essential module for this project, the Water & Rail module. That module will take care of watering the plants, movement on the rail system and will also take care of the tool change on the robot. Besides that, there are 2 more essential things to do, and those are, to finish the mechanical build so I have a place to mount all of the lights as well as the modules and design the tool holder with a couple of different tools. After that is complete, all we have to do is some playing around with the software to tie it all together. I am not sure what will the next blog cover since it depends on how the different parts of the build go. When I decide for all of the connections on the Pi I'll finish up with a few more components for this box and the wiring. I want to add small hatches for HDMI and USB cables as well as a camera mount to the box. When it's up, the next blog will be linked at the bottom of this one.
7. Fun news from the ISS
For this segment of fun news from the ISS, here is some concept art done by Nasa Advanced Concept Laboratory for growing food on Mars. Sadly no robots on rails going between those plants...
8. Summary
This was a bit of a smaller build, but essential non the less. There will probably be a couple of more things added to this box, like a slot and holder for the Raspberry HQ Camera for example. I will be now focusing on the WR module with the tools and main build P2 close behind it. I don't know if I'll be able to do the LAB module in this time, but I will cover my design concept in a future blog if not. All of the relevant links for this competition, link to the next and previous blog as well as my GitHub where I'm uploading all of the models can be found underneath. Thanks for reading the blog, hope you liked it and found it interesting!
Milos
Relevant links for the competition:
Link to my GitHub where you can find all of the files used for this project (code, 3D models,...):
Link to my Project Collection:
Previous Blog | Next Blog |
---|---|
Project R.A.G. - Blog #6 - Mechanical Build P1 - Robot On Rails | Project R.A.G. - Blog #8 - Mechanical Build P2 - Robot On Rails |
Top Comments