Thursday, October 28, 2010

Boise Plasma Donation

Arduino as devboard software written for avr-libc

lights.zip

La tentazione è forte: abbiamo comprato un'ottima scheda italiana Arduino e ora vogliamo cimentarci oltre il linguaggio Wiring, con programmi in assembler o in C (es. avr-libc).

Non c'è bisogno di comprare una scheda di sviluppo, perché è possibile usare il nostro Arduino come una scheda di sviluppo per programmi scritti in avr-libc, assembly, piuttosto che per gli sketch in linguaggio wiring, senza the need for external programmer hardware: our object code will be executed by the boot loader of micro Arduino, a simple and above all totally painless ...

Our config file is modified by adding options for avrdude (the programming software for the AVR micro) that will allow us to "upload" the object code on our Arduino.

below the config file for Arduino 2009 (ATmega168 and 16MHz clock). For later versions of the Arduino reference to the type of micro-and the frequency of the quartz.


  MCU name # MCU  

= ATmega168

# Processor frequency (in Hz)

F_CPU = 16000000

# Target file name (without extension)

TARGET = main

# Object files directory
# To put object files in current directory, use a dot (.), do NOT make
# this an empty or blank macro!

OBJDIR = .

# List C source files here. (C dependencies are automatically generated.)
# The first one must be TARGET above defined, the other ones
# must be separated by a space. Examples:
# SRC = $(TARGET).c lcd.c i2c.

SRC = $( TARGET ) . c


# List C++ source files here. (C dependencies are automatically generated.) spaced

CPPSRC =

# List Assembler source files here.
# Make them always end in a capital .S. Files ending in a lowercase .s
# will not be considered source files but generated files (assembler
# output from the compiler), and will be deleted upon "make clean"!
# Even though the DOS/Win* filesystem matches both .s and .S the same,
# it will preserve the spelling of the filenames, and gcc itself does
# care about how the name is spelled on its command-line.

ASRC =



# List any extra directories to look for include files here.
# Each directory must be seperated by a space.
# Use forward slashes for directory separators.
# For a directory that has spaces, enclose it in quotes.

EXTRAINCDIRS =

# List any extra directories to look for libraries here.
# Each directory must be seperated by a space.
# Use forward slashes for directory separators.
# For a directory that has spaces, enclose it in quotes.

EXTRALIBDIRS =


# Port programmer
... COMx # COM1 (serial port), LPT1 (parallel port)
# Linux: / dev/ttyUSB0 or \u200b\u200b/ dev/ttyUSB1

AVRDUDE_PORT = / dev / ttyUSB0

Type # programmer (stk500v1 for Arduino)

AVRDUDE_PROGRAMMER = stk500v1

speed serial # (19200bps)

AVRDUDE_PORTSPEED = 19200



AVRDUDE_PORT : specificare il device dove è collegato Arduino. Sotto Linux sarà generalmente /dev/ttyUSB0. Per conoscerlo lanciare da shell:


 $ dmesg  a simple program that turns five LEDs in succession. Through a button you can select the desired scrolling effect (SO) and through a second button you can change the flash time from 50ms to 500ms in 50ms increments. The scheme is shown below: 



   


(diagram created with gEDA)


For correspondence ATmega168 pin / pin Arduino:

(image created by Fritzing)



Method of resolution:
at regular time intervals (marked by a timer), it will change the combination of LED's (a combination we call frame), in a manner defined in the vector of its way.
Each element of this array contains a byte that encodes the start of the six LED, frame by frame. The convention is 1 -> LED ON, 0 -> LED off. The carrier will be so marked (in a time interval defined by a timer) in circulation.




time is used for a hardware timing (based on CTC with so Timer1 interrupt) so as to enable even better in practice as seen in previous posts and the management of the buttons are used the two interrupts INT0 and INT1. For the change of time is changed to run the register OCR1A to "step" of 50ms. The suid part with a time of 50ms, and then after 9 presses of the "Time" will reach the maximum value of 0.5 s, the tenth time the pressure starts from


50ms 50ms, 1 -> 100m, 2 -> , 150m, 3 -> 200m, 4 -> 200m, 5->250m, 6->300m, 7->350m, 8->400m, 9->500ms


Ecco il sorgente (main.c):

/*
* LIGHTS
* fp, 2010
*/
#
include
<avr/io.h>
# include <avr/interrupt.h>
#
include
  <avr/pgmspace.h>  # 
include
<util/delay.h>


