Difference between revisions of "ECE434 Project - Comrade Candles: Linked Lighting"

From eLinux.org
Jump to: navigation, search
(Installation Instructions)
m
 
(24 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:ECE497 |PT]]
 
 
[[Category:ECE434Fall2020 |PT]]
 
[[Category:ECE434Fall2020 |PT]]
 
{{YoderHead}}
 
{{YoderHead}}
Line 26: Line 25:
 
== Executive Summary ==
 
== Executive Summary ==
  
(I left in the instructions so we can see them and edit more accordingly-Sam)
 
 
Picture that summarizes the project.
 
 
Give two sentence intro to the project.
 
 
Comrade Candles are a set of customizable led strips that synchronize colors and flashing speeds over the internet, It also has a sound implementation that allows preloaded songs to be played as well. This allows users to have a creative way to communicate and express themselves with a friend so long as both have an internet connection.
 
Comrade Candles are a set of customizable led strips that synchronize colors and flashing speeds over the internet, It also has a sound implementation that allows preloaded songs to be played as well. This allows users to have a creative way to communicate and express themselves with a friend so long as both have an internet connection.
  
Give two sentences telling what works.
 
 
Using flask and pagekite, we are able to use a Beagle Bone to run python files on another Beagle Bone. Using this concept, we have implemented a way for the lights to change on one Beagle and Match the other, as well as play matching audio files (so long as both Bones have the audio file downloaded).
 
Using flask and pagekite, we are able to use a Beagle Bone to run python files on another Beagle Bone. Using this concept, we have implemented a way for the lights to change on one Beagle and Match the other, as well as play matching audio files (so long as both Bones have the audio file downloaded).
  
Give two sentences telling what isn't working.
 
 
The IR remote input was not ale to be implemented for the project. With the remote and transceiver we chose to use and a lack of libraries to use for decoding signals. We could not find any consistent patterns that distinguished each signal from the remote, making it impossible for us to implement.
 
The IR remote input was not ale to be implemented for the project. With the remote and transceiver we chose to use and a lack of libraries to use for decoding signals. We could not find any consistent patterns that distinguished each signal from the remote, making it impossible for us to implement.
  
End with a two sentence conclusion.
 
 
Using the method that implemented the comrade candle project, we are able to create a way to synchronize operations on two bones so long as they have the same scripts on them. While this was used for our comrade candle project, there is a vast range of projects such concepts to apply to. The files should also be able to be modifiable to incorporate more than 2 bones as well. The only negative side is pagekite has only a month long trial so a free solution that could last permanently would be preferred and ideal for a user.
 
Using the method that implemented the comrade candle project, we are able to create a way to synchronize operations on two bones so long as they have the same scripts on them. While this was used for our comrade candle project, there is a vast range of projects such concepts to apply to. The files should also be able to be modifiable to incorporate more than 2 bones as well. The only negative side is pagekite has only a month long trial so a free solution that could last permanently would be preferred and ideal for a user.
 
The sentence count is approximate and only to give an idea of the expected length.
 
  
 
== Packaging ==
 
