, , and Project 2.4. Mint Tin ATmega328P (Modified for COVID 19.1).
The goal of the embedded system designer is to engineer a real time, in-system programmable (ISP) and functioning ATmega328P-based device, housed in a physical and electronically-stable case. This project gives you your first attempt at creating such a device (and sets your design ideas in motion for our custom PCB and CAD design journey in the second and third terms)
Most (all?) ACES projects combine required elements with creative latitude for students to demonstrate competency in both areas. It is your teacher's belief that your careers will demand this of you. This project is representative of this hybrid pairing.
This project is also designed to be a dry-run for your upcoming ISPs in 2021. As of the date of this initial text (November 15, 2020) you have two months before this project is due, giving you the necessary time to think deeply about what inspires you and to invest this dividend as you see fit. Additionally, your device is to be encased, setting you on the ISP design path in which your device will have custom PCB and housing features by the third term.
Read this 2020/2021 Breadboard ATmega328P Primer
Read this Comprehensive Backgrounder on this Project
Task for (2020/2021)
The ULTIMATE GOAL of this project is to create a standalone, sensor-based, In-System Programmable (ISP) (MCU reprogrammable without removing it) device driven by the same MCU at the core of the Arduino, AVR's ATmega328p that will be housed within a closed storage tin with a clear 2"×1.5" viewing window. By way of example, the graphic to the right is a crude simplified layout for a next-to-minimal, standalone ATmega328p on Adafruit's 30-column, Perma-Proto Half-sized Breadboard PCB. I'm sure you'll think of a more optimal layout. Just remember, those 30 columns are precious, so make the best use of them as your design skills will permit.
In the graphic to the right, you'll see the ACES' AVR ISP Programmer breakout board you were supplied with that may be your means to program your in-place SOCKETED MCU (the primer link above provides you with options to consider). On the right, you'll see the 5V regulation section where you may choose to provide a >7V power source as a substitute for 5V power supplied through your ISP BoB by way of your Sparkfun AVR Pocket Programmer.
Most of the additional requirements and wiring are left to you to determine from the direction and knowledge provided in class.
The PRIORITIES of this task are THREE-fold. What your embedded system does is important, but vastly secondary to these three:
- Ensure your MCU is powered with a clean 5V supply from an external 9V source.
- Your device employs the simplest, fastest, and smoothest in-place programmable strategy you can engineer.
- You have a functioning, in place, RESET button for your MCU.
If you can accomplish these three things, in a comfortable, confident manner, keep your engineering dreams alive. Now, on to the secondary part ...
Your functioning MCU will sense environmental input of your choosing (light, temperature, time, audio, etc) and display the result on an optical device of your choice (LEDs, 7-segment displays, bargraph, matrix, etc) (that can be viewed through the clear window, with the lid fully closed should you elect the optional stages of this project.
Task 2.4.1. Breadboard ATmega328P.
||RSGC ACES ISP Breakout v2
- This task is tricky enough without getting carried away. PLAN, SIMPLIFY, OPTIMIZE, and THINK!
- Using the ATmega328p datasheet, and as many additional resources as necessary, familiarize yourself, as thoroughly as possible, with the organization and details of this AVR MCU's pins.
- Using a combination of the parts in your kit and the (optional) supplemental parts provided (i.e. RSGC ACES ISP Breakout v2) create a standalone, in-system programmable, breadboard version of an ATmega328P.
- Should you elect to undertakeProject2.4.2, this breadboard prototype and your soldered version are to be IDENTICAL in terms of their componentry.
- Temporarily insert an LED into digital pin 13 and attempt to flash the Blink sketch with your preferred programming strategy (Sparkfun AVR Pocket Programmer (SAPP), or Serial wires) until successful. Debug as necessary (the wiring is new to you so it may take a number of trials).
- You may immediately notice the flash rate does not match expectation. Hmmm....This is due to the default clock source of the MCU as it leaves the factory (D. Langill: 8 MHz with the 'divide by 8' fuse set, yielding 1 MHz). To set the MCU clock speed to 16 MHz, burn the bootloader as instructed in class, before flashing the Blink sketch again. NOTE. It is NOT the bootloader that influences the clock speed but, rather, in addition to the bootloader being reflashed, the MCU fuses are reprogrammed. A discussion of fuses is beyond the scope of this course, but curious ACES may wish to review this online resource to begin to learn more about this important feature of AVR MCUs.
- Power MUST come from a 9V power source. This will require you to create onboard 5V regulation using your LM7805 and shoulder caps, to smooth spikes.
- Remove the programming connections that provide the two supply lines and construct a 5V regulated power supply fed from one of your 9V power sources to confirm the blinking LED.
- A further requirement for this year's project is that no device required for the embedded system to function will exist outside the case. Exceptions include power and programming tools.
- Assemble and present a simple but interesting circuit of your choosing that you will duplicate in Task 2.4.2 and include a presentation of this breadboard in your DER and media summary.
- IF you find yourself short a part or two consider trading parts with a peer.
- REPORT. Complete add submit a comprehensive DER on this first task of Project 2.4. and add the heading Project 2.4.2 to signal to me you wish to continue to the second Stage of this project.
Task 2.4.2. Perma-Proto ATmega328P (Optional: See Conditions in Conference email on December 1).
The goal of Project 2.4.2 is to create a permanent (soldered), in-place programmable ATmega328P-based prototype of your circuit in Part 2.4.1, that fits inside the clear top storage tin provided you, and is fully operational with the lid CLOSED. (Kickstarter, here we come...)
- PERMA-PROTO PCB. Review your Adafruit Perma-Proto 1/2 Sized PCB thoroughly, front and back, noting in particular, which hole sets are continuous or not. Also review Adafruit's Perma-Proto Tutorial on working with perma-proto materials.
- FULL LAYOUT. Using a combination of the parts in your kit and some of the supplemental parts listed to the right, lay out your components on your perma-proto PCB to get a spatial sense of the device you are about to make permanent. Have respect for the size and location of the openings you will have to create in your tin.
- SOLDERING. Solder up your device ensuring it fits well within your closed Altoids tin. Take considerable care with stage as replacement parts will not be supplied by Mr. D.
- You are strongly encouraged to line the internal walls of your tin with electrician's tape or other insulating material (anti-static foam, thin bubble wrap, etc.) to prevent shorts caused by contact of the solder joints or components with the tin. Consider cutting and shaping the pink/black packing material I use in some of your loot bags.
- TESTING. Upload your code with your SAPP. Debug as necessary. Remove your SAPP and supply 9V power through your DC input jack and 5V regulator to confirm your circuit's reliable performance.
- REPORT. By Saturday January 16 complete add submit a comprehensive DER on this second task of Project 2.4. and add the heading Project 2.4.3 to signal to me you wish to continue to the third and final Stage of this project.
Task 2.4.3. Mint Tin ATmega328P. (Optional: See Conditions in Conference email on December 1)
- GOAL. The goal of the final stage of our ATmega328P project is to encase your functioning Perma-Proto ATmega328P within a small rectangular tin with aclear viewing window that is provided to you.
- APERTURES. This second stage of the project places a small premium on the modifications of the tin to support your circuit's performance all the while with the lid closed.
- ASSEMBLY. An OFTEN overlooked aspect of project development is the simple assembly of the final components. I had to be conscious of this last Spring as I was designing and planning our Binary Challenge Devices. For example, if components stick out from both ends of your PCB, you will not be able to insert the circuit into the case without having to remove substantial parts of the tin. Not good.
- CASE ENHANCEMENTS. At the very least your name is to appear, conspicuously, on the OUTSIDE of the case. Further labeling and identification is/are encouraged.
- REPORT. By Saturday January 30 complete add submit a comprehensive DER on this final task of Project 2.4. Congratulations.
Project 2.3. Ask UNO. for 2020/2021. This project is specifically tailored for the 7-Class, Session 3 segment of COVID-19.1 (my notation for the Year 1 of likely many under COVID-19). I hope you have as much fun developing it as I had imagining and crafting it. The goal is to achieve the final prototype in as stress-free a fashion as possible, by undertaking a sequence of introductory conditioning stages.
Smart Personal Assistant Systems (Siri, Alexa, Home, Nest, etc.) are all the rage and, while we're not at the wireless hardware and AI software stage yet in this course, we can begin to imagine how a simple 'intelligent' wired system might be put together.
Stage 1. Watch this short video with the goal of recreating your own prototype of the same, as follows,
- Wire your Nano (not your UNO; that comes later) and your 16×2 Character LCD Screen together on a breadboard, as reviewed in class.
- Create an Arduino Project by the name of LCDFromSerialMonitor and drop in this code.
- Complete the rest of the code body that will flash "Waiting...Waiting...Waiting..." on the second row as depicted in the video until the user enters text in the Serial Monitor's input box.
- Your code will display the entered text on the second line for 3s before returning to wait for additional input from the user. Repeat.
Stage 2. In this stage, we wish to establish communication between our Nano Host and our UNO Assistant, while maintaining the ability to access the Nano through the Serial Monitor. Since there is only one Hardware UART system on the both devices (each based on the ATmega328p) we need to employ the Arduno's SoftwareSerial Library to emulate the Hardware Serial UART on any two pins, so the Nano and UNO can talk to one another (again, while leaving the Nano's Serial Monitor available for your control).
Before we address the software serial communication connections, consideration must be given to powering both MCUs. A review of this blog suggests that since the Nano Host is our primary device (drawing power from our laptop's USB Cable) when the system is up-and-running, power for the UNO Assistant could come from a second 5V USB source (or, better yet, your 9V AC/DC adapter you should still have from Grade 10) into the barrel jack connector of the UNO.
One more power consideration is access to a common ground. Two independently functioning electric systems will only function in a coordinated manner if they share a common ground reference. This is easily achieved by connecting the grounds on both MCUs together, with a wire. Assemble your hardware prototype as shown, replacing the 9V battery with your 9V ACDC wall adapter, if possible.
- Solder up your LCD Appliance for use with your UNO Assistant using the additional parts provided you on Monday November 9th.
- Watch this short video with the goal of recreating a similar prototype.
- The first software task is to create code that will reside on the UNO Assistant that simply echoes the text passed to it by the Nano Host. Create an Arduino Project by the name of UNOLCDFromNANOHost and drop in this code.
- Upload the code to the UNO Assistant.
- The second software task must confirm that the Nano Host can receive text from the Serial Monitor, transmit it to the UNO Assistant which will, in turn display it on its LCD Appliance. Create an Arduino Project by the name of NANOFromSerialMonitorToUNOLCD and drop in this code.
- Complete the body of the loop() function in NANOFromSerialMonitorToUNOLCD to confirm the video in that text entered through the Serial Monitor to the Nano Host is relayed through the SoftwareSerial object to the UNO Assistant which echoes it on the second row of its LCD Appliance.
Project 2.3. Ask UNO
Your Nano Host requires the suppport of your UNO Assistant for the evaluation of 'simple' arithmetic expressions. By 'simple' I mean your UNO Assistant only accepts expressions in the form, a?b in which the operands a and b are limited to single digit ASCII characters and the ? is one of the 5 arithmetic operators. +, - *. /, or %.
Expressions of the correct form a?b are entered by you in the Serial Monitor and read by your Nano Host. The Nano Host echoes the original expression on the second row of its LCD and transmits it, in its original form, to the UNO Assistant which also echoes it on the second row of its LCD Appliance. The UNO Assistant will parse the String expression, evaluate it, display the result on the second row of its LCD Appliance before transmitting its String equivalent back to the Nano Host for display on the second row of its LCD screen. The original expression and its evaluated result are presented for 5 seconds on both screens before the Nano Host requests the next expression from you through the Serial Monitor.
For the Basic Task your code can assume the user enters correctly-formed expressions. The operands and result remain as integers. You can assume the user does not request division by 0.
Here is a video of what you're going after, including a samples of Enhanced Tasks that include handling malformed expressions and floating point evaluations.
The door is open for creative extensions by inspired ACES, but know yourself and your own personal risk tolerance. Here are some possibilities that you might consider.
- Floating Point. A variation the UNO Assistant will permit is in the form of a?bf in which the f suffix (case-insensitive) indicates that the Nano Host wishes the UNO Assistant to return a string that results from performing the evaluation using floating point numbers (2 decimal places by default). Here are some syntactically-correct expressions and the result they should return.
- Malformed Expressions. The UNO Assistant should ONLY receive syntactically-correct expressions. As a result, the Nano Host should undertake a form of preprocessing (similar to the early stage of the Arduino C execution cycle) through the syntactic analysis of the input with the responsibility of rejecting erroneous strings and saying so on Row 2 of its LCD.
- Defend against requests to divide by 0.
- Multi-Digit Operands. You may wish to permit multi-digit operands, as in aa?bb or aa?bbf
- Multi-Operator Expressions (without Operator Precedence). You may wish to permit multiple operator expressions, similar in form to a?b?c or a?b?c?df. You would not be required to respect operator precedence while maintaining simple left-to-right associativity.
- Multi-Operator Expressions (with Operator Precedence). Same as previous but elevating *. /, or % above +, or -.
- Please do this on your own, seeking a sensible amount of Forum assistance, if necessary.
- You'll receive a terrific mark for doing the Basic Task well, and on your own. Do not attempt an Enriched Task if you've been struggling in any way so far.
- Everyone's project must cover the requirements of the Basic Task, even if you are inspired to undertake an Enhanced Task.
- TIP. This a -project where the bulk of the challenge rests with software as the hardware prototype is all but provided for you. Rather than assemble the entire prototype before coding the Nano Host's and UNO Assistant's sketches, simply develop the code in a separate standalone sketch to see if you can evaluate the expressions accuratley. Work out the best modular approach with strategic reliance on predicate methods to simplify your logic. The image to the right (click to enlarge) is the result of creating an array of possible expression Strings (called a test harness) and iterating each of them through the evaluation code. Once you have the software worked out, only then engage the hardware. Jus' sayin'...
- Should you pursue an enhancement of the sorts outlined above be sure to document them clearly in your Report and accompanying video.
- Both the Nano Host code and the UNO Assistant code should be included in properly formatted text boxes within your Report. Your code should reflect our recent examination of modularity principles as well as the multitude of earlier and ongoing concepts reflecting our emphasis on great code techniques.
- All previous embedded DER comments must have been addressed.
- Attach both sketches as well as your DER.docx file to your submission by the deadline.
Project 2.2. Persistence of Vision. (Reference: AVR Foundations: pp.35-38). It's strange to think that our eyes perceive much of the LED lighting around us to be uniformly ON, when they are actually OFF as much as half the time (maybe this is one of the reasons LED lighting is so cost-effective?). The next time you're in the DES, point your phone's camera at the digital clock and observe the interference bands generated by clock's display alternation and your camera's periodic scan rate.
Perhaps the most remarkable ACES PoV creation was engineered by K. Fiset-Algarvio (ACES '19, Guelph Mech. '23) in his amazing Grade 11 ISP: The Persistence of Vision Globe. Above are two images extracted from his DER. Be sure to watch his detailed video.
You have two 14-Segment Dual CC Alphanumeric Displays in your kit. An image of the device appears below, left, in which I have coloured a few segments to simulate a 'possible' depiction of the two-letter word AS. Here's the link to its datasheet so you can familiarize yourself with its pin layout. Given its 14 segments, this component can be driven by two SN74HC595 shift registers* and a pair of transistors (one NPN and one PNP) under control of a SINGLE square wave (bottom, right), in a Persistence of Vision scheme.
*Although the ATmega328p has enough pins to complete this task without using shift registers, you are required to do so, for practice.
BASIC Task. (Adapted for 2020-2021)
- This project requires you to combine a number of recent hardware and software techniques introduced in class to produce an alphabetic PoV display of letters entered by your users through the Serial Monitor's input text box. In particular, you will employ only TWO Shift Registers and the square wave alternation circuit above, to affect a Persistence of Vision strategy on your dual display device.
- Be sure to have available a complete 26-element array of type uint16_t that defines the segment maps for each uppercase letters from A to Z. The organization of the segments will have to match your wiring to the segments to be effective. These array definitions are typically called Lookup Tables or, simply, LUTs.
- Create the Arduino project, PoVWord.
- Within the project sketch of the same name, develop code that will call upon your LuT to echo the two-letter input from the user on your dual 14-segment display device.
- You do not need to implement the decimal point unless warranted.
- You can assume users enter two letters only, however your code must be prepared to change a lowercase entry to uppercase prior to its display.
- Be sure to FULLY document your (efficient and original as possible) code and attach POVWord.ino to your submission as the second attachment, along with your DER.docx file.
For the ambitious, consider the following any or all of the following. If you implement any enhancement add a section on you DER entitled Enhancement and document your creative extension(s).
- You have TWO of these dual displays...Hmmm....double the fun?
- Software comfortable ACES may wish to dive deeper into the Arduino String library in support of allowing users to enter more than two characters and have them scroll across your display.
- Fans of the Periodic Table fans may wish to create a LuT with each elements' 2-letter symbol (a space is a character) and allow users to enter the number of the element (echoed on two 7-segment displays). Your code would present the elements' symbol on the dual 14-segment display.
- There are many more ASCII characters than the uppercase letters. Consider, for example, enlarging your LuT to include the additional lowercase characters. Note: the ASCII Table inserts 6 characters between the uppercase letters [65,90] and the lowercase letters [97,122].
- Use Write14SegASCIIEEPROMKWA-541XPGB.ino code to populate EEPROM as a means to eliminating the need to define your LuT every time in your application code. Be sure to include this additional EEPROM code in your DER and attach it to your email.
- Lots of other ideas for the imaginative....
Advice (trust Mr. D's experience)
- This is a CHALLENGING project. Do NOT doubt yourself, you are all talented enough to complete it. Success follows those who simply devise a SMART plan and have the DISCIPLINE to execute it.
- If you are thinking about engineering, get used to hard work. A number of your Grade 10 peers have already fallen by the wayside because they feared the workload. More students will end up transferring out of engineering in university because they are not prepared to engage the demands. The GOOD news is that once you get used to the workload, like anything else, it doesn't seem so bad, and feels easier.
- You'll have far less trouble with this project if BREAK THE PROJECT DOWN INTO SMALL STEPS as you go.
- After reading the project description a few times and digesting as much content from the links as possible, CLOSE YOUR LAPTOP AND TOOLKIT, grab a pencil and paper and proceed to write down as many required steps as you can think of, in the correct order.
- Once you've done that. I encourage you to start SMALL and master the little things. For example, on the software side, develop test code to write and read 8 and 16 bit data to and from EEPROM. On the hardware side, wire up a SINGLE shift register and a SINGLE NPN transistor and write some TEST CODE to see if you can, reliably and predictably, light just 8 segments on a SINGLE digit. Again write LOTS of test code sketches as you go. Only after the first test was successful will you add a SECOND shift register and add a little more code to see if you can get 14 segments on the SINGLE digit to accurately present a letter.
- When writing software be wary of external processes taking time. These include, reading from and writing to the Serial Monitor, reading from and writing to the EEPROM, and analogRead functions using the ADC. Adding small delays , even 1 μs, can help and does not slow your performance down noticeably.
- You may wish to write a separate sketch for simply populating EEPROM with your letter segment maps. This could be useful in future projects. If you do, be sure to include this in your Report.
- Wire in the PNP transistor and change one line of your test code to have the same letter appear on the OTHER digit display. You get the idea...
- JUST LIKE SOLDERING, if you try to bang the ENTIRE project together without testing the individual stages along the way, your prototype will NOT work, you'll get depressed, will not finish the project on your own, wonder why you ever took this course, and question whether you have what it takes to be an engineer. All because you simply did not follow a careful step-by-step, stress-free strategy.
- BE SMART ON THIS PROJECT. You'll teach yourself a VALUABLE lesson and skill that you will use again and again, over the entire course of your life!
- Trust Mr. D.
For many of you, next to your Secondary School Graduation Diploma, your DER will be your most important high school document as the two of them may very well open the doors to your careers.
Take great pride in your craftsmanship of this work.
First, make the following edits to your DER,
- Add ICS3U to your title page after ICS2O, separated by a comma of course. Next year you can add ICS4U :)
- Insert a Next Page Section Break at the end of your Grade 10 ICS2O reports
- In the middle of the (divider) page type ICS3U, in large font, centered on the page. Suspend the display of the header and footer on this divider page (Hint: Section Breaks).
- Insert another Page Break.
- Adjust the new header to reflect the ICS3U course code, but continue the page numbering in the footer.
- Begin this year's submissions with a report entitled, Project 2.1. Traffic Light.
- Be sure to update your ToC prior to submission.
Project 2.1. Traffic Light. Since many of you will be pursuing your driver's license in the near future, the focus of this first project is the careful soldering and QUALITY programming of a standard traffic light. When Jasper Schaffer (Fraser's older brother) (ACES '18, Queen's '22) was in his ICS3U year, he designed the handy little PCB pictured to the right that we'll exploit to start our year off. For the assembly aspect of this project you will solder one each of a green, yellow, and red 10mm LED and a four-pin right-angle header from your toolkit onto the Schaffer Traffic Light PCB you have been provided with. Take care as there are NO replacement parts. The right-angled male header pins allow your device to be inserted directly into adjacent female port pins on your Arduino (eliminating the need to use a breadboard and hookup wires). Be sure to document your soldering of the device through video acquisition that you can include in your report. For the testing aspect, you will include media as well as a well-planned sketch modified but based on our discussions and models in class. The fully documented sketch should cycle through the LEDs continuously with the green and red remaining on for four times the duration of the yellow (amber) LED.
In your Report, you are include the Purpose, Reference, Procedure, Code, Media, and Reflection subsections in Heading 2 style. A full Parts Table, with background shading consistent with your previous ICS2O colour theme and width of 3" and should appear right-aligned within the Procedure section. Finally, ensure that no content is allowed to spill into any of the four page margins.