Skip to content

Commit

Permalink
Postlab and tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardalee committed Jul 31, 2023
1 parent ae480f1 commit 390b2ca
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
16 changes: 10 additions & 6 deletions docs/src/Introduction.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# Introduction
This series of labs exposes students to introductory embedded systems concepts.
The labs focus on cyber physical systems modeling and design.
They use the [Lingua Franca coordination language](https://lf-lang.org) to provide timing, concurrency, and state-machine modeling (via its modal models).
All code is run on an inexpensive Raspberry Pi Pico ❤️.
They use the [Lingua Franca coordination language](https://lf-lang.org) to provide timing, concurrency, and state-machine modeling (via its modal models),
and low-level programming is in C.
The labs are designed to be companion exercises for a course based on [Lee and Seshia, _Introduction to Embedded Systems: A Cyber-Physical Systems Approach](https://leeseshia.org), MIT Press, 2017.
The C code runs on a [Raspberry Pi RP2040](https://en.wikipedia.org/wiki/RP2040)
on the [Pololu 3pi+ 2040 robot](https://www.pololu.com/docs/0J86).
The same RP2040 microprocessor is also available on the low-cost [Raspberry Pi Pico board](https://en.wikipedia.org/wiki/Raspberry_Pi#Raspberry_Pi_Pico), but this board does not have the sensors and actuators of the Pololu robot, so you will need the robot to be able to complete all the exercises.

## Resources
## Acknowlegments

- [Online tutorials and reference documents](./Resources.md)
- [Acronyms](./Acronyms.md)
The main authors of this version of the labs are:

- Abhi Gundrala
- Edward A. Lee

## Acknowlegments
These labs are derived from several generations of lab exercises for the Berkeley EECS 149/249A course, Introduction to embedded systems. Contributors to the lab design include:

- Joshua Adkins
Expand Down
4 changes: 0 additions & 4 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Summary

- [Introduction](./Introduction.md)

# Setup

- [Installation](./Installation.md)

# Lab Exercises
Expand Down
11 changes: 11 additions & 0 deletions docs/src/Sensors.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,14 @@ You should see the display light up looking something like this:
3. Create a reactor called `Tilt` that takes as inputs the _x_, _y_, and _z_ readings from the accelerometer and outputs the pitch and roll in degrees. Put this reactor in the `src/lib` directory and then use it in a variant of the `AccelerometerDisplay.lf` named, say, `TiltSolution.lf`, to show pitch and roll in degrees rather than _g_ force accelerations in the LCD display. **Save your `Tilt` reactor for use in future labs.**

**CHECKOFF:** Show your pitch and roll displays and check that they are reasonable.


## Postlab Questions

1. Suppose a sensor gives you a 16-bit signed integer representing some measured quantity in some well-defined units, that the range of the sensor in those units is -4.0 to 4.0, and that the sensitivity in those units is 0.000122 (1/2<sup>13</sup>). What is representation in hex and in binary of a sensor reading of 1.0 in those units?

2. Suppose that your goal with the accelerometer is to measure the tilt in degrees of the surface on which your robot is moving. How would you measure the bias and then compensate for this bias?

3. Suppose that your goal is to orient the robot to point straight up the hill. How would you use the pitch and roll measurements to accomplish this?

4. What were your takeaways from the lab? What did you learn during the lab? Did any results in the lab surprise you?
16 changes: 8 additions & 8 deletions docs/src/Tools.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 1. Tools and Environments
# 3. Tools and Environments
The purpose of this lab exercise is to familiarize you with the hardware and software used for embedded software programming. This lab exercise assumes you have followed the [Installation instructions](./Installation.md). The [Resources](./Resources.md) and [Acronyms](./Acronyms.md) pages will also prove particularly useful.

Embedded systems often have limited resources and interaction methods and hence require a different approach for programming.
Expand Down Expand Up @@ -52,7 +52,7 @@ The VS Code extension for Lingua Franca has a particularly useful feature where

<img src="img/VSCodeExtension.png" alt="VS Code extension for Lingua Franca"/>

## 1.1 Prelab
## 3.1 Prelab

These exercises are intended to make sure you are up-to-speed on using the Unix command line. See [Resources](./Resources.md) for some pointers.

Expand All @@ -63,7 +63,7 @@ These exercises are intended to make sure you are up-to-speed on using the Unix
5. In a git repository, what command displays whether there are any local changes and what they are?
6. In a git repository, what does `git pull` do?

## 1.2 A First C Program
## 3.2 A First C Program

First, check your installation has been done correctly. One of the side effects of the installation is to define an environment variable called `PICO_SDK_PATH` that points to the root location of the RPi-Pico SDK. Check it:

Expand Down Expand Up @@ -159,7 +159,7 @@ Find and examine the C program `blink.c`. How is it controlling the timing of th
Explain how the timing of the blinking of the LED is controlled.


## 1.3 A First Lingua Franca Program
## 3.3 A First Lingua Franca Program

Start code in the root `lf-pico` directory:

Expand Down Expand Up @@ -191,7 +191,7 @@ Modify the Blink.lf program to use two timers, one that turns on the LED and one

**Checkoff:** Show your modified LF program. Explain how this use of timers is different from the sleep function used in the C code `blink.c`.

## 1.4 Printing Output
## 3.4 Printing Output

As is typical of embedded platforms, the Pololu robot does not normally have a terminal connected to it. The LEDs and small LCD display can be used to get information about the running program, but often, particularly while debugging, it is convenient to be able to simply insert `printf` statements into your programs to see what is going on.

Expand Down Expand Up @@ -232,7 +232,7 @@ To permanently end screen, type Control-A k (for kill).

**Checkoff:** Show ON-OFF output.

## 1.5 Modular Reusable Reactors
## 3.5 Modular Reusable Reactors

The LED code in `Blink.lf` is in a main reactor, which cannot be imported into any other Lingua Franca application.
Your next task is to create reusable reactor called \code{LED} that has a single input named \code{set} with type `bool`.
Expand Down Expand Up @@ -298,7 +298,7 @@ Subsequent labs will explore more deeply the use memory-mapped registers for I/O
**Checkoff:** Show the diagram for your program.


## Postlab Questions
## 3.6 Postlab Questions

1. What format specifier(s) for `printf` allows the printing of floats (there may be several)?

Expand All @@ -308,4 +308,4 @@ Subsequent labs will explore more deeply the use memory-mapped registers for I/O

4. What does the volatile keyword mean in C? \points{3}

5. What were your takeaways from the lab? What did you learn during the lab? Did any results in the lab surprise you?
5. What were your takeaways from the lab? What did you learn during the lab? Did any results in the lab surprise you?

0 comments on commit 390b2ca

Please sign in to comment.