Week 13 - lglik/Portfolio GitHub Wiki

11/14/18 - 11/27/18

Day One:

Absent.

Day Two:

Today, I was able to successfully change the direction of the current going through the magnets. Using this, I wrote some code as a proof of concept that would slowly move the trees out, off, in, off, out, off, in, in a loop. I was also able to easily change the speed at which it does so which will be very useful in the future. I have started to write methods that will make the magnets move to a certain state, and will use if statements to make it so the current state of the magnet does not need to be specified. I also worked with Ken on the board that reads current from the batteries. One of the issues is that the board was not attached via the default port so the example code was not working. We then received actual values from the boards which was great, but they were not reflective of the actual state of the batteries. We believe that the issue lies in parts of the board and one of the pairs of batteries, not being grounded.

Day Three:

I continued to work on writing code to ramp the PWM values of the magnets. I had already made it so that I could tell the magnets to move between certain predetermined states, where I was hard coding what PWM values it should go to. today, I wrote code that calculates how fast and between which the values the PWM should change in order to change to a specified state. during this process I discovered that unfortunately, no matter what code I write, it is likely filings will be flung off from the magnets, because there is no way to save what state each one was in when the project was turned off. I also made a lot of my code into methods to make the code easier to understand and shorter. I made functions for switching direction, setting speed and turning all of the magnets, not just one at a time, to a certain state. It was really great to finally have all of this working after so many weeks. The next step is to actually move over and implement this code into the main.py file for the project. At some point, I will also need to figure out what the fastest speed is that the magnets can change PWM values at without filings being flung off.

Image 1

The code that changes a magnet from any state to the "in" position

No School until 11/26

Day Four:

Instead of actually moving over all of the code for making the PWM values change more slowly, I just imported the code. I replaced the old code for changing the states with function calls to the new code. Amazingly, with the addition of just those three lines of code, everything worked perfectly. The whole project runs as normal but the trees can be made to move at any desired speed. The next issue I wanted to address was that in the design scene, when a tree to pressed, the magnet that actually changes is on the opposite side of the project. I spent a while learning how the Kivy graphic was made and how it used the touch input to change the state of the magnet. In the end, I simply changed the code so that each row of trees on the screen was generated from left to right instead of right to left. This fixed the issue. I also added a wire to the project that connects the ground of both of the batteries which should make it so that I can actually detect what the voltage of each one is.

Day Five:

With the batteries now properly grounded, the example code, when ran, would output the correct voltage values of the batteries as verified with a multimeter. I created a new file that uses the Adafruit library to check the voltage of each battery. I then wrote a function to read voltage and then switch to whichever battery has less voltage. Implemented the code from the new file into the code for the project by importing it and calling its functions. One of the main issues I had at first was that the board that reads the voltage of the batteries requires a battery to be on for it to work. Therefore, when the code for the project is run, I have to first tell it to use one of the batteries and, then once that battery is providing power to all the I2C devices, decide using the new input to either stay on the battery, or switch to the other one. At this point, I have only put in code to check the batteries when the project is turned on and will have to add code that checks at regular intervals of time.