#define N 31249
/* Numero del timer1 per avere un tempo max (31249=0.5s@fck=16MHz:256) */
#define NA
3124 /* Numero del timer1 per avere uno step minimo (3124=50ms@fck=16MHz:256) */


#define NMODI 4 /* Numero di modi di funzionamento */
#define PORTDATALED PORTB /* Porta dove sono collegati i sei LED */ #define PORTDDRLED DDRB
/* Registro direzione di PORTDATALED */ /* Prototipi delle routine dei various modes of operation * / void
Shift_DX ();
Shift_SX void (); Shift_SX_DX void ();

Out_In void ();

/ * Global Variables (qualifying static because they have to "live" even on function exit * /
/ * volatile and those shared with the interrupt service routine) * / static

int frame = 0 ;
/ * Frame to be shown * / volatile


static uint8_t mode = 0
; / * Initial mode of operation (0 to nMode -1) * / static uint8_t status = 0 ; / * State variable (used for and how ShiftSXDX OnOff) * /
/ * sequences of frames for each mode * / / * stored in flash memory (to save RAM) * / const
uint8_t sx_dx [ 6] = {PROGMEM b00100000 0, 0

b00010000,
0 b00001000,
b00000100 0, 0 b00000010,
b00000001 0}; const uint8_t out_in [ 4] PROGMEM = {0 b00100001, b00010010 0, 0 b00001100, b00010010 0};
/ * initialize / configure the hwardware (direction pin I / O, timer, interrupt) * / void init () { PORTDDRLED (On OCR1A) OCR1A = NA; / / load register OCR1A NA (minimum time)
TIMSK1 = (1

\u0026lt;\u0026lt;OCIE1A)
/ / Enable CTC interrupt on OCR1A TCCR1B * /}


} / * TIMER1 interrupt service routine CTC: runs each (OCR1A +1) * 256 * Tck sec. * /
ISR (TIMER1_COMPA_vect) { switch (mode) {case
0 : Shift_DX ();
break; homes
1: Shift_SX (); break
; homes
2: Shift_SX_DX ();


break;
homes 3 : Out_In ();


break;}

}

/* Routine servizio interrupt INT0 (pulsante variazione del tempo in step di 50ms ) */ ISR ( INT0_vect ) {
OCR1A += NA;
// incrementa di 50ms
if
(OCR1A >= N)
// raggiunto il tempo max...

OCR1A=NA;
//...torna al tempo min. _delay_ms(
500
);
// debounce }
/* Routine servizio interrupt INT1 (pulsante variazione del modo fra o e NMODI) */
ISR ( INT1_vect ) {
modo++; // passa al modo successivo if
(modo==NMODI) // raggiunto il massimo modo...
modo= 0 ; // ...riparti dal modo 0
_delay_ms( 500 );
// debounce }
/* Modo 0: Scorre i LED verso destra */


void
Shift_DX()
{
if (frame==
6
)
// raggiunto l'estremo dx... frame=
0 ; // ...vai al LED estremo sinistro PORTDATALED = pgm_read_byte(&sx_dx[frame]);
// leggi il frame e invialo the port frame + +;
/ / pass to the next frame }

/ * Mode 1: Scrolls the LED to the left * /


void Shift_SX () {

if
(frame == - 1)
/ / reached the extreme left ... frame = 5 ;
/ / ... go to the far right LED PORTDATALED pgm_read_byte = (& sx_dx [frame]); / / read the frame and send it to port
frame -; / / go to the previous frame




} / * Mode 2: Scrolls i LED da sinistra e poi da destra */
void Shift_SX_DX() {

if (frame== 6 ) // raggiunto il LED estremo destro {
frame= 4 ; // vai indietro di un LED
stato= 1 ;
// stato 1: ora scorri i LED da dx a sx }

if
(frame==-
1 ) // raggiunto il LED estremo sinistro
{ frame=
1
; // vai avanti di un LED stato= 0 ; // stato 0: ora scorri i LED da sx a dx
} PORTDATALED = pgm_read_byte (& sx_dx [frame]); / / read the frame and send it to port

switch
(state) { homes

0
: frame + +;
break
; / / if you scroll from left to right, increases
homes

1: frame -; break; / / if you scroll from right to left, it decreases }}

/ * Mode 3: Cycle through the LEDs from the outside and then back out * / void
Out_In () {
if
(frame>= 4 ) // se siamo a un frame superiore a quello massimo frame= 0
;
// riparti dal primo frame PORTDATALED = pgm_read_byte(&out_in[frame]); // leggi il frame e invialo al port
frame++; }


Creiamo una cartella (es. lights) nella quale ricopiamo i file:
main.c
config makefile
Portiamoci in questa directory e lanciamo make all e dunque "uploadiamo" il file oggetto su Arduino con:
make program If all goes well, in our shell will display the following output from avrdude: make program ATmega168 avrdude-p-P / dev/ttyUSB0-b-c stk500v1 19200-F-U flash : w: main.hex

avrdude: AVR device initialized and ready to accept Instructions

Reading an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip avrdude: reading input file "main.hex" avrdude: input file main.hex auto detected as Intel Hex
avrdude: writing flash (790 bytes): Writing
bytes avrdude: reading on-chip flash data: Reading
varying the duty cycle remains unchanged, the wave generated not only the signal frequency, but also the implementation stage, this feature is therefore preferred for motor control. In this mode the timer counts up from 0 and the maximum value N. Reached the maximum value N continues to count, but back to 0, and then recount again to N and so on, periodically. So the time trend of the data in the register of timer1 (TCNT1) assumes a symmetrical triangular shape, rather than to ramp as fast mode, as illustrated in the following illustration:



The front
describes the rise of the wave count up (between 0 and N), while the count down is back (between N and 0).


We note that the period of the signal generated (Ts) is twice the period T is obtained at N
and that it should be taken into account in subsequent calculations, even for Ton.


You have up to two PWM channels: A (pin OC1A) and B (pin OC1B), then we can have two waveforms with different duty cycle, but of course both have the same period as the share the same timer.
The comparison is done on both sides wave (and not a single wave front as in fast mode) and what implies a maximum operating frequency is lower than that of a "fast".
Pin OC1A (or OC1B) is enabled the first comparison that occurs during the rising edge of reset and the next comparison, which occurs on the falling edge.

It is always possible to configure a waveform reversed, eliminating the pin on the comparison OC1x up and activating it on the falling edge.

The changeover takes place at the next clock pulse of the future equality between the value contained in the register TCNT1 and the value contained in the register OCR1A (OCR1B or whether we are using the second B channel) when
 the maximum value of N was defined in Register ICR1 
(1)

. The value N, which thus establishes the resolution of Timer1, can take a value between 3 (minimum resolution of 2bit) and 65535 (maximum resolution of 16 bits).
 Suppose we have a little problem typical for the control of a servant 

timer1 to generate an ATmega168, OC1A pin on the back edge square wave signal (Ton = 2ms) with frequency of 50 Hz (T = 20ms) using as than the system clock (fc = 1MHz):

 V (OC1A) 

5V
_ _ = 0V
Ton Ton = 2ms 2ms
->
For k = 1, 8, 64, 256, 1024, and Tc = 0.25 us (fc = 1MHz), substituting, we have:


----------
N



sostituendo, abbiamo
NA=999



Abbiamo tutti i dati per scrivere un possibile pseudocodice:


Imposta PB1 come pin d'uscita;
Imposta la modalità PWM a correzione di fase e di frequenza (e valore N definito in ICR1)
Carica 9999 nel registro ICR1;
Carica 999 nel registro OCR1A;
Imposta forma d'onda non invertita;
Imposta prescaler :1 (nessun prescaling, k=1)


Come noto, l'istruzione di definizione del prescaler va sempre messa per ultima, in quanto dopo la sua esecuzione viene avviato il timer.

Per quanto riguarda l'impostazione della modalità PWM a correzione di frequency and phase (with value defined in ICR1 N) just look at the datasheet dell'ATmega168 Table 15-4:



TCCR1B when the register value OCR1A (for OC1A) and / or register OCR1B (for OC1B) equals that of the timer register TCNT1, through a combination of bits COM1A1/COM1A0 (to configure the waveform on pin OC1A) and COM1B1 / COM1B0 (to configure the waveform on pin OC1B) log TCCR1A:
----------------------------- -------------------------------------------------- ----
COM1A1/COM1B1 COM1A0/COM1B0 Description
------------------------------------- ----------------------------------------------

0 0 default: OC1A/OC1B pins are normally used as
pin I / O (not to pick PWM signals)

--------------------------------------------- --------------------------------------

0 1 pins are used OC1A/OC1B normally as pin I / O or if
set modes 9 or 11 (Table 15-4) Clear OC1A/OC1B when equality is a
0 on the rising edge and active OC1A/OC1B
when equality occurs on the falling edge

(the waveform is NOT INVERTED)
--------------- -------------------------------------------------- ------------------

Enable OC1A/OC1B when equality is
1 1 on the rising edge and resets when OC1A/OC1B
equality is on the front of

descent (the waveform is inverted)

------------------------------------ -----------------------------------------------


So, wanting a waveform is not reversed, the only pin OC1A, the code will be: TCCR1A 9999 ;
// Ts=20ms @ fc=1MHz (:1)

OCR1A =
999
;
// Ton=2ms @ fc=1MHz (:1)
   TCCR1A  with VMLAB, are shown below. The measure 

Ton, as the difference between the times measured by two markers corresponds to the calculated 2ms:







Finally, the measure of frequency, which confirms

Ts = 20ms (ie
fs
= 50Hz):





In
pwm2.zip
file contains the source main.c, makefile, and config files and project files for pwm2.prj VMLAB.

___________________
 
Note 1) E 'can be used alternatively register OCR1A. V. d / sheet



