Electronic Technologies and Biosensors Laboratory
A.Y. 2019/2020 โ II Semester
Project #2: Variant 2
Group #6:
Manuel Carzaniga
Lorenzo Gualniera
In this project, students have to design and develop a system that controls the blinking frequency of an RGB LED based on the data read from the LIS3DH (3-axis accelerometer). Each channel of the sensor should control one color of the LED. The main objectives of the project are:
- Acquire data from the accelerometer using its built-in FIFO to reduce the load of the CPU
- Process the raw acceleration data to control the blinking frequency of the RGB LED
- Provide the end user with a hardware menu to configure some settings related to the program
- Implement a hardware feedback for the configuration with the BLUE channel of the RGB LED to indicate the value of the parameter during the configuration mode.
Project components:
- PSoC 5LP CY8C5888LTI-LP097
- LIS3DH breakout board
- 25LC256 EEPROM
- Common anode RGB LED
- Resistors 330 Ohm (x3)
- Potentiometer 10k Ohm
Power supply components:
- Ceramic capacitors 1 nF (x2)
- Electrolytic capacitors 100 uF (x2)
- Voltage regulator LM7805
- On/off switch
- Alkaline battery 9V
Prototype breadboard version:
Soldered battery powered version:
There are 3 main internal states:
-
STOP MODE:
- LIS3DH data acquisition is stopped
- On-board notification LED is turned off
- External RGB LED is turned off
-
START MODE:
- LIS3DH data acquisition is started,
- The RGB LED is driven by processed inertial measurements from the IMU FIFO
- On-board LED is turned on
-
CONFIG MODE
- LIS3DH data acquisition is stopped
- User input is taken through the knob of a potentiomenter sampled by an ADC
- RGB LED blue channel only is driven by the logical value of the flag set by the knob
- Exiting this mode will resume the previous state
Transitions between internal states, such as start, stop and configuration, are handled with either a quick double click or a long pression of the PSoC on-board button. The logic behind the button functioning has been designed completely in hardware in the top design of PSoC creator, as shown in the next schematic:
A local queue is kept in order to store 6 FIFO of LIS3DH data at a time, enqueing the newest FIFO and dequeing the oldest FIFO of data.
Whenever an over threshold event occurs this local queue is stored in the EEPROM as a log message of 5 pages (64 bytes each) structured as follow:
+--------------------+
| Log ID | <1 byte>
+--------------------+
| INT register | <1 byte>
+--------------------+
| Timestamp | <2 bytes>
+--------------------+
| |
| Data | <60 bytes>
| |
+--------------------+
The overall data payload of 6 FIFO (576 bytes) is down sampled by 2 (288 bytes) to fit 5 pages of the EEPROM (except the last page that has only 60*5 - 288 = 48 bytes, the remaining 12 bytes are padded as zeros). This permits to be consinstent in storing the same amount of samples (288 bytes --> 0.96s) at each over thresold event.
The SEND_FLAG set by the user during CONFIG mode allows to send raw FIFO data stream over UART to the Bridge Control Panel. The settings needed to plot the data correctly can be found inside Bridge_Control_Panel folder.
As an extra feature, a simple python script for debugging the EEPROM memory, with useful commands that interface with the PSoC using UART communication, is provided.
-
Install the requirements in /Python_Script/requirements.txt
$ pip3 install -r requirements.txt
-
Run the script in Python_Script folder
$ python3 psoc.py
-
Wait for automatic scanning for the serial port on which is connected the PSoC (make sure to have only one device connected, and that the port is free)
-
Choose a command from the list:
-
R = reset logs in EEPROM memory and sets the Reset Flag in the control register to 1.
-
C = request control register status of the EEPROM.
Reset flag Send flag Config Mode Start/Stop Mode 0 0 0 1 -
L = request specific log by ID, it will print on the terminal the header of the log and plot the data saved in the log.
LOG_ID Timestamp (s) INT1_REG 2 105 0x56 -
N = request number of logs stored in the EEPROM.
Before requesting a specific log, you must first request the number of stored log at least once. This is done in order to check for bad log ID requests.
-
- The python script should be supported on all major operating systems (windows, macOS, Linux), but it was tested on windows machines only.
- The python script is unable to work properly if the UART communication is flodded (i.e when the verbose flag SEND_FLAG is set to 1 allowing the IMU data transmission used for serial plotting).