Landing : Athabascau University
  • Blogs
  • COMP444 Assignment "0" - First Steps With SparkFun Inventor's Kit

COMP444 Assignment "0" - First Steps With SparkFun Inventor's Kit

COMP444 Assignment "0" - First Steps With SparkFun Inventor's Kit

Where to find resources?

With experience developing electrical and mechanical devices, and some programming experience, I have quite a few “go to” standards for finding information, inspiration, and bouncing ideas around. I’ll cover them in order of how often I use them, and by category.

Electronic design resources:

  1. Component datasheets and reference designs.
    Reputable manufacturers like Texas Instruments, Maxim, and Atmel, and distributors like DigiKey and Mouser, have fantastic information not only in individual component datasheets but arranged in a reference design library. These are proven working and often industry standard designs, created by engineers to ease and promote the use of their product. Though they can sometimes be used as is, these designs are meant to be adjusted for their final application. The first step when approaching the use of a component is to look over the datasheet and related reference designs.
  2. Searching online for similar projects, circuits, or solutions.
    The do-it-yourself community and professionals alike are active in online forums and blogs, sharing their experience and opinions. The following forums have been most helpful to me:

                                 i.            AVR Freaks http://www.avrfreaks.net/forum
This is a long-standing forum centered around the Atmel product line, which is what the original Arduinos were made of and what powers the board in our SparkFun Inventor’s Kit. Longstanding members of this forum have a habit of scaring new members away with their gruff attitude, but their experience and, compared to what you find in many other electronics-centered forums, design ingenuity, cannot be denied. If continuing development with Atmel products (or Microchip, it so happens) then you would be remiss to not join this community.

                               ii.            EEVBlog Forum http://www.eevblog.com/forum/
This is forum that grew from a community of people drawn together by particularly engaging electrical engineer and YouTube video blogger Dave Jones. Compared to the community AVR Freaks, it is more so geared towards and open to newer and inexperienced designers, though still with excellent information.

                             iii.            Stack Exchange: Electrical Engineering https://electronics.stackexchange.com/, and a host of Reddit “sub-Reddits” https://www.reddit.com/
This first is part of the Stack Exchange family of communities originated by Stack Overflow, it is built as a question and answer with user ranking of each with a bit of moderating. The second, Reddit, is similar, but broken up into more sub-groups called “sub-Reddits”. Personally I don’t find the question-and-answer format to be a good fit for those looking for help with electronics design, but many questions have been posed and answered, so you may find the answer to yours just waiting for you.

  1. 3.       There are some reference texts that stand above the others, as in I actually use them every once in a while, instead of endlessly plugging different versions of my search into Google.

                                 i.            Art of Electronics, by Horowitz and Hill http://artofelectronics.net/
This is the grand-daddy of electronic circuit references. It is the best electronics reference available.

                               ii.            Modern Control Systems, by Richard C Dorf and Robert H. Bishop
This isn’t one I consult often, but when I do, I mean business. This is the theory behind control systems, from single transistor feedback circuit design in electronics to multiple-input multiple-output delayed digital systems, like our Arduino or the Tesla self-driving cars. You might think you could get rid of this text once you’ve passed the related course at university, but I find myself coming back to it in order to write good code. Most hobbyist control systems peak in complexity with a PID algorithm, but there is much more to it than this. It’s a book you won’t need until you’re looking at a problem that requires a robust and efficient control system, like balancing a Segway or auto-piloting a drone. I don’t recommend just reading the book unless you’ve taken a related course, as it is dense. A similar text, but even more theory-oriented, is Signal Processing & Linear Systems by B.P. Lathi, the last few chapters of which are useful for transforming your control system into a more effective one (efficient, fast, cheap – pick your optimization). I imagine I will consult these texts less often the more I use them, as I internalize their lessons.

Programming Resources:

  1. When programming, one always has their preferred online reference or references open on another screen or in the background. Mine are the following:

                                 i.            Stack Exchange: Stack Overflowhttps://stackoverflow.com/
