Here, we are meant to redraw the echo hello-world board. I plan to add buttons and LEDs with resistors. I then get to check, make, test, measure and simulate the board. This assignment will be a good opportunity to gain skills that I can apply to my final project.
I need to find out how big of a capacitor I need for my final project. It is also important to know what sort of voltage I will need to create enough lumens for a usable lamp.
Button and LEDEagle files Phototransistor and RGB LEDCutfilesThe tutorial provided by fab academy was crucial to my first adventure into electronics design. Having some idea of what it ought to look like really helped me feel confident in picking and placing my components.
Fab Academy tutorialThe second most important resource was the fab wiki entry on electronic design with Eagle. It gives more specific guidance about which library to download, which components to use and how.
Fab Wiki pageWhen it said to connect a LED, I thought it wouldn't matter which color I picked. My favourite color is blue. As it turns out, blue has 3.3Vf while the red LED has 1.8Vf. Therefore, the resistor didn't match with the LED I used, and the circuit didn't work! I am using this calculator from now on to avoid future confusion.
Calculator and guideEagle is the easiest program to use when you begin drawing circuits as a novice, but it is also a powerful suite which allows professionals to create circuit boards intended for mass production.
EagleA few months before Fab Academy, I downloaded Eagle and poked around for a bit. At the time, I didn't spend much time with it, did not really understand the libraries, and gave up after a short time. I thought it had been a waste of time, but somehow, when I now began using it, that little experience removed a great deal of the overwhelming nature of Eagle.
I followed the tutorial on how to make the schematic, then followed along with Bas' lecture the next day. I milled the traces and the outline and soldered my components, much like we did when we were making our FabISPs.
TutorialMy FabISPMy FabISPNo matter what I did, the board refused to work, and my attempts at programming it failed. I decided to review the schematics and found my mistake. I had somehow failed to connect the RESET (RST) pins on the microcontroller and the ISP, meaning that the RST pin on the microcontroller was just connected through the 10k resistor to VCC but nothing else.
The reason why we need the reset pin is so that we get the correct bits of code in the correct order, as opposed to starting somewhere in the middle.
Once I discovered the flaw, I connected the two pins with a wire to see if this would fix my issue. Fortunately it did! I redrew the schematic as seen above, and added the trace to my board as seen on the left. Since my board works with the jury-rigged wire connection, I decided not to mill it again, but rather use it as is for now.
I grabbed Neil's code from the Fab Academy archives, and used it without editing it. In order for this string of code to work correctly, you need to download the c file and the py file and keep them in the same folder. Otherwise you must navigate to the correct folder before using the py string.
.c codeterm.pyNow that my board worked, I programmed it using my FabISP with the make code from the fab academy website. I plugged it in, loaded the code, downloaded the python code and connected it to the board.
For some reason, it took me a while to understand that I needed to write three strings of code before using the python window to communicate with the board. Once this was in place however, it worked beautifully:
Once the code had successfully been programmed onto my circuit, I unplugged the FabISP and connected the circuit directly to the computer using an FTDI cable. I could then use the term.py code to test my board.
Because it worked, it opened a small python window, where if I wrote something, the circuit board recognized my input and echoed it back. (step by step until my final sentance read: hello.ftdi.44.echo.c: you typed "hello world")
Directions for programmingIf you're here for interesting things, follow the link below to skip this boring and rather pointless part. If not, by all means read on and see my own version of the millions of existing tutorials on Eagle
In Eagle, the work area is divided into three windows. The main menu, the schematic and the board. We'll cover each in more detail below. The first step is to download Eagle and install it, then connect your Autodesk account. Then download the fablab library for Eagle, and place it in the library section of your eagle folder. Then in the main Eagle window, turn off all libraries except the Fab lab and Source libraries to begin with. This will save you time when you are getting started on the schematic. For now, click "file" - "New" - "Schematic" to begin!
Back to the real stuffFab lab library for EagleYour empty schematic can be scary, since it's just a white page with nothing on it. Let's deal with that my clicking "add component" It is nice to start with a microcontroller, so go ahead and grab the ATtiny45. Open the fab library and scroll around until you find it.
Skip aheadOpen the fab library and scroll around until you find the ATtiny 45. Then click "OK" if you're okay, or cancel if you want to cry because this guide is depressing.
Skip aheadDon't worry too much about connecting the pieces yet. First add all the components you want. In this example, I've added all the components needed for my TinyBLE, a bluetooth module I made much later in the Fab Academy timeline, but which is neatly arranged and pretty and doesn't make me angry to look at, nor think about all the better things I'd like to do with my time than write this guide.
Skip aheadNow you need to connect all the things that should be connected. For example, make sure to connect the reset pin on your microcontroller to the reset pin on your ISP pin header. To connect components, use the "draw electrical connection" button in the left hand toolbar. It looks like a small green "L" that fell down. You can either connect the pins directly with the green line, or you can draw the green line out a short way, then name it. For example, you might name the line "reset". You then draw another short green line where you want to connect "reset" to, then name that "reset" as well. This makes for a neater schematic if your lines would otherwise criss cross across the schematic.
Once you have connected all your pins on all your components, click the "schbrd" button. It's the 4th button in the top toolbar. This will tell you that you don't have a board yet, and ask if you want to create a new one from he schematic. Carefully click "yes". If you click "no", it won't make a new board for you.
Skip aheadBefore you do anything else on the board window, adjust your drc settings! Bas showed us settings which are good for the Roland Modela, so I usually just load those settings back in. If you want to use them too, click the button below. These settings govern the layer setup, the minimum drill size, allowance, distance between things and much more, and you therefore need to have them in order before you do anything else.
Skip aheadBas DRCAll the components are now neatly crammed into the bottom left corner of your board window. They are connected with yellow lines called "airwires" These lines tell you which components still need to be connected. Drag your components onto the table and arrange them as neatly as possible, so that you can draw the traces.
Skip aheadMy favourite settings for routing traces is to have them at width 12, to push obstacles and using wire bend style 1.
Skip aheadNow you carefully connect all the pieces that need to be connected. If you make mistakes, you can "rip up" traces, or if everything is messed up and you want to start over, you can type "ripup;" and it will remove every trace you have placed.
Skip aheadAdjust your dimension until your baord is the size and shape you want it to be. It can be square, but it can also be more dynamic in shape You can use the existing lines, or draw a new shape. Use super slim width for this part. Then draw a square on layer 200. This is a bitmap layer, and we will hide it later. We are using it to make it easier to get our png files to be the way we want them to be. Draw the square from (0,0), then place your entire design starting at (5,5). Turn on all layers to see if there are any artefacts on your board that need deleting. Once you are satisfied, hide everything except the top layer.
Skip aheadWith only the top layer visible, select "File"-"Export"-"Image". Tick the box marked monochrome, set resolution to 1500 dpi. Save this in a place you'll find it, and name it "name.traces" for example, this one is called "TinyBLE.traces" Then go back to the layers and hide everything except the dimension layer. Repeat the steps to export the image, but name this one "name.interior". Immediately open this image in gimp, and use the fill tool to fill the interior with white. Then select "file"-"overwrite name.interior.png".
Skip aheadOpen the name.interior image in gimp, and use the fill tool to fill the interior with white. Then select "file"-"overwrite name.interior.png". Now your image is ready to be imported into fabmodules. Congratulations.
It's finally over and we can get on with the real stuff.In my first attempt I was able to make a functioning circuit, but not until mistakes had been made which needed rectifying. As this suggests that more study is required in order to gain sufficient understanding, I decided to redraw the ATtiny45 echo circuit, this time with an rgb led and a phototransistor.
The circuit works and I was able to program the LED to cycle through colors with the standard .c code from Fab Academy. Scroll down for information on how I did it.
Directions for programmingI began by comparing the hello.rgb.45 (RGB circuit) and hello.light.45(phototransistor circuit) boards for similarities and differences
In combining the two boards together, I realized that the ISP pins and microcontroller pins could be set up nearly identially to the way they were set up on the rgb board, with the exception that PB3 on the microcontroller connects to the collector on the phototransistor.
Resistors and the Capacitor could be configured the same way they were for their respective components, and using a 2x2 ISP and a 5V regulator was the simplest way of setting up the power supply. Essentially, what I've drawn is the standard RGB circuit with an added phototransistor. This means, that for simplicity's sake I can test the RGB part of the circuit with the standard RGB make code, then later add in code that makes use of the signal from the phototransistor.
Milling the board did not pose any noteworthy challenges, and soldering it only took about 15 minutes. It's amazing what a difference a few weeks make.
For programming this board I downloaded the .c and .make code for the hello.RGB.45 board. I then plan to edit this code file to incorporate the phototransistor. As is, it shines red when plugged into the battery, then alternates between being off completely and flashing purple. Something must be off in my soldering, or possibly my connections. Possibly the LED is facing wrong?
Checking my work, I found the most frustrating answer. In the Fablib in Eagle, there are two rgb leds. An old and a new. Upon closer inspection there is a very important difference between the two. The A and the G pins swap places. Presumably, we used to use one type of rgb led and are now using a different one, where the corners are swapped?
On my board, the orientation is based on the old RGB LED, meaning that my pins are A B, R G. According to the other circuit diagrams, they ought to be A R, B G. I am milling this again, with the proper component config.
It works! It works. Note to self: Always, ALWAYS use the "rgbnew" component. Now I just need to figure out how to alter the code to use the input from the phototransistor.
Electronics Design is amazingly fun. It is also incredibly complex, but these projects, where we take existing configurations and work our way through them makes it accessible. For the following weeks in electronics and programming: Embedded programming, Input devices and Output devices, I plan to use what I learned this week to create the electronic components that provide the functionality of my final project.
Next page Fab Academy