Hydroplant Subsystems – Week 5


Introduction to This Week’s Update on Smart Systems

This week have been a lot of “git pull problems” and “git push problems”, but in the end we fixed it. So here is a quote which kept us going through the problem:

We’re so good at developing smart systems, even our bugs turn into features.


Shahin Ostadahmadi

Refactoring

Code abstraction

After passing our system test last week, I moved some of the code for handling commands and communication in Arduino to our Library. The abstraction makes our code more modular since the communication and command processing are now in the library and have been handled in the background. The different nodes now, only need to construct a command handler function to decide how they will handle the node specific commands. They do that by setting a function pointer in the communicationHandler class as you can see in the documentation:

Refactoring code

Since we got our system work this time, i used this week to refactor the code i have written both for GUI and in the Library before we are moving forward. Most of the refactoring process was dividing functions into smaller functions so each function have only one purpose, changing to more describing names, rewrite some of the code to make it more readable, and commenting classes and functions for the documentation. The refactoring code was also tested before we merged into our dev branch.

Documentation

GUI documentation

Last week I tested QDoc for documentation but I found out that Doxygen was a better option. Doxygen provide a HTML file for the whole applicaiton, while QDoc created HTML files alone for each class seperatly, and it requires additional HTML file to bind all together, which will lead to too much unnecessary work. Another advantage with doxygen is that we can make a general layout and structure for the documentation and use it for all our different libraries. You can see a picture of the GUI documentation below, and it is simple to update the documentation whenever we want. I found a library with a simple HTML and css layout that I’m using.

Since we are using C++, QML, and javascript, I have to find a solution to include all file extensions we use. Doxygen does not look for .qml and .js file extensions by default, I have to find a solution to do that in the following weeks.

Library documentation

I also updated the documentation for our library with the same layout. The next step for documentation is:

  • Host a GitHub action to update the documentation when new changes available in the remote repository
  • Host all the documentation for the Master Controller, GUI, and Library on our website hydroplant.no.

Our expert in the domain Oscar Melby will take care of GitHub actions, and I will fix the website on WordPress.

Merging into dev branch

I made a git mess! big mess! and never going to forget!

We has some problems with merging the branches this week, it took quite some time to fix. The problem was with our submodules, since i copied the files structure for a new node last week, some git configurations in the .git/config file were all wrong and pointed to wrong remote branches, and some of the submodules did not point to any remote repository. Every thing seemed to be normal, but i found out that some of my changes never were pushed to the remote repo and lost some of the code. In the end me and Oscar found a solution and were able to merge it all right into dev branch. I understand if you did not understand the problem, i have no idea how to explain it writing, but hook me up and i will tell you. You should bring a pot of coffee!

Commits

Only members of the organization can see these commits.

https://github.com/hydroplantno/mqtt-nodes/commit/6005c4bdf3f680b54b69afdedcf9e555b95c0b34#diff-79d9b80e4bc0515e2e6324a0d0697faa13b10cc604f0b9e615534e4a06a195dd – Connect your Github account

This commit was too large because i forgot to exclude the autogenerated documentation files from doxygen. They were removed.

https://github.com/hydroplantno/mqtt-nodes/commit/f1affca34e712afd8c30f284f1ae5946d4a4f6cf – Connect your Github account

https://github.com/hydroplantno/library/commit/dbe435bde47ce72dd70a8db09dbf109b09e1bed4 – Connect your Github account

Oscar Melby

Testing and submodules-hell

Helped Aditi and Theo out with making their branches up-to-date with the new communication, but struggled quite a bit with this, since there were some merge conflicts and had to add new submodules which was harder than I expected. Wanted to have these branches up-to-date so Aditi and Theo could use MQTT to communicate, and to be able to merge these branches into dev later.