Monday, October 25, 2010

Play Original Poptropica

THE ADVENTURE OF A HEROIC

Thanks to the cooperation of the Section of AAA Pescara "G. D'Annunzio was possible to publish the following article will certainly welcome the many members of the Society that I am honored to attend this web space.
of Luigi Passera

There are men who do not surrender in the face the obstacles to their ideas, passions which devour them, to their inner certainty. Unfortunately, these men are often too often forgotten places, and their lives should become an example example for new generations.
Such is the case of Hugh Zannier, born 1913, native of Clauzetto, now the province of Pordenone (beyond the AGHE we would say in Friuli).


He attended the School of cabinetry at the Salesians in Venice and had also obtained the certificate "A" (almost a patent) by gliding in Pavullo Frignano. Unfortunately, his passion for flying was dramatically shock elimination in the competition for students of the Royal Air Force non-commissioned pilots for heart failure.


But he had not given up. He had read the book The "Soaring", published by the owner of a manufacturer of gliders based in Canterbury and, combining the craft learned in Venice with the instructions and drawings in the book, adding their own ideas and insights , decided to build himself a glider.


A Clauzetto had found help and support from family and friends, conquered by the beautiful and tall, proud and intelligent, to the point of obtaining the use of a classroom of the school used as a laboratory for design, unable to assemble the aircraft in the attic of the house. Similar aid was found to Campoformido, famous and recognized as a university of the flight. Here you could find technical material, practical advice, technical assistance.


