<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ca">
	<id>http://wiki.joanillo.org/index.php?action=history&amp;feed=atom&amp;title=ELECT_28%3A_Balan%C3%A7a_basada_amb_Arduino</id>
	<title>ELECT 28: Balança basada amb Arduino - Historial de revisió</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.joanillo.org/index.php?action=history&amp;feed=atom&amp;title=ELECT_28%3A_Balan%C3%A7a_basada_amb_Arduino"/>
	<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=ELECT_28:_Balan%C3%A7a_basada_amb_Arduino&amp;action=history"/>
	<updated>2026-08-30T10:19:29Z</updated>
	<subtitle>Historial de revisió per a aquesta pàgina del wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://wiki.joanillo.org/index.php?title=ELECT_28:_Balan%C3%A7a_basada_amb_Arduino&amp;diff=5836&amp;oldid=prev</id>
		<title>88.6.162.61: /* proves amb el Arduino Mega */</title>
		<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=ELECT_28:_Balan%C3%A7a_basada_amb_Arduino&amp;diff=5836&amp;oldid=prev"/>
		<updated>2010-05-04T22:15:40Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;proves amb el Arduino Mega&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pàgina nova&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Per fer la balança:&lt;br /&gt;
*FSR: http://www.sparkfun.com/commerce/product_info.php?products_id=9375&lt;br /&gt;
*[[Imatge:Fsrguide.pdf]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Description: This is a force sensitive resistor with a round, 0.5&amp;quot; diameter, sensing area. This FSR will vary its resistance depending on how much pressure is being applied to the sensing area. The harder the force, the lower the resistance. When no pressure is being applied to the FSR its resistance will be larger than 1MΩ. This FSR can sense applied force anywhere in the range of 100g-10kg.&lt;br /&gt;
&lt;br /&gt;
These sensors are simple to set up and great for sensing pressure, but they aren't incredibly accurate. Use them to sense if it's being squeezed, but you may not want to use it as a scale.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Diu que no són molt precisos, i que no s'haurien d'utilitzar per fer una balança...&lt;br /&gt;
&lt;br /&gt;
Llegeixo en la FSR Integration Notes (pdf):&lt;br /&gt;
*The FSR sensor is not a strain gauge, load cell or pressure transducer. While it can be used for dynamic&lt;br /&gt;
measurement, only qualitative results are generally obtainable. Force accuracy ranges from&lt;br /&gt;
approximately ± 5% to ± 25% depending on the consistency of the measurement and actuation system,&lt;br /&gt;
the repeatability tolerance held in manufacturing, and the use of part calibration.&lt;br /&gt;
Accuracy should not be confused with resolution. The force resolution of FSR devices is better than&lt;br /&gt;
± 0.5% of full use force.&lt;br /&gt;
*For FSR Pressure or Force Switches, use the simple interfaces detailed on pages 16 and 17. (És el que jo necessito)&lt;br /&gt;
*Force Sensitivity Range &amp;lt; 100 g to &amp;gt; 10 kg, dependent on mechanics&lt;br /&gt;
*Break Force (Turn-on Force) 20 g to 100 g (0.7 oz to 3.5 oz). Dependent on mechanics and FSR build. És la força que he de fer per començar a mesurar.&lt;br /&gt;
&lt;br /&gt;
La interfície elèctrica més senzilla és fer un divisor de tensió (pàg 18). &lt;br /&gt;
[[Imatge:FSR Voltage Divider.jpg|thumbnail]]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
For a simple force-to-voltage conversion, the FSR device is tied to a measuring resistor in a voltage divider&lt;br /&gt;
configuration. The output is described by the equation:&lt;br /&gt;
                                      VOUT = (V+) / [1 + RFSR/RM].&lt;br /&gt;
In the shown configuration, the output voltage increases with increasing force. If RFSR and RM are&lt;br /&gt;
swapped, the output swing will decrease with increasing force. These two output forms are mirror images&lt;br /&gt;
about the line VOUT = (V+) / 2.&lt;br /&gt;
The measuring resistor, RM, is chosen to maximize the desired force sensitivity range and to limit current.&lt;br /&gt;
The current through the FSR should be limited to less than 1 mA/square cm of applied force. Suggested op-&lt;br /&gt;
amps for single sided supply designs are LM358 and LM324. FET input devices such as LF355 and TL082&lt;br /&gt;
are also good. The low bias currents of these op-amps reduce the error due to the source impedance of the&lt;br /&gt;
voltage divider.&lt;br /&gt;
A family of FORCE vs. VOUT curves is shown on the graph above for a standard FSR in a voltage divider&lt;br /&gt;
configuration with various RM resistors. A (V+) of +5V was used for these examples.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Però té una resposta millor fer un FSR Current-to-Voltage Converter (pàg 23)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
In this circuit, the FSR device is the input of&lt;br /&gt;
a current-to-voltage converter. The output&lt;br /&gt;
of this amplifier is described by the&lt;br /&gt;
equation:&lt;br /&gt;
       VOUT = VREF • [-RG/RFSR].&lt;br /&gt;
With a positive reference voltage, the output&lt;br /&gt;
of the op-amp must be able to swing below&lt;br /&gt;
ground, from 0V to –VREF, therefore dual&lt;br /&gt;
sided supplies are necessary. A negative&lt;br /&gt;
reference voltage will yield a positive output&lt;br /&gt;
swing, from 0V to +VREF.&lt;br /&gt;
       VOUT = (-RG • VREF) /RFSR.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Ara bé, el desavantatge és que es necessita un Vcc dual (+-5V). Per tant, d'entrada ho descarto i em quedaré amb la configuració més simple.&lt;br /&gt;
&lt;br /&gt;
=Desenvolupament=&lt;br /&gt;
==proves amb el Arduino Mega==&lt;br /&gt;
[[Imatge:Balança1.jpg|thumbnail]]&lt;br /&gt;
[[Imatge:Balança2.jpg|thumbnail]]&lt;br /&gt;
De moment no faig proves amb el ''paperduino'' perquè el cable FTDI que tinc només em proporciona 3,3V, i he d'aconseguir el cable que m'alimenti 5V a l'arduino. Per tant, les següents proves són amb el Arduino Mega.&lt;br /&gt;
&lt;br /&gt;
De moment només faig servir un sensor dels 4 que utilitzaré. La idea de fer servir 4 sensors amb una geometria equidistant és que se suposa que si faig la mitja dels 4 sensors obtindré un valor més fiable. També es farà una mitja en el temps, fent la mitja de 8 valors successiu. Recordem que l'ús de 4 sensors fa que la pressió que nota cada sensor és la cuarta part.&lt;br /&gt;
&lt;br /&gt;
El FSR forma un divisor de tensió amb una resistència de 4,7Kohm. Aquesta resistència en la imatge es veu que és una resistència variable, doncs és la millor manera de fer proves per veure quan el sensor és més sensible. Al final concloc que una resistència de 4,7Kohm és un bon valor.&lt;br /&gt;
&lt;br /&gt;
Fent proves amb ''DEFAULT'' i ''INTERNAL'', queda clar que he d'utilitzar ''EXTERNAL'' (AREF). El procediment és mirar, pel rang de pesos que vull utiilitzar, quina és la sortida de tensió de Vout. Veig que com a molt obtindré 0,4V. Per tant, he d'aconseguir aplicar aquesta tensió a AREF, i això s'aconsegueix mitjançant un divisió de tensió tal com s'explica en la imatge i com s'explica a http://arduino.cc/en/Reference/AnalogReference?from=Reference.AREF. Si llegim bé veiem que s'ha de posar una resistència de 5Kohm (potser un valor més petit?) al pin AREF. Aquest PIN internament té una resistència de 32Kohm.&lt;br /&gt;
&lt;br /&gt;
La qüestió és aconseguir uns valors de resistència que facin que el rang de l'entrada analògica, en el rang de pesos que vull considerar, s'acosti a 0-1023. És a dir, aconsegueixo la màxima precisió.&lt;br /&gt;
&lt;br /&gt;
Quan tingui fet tot el muntatge amb els 4 sensors hauré de mirar, a partir de pesos coneguts, quin factor de conversió he d'aplicar, tenint en consideració un possible offset, i suposant una resposta lineal com es mostra en la gràfica d'instruccions del FSR. (Veure [[Imatge:Fsrguide.pdf]])&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
És el script balanca.pde&lt;br /&gt;
&lt;br /&gt;
==proves amb el paperduino==&lt;br /&gt;
Si fico &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sensorPin[0] = 2;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
vol dir que amb el arduino és el ANALOG2.&lt;br /&gt;
&lt;br /&gt;
'''Compte!''' perquè en el disseny original del paperduino VCC i AREF estan connectats. Si vull utilitzar AREF, com és el cas, l'hauré de desconnectar del senyal de VCC.&lt;br /&gt;
&lt;br /&gt;
==Proves amb un LED RGB==&lt;br /&gt;
El GND és el que té la pota més llarga&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
-------       Verd (G)&lt;br /&gt;
---------     Vermell (R)&lt;br /&gt;
------------  GND (ànode comú)&lt;br /&gt;
-------       Blau (B)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Utilitzo els pins digitals: 51 (R), 52 (G) i 53 (B).&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
 * LilyPad tutorial: color (RGB LEDs)&lt;br /&gt;
 *&lt;br /&gt;
 * Uses a LilyPad RGB LED module to play with&lt;br /&gt;
  * dynamic colored light. See this web color chart&lt;br /&gt;
  * for the (Red,Green,Blue) values of different colors:&lt;br /&gt;
 * http://www.visibone.com/colorlab/&lt;br /&gt;
 */&lt;br /&gt;
 &lt;br /&gt;
int redPin = 51; //11; 	// R petal on RGB LED module connected to digital pin 11&lt;br /&gt;
int greenPin = 52; //9; 	// G petal on RGB LED module connected to digital pin 9&lt;br /&gt;
int bluePin = 53; //10; 	// B petal on RGB LED module connected to digital pin 10&lt;br /&gt;
  	 &lt;br /&gt;
void setup() 	 &lt;br /&gt;
{ 	 &lt;br /&gt;
         pinMode(redPin, OUTPUT); 	// sets the redPin to be an output&lt;br /&gt;
         pinMode(greenPin, OUTPUT); 	// sets the greenPin to be an output&lt;br /&gt;
         pinMode(bluePin, OUTPUT); 	// sets the bluePin to be an output&lt;br /&gt;
} 	 &lt;br /&gt;
  	 &lt;br /&gt;
void loop() 	// run over and over again&lt;br /&gt;
{ 	 &lt;br /&gt;
          // Basic colors:&lt;br /&gt;
          color(255, 0, 0); 	// turn the RGB LED red&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
          color(0,255, 0); 	// turn the RGB LED green&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
          color(0, 0, 255); 	// turn the RGB LED blue&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
 &lt;br /&gt;
          // Example blended colors:&lt;br /&gt;
          color(255,255,0); 	// turn the RGB LED yellow&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
          color(255,255,255); 	// turn the RGB LED white&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
          color(128,0,255); 	// turn the RGB LED purple -&amp;gt; no funciona utilitzant els pins digitals!&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
          color(50,50,50); 	// llum blanca poc clara -&amp;gt; no funciona utilitzant els pins digitals!&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
          color(0,0,0); 	// turn the RGB LED off&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
          &lt;br /&gt;
&lt;br /&gt;
} 	 &lt;br /&gt;
  	 &lt;br /&gt;
void color (unsigned char red, unsigned char green, unsigned char blue)     // the color generating function&lt;br /&gt;
{ 	 &lt;br /&gt;
          analogWrite(redPin, red); 	 &lt;br /&gt;
          analogWrite(bluePin, blue);&lt;br /&gt;
          analogWrite(greenPin, green);&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Ara bé, utilitzant els pins digitals no puc ficar informació entre 0 i 255 pins (sí que puc, però el pin només agafarà els valors HIGH i LOW). Per tant, si vull fer coses com &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
color(128,0,255);&lt;br /&gt;
color(50,50,50); 	// llum blanca poc clara -&amp;gt; no funciona utilitzant els pins digitals!&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
he d'utilitzar els pins analògics i utilitzar PWM per aplicar la tensió correcta (pins 9, 10 i 11)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
int redPin = 9;	        // R petal on RGB LED module connected to digital pin 11&lt;br /&gt;
int greenPin = 10;	// G petal on RGB LED module connected to digital pin 9&lt;br /&gt;
int bluePin = 11; 	// B petal on RGB LED module connected to digital pin 10&lt;br /&gt;
  	 &lt;br /&gt;
void setup() 	 &lt;br /&gt;
{ 	 &lt;br /&gt;
         pinMode(redPin, OUTPUT); 	// sets the redPin to be an output&lt;br /&gt;
         pinMode(greenPin, OUTPUT); 	// sets the greenPin to be an output&lt;br /&gt;
         pinMode(bluePin, OUTPUT); 	// sets the bluePin to be an output&lt;br /&gt;
} 	 &lt;br /&gt;
  	 &lt;br /&gt;
void loop() 	// run over and over again&lt;br /&gt;
{ 	 &lt;br /&gt;
  /*&lt;br /&gt;
          // Basic colors:&lt;br /&gt;
          color(255, 0, 0); 	// turn the RGB LED red&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
          color(0,255, 0); 	// turn the RGB LED green&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
          color(0, 0, 255); 	// turn the RGB LED blue&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
 &lt;br /&gt;
          // Example blended colors:&lt;br /&gt;
          color(255,255,0); 	// turn the RGB LED yellow&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
          color(255,255,255); 	// turn the RGB LED white&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
          color(128,0,255); 	// turn the RGB LED purple -&amp;gt; no funciona utilitzant els pins digitals!&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
          color(20,20,20); 	// llum blanca poc clara -&amp;gt; no funciona utilitzant els pins digitals!&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
          color(0,0,0); 	// turn the RGB LED off&lt;br /&gt;
          delay(1000); 	// delay for 1 second&lt;br /&gt;
    */      &lt;br /&gt;
          for (int i=0; i&amp;lt;=255; i=i+5){&lt;br /&gt;
            color(i,i,i); 	// canviem el color blanc gradualment&lt;br /&gt;
            delay(50); 	// delay for 1 second&lt;br /&gt;
          }&lt;br /&gt;
          for (int i=255; i&amp;gt;=0; i=i-5){&lt;br /&gt;
            color(i,i,i); 	// canviem el color blanc gradualment&lt;br /&gt;
            delay(50); 	// delay for 1 second&lt;br /&gt;
          }          &lt;br /&gt;
&lt;br /&gt;
} 	 &lt;br /&gt;
  	 &lt;br /&gt;
void color (unsigned char red, unsigned char green, unsigned char blue)     // the color generating function&lt;br /&gt;
{ 	 &lt;br /&gt;
          analogWrite(redPin, red); 	 &lt;br /&gt;
          analogWrite(greenPin, green);&lt;br /&gt;
          analogWrite(bluePin, blue);&lt;br /&gt;
} 	&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
{{Autor}}, abril 2010&lt;br /&gt;
[[Categoria: Electrònica]]&lt;br /&gt;
[[Categoria: Arduino]]&lt;br /&gt;
[[Categoria: 5 maneres de calcular g]]&lt;/div&gt;</summary>
		<author><name>88.6.162.61</name></author>
		
	</entry>
</feed>