Difference between revisions of "Simple Embedded System Project"

From Embedded Systems Learning Academy
Jump to: navigation, search
Line 3: Line 3:
  
 
== Structure ==
 
== Structure ==
There are minimum four nodes to be designed by a team of 10.  Each team is then split into smaller sub-team for the design of each of the four nodes.  Each team of 10 will also compete with the other teams in your class and your grade will be assigned relative to each other with the best team earning the best grade.
+
There are minimum three nodes to be designed by a team of 6; you can add more nodes and more people in a team if you project is challenging enough.  Each team is then split into smaller sub-team for the design of each of the nodes.  Each team will also compete with the other teams in your class and your grade will be assigned relative to each other with the best team earning the best grade.
  
 
== Example Nodes ==
 
== Example Nodes ==
Line 16: Line 16:
 
=== Commander Node ===
 
=== Commander Node ===
 
This node shall be responsible to put it all together and serve as a single commanding node to get sensor input and control the lights.  This node shall provide the interface for the user, so try to provide user options to configure features such as automatic lights, or remote controlled operation.
 
This node shall be responsible to put it all together and serve as a single commanding node to get sensor input and control the lights.  This node shall provide the interface for the user, so try to provide user options to configure features such as automatic lights, or remote controlled operation.
 +
 +
<BR/>
 +
== Requirements ==
 +
=== Technical ===
 +
*  You must use a '''<code>switch / case </code>''' code section in your code.
 +
*  Use a state machine in you code.
 +
*:  This could be as simple as a state machine for "Manual Lights" vs. "Automatic Lights"
 +
*  You must utilize functions that use pass-by-value and pass-by-reference.
 +
*  Project should be self-contained
 +
*:  Project should be enclosed, with no wires visible.
 +
*:  Should not require the Hecules Terminal to operate
 +
*:  All buttons should be labeled.
 +
 +
=== Deliverables ===
 +
At the end of the project, the following items need to be submitted :
 +
*  Full source-code of all the projects
 +
*  Individual evaluations about team members and their contribution
 +
*:  This will be confidential, and you can submit as one per person (at Canvas).
  
 
<BR/>
 
<BR/>
Line 33: Line 51:
 
=== Light Sensor Node ===
 
=== Light Sensor Node ===
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
#include "mesh.h"
+
#include "wireless.h"
#include "nrf_driver.h"
 
  
 
void process_command(char command);
 