We have (mostly Shahin) rewritten some parts that previously were in main.cpp to be included in the library. We managed to test this new structure out this week and update the dev branch (library) to include these changes. We also updated the dev branch in our mqtt-nodes repo to include new changes, which was easier said than done. Since we use library as a submodule in each node (which is a folder in the repo) and library again has submodules, we used quite a bit of time to get everything up to date. Shahin had also made changes in the library submodule, but since these versions are “sticky”, the HEAD is detached when you cd into the submodule, so pushing changes here without changing the branch first is quite difficult. Also when updating a submodule we need to cd into the library submodule in each folder, pull changes, switch branches to the new one, cd out again, and commit these changes.

In addition, turns out submodules suck if you want to make changes to them. We use the pubsubclient C++ library for MQTT communication, but for Arduino UNO R4 this doesn’t work out of the box since the strnlen function is for some reason not implemented for this Arduino. So we made a fork of the repo and used this as our submodule instead.

Also did some minor changes in autonomy.

Commits

Only members of the organization can see these commits.

Commits were all over the place this week, but quite small. (18. sep to 22. sep)

https://github.com/hydroplantno/master-controller/commit/8b24d4120ebbb666627c1866b80a274336a59c5a – Connect your Github account

https://github.com/hydroplantno/mqtt-nodes/commits/theo/plant-mover-communication

https://github.com/hydroplantno/mqtt-nodes/commits/aditi/plant-information-communication

Commits · hydroplantno/pubsubclient

https://github.com/hydroplantno/mqtt-nodes/commits/dev

https://github.com/hydroplantno/library/commits/dev

Aditi Deshpande

On Monday I got help from Oscar to create a new branch on GitHub which included the new changes Shahin had made in regards to the communication between the master controller and the Arduino. We tried to integrate our branch with the library submodule but we encountered a lot of path errors and we had problems receiving the submodules. Later Oscar and Shahin worked on the problem so we will hopefully merge everything next week.

On Friday Theo and I immediately started to work on incorporating the switches with the help of the document and datasheet from Mustafa( our electronics guy in the main project of Hydroplant). The problem was that we didn’t have the exact shift register that he suggested we should use. We borrowed a SIPO register and connected the register to the Arduino and also connected the buttons which acted like switches, but of course, as we had chosen the wrong switch register it didn’t work. We realized that we should have used a PISO register which takes in parallel inputs(all the bits from the buttons if they were being pressed or not) and gives out a serial input, a byte that contains the activation information of all the switches. We tried finding the exact 74HC166 shift register, but we didn’t find it. However after our electronics lead Ivan and Mustafa talked to their teacher and asked if we could borrow a PISO shift register they didn’t find the 74HC166 one, but they found the 74HC165N one which was also a PISO SR. So Theo and I started to connect again, but we were not getting the results we wanted and the datasheet of both the registers looked different. We were confused about what SH/LD was, and after connecting everything and uploading the code the button states were 1 all the time when it should have been 0. Hopefully by next week we can get the original 166 SR and we can test it.

Things to do next week:

  1. Integrate our code with the communication MQTT nodes
  2. Integrate switches in our code
  3. Prepare the midway presentation

Theo Magnor

This week has not been so productive due to technical difficulties with git both on monday and friday. We have done some testing of the switchController, which will read the switch states so that the system will know where the plant mover is located. After some discussion we decided to move away from this, rather have a switch on the plant mover, it will registers every time it moves under a plant row. This is a simpler and better solution as we dont need switches at each plant row, and it will be easier to code as we down need a switch controller, but rather increase or decrease an int depending on what direction the plant mover is moving.

The team work in the group is amazing, and it truly motivates me!

Ivan Bergmann Maronsson

This week I found out that I overlooked, that the PCB is only going to take DC voltage and other signals. so my PCB design from last week would not have worked. Considering that capacitors won’t let DC current/voltage through, it only charges up the capacitor. During this week I also worked on making a logo for the layout. And I have ran into problems, with sizing the image to the right proportions. causing the logo to be either, too big where it won’t fit on the board, or too small where it won’t render the logo properly.

In the figure below we can see the logo process.

And here is the Current layout of the PCB

And the 3D equivalent.

Things to do next:
1. Create mounting holes
2. Create a netlist
3. Getting the names of components on the board

Have a nice week!


Leave a Reply