This is the site after which the entire Stack Exchange network of Q&A websites are modeled. It has been programmers’ #1 site for years, shown by the thousands of quality questions and answers. Chances are any problem you’re having has already been examined and thoroughly addressed in some form on this site.

                               ii.            Google
Yep, just plug your error message (if your programming workflow includes a debugger), or whatever you think your issue is, into the Google search bar and see what pops up. I mention this obvious choice only to show that I haven’t found a site comprehensive enough to warrant searching on it alone, other than Stack Overflow, but the indexed conglomerate of all of them is quite useful. You learn to avoid those sites with pop-up “sign up” messages, auto-play audio/video feeds, and paywalls.

  1. A non-traditional resource is the book The Pragmatic Programmer, by Andrew Hunt and David Thomas. It is unlike most other references or introductions about programming, in ways that I’m not about to expound on here. Instead, look for yourself and this question on Stack Overflow: What is the single most influential book every programmer should read? It’s #2, right after Code Complete (2nd Edition)which is a great text, but not one I ever refer to, whereas I will skim the intro to a chapter in The Pragmatic Programmer just to get a refresher. And it is refreshing.

Inspiration

Hackaday https://hackaday.com/andhttps://hackaday.io/, and All About Circuits http://www.allaboutcircuits.com/.
Both of these are a combination of interesting blogs and a vibrant community of followers. Hackaday also has, in their words, “the world's largest collaborative hardware development community” at hackaday.io, hosting peoples’ projects in dozens of categories in a structure that allows others to follow and contribute.

Examining the SparkFun Inventor’s Kit

What a great box! It’s got a manual… let’s see… Ooo, it has pretty pictures inside. Well, enough of that.

Here’s the Arduino board itself, half breadboard, and mounting plate. We’ll screw that on right away with this included screwdriver. Nix that, the screwdriver is rubbish – using my own. The mounting plate screw holes are a bit tight and have plastic bits and bobs on them. I’ll use different screws with actual pointed ends to make it easier. Two #4 – 3/8” screws did the job nicely. The back of the breadboard peels away to make it stick to the mounting plate.

What else is in there? LCD screen with its own driver circuit – nice; two motors; a bag of sensors and transistors and buttons and more fun stuff; a 74HC595, which Google tells me is an 8-bit shift register; a bunch of pre-formed wires with rubber bits to make them easier to handle (that might get annoying, as I usually cut my breadboard wires such that they don’t flap in the wind); a bunch of resistors; and a bunch of LEDs. Oh, and this fancy red USB cable.

Let’s hook it up! Great, some green and blue flashing lights, plus Windows just told me that it sees the device and is setting it up. All done. Right, this thing doesn’t do anything out of the box except flash the blue light.

Installing the Arduino IDE

Time for the software. As per the class notes I’ve downloaded and installed the Arduino IDE (it was cake), so let’s fire it up. Alright, looks just like a text code editor, but it’s supposed to be an IDE so there must be a serial comm tool here somewhere. There it is, at Tools > Serial Monitor. Eh, nothing on COM4? Let’s find out which port the Arduino is on, then. Tools > Port only shows COM3, so it must be that one. Surely it could have figured that out? Ah well, let’s open up the serial monitor and see what this thing is saying out of the box. … Nada, not even on reboot. Maybe it’s the wrong baud? Default is 115k. Eh, better look at the book. Stinkin’ manuals. Looks like I was supposed to install FTDI drivers, first, but I’m pretty sure I’ve already done that for other serial devices I’ve worked with, so I’ll skip it. Ah, was also supposed to change the board to Arduino UNO – done. Now I need to get some code from sparkfun.com/sikcode – done, and unzipped into the Arduino examples folder. Oh, that’s the end of the setup. No initial demo. Guess I had better get started.

Writing and executing your first program