On July 31, 1933, in Heath Sequals, was the baptism of the glider, called the "Friuli". After the crash bottle of sparkling wine, was made the first launch, with Zannier at the steering position. Were present Mr. Volpe, industrial Brovedani, journalist Grinovero of the "People of Friuli." The event aroused enthusiasm and had immediate resonance in the province.


order to use fruitfully the glider, Zannier decided to throw some high ground, but was not experienced in the pilot being in possession of the certificate only "A". Then the flight instructor sailing Campoformido, who had assisted in every way in his business as a builder with tips, presentations and other aid, he brought in several times with a share AS.1 then shut off the engine and as they had been on board a Glider, taught him the secrets of soaring flight and the best way to land properly in place previously fixed.


After a few lessons the instructor noticed the rapid and remarkable pupil. It seemed as if he were born with wings, as he showed a few years after giving evidence of his amazing acrobatic skills with CR.32: among other figures sank flying low and began a series of barrel touching the grass with wings without deviating slightly from the flight path.


When it was Zannier quite certain capacity to fly the plane safely with the engine switched off and from any point on the share of 1,000 meters was able to land safely in a well-defined area of \u200b\u200bthe camp, the instructor gave his approval to the first launch the glider from a mountain. Of course the attempt was given wide publicity, attracting public attention, and authorities on the importance of gliding.

was chosen Mount Valinis, Meduno above, because its peak was easily accessible even with bulky loads.

On October 28, in late afternoon, Zannier made its first flight from an altitude of about L.100 m. After having flown over Meduno, and New Cavasso Orgnese, landed safely on the grass near Solimbergo chosen. The operation, by climbing the mountain, and launching the overflights was followed by a multitude of friends, admirers and curious.


