Following up from my last post about the Bluetooth Controlled AC Switch, our project was a success at the first-ever Junior Design expo here at Oregon State. With the project fully functional, I’d like to take some time to write about the process and the design we came up with and used.
First of all, our complete block diagram of the system is here:
The system was originally divided into eight blocks, but for the purposes of easily dividing work into two blocks per person several blocks were merged together. At the end of the first term, our block diagram for the system was essentially finalized and individual work was assigned. I was tasked with completing the AC Sense, AC Control, Embedded Bluetooth and Microcontroller Processing blocks, which became the Current Sensor and Switches block along with Microcontroller Processing (+ Bluetooth).
Our more or less complete implementation schematic of this system is here:
The system was more or less designed over the 13 weeks given to us (3 weeks in the first term, 10 in the second), and implemented almost entirely over the final 10 weeks of the term. Team members were expected to complete one entire block’s implementation ompleting one block’s implementation by week 5 (week 2 of the second term), and then the second block by week 9, leaving the final 4 weeks for system integration and testing.
I was in charge of the main microcontroller, the Bluetooth communication link on the embedded side of the design, and the AC current channels. The first design decisions I made were to try and reuse as much design as possible for the AC front end as I had never worked with high-voltage/AC mains electronics before, and so I wanted to play it as safe as possible. To that end we used ACS713 breakbout boards for AC current sensing, and some SunFounder 5V actuated relays for enabling/disabling our AC output channels. The final design includes ACS723 ICs as the ACS712 has been deprecated in favor of these newer chips, but other than this change the AC Current Sense and Control block remains identical.
For the main microcontroller block, I wrote almost all the firmware for the ATMega328P using a mixture of plain C, C++, and Arduino-style C++. Arduino-style code is mostly constrained to working with the SPI bus in an interrupt-safe manner, and for interacting with the Adafruit Bluefruit BLE coprocessor, which had existing library support in the Arduino ecosystem.
All in all this project was quite the learning experience, and a lot of the most difficult aspects were things I certainly didnt expect to be so difficult ahead of time. Firmware development was mostly smooth, save for some severe bugs such as one race condition that was caused by using the SPI bus of the AVR in both interrupt routines and main code - which was difficult to debug, but easy to fix, as described in this DorkbotPDX blog post, which explains some of the motivations behind the Arduino ecosystem’s move to using Transaction-based communications over the SPI bus.
The main board design unfortunately had some fairly large errors; the first of which was discovered shortly after putting all the surface mount components on the board through the IR oven… See if you can catch it here in the power supply block:
KiCad’s DRC is fairly good, but it didn’t save me from making this one major mistake with reimplementing this common design for the TPS54232. While moving some things around on the main schematic sheet, apparently the junction at the PH pin got disconnected:
After having worked many 10+ hour days on the board design in a row, I apparently wasn’t capable of noticing the error myself. The DRC didn’t look for any suspiciously unconnected lines, or report for junctions with only 2 active connections, which is unfortunate. Ultimately this leads me to one of the most important lessons of this project, and Junior Design as a whole: the importance of design reviews. Design review isn’t just for code; it’s for everything in a project of this scale. A few more issues could have easily been caught earlier in the process that would have made the entire design easier to work with by the time the Expo came around, including more communication between the board designer (me) and the mechanical enclosure designer, as ultimately it became difficult to integrate our blocks together due to a lack of reviewing each other’s work.
Having spoken with a number of students currently in OSU’s ECE Senior Design project, I feel much better about how hectic and difficult this project turned out to be to achieve for our group of three students. I learned a few technical skills throughout the project to be sure, but I think the most rewarding lessons from this are the ones about project and time management, and hammering out some of the more difficult aspects of working in a team of engineers.