Translate

Sunday, March 29, 2015

Monitoring health data - my way - #2

On this article I'll discuss how I track data related to the food.
A very important thing to do if you are dieting or keeping track of your health numbers, is to monitor the carbs and other nutrient intake, i.e. how many carbs you are eating.
In order to do so, it is important to know exactly what and when you are eating.

It seems easy but is not.
Why is not easy ? Well, let see some reasons (just a few) :
  • not all the food you are eating is labeled
  • the food is not  "homogeneous", the same food can be present in different forms
  • often a processed food have different characteristics  than a less processed food
  • often are indicated base chemical compost rather than more "human" description
  • different companies label the food in different way
  • all the companies who sell food, always try to hide or manipulate information in order to make more palatable the food they sell. The rule seems to be, if you can't be vague, obscure with chemistry and strange words
  • hidden basic ingredients in processed food (like salt or sugar) often requires to "split" a food in it's basic elements
  • etc.
So monitoring what you want to eat is not an easy business, it takes time and organization.
Here  is "my way". Repeating myself, this is how  I do that, I'm not stating it is the right way to do it.
It is good for me.

I maintain basically 3 documents :
  1. a "food information" document (word processor)
  2. a "food journal" document (word processor)
  3. the spreadsheet where I track also the sugar level and other measurements (spreadsheet)

Food information


The food information document contains information about the food I eat.
Usually I save a picture of the food or box, for an easy visual reference, and then some nutrient information.
Plus I add some notes to clarify how many carbs are actually present, just to simplify when I have to figure out quickly how much carbs I'm having.

The main problem is due by the fact that manufacturers give the information often in a very complicated way.
For example, many "soups" containers  contains 2 servings, but often the nutrient information are for about 1 serving.
Often you find 2.5 servings per container, other times 1 ... doesn't exists a standard.
Some manufactures express the "serving" in grams, other in oz, other per cup, other per bowl other as a generic "serving", or specific food description.
So in order to figure out what you are eating, to calculate carbs and other measurement, you need to spend time researching information.

Thus I decided to "save" these researches, the results, in a document.
Each entry has a picture of the product, a copy of the nutrition chart, a thumb up or down to indicate that tastes good, and eventually some notes.

Here an example of entry:








Again, the main purpose of this document is to have a quick recap of the food I usually ate, in order to avoid to do the same research over and over.

On this document are also documented some "home made recipes", in order to calculate the nutrition info for that.
What I usually do, is to put down the basic nutrients of each component of the recipe, then calculate the total amount of carbs (and other nutrients) and then divide in cups or bowls.

Food journal


Once you figure out how many carbs (and other nutrients) are in the food, the second step is to write down somewhere what you ate on a specific day.
This is the Food Journal document.
For each day there are 4 entries :
  • Breakfast
  • Lunch
  • Dinner
  • Snacks
Each entry will collect information about what I'm eating. Quantity, food, estimated carbs, often divided by food.
With these info I can sum up the number of carbs for each "period" and transpose that value in the spreadsheet.

Here an example of entry :


February 26, 2015
  • Breakfast
    1 low carb tortilla (3g) with cheese, 4 slices capocollo (0g), eggs beater
    Coffee
  • Lunch
    1 serving Chicken Enchilada bake (15g)
    Pringles chip onion sour – single serve (10g)
    Cornetti single serving (3 g)
  • Dinner
    Panera Bread – Chicken Kale and sweet potato soup – 1 cup (9g)
    1 Morey's grilled salmon (1g) with zucchini (5g)
  • Snacks
    10 am – 1 pouch Skinny zero popcorn (5g)
    3 pm - Chiquita – Bites juicy red apple (6g) with string cheese
    9 pm – low carb cake (4 g)
More details are put in this document, more is easy to calculate the carbs but there is always a trade between efficiency and time spent doing that.
Being too precise requires a lot of time, so know what to write as amount of information is something that is coming with the experience of doing that daily.

Note that the food journal reports mainly the carbs intake and not all the others nutrient,
This because the carbs intake is the main key in my case, however, other articles will explain how to use the nutrient information and create a daily journal.

