Week 14 - lglik/Portfolio GitHub Wiki

11/28/18 - 12/04/18

Day One:

When experimenting with changing the battery while the project was running, I quickly realized that if any I2C or GPIO devices are in use when the batteries switch, the project crashes because the temporary loss of power shuts off communication with most of the project. The only time the project is not using any of these devices is when the information scene is active. In this scene some graphics and text are displayed but nothing outside of the Pi is being used. As a temporary solution, I edited the code so that the batteries are checked once when the project starts and whenever the information scene becomes active. This works well enough most of the time but in a museum setting where the project is running for hours and hours its not worth taking the risk that someone would happen to navigate to the information scene every hour or so. I decided to use Python’s built in threading library to create a thread that would check the batteries once an hour. I wrote a thread that constituted of a while True loop that contains an if statement that would constantly be checking the time to see if an hour had passed since the batteries had last been checked.

Day Two:

There were two issue with my approach of using the threading library. One, was that this thread would crash the project if it did not somehow happen to be on the information scene when the check happened. The other, was that this thread used way too many resources, slowing the project down to unacceptable speeds. I decided that threading just wasn’t going to work for this application and decided to try to use Kivy’s clock library instead. The ivy clock library allows for the scheduling of events over time intervals. This worked really well for what I was trying to do but still did not fix the temporary power loss issue. I added more code to the event I had scheduled that would first switch the scene to the info scene, check and update the batteries, and then switch back the scene it was on before. This would, without ever crashing, regularly check and update the batteries, however, this would be quite annoying for the user. I tried to just have the scene change instantly back once the batteries had been checked but this would crash the project. I can only assume that it takes a fraction of a second between when power is sent to the I2C devices and when they start sending back information.

Day Three:

First, I started with waiting on the info scene for a couple of seconds which would obviously be very noticeable to a user. Then, I ran the program many times until I empirically determined that a wait 0.05 seconds would work without crashing. This shift to the info scene is so fast and the break in movement of the trees so quick, that it is nearly impossible for the user to notice. After finishing the code for this, I decided to improve the admin scene. Previously, there were two hidden buttons on the main screen that needed to be pressed in a certain order, at which point full and unrestricted access to the admin screen was granted. I worked to make access more standardized and secured by making it so there was only one button, in the usual corner, which was much smaller than before. I then added some more files and code from other projects. Now, when this one button was pressed, the project would move to a scene that had a keypad and only when the correct code is entered will the project move to the admin scene.

Day Four:

Absent.

Day Five:

There are also Magnetic Trees on the Carousel of physics. Theoretically, there is no difference in the electromagnets between the project. However, the one on the carousel has significantly more filings on it and they move much more. I tried stacking more of the magnets on the electromagnet bringing the total from 2 to 4 on top of it. This increased the height of the tree but did not otherwise affect anything visually. I also had the project run overnight switching batteries every hour to see the long-term changes in the distribution of the iron filings. It was also possible that the permanent magnets simply weren't strong enough so I decided to try replacing the permanent magnets with neodymium ones which are much stronger. The electromagnetic field encompasses and is much stronger than that of the permanent magnet. It is possible than that the magnet is slowly demagnetized the more the electromagnet is used. If the magnetic tree project has been used more than the carousel than that would explain the difference in the behavior of the filings.

Image 1