grande.risonanza The event was also outside the province, and called the attention of the General Alberto Liuzzi, which at the time he was training a unit of mountain climbers in Carnia. General Liuzzi was Gemona del Friuli (his house was near the underpass of the railway station, next to the villa Morgan) and became interested in the operation for the possible effects of war, such as transport in high-altitude flight of troops especially trained on specially built gliders. This will be the element of surprise and used soldiers undergo the fatigue of climbing in the rock. The Wehrmacht such a large demonstration of that possibility during the 2nd World War.


The idea had taken so Zannier to convince him to take another flight, this time from the top of the mountain Quarnan, above Gemona del Friuli, clearly visible from the plains to the Redeemer monument inaugurated a few years earlier. He led an expedition in person with his flight instructor and other on top of the mountain, although it was already covered with snow to see the space for the assembly of the glider and to verify the feasibility of the access path from the road leading to Foredor Sella. It was necessary, in fact, disassemble the glider into six pieces and then reassemble it with the utmost precision, particularly with respect to the rim of the attacks, the tension cables to the incidence of the wings and control of the rudders.


On 19 November 1934, three weeks after the first flight, Ugo Zannier stood the second flight from an altitude of 1,370 meters, and landed at the place chosen among Osoppo and Majano, in the vicinity of the airfields named after the late commander Nino Pittini. Once again the crowd was large, even for the propaganda made by the press. General Liuzzi, who had helped the company well with men and means, was at the height of joy, together with Mr. Barnabas.


Zannier was radiant: she had obtained a patent for civil aircraft pilots with AS. 1 to Campoformido and obtained satisfaction and celebrities deserve.


With these premises had been admitted to a new course for students of the Royal Air Force non-commissioned pilots. In addition, the Aero Club had purchased his glider and with the proceeds had been able to pay off the debt incurred to obtain the patent.

obtained by the pilot's military flight school at Grottaglie, went to the English Civil War, assigned to the squadron Autonomous "Arrows", attached to the famous Squadron "Cucaracha".


few days before the end of the war, December 30, 1938, the sergeant pilot Hugh Zannier fell in combat Sky Air Bayon, he was awarded the Gold Medal of Valor. The justification was given wide coverage to heroic self-sacrifice made in defense of their commander surrounded by enemy aircraft.


For Ugo Zannier were then named the School of Design Professional Meduno, where he had been able to follow their creative impulses, and the School of gliding of Udine, who had been born after the many exciting business.


now disappeared and that the professional school of flight; Ugo Zannier throughout Friuli has forgotten, for many reasons, the list of which could give rise to unnecessary controversy or sterile.

However, I needed an appendix to this story is still about the glider "Friuli".


To give further impetus to the nascent School of gliding, the instructor of Zannier found it necessary to recall another media. So with the support of the provincial OND, it was decided to perform a third launch, this time from the top of the mountain Cjampeon, above Magnano in Riviera, Tarcento, Artegna Montenars and, from an altitude of 740 meters.

Point Landing was set on the lawns of between the railway line, after the station Tarcento, and the highway that leads to Tarcento Buja. Access to the mountain was facilitated by Montenars, the military road built at the beginning of the century for the construction of the fort and the barracks on the mountain.

was April 21, 1934, anniversary of the "birth" of Rome, a national holiday. When everything was ready to launch a sudden storm broke soaked everyone present. Succeeded by a cold north wind that Fugo rain, but that complicates the calculation because it blew the side of the route required and tended to drag downwards, towards the town of Billerica.

Given the overflowing crowd agreed by all the countries of Friuli for the event, the instructor decided to launch even in those weather conditions. The experience and flying skills of the pilot allowed to land regularly at the point agreed.


This third flight was the real takeoff of Flight School Sailing Campoformido.

The photos are from the book The sky Campoformido "R. Bass - Ed Campanotto Pasian di Pratora gc Mr. Scarton Michele.






Tuesday, October 5, 2010

Pokemon Free Virtual Worlds

141 - Trapani

this is a message by running fast .. .
:-) Here I am, after Monfalcone and Treviso ...
to Trapani to Friday 8
to do a small part in the movie that is filming Luigi Cinque.




Sunday I'll be 10 in Pisa , all day, at the Stazione Leopolda
for the award "Experiments in dialogue."

then distributed to Naples, at Science City, October 12 to 14
to test some new ideas on the virtual character of the TWIST project on women and science.

the morning of 15 I must be in Genoa,
justice of the peace, for an old and unjust fine.

Finally ultmo trip of the month should be
Vimercate Sunday 24 , theater Oreno video backdrops for the reading-concert "Odyssey" he

quick message? :-)
Salutoni
giac