Tuesday, 18 March 2014

Wow that a long time since my last post



Wow , it`s a long time since I`ve updated my blog , and lot have happened in my embedded computer world .
It the last year I have added the following platforms to my collection .

MBED ( Arc Pro ) , Cubietruck and my latest the Udoo .

Sunday, 13 January 2013

tmp102 for the Raspberry Pi

I`ve been using the tmp102 for a couple , but never really got to grips with how to deal with minus temperatures.
If you want a good night sleep try reading and fully understanding it`s pdf document .
I can now understand just about any spi or i2c device document, But this a is most harder to decipher.

http://www.ti.com/lit/ds/symlink/tmp102.pdf

How to read from the chip :

It`s I2C address depend on where you connect the ADD0 too.

Ground = 0x48 , V+ = 0x49 , SDA = 0x4A , SCL = 0x4B


Read two Bytes  ( High byte is first followed by the Low byte )

High byte ( Full degrees )
Low byte ( fraction degrees )


To get the temperature
Multiply the Hi_byte by 16 ( <<  4 )  +  Divide Low_byte by 16 ( >> 4 )
Now multiply the result by 0.0625 and you have the temperature.
Temperature = (( Hi_byte << 4) | ( Low_byte >> 4)) * 0.0625  
This works if the temperature is above zero.

Minis temperature problem
The most significant bit of High byte says if the temperature is a negative or positive value.
The documents explanation on how to convert the negative value is:-

For negative temperatures (for example, –25°C):
Generate the twos complement of a negative number by complementing the absolute value binary number
and adding 1. Denote a negative number with MSB = 1.
Example: (|–25°C|)/(0.0625°C/count) = 400 = 190h = 0001 1001 0000
Twos complement format: 1110 0110 1111 + 1 = 1110 0111 0000

My way I converting this into a usable form , is to test if the most significant bit is set  :-
if Hi_byte & 0x80 == 0x80:
If this is True we need to add 1 to the Hi_byte and remove any overflow and keep the value byte size  :-
Hi_byte = (Hi_byte + 1 & 0xff) 
This don`t work in fact , after waiting for it to freeze to test out my code.

I`ve found the way to do it , is 
 
0 - ( 256 - Temperature )  

 
To download the complete working code for python 3 using Quick2wire my link is below.
This can be converted to any i2c library , all you need is the High and Low byte.

 https://github.com/peter247/Pi_Weather_monitor/blob/master/examples/tmp102.py

Saturday, 12 January 2013

Setting up a git Repository

After finding that Blogger is not the ideal method to post any code I thought it was time to learn how to make a git repository for any my code.

I have used git many times before but only used git to get code from the repository using git clone git:repository.
They say learning from your mistakes help you to learn, then I`ve done a lot of learning with this excise .

If there is a way to get it wrong I`ve made it.  

I had all ready install all the relevant modules for downloading code:
 eg git and git-core.

I followed the instruction from :  

https://help.github.com/articles/set-up-git
https://help.github.com/articles/generating-ssh-keys

Made my key pair because my raspberry pi didn`t have one by default ,   and posted it to the git repository ssh key profile screen.

Tried to load in  with "ssh -T git@github.com" , wow all worked !!!.
I now made my first repository and clicked on the option to add a readme file to start the repository off. 

This is where my mistakes started to come think and fast !!!!


I log in my Pi and did my normal way to download a git:repository using the read only method .

eg with "git clone git://github.com/my_account/project_name.git" big mistake I was later to find.

I started to read this :-
http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository

# Made a new file .
git add the_new_file
git commit -m "start off"
git push

from the push, got I you can`t push you "git://github.com/my_account/project_name.git" try using "git@github.com:my_account/project_name.git"

So I guess that was learn one.

I started to make a real project , and made a new project like before , but this time using the ssh address method.
I tried repeating the above excise making a new file , adding the file , committing the file , then pushing the file , wow no problems this time.
Copied my project to the project folder and did a "git add *" .
Them thought that`s a bad idea all my password and key files are still in my code , so for I haven`t committed the files yet, so I can still just remove them before committing the files. It didn`t work that way and after I pushed my files to the repository I could see my password and key files and commit showing the changes to these files.

So I guess that was learn two , Remove any bit you don`t want to be shown before you add them
  
It was delete and start again with 3rd time lucky.

Friday, 11 January 2013

My projects

This is a picture of my project bench.
Which is a change to now have a computer with i2c , spi and gpio support , and have full Linux instead of having to program in c or c++ like my other embedded platforms. ( Arduino , Fltyport )

I using a Raspberry Pi , which is hidden under my soldering iron unit in the photo.
on one breadboard directly connected to the Pi is a mcp3008 which is a spi , analogue to digital convertor,  a level shifter connected to a second breadboard feed with a external 5 volt power supply , so keep the 3.3 volt and the 5 volt chip on separate breadboards.
The second breadboard contains a mcp23017 i2c expander chip , half of the chip is been used for input via switches and the other half connected to a ULN2803a  , Darlington transistor array to power two rbg leds .

My two project which I`m playing with right now is :-

1/ MPC controller .
2/ Weather station / monitor .

The Music Player Daemon controller , which is finished unless I need to add a little afterThe switches control , pause / play ,  previous  , next , delete track from play list and drive , volume up and down , etc

The Weather station / monitor , which is a never ending story .
This project started on the Arduino moved to the Flyport and as now moved to the Raspberry Pi Model A I hope soon.

The project now monitors air temperature inside / outside and sends the data to cosm and thingspeak ,  the temperature changes the colour of the rbg led.
Too hot is red , too cold is blue and just nice is green .
The full project is controlling the solar powered garden lights , which is state of charge / discharge is monitored.

All in all , it learning about programming and the best way to learn is find a project you can add too , as more you learn the more complex to gets.

 
  


 

Wow , it is a long time since my last post

Wow , it`s a long time since I wrote anything in this blog. So I guess it is time to add my new projects and computers to the list. Most of my programming time is now on the Raspberry pi.

Saturday, 18 June 2011

Flyport

Just got a new toy a Flyport :- http://www.openpicus.com/cms/

it time to find how it works and making my own project.

Tuesday, 23 June 2009

New Embembed micro

Hi , I`ve got a new embebbed micro to play with a BV513 from Byvac.

http://www.byvac.co.uk/bv/bv513.htm

So it`s back to learning a form of basic, which other than visual basic , most of my programing time as been spent learning to program in C or C++

And the good thing about this micro over the Arduino is the high amout of storage.
512k to 16k flash and 32k compared to 1k.