Well, the first circuit in the book is Blinking an LED. All of my projects that use a microcontroller have a blinking LED during development. I call it the project’s heartbeat. If that LED quits blinking it means that there is something severely wrong with your code or circuitry, so you’d better quit pretending to write that grant proposal and get out your debugging kit. (There are other, better error indicators, but I still keep this ‘heartbeat’ around. Another way to think of it is a human watchdog: an electronic watchdog makes sure your code keeps running by resetting internal states to known working states, just like you will reset your project to a working state if the blinking LED stops.) Anyway, onwards.

First, energize up the breadboard power rails from the Arduino. Blast, the wires are clipped together – gotta’ get the snips. Alright, snipped, and a black and a red wire chosen to match the breadboard colours. The Arduino pins are all labelled, which is awesome. I’ll use the 5V and GND pins for this rail. Now I need a 330Ω resistor. Man, I can never remember the resistor colour codes, this is going to take forever… Oh, wait a minute, there’s only two values in this kit: 330Ω and 10kΩ – sweet. Resistor plugged in. LED plugged – eh, just a sec – which way? Says flat side to negative. Most LEDs don’t have this handy flat edge, but they do all have a larger anode (-) than cathode (+) inside of the plastic bit, so I’ll go with that. No big deal if it’s backwards at these voltages, as I haven’t seen a non-zener diode or LED with a reverse breakdown less than 20V. Green wire plugged in.

Hey, it’s blinking, and at the exact opposite rate as the on-board blue LED. Must be related. Yeah, I can see the number “13” printed next to the LED. There must be a resistor between the blue LED and pin 13, too – maybe that tiny one right beside it? Surely there’s some programming involved in this circuit… next page.

Alright, I’ve opened… oh, wait, the examples aren’t showing up. Maybe because I migrated the files while the program was open. Close, restart IDE. Yep, there they are. Okay, circuit example number 1 opened.

Wow, that is tiny text. Must be my high-resolution monitor tricking the IDE into thinking it’s a large monitor. How do I fix that? Can’t see it at all. Let’s ask Google… Alright, this is apparently a common flaw with not only the Arduino IDE but also Swing, a common Java GUI framework, with no official fix. To work around it I must close the IDE and edit preferences.txt. Okay, closed IDE, opened C:\Program Files (x86)\Arduino\lib\preferences.txt with Notepad++ (eh, that needed updated – now updated), and I see this message: # DO NOT MODIFY THIS FILE, OR DELETE SETTINGS FROM THIS FILE. I’m in the wrong preferences.txt. Closed that one, opened ~\AppData\Roaming\Arduino15\preferences.txt, and edited a section to read the following:


... 
editor.font=Monospaced,plain,24 
... 
editor.window.height.default=1700 
editor.window.height.min=290 
editor.window.width.default=3100 
editor.window.width.min=400 
...

Looks better now.

Again, example circuit #1 opened. Reading the comments, it looks like we wired it up the opposite way to that in the code commends. The code comments describe wiring the LED and resistor between pin 13 and ground, whereas we wired them between power (+5V) and pin 13. In electronics lingo, we’re using pin 13 as a sink instead of a source. Some microcontrollers, sink and source different amounts of current and require different states to do so, but this one works as is. Still, it’s an oversight.

Hit Sketch > Verify / Compile, and everything went smoothly, then File > Upload. It compiled the program again before uploading. This doesn’t mean I can skip the Verify / Compile step, though, as I’m not sure that it’ll automatically abort the upload if there are compile errors. It doesn’t look like anything changed, but it worked.

Let’s play with the delay values. I’ll make them 100 ms instead of 1000. Ctrl+U compiles and uploads. Yep, they’re blinking like crazy now, and I feel guilty like I’ve just been caught speeding. Let’s go with 10 ms. Well, I can’t see it blink any more. My multimeter says that it’s buzzing at 49.95 Hz. Is that right? That’s 20.02 ms – the two 10 ms delays are adding to 20 ms, plus some time to get the switching done, and it probably needs to time to do other stuff that we don’t know about yet. I’ll increase those delays to something easier on the eyes before shutting down the IDE, how about 1500 ms and 500 ms.

Well, that was fun. I’ll have to try out the rest of the example circuits, next time.

PDF version available here: https://goo.gl/6DAqkm