== Packaging ==
If you have hardware, consider [http://cpprojects.blogspot.com/2013/07/small-build-big-execuition.html Small Build, Big Execuition] for ideas on the final packaging.
+
There is no specific packaging for this project. The structure of it allows you to customize it how you want. Hang up the LED strips in your room for mood lighting, use it to make a lamp, or whatever you can think of. Feel free to get creative.
  
 
== Installation Instructions ==
 
== Installation Instructions ==
 +
Github Repository:  [https://github.com/rutantj/comrade-candles-ECE434 https://github.com/rutantj/comrade-candles-ECE434]. The final code for this project is in musicAndLED folder but you can use the other folders to implement only certain parts of the project. It should be noted that while the ir-and-uart files have the ability to take input from an IR sensor, it can not reliably distinguish between different inputs and should not be used in its current state.
  
Give step by step instructions on how to install your project.   
+
Before we can run the code we must first setup Pagekite accounts to allow our bones to be access through the internet. Head over to [https://pagekite.net/ https://pagekite.net/], make an account for each device.
 +
Then run the following code to setup Pagekite on your device:
 +
bone1$ '''curl -O https://pagekite.net/pk/pagekite.py'''
 +
  bone1$ '''python pagekite.py 80 username.pagekite.me'''
 +
This will take you through the pagekite setup process if you have not done it before. Use your first account
 +
Repeat on your second device with your second account.
  
* Github Repository: [https://github.com/rutantj/comrade-candles-ECE434 https://github.com/rutantj/comrade-candles-ECE434]. The final code for this project is in musicAndLED folder but you can use the other folders to implement only certain parts of the project. It should be noted that while the ir-and-uart files have the ability to take input from an IR sensor, it can not reliably distinguish between different inputs and should not be used in its current state.  
+
Note: your pagekite page is what will be used in the code so you will need to edit the pagekite links in serverLED.py and serverLED2.py to the two pagekite pages that you created.
  
* Before we can run the code we must first setup Pagekite accounts to allow our bones to be access through the internet. Head over to [https://pagekite.net/ https://pagekite.net/], make an account and curl Pagekite to the bone using the following: TODO show how to curl Pagekite
+
After navigate to the musicAndLED folder, set up the PRU (our code uses PRU0 but you could configure it to work with PRU 1) source the setup.sh file. Then log in as root and run make (sudo will not work with the make file)
 
+
bone1$ '''source setup.sh'''
* After navigating to the musicAndLED folder, set up the PRU (our code uses PRU0 but you could configure it to work with PRU 1) source the setup.sh file. Then log in as root and run make (sudo will not work with the make file)
+
bone1$ '''sudo bash'''
bone1$ '''source setup.sh'''
+
bone1@root# '''make'''
bone1$ '''make'''
 
  
 
TODO: talk about make file problem
 
TODO: talk about make file problem
  
 
Finally, we will connect to our Pagekite page
 
Finally, we will connect to our Pagekite page
bone1$ '''python pagekite ''username1''.pagekite.me'''
+
bone1$ '''python pagekite ''username1''.pagekite.me'''
 
 
Your bone is now ready to run the code!  Open a new terminal and run serverLED.py and you'll bone will be ready to communicate.
 
bone1$ '''serverLED.py'''  
 
  
* The last step is to repeat this process with the 2nd bone and your bones you're ready to start sending LED messages to each other.
+
The last step is to repeat this process with the 2nd bone and your bones you're ready to start sending LED messages to each other.
  
bone2$ '''source setup.sh'''
+
bone2$ '''source setup.sh'''
bone2$ '''make'''
+
bone2$ '''make'''
bone2$ '''python pagekite ''username2''.pagekite.me'''  TODO: double check this
+
bone2$ '''python pagekite ''username2''.pagekite.me'''  TODO: double check this
bone2$ '''serverLED.py
 
  
 
== User Instructions ==
 
== User Instructions ==
  
Once everything is installed, how do you use the program?  Give details here, so if you have a long user manual, link to it here.
+
Now that the program is everything is setup. Run the program on both bones using the serverLED.py and ./serverLED2.py
  
Consider making it autostart for full credit.
+
bone1$ '''./serverLED.py'''
 +
bone2$ '''./serverLED2.py'''
  
== Highlights ==
+
To initialize the bones in a state where they can begin sending signals they must first receive a signal. The easiest way to this is to open a new terminal window or tab and run:
 +
bone1or2$ '''wget --spider --server-response ''username1''.pagekite.me/22/22/22/0/2/tt ''''
 +
bone1or2$ '''wget --spider --server-response ''username2''.pagekite.me/22/22/22/0/2/tt ''''
 +
Open up your bone's flask url with the extension of the r,g,b,flash delay values and whether or not you want the bone to play music (true or false). For example: ''https://123.456.789:8081/r/g/b/flashDelay/true''.
  
Here is where you brag about what your project can do.
+
From here the bones will take care of communication between themselves. All you have to do now is simply select the color, flash rate, and the song you want to play with the respective pushbuttons. The other bone will match. This communication works both ways.
  
Include a [http://www.youtube.com/ YouTube] demo the audio description.
+
== Highlights ==
 +
Watch our video demonstration here [https://youtu.be/t3a5vfN833k Demonstration].
  
 
== Theory of Operation ==
 
== Theory of Operation ==
  
Give a high level overview of the structure of your software. Are you using GStreamer?  Show a diagram of the pipeline.  Are you running multiple tasks?  Show what they do and how they interact.
+
Please reference the diagram at the bottom right as I explain how the project functions. The Diagram depicts how one of the devices in the pairing operates. Note all code on one bone has mirrored code on the other bone.
 +
We start with beaglebone1. Bone1 creates a server on a specific port. Pagekite listens in on the port forwards all communication to the public internet. The server we have coded detects when someone connects to a specific url then pulls the commands from the url. The server will then run a script on the local that handles the PRU LED code and gpio buttons. When a button is pressed on Bone1 the script briefly connects to the corresponding url for Bone2's pagekite, thus syncing the devices together.
 +
 
 +
[[File:ComradeCandlesDiagram.jpg|thumb|This diagram shows the flow of information between the BeagleBones, Flask, Pagekite, and the public domain.]]
  
 
== Work Breakdown ==
 
== Work Breakdown ==
  
List the major tasks in your project and who did what.
+
Sam worked primarily on getting the LEDs to run properly with the PRU by using examples from the [https://markayoder.github.io/PRUCookbook/ PRU Cookbook] and also helped out Tom with the online interactivity.  
  
Also list here what doesn't work yet and when you think it will be finished and who is finishing it.
+
Tom worked on the [https://flask.palletsprojects.com/en/2.0.x/ Flask] and [https://pagekite.net/downloads Pagekite] features which allowed the Bones to updated each other's LEDs and audio tracks.
 +
 
 +
T.J. worked on the the music playing feature and the IR remote feature that did not end up in the final model of the project. You can read more about that below.
  
 
== Future Work ==
 
== Future Work ==
  
Suggest addition things that could be done with this project.
+
We originally had plans to have the music and LEDs update from an IR remote that would send commands to an IR receiver on the Bone. We managed to get the UART communication on the BeagleBone to work via [https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/uart Adafruit's UART module] in Python and had the IR pulses written to the terminal by using [https://pythonhosted.org/pyserial/ pySerial]. Our issue was with processing the signals, as the input from a single button would often deviate between button presses and the signals from different buttons would often be too similar to distinguish. We were hoping we could calculate the Hamming Distance of a received signal and match it with the closest of the expected values for the implemented commands, but there wasn't a large enough difference between the signal values to use this process effectively.
 +
 
 +
Given more time, we would have liked to add this as one of the ways to interact with the Bone and provide a better user experience. The code examples and documentation from this feature's development have been left in the [https://github.com/rutantj/comrade-candles-ECE434 GitHub repository].
  
 
== Conclusions ==
 
== Conclusions ==
  
Give some concluding thoughts about the project. Suggest some future additions that could make it even more interesting.
+
From this project, we learned a lot about how the interface with the Internet by using multiple Bones and communicate with each other indirectly by using Flask and Pagekite. We also learned more about how the UART protocol works and how to find new useful Python modules that run on the BeagleBone Black. We now have a better understanding of how research and development for embedded systems works and how to adapt to issues with preliminary design ideas and complicated software.  
  
 
{{YoderFoot}}
 
{{YoderFoot}}

Latest revision as of 08:28, 30 November 2022

thumb‎ Embedded Linux Class by Mark A. Yoder


Team members: Tom Kirchhoffer, T.J. Rutan, and Samuel VanDenburgh

Grading Template

I'm using the following template to grade. Each slot is 10 points. 0 = Missing, 5=OK, 10=Wow!

09 Executive Summary
09 Packaging
09 Installation Instructions 
09 User Instructions
09 Highlights
09 Theory of Operation
09 Work Breakdown
09 Future Work/Conclusions
09 Hackster.io
09 Demo/Poster
00 Not Late

Score:  90/100

Executive Summary

Comrade Candles are a set of customizable led strips that synchronize colors and flashing speeds over the internet, It also has a sound implementation that allows preloaded songs to be played as well. This allows users to have a creative way to communicate and express themselves with a friend so long as both have an internet connection.

Using flask and pagekite, we are able to use a Beagle Bone to run python files on another Beagle Bone. Using this concept, we have implemented a way for the lights to change on one Beagle and Match the other, as well as play matching audio files (so long as both Bones have the audio file downloaded).

The IR remote input was not ale to be implemented for the project. With the remote and transceiver we chose to use and a lack of libraries to use for decoding signals. We could not find any consistent patterns that distinguished each signal from the remote, making it impossible for us to implement.

Using the method that implemented the comrade candle project, we are able to create a way to synchronize operations on two bones so long as they have the same scripts on them. While this was used for our comrade candle project, there is a vast range of projects such concepts to apply to. The files should also be able to be modifiable to incorporate more than 2 bones as well. The only negative side is pagekite has only a month long trial so a free solution that could last permanently would be preferred and ideal for a user.

Packaging

There is no specific packaging for this project. The structure of it allows you to customize it how you want. Hang up the LED strips in your room for mood lighting, use it to make a lamp, or whatever you can think of. Feel free to get creative.

Installation Instructions

Github Repository: https://github.com/rutantj/comrade-candles-ECE434. The final code for this project is in musicAndLED folder but you can use the other folders to implement only certain parts of the project. It should be noted that while the ir-and-uart files have the ability to take input from an IR sensor, it can not reliably distinguish between different inputs and should not be used in its current state.

Before we can run the code we must first setup Pagekite accounts to allow our bones to be access through the internet. Head over to https://pagekite.net/, make an account for each device. Then run the following code to setup Pagekite on your device:

bone1$ curl -O https://pagekite.net/pk/pagekite.py
bone1$ python pagekite.py 80 username.pagekite.me

This will take you through the pagekite setup process if you have not done it before. Use your first account Repeat on your second device with your second account.

Note: your pagekite page is what will be used in the code so you will need to edit the pagekite links in serverLED.py and serverLED2.py to the two pagekite pages that you created.

After navigate to the musicAndLED folder, set up the PRU (our code uses PRU0 but you could configure it to work with PRU 1) source the setup.sh file. Then log in as root and run make (sudo will not work with the make file)

bone1$ source setup.sh
bone1$ sudo bash
bone1@root# make

TODO: talk about make file problem

Finally, we will connect to our Pagekite page

bone1$ python pagekite username1.pagekite.me

The last step is to repeat this process with the 2nd bone and your bones you're ready to start sending LED messages to each other.

bone2$ source setup.sh
bone2$ make
bone2$ python pagekite username2.pagekite.me  TODO: double check this

User Instructions

Now that the program is everything is setup. Run the program on both bones using the serverLED.py and ./serverLED2.py

bone1$ ./serverLED.py
bone2$ ./serverLED2.py

To initialize the bones in a state where they can begin sending signals they must first receive a signal. The easiest way to this is to open a new terminal window or tab and run:

bone1or2$ wget --spider --server-response username1.pagekite.me/22/22/22/0/2/tt '
bone1or2$ wget --spider --server-response username2.pagekite.me/22/22/22/0/2/tt '
Open up your bone's flask url with the extension of the r,g,b,flash delay values and whether or not you want the bone to play music (true or false). For example: https://123.456.789:8081/r/g/b/flashDelay/true.

From here the bones will take care of communication between themselves. All you have to do now is simply select the color, flash rate, and the song you want to play with the respective pushbuttons. The other bone will match. This communication works both ways.

Highlights

Watch our video demonstration here Demonstration.

Theory of Operation

Please reference the diagram at the bottom right as I explain how the project functions. The Diagram depicts how one of the devices in the pairing operates. Note all code on one bone has mirrored code on the other bone. We start with beaglebone1. Bone1 creates a server on a specific port. Pagekite listens in on the port forwards all communication to the public internet. The server we have coded detects when someone connects to a specific url then pulls the commands from the url. The server will then run a script on the local that handles the PRU LED code and gpio buttons. When a button is pressed on Bone1 the script briefly connects to the corresponding url for Bone2's pagekite, thus syncing the devices together.

This diagram shows the flow of information between the BeagleBones, Flask, Pagekite, and the public domain.

Work Breakdown

Sam worked primarily on getting the LEDs to run properly with the PRU by using examples from the PRU Cookbook and also helped out Tom with the online interactivity.

Tom worked on the Flask and Pagekite features which allowed the Bones to updated each other's LEDs and audio tracks.

T.J. worked on the the music playing feature and the IR remote feature that did not end up in the final model of the project. You can read more about that below.

Future Work

We originally had plans to have the music and LEDs update from an IR remote that would send commands to an IR receiver on the Bone. We managed to get the UART communication on the BeagleBone to work via Adafruit's UART module in Python and had the IR pulses written to the terminal by using pySerial. Our issue was with processing the signals, as the input from a single button would often deviate between button presses and the signals from different buttons would often be too similar to distinguish. We were hoping we could calculate the Hamming Distance of a received signal and match it with the closest of the expected values for the implemented commands, but there wasn't a large enough difference between the signal values to use this process effectively.

Given more time, we would have liked to add this as one of the ways to interact with the Bone and provide a better user experience. The code examples and documentation from this feature's development have been left in the GitHub repository.

Conclusions

From this project, we learned a lot about how the interface with the Internet by using multiple Bones and communicate with each other indirectly by using Flask and Pagekite. We also learned more about how the UART protocol works and how to find new useful Python modules that run on the BeagleBone Black. We now have a better understanding of how research and development for embedded systems works and how to adapt to issues with preliminary design ideas and complicated software.




thumb‎ Embedded Linux Class by Mark A. Yoder