Spreadsheet


In the end the goal is to come up with some carbs number to put in the spreadsheet I described in the previous article (Monitoring health data - my way #1).
The day is divided in 6 time areas :
  • breakfast
  • morning snack
  • lunch
  • afternoon snack
  • dinner
  • night snack
For each area the goal is to assign a value (if any).
See the previous document for details.

Wednesday, March 25, 2015

Monitoring health data - my way - #1

Everybody should be aware about his/her health, using real time data, but of course only when an illness is developed we really starts to pay attention to that.

I started to measure the sugar level in the blood regularly and  record these data on a spreadsheet.
It is relatively convenient to keep track on these data in this way, but it has many limits, especially when I started to collect other data as well, like the weight, my daily intake of carbohydrates, how much exercise I do, what medications I'm taking and when, and so on.

This article describes the way I started to collect/store/retrieve information using LibreOffice Calc.
I'm sure exists many other better ways to do so, but this is my way.

Software

The main tool used to store the data is LibreOffice Calc.
I'm using it in two flavors :

  • LibreOffice Calc 4.3.1.2 for Windows
  • LibreOffice Calc 4.2.7.2 for Linux
The spreadsheet is divided in different tabs.
A tab for each month, a tab to recollect all the data, a tab to recollect only the fasting measurements and other tabs for the conversion (will be discussed in other articles).
Let see more in details the main tabs.

Monthly tab


Each month of collected data has a tab, named with Month and Year, like "January 2015".
The data collected in the tabs are the carbs intake, the glucose reading, what medications are taken, the weight, the ketons and some notes.
Additionally in the notes field is reported what kind of exercise is done and other remarks.

Here the columns on this tab :

Date Meal Carbs Daily carbs Glucose reading Time ml/dg Medications Weight (lb) Notes Ketons

  • Date
    The date of the measurement.
    Since the tab contains different data, there are at least 6 entries for each date, i.e. every day there are 6 entries (rows) with the same date.
  • Meal
    Indicates a specific period of the day. It is used  to record the intake of carbs in gram.
    The values of this column are :
    • Breakfast
    • Snack (morning)
    • Lunch
    • Snack (afternoon)
    • Dinner
    • Snack (night)
  • Carbs
    A value in grams of the net carbs for each specific period (see previous column)
  • Daily Carbs
    A sum of the 6 previous field (see Carbs)
  • Glucose reading
    A description associated to the glucose reading.
    The three major measurements of glucose are done before breakfast, before lunch and before dinner.
    There are three "fixed" descriptions, plus a random description (up to three) :
    • Before breakfast
    • Before lunch
    • Before dinner
    • Random
  • Time
    Time of the glucose reading
  • ml/dg
    Value of the glucose reading
  • Medications
    List of the medication taken in the day
  • Weight (lb)
    Weight measured. Usually once a day. not in a specific time.
  • Notes
    Generic notes. Usually I put in here what exercise I do and how long or other notes, maybe associated to other fields
  • Ketons
    Value of the ketons. I'm trying to mimic the colors used by the strips and putting an estimate value in one of the cell.
  • bpm (after March)
  • Systolic
  • Dyastolic

Here an example of a monthly tab, how is look (is a demo page, the values are fake):

















After March, three extra columns will be added, to save the blood pressure and the heart beat.

Chart

In the end of the table, a chart is present to show the main collected data.
The chart is a linear one and shows the weigh, the glucose level, the daily carb intake and the carb intake.
The colors used and the scale are kept for all the monthly tabs in order to facilitate to compare them.

Here an example of the monthly chart (it's a demo - fake values):






There are two different scales on the Y axes.
On the left from o to 200 for the weight and ml/dg.
On the right from 0 to 400 for the carbs intake.

The reason was to leave more space between the carbs and the other two lines.
Using the same scale, sometime the lower part of the glucose line and the upper part of the daily carb intake, were mixing. The chart is important to show quickly the patterns, not reading specific values, so the two scales are just OK.

All times tab

This tab recollect all the data present in the monthly tabs.
Originally the data were simply copied in this tab, since January 2015 some operations are automated, so that the update happens when the monthly tab is updated.
The reason to have an extra tab to recollect all the data previously collected, is to easily generate a chart.

Date Meal Carbs Daily carbs Glucose reading Time ml/dg Weight (lb)

  • Date
    The date of the measurement.
    Since the tab contains different data, there are at least 6 entries for each date, i.e. every day there are 6 entries with the same date.
  • Meal
    Indicates a specific period of the day. It is used to record the intake of carbs in gram.
    The values of this column are :
    • Breakfast
    • Snack
    • Lunch
    • Snack
    • Dinner
    • Snack
  • Carbs
    A value in grams of the net carbs for each specific period (see previous column)
    Since January the value of this cell is copied automatically from the specific monthly tab.
    Example : =IF(('January 2015'.C2 = 0),"",'January 2015'.C2)
  • Daily Carbs
    A sum of the 6 previous field (see Carbs)
  • Glucose reading
    A description associated to the glucose reading.
    It is used to divide the day. The three major measurements of glucose are done before breakfast, before lunch and before dinner.
    There are three "fixed" descriptions, plus a random description :
    • Before breakfast
    • Before lunch
    • Before dinner
    • Random
  • Time
    Time of the glucose reading
    Since January the value of this cell is copied automatically from the specific monthly tab.
    Example : =IF(('January 2015'.F2 = 0),"",'January 2015'.F2)
  • ml/dg
    Value of the glucose reading
    Since January the value of this cell is copied automatically from the specific monthly tab.
    Example : =IF(('January 2015'.G2 = 0),"",'January 2015'.G2)
  • Weight (lb)Weight measured. Usually once a day. not in a specific time.
    Since January the value of this cell is copied automatically from the specific monthly tab.
    Example : =IF(('January 2015'.I2 = 0),"",'January 2015'.I2)

Chart

In the end of the table, a chart is present to show the collected data.
The chart is a linear one and shows the weigh, the glucose level and the daily carb intake like the monthly one, but it will include more months.

All time only fast tab

This tab recollect all the data present in the monthly tabs but only for the "Before breakfast" glucose levels.
Originally the data were simply copied in this tab, since January 2015 some operations are automated, so that the update happens when the monthly tab is updated.
The reason to have an extra tab to recollect all the data previously collected, is to easily generate a chart.
Basically this tab is identical to the previous one (All times tab) but the glucose values copied are only the ones before breakfast.

Date Meal Carbs Daily carbs Glucose reading Time ml/dg Weight (lb)
  • Date
    The date of the measurement.
    Since the tabspreadsheet contains different data, there are at least 6 entries for each date, i.e. every day there are 6 entries with the same date.
  • Meal
    Indicates a specific period of the day,  used to record the intake of carbs in gram.
    The values of this column are :
    • Breakfast
    • Snack
    • Lunch
    • Snack
    • Dinner
    • Snack
  • Carbs
    A value in grams of the net carbs for each specific period (see previous column)
    Since January the value of this cell is copied automatically from the specific monthly tab.
    Example : =IF(('January 2015'.C2 = 0),"",'January 2015'.C2)
  • Daily Carbs
    A sum of the 6 previous field (see Carbs)
  • Glucose reading
    A description associated to the glucose reading.
    The three major measurements of glucose are done before breakfast, before lunch and before dinner.
    There are three "fixed" descriptions, plus a random description :
    • Before breakfast
    • Before lunch
    • Before dinner
    • Random
  • Time
    Time of the glucose reading
    Since January the value of this cell is copied automatically from the specific monthly tab.
    Example : =IF(('January 2015'.F2 = 0),"",'January 2015'.F2)
  • ml/dg
    Value of the glucose reading
    Since January the value of this cell is copied automatically from the specific monthly tab.
    Example : =IF(('January 2015'.G2 = 0),"",'January 2015'.G2)
  • Weight (lb)Weight measured. Usually once a day. not in a specific time.
    Since January the value of this cell is copied automatically from the specific monthly tab.
    Example : =IF(('January 2015'.I2 = 0),"",'January 2015'.I2)

Chart

In the end of the table, a chart is present to show the collected data.
The chart is a linear one and shows the weigh, the glucose level and the daily carb intake like the monthly one, but it will include more months.

More articles will follow in order to describe the system I'm setting up to deal with all these data.

Saturday, March 14, 2015

MSP430 GCC compiler

For the MSP430 family there are many different compiler out there.
One of the most used, especially on Linux machines, is the mspgcc.
This article explain how to install one of the versions of this compiler.

What version to use ?


There are different versions of this compiler.
However, is a good starting point to use the one officially endorsed by Texas Instrument.

At the writing date, the "officially endorsed version of mspgcc" is the 3_02_03_00.
These instructions are for Linux only !  I'm not covering Windows at this time (and probably I'll never cover it).
Go to the Texas Instrument website and download this code :

MSP430-GCC Product Downloads
TitleDescriptionSize
Unlockedmsp430-gcc-full-linux-installer-3.2.3.0.runRedhat GCC Linux installer incl. support files and debug stack and USB drivers - apply chmod x before executing the package77640K




msp430-gcc-support-files.zipHeader Files18044K
msp430-gcc-source.tar.bz2Redhat GCC source filesK
md5sum.txtMD5 Checksums4K

Basically the first code is what we need to install the MSP430 C compiler on our machine.

In order to download the code is necessary to register to the Texas Instrument website and answer to a questionnaire.

Once downloaded the files we can proceed to install it on our machine.
At the writing time of this article the MSP430 gcc (msp430-elf-gcc) version is the 4.9.1

Installation

Copy the file msp430-gcc-full-linux-installer-3.2.3.0.run in a directory, chmod it to allow execution, then run it.
A guided installation menu will appear.
Once installed, add the path where the compiler is installed, in the system variable path.

For example under xbuntu (Ubuntu, Kubuntu, Lbuntu, ecc.) is enough to edit the file .profile in the home directory.
It is easy to create a local variable and then add it to the $PATH with export.
For example, assuming the toolchain was installed in /home/username/ti, add at the end of the .profile file :

export MSP430_TI="/home/username/ti/gcc"
export PATH="$PATH:$MSP430_TI/bin"

Save the file and reboot the computer.
Opening a terminal after that operation, the path of the compiler should be available.
To test it, try to run the command msp430-elf-gcc :

$ msp430-elf-gcc
msp430-elf-gcc: fatal error: no input files
compilation terminated.


Note that it will be available also the specific system variable MSP430_TI, necessary in the makefile usage.

Tuning the system


There are some differences between this version of the MSP430 GCC compiler and previous ones.
Some include files are not present, others have some basic define name differences.
Let see some differences to be addressed:

Makefile
  • the compiler flag mmcu requires specific component name.
    Not anymore msp430xtype but msp430ftype.
    So for example, instead of msp430x169, msp430f169 must be used.
  • Be sure to use the correct compiler name:

    CC=msp430-elf-gcc
  • It must be used the inclusion path for the headers file and environment libraries
    In the flag part :

    CFLAGS=-O0 -Wall -g -mmcu=msp430f2013 -I$(MSP430_TI)/include -L$(MSP430_TI)/include

    It is assumed of course that exists a system variable called MSP430_TI as described in this article.
Source file
  • the header file io.h doesn't exists
  • be sure to include in the source file the file msp430.h header since specific component defines are included there
  • the interrupt declaration is different
    To declare an interrupt, now the declaration needs to be split in two lines and changed.
    For example, for the timer A interrupt, the syntax is:

    __attribute__((__interrupt__(TIMERA0_VECTOR)))
    void Timer_A (void)
    {
    ............
    }

    It is possible to have other some issues on this, older versions of this line of MPS430 gcc toolchain require different syntax, TI changed some things along the way
Include file
  • #include <io.h> is obsoleted, don't include it anymore
  • #include <msp430legacy.h> is obsoleted, don't include it anymore
  • #include <msp430.h> must be present in any source file
  • #include <signal.h> need to be present for interrupt operations

Links


Here some useful links to the documentation I found so far :