siemanko / microgrid

1 stars 0 forks source link

The Microgrid Project

This is a project that aims to help electrify villages in India. Right now it does not have that many features but it runs quite reliably on a very low cost hardware. In the future we hope to deply much more advanced demand reponse algorithms here. Right now it uses simple hardcoded logic.

Target Audience

This project is fairly tied to a corresponding TATA Microgrid Project Effort at MIT is hard to be run on boards different than designed by our group. That being said it has a lot of tiny little pieces of code that makes writing programs on embeded hardware a little bit of a headached. Some gems include:

And many more little things.

Code organization

Code is divided into 5 different folders

comm_board - communication

comm_board - data logger

Fairly self explanatory - it's pretty cool, because one only needs to define names and types of pieces of data, functions to get them and the code takes care of the reast - it's quite easy to modify if we want to get different data.

comm_board - demand_reponse

high level logic for demand reponse on both boxes - again fairly self explanatory. Basically we do a kalman filter based on combination of culomb counting and voltage/current based absolute value of soc estimation. soc_interpolation has the hardcore interpolation based on voltage/messasurement. state_of_charge has the Kalman Filter.

comm_board - drivers

All the drivers reside here. In theory if you swap out those files the code should work with arbitrary board.

comm_board - user_interface

comm_board - storage

Describes how things are layed out in EEPROM

comm_board - constants

you should REALLY REALLY read that file

link board

load board

shared

p33FJ64GS406_drivers

About User Interface

The user interface is slightly chaotic in its current form. By the looks of it you can see exactly the way it was built. Initially it was well thought out and I had ambition to make it run on a tablet, but in the end I run out of time. There's potential to quite easily port it. The only problem is figuring out serial port communication functionality on Android, but from what I know this can be done. The way it works also requires clean up. It should be much smoother to use if we want to leter give it to villagers (I imagine it should be more like an installation flow of configuring a box with each step described in the UI).

User Interface functionality

For each piece of UI I indicate wether it works form A box only, B box only or both.

Debug Tab

Settings Tab

Pressing enter is not enough to set the value - you must click buttons.

Data logs tab Pull logs (A,B) - pulls data logs and saves them to UID_logs.txt. Can take some time.

Installing on Fedora Linux First of all make sure you have installed all the required linux dependencies:

yum install mesa-libGL mesa-libGL-devel python3 libev SDL-* libtool

Then install all the required Python dependencies

pip3 install Cython==0.21.2
pip3 install pyserial pytz kivy

Clone the Pygame repo and install it

hg clone [pygame url]
cd pygame
python3 setup.py install 

Finally you are ready to compile serial communication code. Got to microgrid/interface/communication and run

make

Once the command terminates succesfully you are ready to run the interface. Go to microgrid/interface and type python3 run.py

Additional steps for virtual machine

Make sure that virtual machine has at least 2gb of memory and at least 2 core to operate. Download and install virtualbox extensions and in usb settings tick usb 2.0. Also make sure that in usb settings you add the serial port device to the list of forwarded port.

After you install fedora in your VM, take the following steps.

yum install kernel-devel kernel-sources dkms
# In VM menu klick Devices -> cd/dvd/insert guest additions cd. The names below are typed from memory so they might differ slightly.
cd /run/media/USER/VBOXGUESTADDITIONSCDNAME/
./VBoxLinuxAdditions

Now after you reboot your machine should suck much less. To check if serial port gets forwarded type

lsusb

in terminal (try removing and inserting usb and seeing if output changes).

Troubleshooting

If you get a permission denied error on any command try using

su -c 'command'

instead.

Known bugs and todos

  1. Trying to pull data logs from comm board crashes the comm board
  2. Flow of time is too slow on comm board.
  3. State of chrage estimate is currently not logged
  4. Uncertainty for motion and mesurment step should be squuared (uncertainty_of_charge is correctly considered to be squared, but motion and measurement uncertainty are not).
  5. button reacts slowly - maybe decrease the number of debounce readings.

Security Issues

Current Version of ulink is pathetic secruitywise. Below a just few examples: