Thursday, December 27, 2012

Measure light (lux) with LDR on AVR Atmega using LDR library 01

A photoresistor or light dependent resistor (LDR) is a resistor whose resistance decreases with increasing incident light intensity; in other words, it exhibits photoconductivity.
The lux (symbol: lx) is the SI unit of illuminance and luminous emittance, measuring luminous flux per unit area.


This library implements a way to estimate lux given a LDR resistance value read from an ADC input pin of an AVR Atmega.
The estimation is based on this formula:
lux = A*((R/B)^C)
where R is the LDR resistance.
An Excel spreadsheet is provided to help the estimation of A, B and C values. You have to read lux values using a calibrated luxmeter, and the R values of your LDR, write it down on the Excel sheet, and estimate A, B and C, power regression can help you estimating values.

Code

Notes
  • read risk disclaimer
  • excuse my bad english

Friday, December 21, 2012

Reading temperature on AVR Atmega using a thermistor with NTCtemp library 02

This library is an update to ntctemp 01, look here for info: http://davidegironi.blogspot.it/2012/06/ntctemp-simple-avr-library-to-read.html

A thermistor is a type of resistor whose resistance varies significantly with temperature, more so than in standard resistors.


NTCtemp is a simple AVR library to read temperature from a thermistor connected to an atmega micro.
The library implements three models convert adc value read from analog input to temperature:
  • Steinhart-Hart Thermistor Equation
  • Beta Model Equation
  • Lookup Table estimation
A digital iir filter is implemented to remove unwanted reading errors.

For Steinhart-Hart and Beta model equation, look at the previous article.
This version of the library implements a Lookup Table estimation method, which can be usefull if you do not want to include log function, and mantain you hex smaller.

To helper are provided:
  • the beta estimation helper
  • the make lookup table helper
The beta estimation helper, helps you to estimate beta value of unknown thermistor.
It is almost the same provided in the reprap wiki page here: http://reprap.org/wiki/MeasuringThermistorBeta. A readme file with instruction is provided with the spreadsheet of the helper

The make lookup table helper is a spreadsheet which generate the lookup table according to preselected values. Estimation is done using the Beta Model Equation: temperature (Celsius) = beta / ( beta / tref + ln ( R / rref ) ) - 273.15

Each element in the table is a temperature for a given ADC value.
Given the ADC value of the connected thermistor, we can measure the temperature using the lookup table.
Because we know the ADC value for the first element of the table, and the interval between values, we can select the nearest lower index for any given ADC.
Then we can select the upper and lower temperature values for the selected index.
On those values we do interpolation to obtain a correct temperature value.
We must calculate the inverval step, indicates the position between upper and lower index, of the current adc value.
Then we can do interpolation of values.
intervalstep = currentadcvalue-minindex
t = lowertemp + ((uppertemp-lowertemp)/lookupadcstep) * (intervalstep);

Es. given a table which contains temperature for ADC: ..201,211,221.. temp: ..-7.21, -5.97, -4.75, the current ADC is 214, the lower index should be 211, and upper 221, so lower and upper temperature is -5,97 and -4.75. intervalstep is 214-211 = 3. t = -5.97 + (-4.75- -5.97)/10 * 3 = -5.604. Which is near to the value obtained using the beta model equation (-5.599). 0.005 degree of error.

This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.


Code

Notes
  • read risk disclaimer
  • excuse my bad english


Monday, December 17, 2012

Reading Temperature and Humidity on AVR Atmega using DHT11 library 01

updated version: http://davidegironi.blogspot.it/2013/02/reading-temperature-and-humidity-on-avr.html

The DHT11 is a basic, low-cost digital temperature and humidity sensor. It uses a capacitive humidity sensor and a thermistor to measure the surrounding air, and spits out a digital signal on the data pin (no analog input pins needed).


This library use DHT11 sensor to read temperature and humidity on on Atmega micro.
Setup the data port connected to the micro pin, and call the function to get humidity and / or temperature.

DHT11
  • Power supply 3.5-5.5V DC
  • Measuring range Humidity: 20-90%RH
  • Measuring range Temperature: 0-50 Celsius.

Setup parameter are stored in file dht11.h

Code

Notes
  • read risk disclaimer
  • excuse my bad english

Saturday, December 8, 2012

Drive multiple (up to 12) stepper motors on Atmega using 74hc595 and "stepper04multi" library 01

A stepper motor is a brushless DC electric motor that divides a full rotation into a number of equal steps.



Stepper04multi is an AVR Atmega stepper motor library.
Stepper04multi can run multiple stepper motor (up to 12) having different direction, type and speed with a precision of 256us per step @8Mhz.
Setup parameters is stored in stepper04multi.h files.
Stepper04multi use 74hc595 ics to expands the number of micro ports.



This libray drives many stepper motors, to drive motors, every step is computed during timer interrupt. If you are running many tasks on the micro, your should check that motor step happens at a correct speed. If not, you have to increase the micro frequency, or reduce the number to motors to run. As example, on Atmega8 less than 3 motors runs without timing problem at 1Mhz.
Setup parameters is stored in stepper04multi.h files.

Pictures and video shows only two motors connected, cause i've only 2, but up to 12 can be connected, i've checked output pin using a logical analyzer, and results are fine.
The picture below refers to one motor output, during the sample motor velocity was 1280us, as you see the step is 1.250ms = 1250us, which is close to the requested velocity.


This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 8MHz (fuse LF: 0xE4, HF: 0xD9)


Code

Notes
  • read risk disclaimer
  • excuse my bad english

Tuesday, December 4, 2012

Drive up to 3 stepper motors on Atmega using "stepper02" library 01

A stepper motor is a brushless DC electric motor that divides a full rotation into a number of equal steps.



Stepper02 is an AVR Atmega stepper motor library that can drive up to 3 motors having different direction, type and speed with a precision of 256us per step @8Mhz.
To drive a motors connect an ic driver between atmega pin and motor.
Setup parameters is stored in stepper02.h files.



This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 8MHz (fuse LF: 0xE4, HF: 0xD9)

Code

Notes
  • read risk disclaimer
  • excuse my bad english

Tuesday, November 27, 2012

DocOM, an open source Document Management System written in PHP

-- ref 2007

Today i release a Document Management System written nn 2007. I know is a long time ago, but i can not release it before cause it was used by the company which request me this application. The code is a little bit old, but it works.



DocOM is an open source web application created for document management.
DocOM is written in PHP to allow document deploy with viewing permissions.
For every document the administrator can define users, or group of users, that can reading or download it.
Administrator can also send message to users, and setup a knowledge base system with categories.

Website

Notes
  • read risk disclaimer
  • excuse my bad english

Thursday, November 22, 2012

AVR Atmega hall effect water flow sensor FS300A

FS300A is an hall-effect based water flow sensor.


When water flows a rotor rolls and a hall sensor emit the corrisponding pulse signal.
This library implements a way to read the pulse signal and convert it to Litre\Hour.
You have to setup some timer parameters to make this library works.
Setup parameters in fs300a.h


Most of the code taken from http://www.seeedstudio.com/wiki/G3/4_Water_Flow_sensor

This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.

Code

Notes
  • read risk disclaimer
  • excuse my bad english

Friday, November 16, 2012

AVR Atmega wii nunchuck library

Updated to version 02

AVR Atmega library for Wii Nunchuck

Nunchuck is a wii 2-axis joystick, two buttons and a 3 axis 2g accelerometer,
capable of I2C can communicate with it.



User can enable a avarage filter on accelerometer measurements.
An attitude (roll and pitch) estimation function can be enabled.
Calibration is suggested to get more accurate parameters.
To calibrate the device read the raw values using the get non calibrated mode
then calculate the offset.

This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.



Changelog

  • 02: fixed attitude estimation
  • 01: first release


Code

Notes
  • read risk disclaimer
  • excuse my bad english

Monday, November 12, 2012

AVR Atmega 74HC4051 library 01

The 74HC4051 is a high-speed Si-gate CMOS device and is pin compatible with Low-power Schottky TTL (LSTTL).


74HC4051 can be used to expand analog input port of AVR Atmega micro.
This library implements a way to run 74HC4051 ics.

This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.


Code

Notes
  • read risk disclaimer
  • excuse my bad english

Monday, November 5, 2012

AVR Atmega 74HC165 library 01

The 74HC165 is 8-bit parallel-load or serial-in shift registers with
complementary serial outputs.


74HC165 can be used to expand input ports of a micro.
This library implements a way to read from 74HC165 pins.

Setup parameters in l74hc165.h


This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.


Code


Notes
  • read risk disclaimer
  • excuse my bad english

Tuesday, October 30, 2012

AVR Atmega 74HC595 library 01

74HC595 is a 8-bit serial-in, serial or parallel-out shift register.



74HC595 ics are usefull to expand output ports of a micro.
This library implements a way to setup 74HC595 pins.

This library is inspired on bildr 74hc595 library for arduino http://bildr.org/2011/08/74hc595-breakout-arduino/.
Setup parameters in l74hc595.h
This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.



Code


Notes
  • read risk disclaimer
  • excuse my bad english

Monday, October 22, 2012

AVR Atmega ADXL345 accelerometer library 02 + processing

ADXL345 3-axis Accelerometer AVR Atmega library.



The ADXL345 is a small, thin, low power, 3-axis accelerometer with high
resolution (13-bit) measurement at up to ±16 g. Digital output data is
formatted as 16-bit twos complement and is acces-sible through either
a SPI (3- or 4-wire) or I2C digital interface.


User can setup measurement mode to 2/4/8/16G.
Calibration is suggested to get more accurate paramenters.


Setup parameters are stored in file adxl345.h
This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.


Code


Notes
  • read risk disclaimer
  • excuse my bad english

Monday, October 15, 2012

AVR Atmega BMP085/BMP180 pressure sensor library 01

update: checked and working on BMP180 too

BMP085/BMP180 Barometric Pressure Sensor AVR Atmega library.



The BMP085 is a high-precision, low-power barometric pressure sensor.
The BMP085 offers a measuring range of 300 to 1100 hPa with an absolute accuracy of down to 0.03 hPa.

User can setup parameter in file bmp085.h.
User can select the mode of operation, and the offset for the reading, also can enable an avarage filter on measurements. It can measure pressure, altitude, and temperature.

This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.





Code


Notes
  • read risk disclaimer
  • excuse my bad english

Tuesday, October 9, 2012

AVR Atmega MMA7455 accelerometer library 02 + processing

MMA7455 3-axis Accelerometer AVR Atmega library.



MMA7455 is a very low power 3 axis digital accelerometer from Freescale
Semiconductors. It's micro machined nano structure is capable of measuring
acceleration along its X, Y and Z axes.


User can setup sensitivity to 8bit, or 10bit, and measurement mode to 2/4/8G.
You should calibrate the sensor before use it, to calibrate it collect values
placing the accelerometer on every position of an ideal cube and then edit
calibration offset values.

For my tests calibration is done using the method proposed here: Using an Accelerometer for Inclination Sensing [Analog Devices]
A processing visualization tool is provided.
Attitude estimation can be done in firmware or in the visualization tool.
To estimate pitch and roll:

Code


Notes
  • read risk disclaimer
  • excuse my bad english

Tuesday, September 25, 2012

Air Action Vigorsol Drawdio

The Drawdio circuit-craft lets you MacGuyver your everyday objects into musical instruments: paintbrushes, macaroni, trees, grandpa, even the kitchen sink...

This is my drawdio implementation, mounted in an air action vigorsol box.




I've used a NE555, this chip has enough power to move a small 8ohm speaker, so you can omit - as i've done - the pnp transistor and 10ohm resistor of the schematic, and connect the speaker directly to the pin 3 of the 555 timer. But if you need more power, or if you use the low voltage version of NE555 you should add a Class B 'pushpull' amplifier, or even one simple transistor as you can see in my circuit.
Also i've connected two screws as drawdio contacts.





Notes
  • read risk disclaimer
  • excuse my bad english

Friday, September 21, 2012

AVR Atmega Allegro ACS712 library, low current AC DC Sensor

ACS712 is an avr library for ACS712 low current sensor.
This current sensor gives precise current measurement for both AC and DC
signals.



This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.

Code

Notes
  • read risk disclaimer
  • excuse my bad english

Monday, September 3, 2012

avr nRF24L01 library running on atmega - v.02

This is my Nordic Semiconductor nRF24L01 driver for atmega8 micro, it should work even with other atmel micro with small changes.
Most of the works is based upon nRF24L01 avr lib by Stefan Engelke http://www.tinkerer.eu/AVRLib/nRF24L01 and arduino lib by 2011 J. Coliz http://github.com/maniacbug/RF24.



This library is more stable than the previos one, which you can also find in this blog. There are some bugfix I've corrected in the source code, and the developer board schematics, added 3 diode to drop down power voltage on nRF24L01 and a capacitor to stabilize it.

Testing done with Eclipse, avrgcc on atmega8 @ 1Mhz.



Code


Notes
  • read risk disclaimer
  • excuse my bad english

Tuesday, July 31, 2012

DIY SteadiCam Model 3.0

An experimental DIY steadicam project.
Model 3.0, inspired by merlin design.



For the gimbal i've use with Traxxas #5151 half shaft, and a ball bearing, soldered at the top of a metal pipe.
The camera is fixed on an ebay flash bracket stand, so it can slide and change the position.
There are a few connections for counterweights, i've use some metal plate and washers.
The example video is filmed very fast, this stabilizer can be more accurate, in my opinion, by a more carefull counterweight load, and with a more experienced operator.




Notes
  • read risk disclaimer
  • excuse my bad english

Monday, July 16, 2012

a very simple DIY camera slider

This is my very simple camera slider made up using a 5 Euro mini skateboard, and a piece of wood.







Notes
  • read risk disclaimer
  • excuse my bad english

Friday, July 6, 2012

an AVR Atmega 7-segment commond anode / cathode display library

Updated to version 0x03

A seven-segment display (SSD), or seven-segment indicator, is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix displays.



This is a simple seven segment library that let you display char / numbers, or any sequance you need to multiple display.
It runs both on common anode, and common cathode display.
I've used a lookup table to convert ascii table. Also a function to display any sequence you want is available.


Below you can find sample schematics to run multiple diasplay.
The full transistor version let you run disaply at your desired voltage.


7 segment common cathode schematics example


7 segment common anode schematics example


7 segment common cathode with full transistor schematics example


7 segment common anode with full transistor schematics example


Code

Notes
  • read risk disclaimer
  • excuse my bad english

Thursday, June 21, 2012

AVR uartConfig - an atmega eeprom config library

Last release here: http://davidegironi.blogspot.it/2013/03/avr-uartconfig-atmega-and-arduino.html


With AVR uartConfig you can config your atmega eeprom using uart
communication
.

Using any rs232 usb adapter or port connected to your atmega, you can easly setup your eeprom device.


AVR uartConfig is a set of tools running on Windows, Linux and Mac, made up or:
* a avrgcc firmware library
* a command line utility
* a gui tool

This lib was check on atmega8 with windows 7, mac lion, and ubuntu linux 10.
To setup this library please read the README file provided with code.



Code


Notes
  • read risk disclaimer
  • excuse my bad english

Monday, June 11, 2012

NTCtemp: a simple AVR library to read temperature from ntc thermistor

updated version here: http://davidegironi.blogspot.it/2012/12/reading-temperature-on-avr-atmega-using.html

NTCtemp is a simple AVR library to read temperature from ntc thermistor connected to an atmega micro.



The library implements the Steinhart-Hart Thermistor Equation or the Beta Model Equation to convert adc value read from analog input to temperature (Celsius).
There are plenty of articles around here speaking about the theory behind those equations, it's not the purpose of this post to teach you this, i just want to provide you a simple library.

Code was tested on an atmega8 connected with a cheap ebay ntc sensor.
I've compared results with a digital thermometer. Temperatures are almost the same, i.e. +/-0.5 Celsius from 20 to 90 Celsius.
Code is release under GPL3 license.


A sample circuit to interface with a thermistor and filter noise is provided.
On the left upper side there is an rc filter, which remove high freq noise. On the right side the thermistor wiring. For further informations and as references please look at http://arduino.cc/playground/ComponentLib/Thermistor4 or RLC Filter Design for ADC Interface Applications (Texas Instruments).


A digital iir filter is implemented to remove unwanted reading errors. As reference please look at "Guillem Planissi tutorial: Measurement and filtering of temperatures with NTC", you should find this tutorial here: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=61128



Code


Notes
  • read risk disclaimer
  • excuse my bad english