void process_command(char command);
Line 46: Line 63:
 
         /* Check if we get a packet within 1 second : */
 
         /* Check if we get a packet within 1 second : */
 
         mesh_packet_t wireless_pkt;
 
         mesh_packet_t wireless_pkt;
         if (nrf_get_pkt_received(&pkt, 1000)) {
+
         if (wireless_get_pkt_received(&wireless_pkt, 1000)) {
 
             /* Assuming first data byte is our command: */
 
             /* Assuming first data byte is our command: */
 
             process_command(pkt.data[0]);
 
             process_command(pkt.data[0]);
Line 80: Line 97:
 
=== Commander Node ===
 
=== Commander Node ===
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
#include "mesh.h"
+
#include "wireless.h"
#include "nrf_driver.h"
 
  
 
int main(void)
 
int main(void)
Line 100: Line 116:
  
 
         cmd = lights_on;
 
         cmd = lights_on;
         mesh_send(lights_addr, mesh_pkt_ack, &cmd, 1);
+
         wireless_send(lights_addr, mesh_pkt_ack, &cmd, 1);
         /* TODO Check if we got an ACK */
+
         if (wireless_get_ack_pkt(&pkt, 100)) {
 +
            // We got an acknowledge from lights_addr
 +
        }
 +
        else {
 +
            printf("ERROR: No acknowledge from %i (lights)\n", lights_addr);
 +
        }
 
         delay_ms(3000);
 
         delay_ms(3000);
  
 
         cmd = lights_off;
 
         cmd = lights_off;
         mesh_send(lights_addr, mesh_pkt_ack, &cmd, 1);
+
         wireless_send(lights_addr, mesh_pkt_ack, &cmd, 1);
 
         /* TODO Check if we got an ACK */
 
         /* TODO Check if we got an ACK */
 
         delay_ms(3000);
 
         delay_ms(3000);

Revision as of 01:10, 9 August 2013

Objective

Work together as a class to create a wireless network of interactive devices. An example would be one controller responsible for lights, another controller responsible for motion sensor, and a central control can interact with these controllers to perform tasks such as turning on lights when motion has been detected.

Structure

There are minimum three nodes to be designed by a team of 6; you can add more nodes and more people in a team if you project is challenging enough. Each team is then split into smaller sub-team for the design of each of the nodes. Each team will also compete with the other teams in your class and your grade will be assigned relative to each other with the best team earning the best grade.

Example Nodes

The nodes listed below are just examples. You can and should create your own node with its own purpose that goes above and beyond the examples listed in this article. Four unique features are required per node, and some hints are provided in the latter part of this document.

Lights Node

This node shall act like a wireless node that is responsible to turn on and off lights. This will involve some hardware design such that you can connect your board to some high-power LEDs. Look-up “super bright led” at sparkfun.com for examples.

Sensor Node

This node shall act like a sense point for the commander node. The objective is not just to provide the on-board sense points such as temperature and light, but also implement features such that you can report other creative sense points such as a motion sensor, and distance sensor.

Commander Node

This node shall be responsible to put it all together and serve as a single commanding node to get sensor input and control the lights. This node shall provide the interface for the user, so try to provide user options to configure features such as automatic lights, or remote controlled operation.


Requirements

Technical

  • You must use a switch / case code section in your code.
  • Use a state machine in you code.
    This could be as simple as a state machine for "Manual Lights" vs. "Automatic Lights"
  • You must utilize functions that use pass-by-value and pass-by-reference.
  • Project should be self-contained
    Project should be enclosed, with no wires visible.
    Should not require the Hecules Terminal to operate
    All buttons should be labeled.

Deliverables

At the end of the project, the following items need to be submitted :

  • Full source-code of all the projects
  • Individual evaluations about team members and their contribution
    This will be confidential, and you can submit as one per person (at Canvas).


Challenges

Over the course of the project, you will encounter some real-world problems such as :

  • How will you design your project to be user friendly?
  • How will you collaborate in your large team?
  • How will you balance your budget and keep parts cost to a minimum?
  • How will you design your network protocol such that each team understands a command and response system well?
  • How will you make your project more creative? How will it stand out?
  • What if you command a light output node that is not responding?
    How will you report this to the user and what would you do?


Sample Code

Light Sensor Node

#include "wireless.h"

void process_command(char command);

int main(void)
{
    char our_addr = 100;
    mesh_set_node_addr(our_addr);

    while (1) {
        /* Check if we get a packet within 1 second : */
        mesh_packet_t wireless_pkt;
        if (wireless_get_pkt_received(&wireless_pkt, 1000)) {
            /* Assuming first data byte is our command: */
            process_command(pkt.data[0]);
        }
    }
    return 0;
}

void process_command(char command)
{
    enum {
        lights_on = 1;
        lights_off = 2;
    }

    switch(command) {
        case lights_on:
            /* TODO Turn on lights */
        break;

        case lights_off:
            /* TODO Turn off lights */
        break;

        default:
            /* TODO Take action for invalid command */
        break;
    }
}


Commander Node

#include "wireless.h"

int main(void)
{
    /* Same enum as lights controller */
    enum {
        lights_on = 1;
        lights_off = 2;
    }

    char our_addr = 200;
    char lights_addr = 100;
    mesh_set_node_addr(our_addr);

    while (1) {
        /* Turn lights on/off every 3 seconds */
        char cmd = 0;

        cmd = lights_on;
        wireless_send(lights_addr, mesh_pkt_ack, &cmd, 1);
        if (wireless_get_ack_pkt(&pkt, 100)) {
            // We got an acknowledge from lights_addr
        }
        else {
            printf("ERROR: No acknowledge from %i (lights)\n", lights_addr);
        }
        delay_ms(3000);

        cmd = lights_off;
        wireless_send(lights_addr, mesh_pkt_ack, &cmd, 1);
        /* TODO Check if we got an ACK */
        delay_ms(3000);
    }
    return 0;
}