Week 10 - lglik/Portfolio GitHub Wiki

10/24/18 - 10/30/18

Day One:

Today, I worked more on the code for making the electromagnets change state slower. I spent a large amount of time trying to troubleshoot why the code was not working. Eventually, I realized the problem was that I was using a variable to store the previous state of the magnets. There are thirty-three magnets, so when I ran the code, only the first magnet would change state, because when the other magnets tried to change state, it thought that they were already at the desired state, so the PWM value was not changed. I replaced the variable with an array with each magnet at its index, and the code worked perfectly. I then began work on how to make them change state slower. I wrote some code that increments or decrements the PWM values extremely slowly. There were no errors, but the GUI would freeze when I tried to press a button to change the state of the magnets.

Day Two:

absent

Day Three:

My wrist had been hurting from standing up and using the built-in monitor on the project. To fix this, I set up a table next to the project with my Surface Pro. I connected it to the magnetic trees project using ssh and set up a new project in PyCharm that is synced with the Pi. Now that I was using a real IDE, I was able to go through the code and make a lot of improvements. I was able to use PyCharm to reformat all the code, remove redundant parentheses, redundant statements and automatically fix the capitalization of many variables. After doing all of that, I worked more on getting the electromagnets to ramp up and down. I am now able to get the magnets to do that one at a time, but I would like to have them do it all at once, so it is faster and looks nicer. Changing that will require a lot of code restructuring.

Day Four:

I continued to do some code restructuring using PyCharm. I had been trying to get the magnets to ramp up and down using a for loop where the PWM slowly moved to the correct value. Unfortunately, this had not been working. Today I figured out why. The value that is passed from the Pi to the servo driver is not actually the PWM but information for both the PWM and the direction with a bit mask. So, when I tried to iterate through values near it, I was passing along nonsense that did not make the magnets do anything. I then changed back a fair bit of my new code so it did not do this and would work well. From talking to a mentor, I realize that I need to spend more time understanding the lower level aspects of the code. I also plan on making a block diagram of all the hardware between the Pi and the electromagnets and the channels.

Image 1

The GUI layout for making a frame of the magnetic trees show.

Day Five:

absent