1-Pull up resistor ~ 1KOhm to 5V, switch to ground. 2-Rebote de los contactos (Bouncing). Puedes tartar de eliminarlo con: -delay() -Utilizando banderas como aqui: http://forum.arduino.cc/index.php?topic=222479.0 Quizas eso te ayude Suerte.
I think it was a good starter project and the best part is that we have learnt from it. If you have a chance just try with the BIFET OpAmp. Maybe it will let you go a little bit lower in the Cap value and improves accuracy. Thanks for sharing and good luck.
Looks much better. -Remember damper diodes for the relays coils to prevent negative spikes. -The 100R I think is too low for the pF region. -I would use more ranging resistors. You are changing the caps range in about 6 orders of magnitude I think. I've been thinking the relays aren't perfect either as they will introduce other problems such as: bouncing of the contacts, probably oscillatory response and delays in the commutation; but testing will tell. Good luck.
However I would expect any impedance mismatch to be constant during the cap discharge as I can't imagine the circuit impedance changing as the DC voltage falls or the capacitance is changed.
That makes a lot of sense; but still better nor to have it neither having to compensate. On the other hand, the impedance could behave non linear still at such low currents. Testing will tell. I don't know.
Although I have not clear idea of the connections you have made and I need to put more time analyzing the circuit. It looks, the resistors connected to pins 9 and 12 could be creating a voltage divider connected to the cap. When one of the pins let's say 9 goes to LOW, the other (12) I guess is HIGH to suppress the ground path. That in reality connects it to 5V and with the other to ground there is a voltage divider. If both are LOW or HIGH then they are simply in parallel to either ground or 5V. I think Arduino digital outputs can't take 3rd state of high impedance and they are either low or high??
One thing at a time. The method in theory should work as it is already proven science. Implementing it in practice is a different story. Trying to achieve "auto ranging" at the same time is introducing additional problems, before implementing the basic solution to have a working circuit. So, I would try to go step by step and have a working thing first and then auto ranging. -It looks this is a typical case where the measuring method is affecting the variable being measured. The Arduino A0 and pin 13 are connected to the cap under test. Maybe in the picofarad region for the tested caps, the effect of the leakage currents involved are in the same orders of magnitude as the discharge currents through the discharge resistors. That could be contributing to the nonlinearities and errors you are getting in the results. Possible solutions: -Use a buffer OpAmp (as voltage follower) with BIFET high input impedance to tap the voltage on the cap and send it to A0. This will minimize loading the cap with the instrument of measurement. -The discharge resistor should be high as to provide enough time for the readings to take place; but not too high as to be comparable with the leakage currents of the cap being measured. Also if the discharge takes too long then the voltage presented to the Arduino A/D converter may take too long to change one quantifiable step, reducing the resolution in the time measurement. -Make sure when the measurement is done only the discharge resistor and the OpAmp input are connected to the cap. For that, you can use relays as the switching devices to avoid any leaks which will influence the measurement. -Concentrate on having a working circuit first and then move into auto ranging.
Esta es una version mejorada del Controlador de Voltage (iluminacion) construido anteriormente. http://forum.arduino.cc/index.php?topic=223712.0 En el caso anterior, al utilizarse analogWrite() para manejar las salidas, la resolucion de la senal de PWM y los pasos de voltaje obtenidos estaban limitados a 256. Esto pudiera no ser suficiente en algunas aplicaciones donde se requiera mas precision. En la nueva version aqui mostrada, la senal de PWM y el voltaje pueden cambiar en 1000 pasos diferentes. Hay una pequenisima inestabilidad como se observa en el video; pero aun asi, en mi opinion es mejor que solo disponer de 256 pasos diferentes.. La inestabilidad puede ser causada por varios factores, tales como: el tiempo que demora Arduino en leer los valores recibidos desde la computadora, es decir, el tiempo de comunicacion o el ruido introducido por las lamparas entre otros. La frecuencia de la senal de PWM seleccionada es de 1/15msec~66Hz y el ciclo util varia de 0 a 100%, como se muestra en el video. Se emplearon para manejar las lamparas los pines de salida 8,9,10,11 correspondientes a Dim 1,2,3,4. Este fue un projecto construido rapidamente, asi es que si encuentran algun problema, por favor dejenme saber. Construido con Processing 1.5.1 y Arduino UNO. Gracias. http://www.youtube.com/watch?v=271qPIFaC2E&feature=youtu.be
This is an improvement of the previous computer dimmer (voltage controller) here: http://forum.arduino.cc/index.php?topic=223709.0 In that case, since I was using analogWrite() to drive the outputs the resolution of the PWM signal generated and the voltage steps were limited to 256. That could be not enough for some voltage control applications where more precision is required. In this update, the PWM signal generated and the voltage can change in 1000 steps. There is a little instability though, as can be observed in the video; but still its better than having only 256 steps only, I think. The instability may be caused by different factors, such as: the time it takes for Arduino to read the values coming from the computer and the noisy lamps being used. The PWM frequency selected in this case is about 1/15 msec ~ 66 Hz and the duty cycle is changed from 0 to 100% as shown in the video. The digital output pins used are 8,9,10,11, corresponding to Dim 1,2,3,4. Built with Processing 1.5.1 and Arduino UNO. http://www.youtube.com/watch?v=271qPIFaC2E&feature=youtu.be
I have been working for a long time now on something which even when is for a different purpose; is very similar in operation. I ran into several of the same problems you are having now. Some of the experiences learnt while doing it are these: -To gain in accuracy, the loop should be as fast as possible or at least the reading and comparison with the target voltage, has to be performed several times within the same loop. That will allow you to detect when the threshold is surpassed almost immediately, otherwise the error introduced in the measurement will be too much and probably unacceptable. - Increase the discharge time (increase the discharge resistor) as much as possible. That will make any delays in the detection insignificant with respect to the total time, thus reducing the error. In my case, the discharge time is about 100 sec; but its a different application though. -Try using micros(); -Create a function to read the voltage and make the comparison. Call that function inside the loop several times, whenever you think there has been too much time elapsed which may compromise accuracy. -Set a target loop or inter-readings time, that will satisfy the speed required for the readings and comparisons intervals which will introduce an error in the measurement, acceptable for your needs. For example, less than 1% of the time constant you are determining. -Use precise 1% or lower discharge resistors. They should also be high stability and low temp coefficient. If not, there will have unacceptable temp drift. You can increase the loop speed by: -Reducing the info sent to se serial monitor, both in length and quantity. -Avoid complicated math operations. I'm not sure; but floating point math may be slower. -delay() is forbidden! -Do not use while(). If there is no other option call the ReadAndCompare() function from inside it. -Reduce the amount of instructions to a minimum possible. Perform any non essential tasks after the discharge time has been measured. Then there is plenty of time for non essential calculations, etc. -Another possibility is to set a while loop to ReadAndCompare() only and when the value is found the exit condition is met. That way, it will search constantly in very short time intervals, which may increase your accuracy. In this case, you need to guarantee the condition will be met at some point. Set an alternative exit route from the while loop with a push button or similar, in case there is a failure and the program gets stuck. Hope this help you with your Project.
-unsigned long timevariable??? time can't be negative I think, so better only long timevariable. -Do you really need long variables. Does your time can get longer than what an int can take? Please check that. -Try using micros() instead. You may be able to boost accuracy, but you will probably need longs, which you already have. -From the results, the loop is taking about 214msec. Isn't that too slow?. That can be contributing to the jumps from 0-1022 although I don't think that's the only reason. There maybe more. -Sending tons of huge strings to the serial monitor is good for step by step checking or presenting examples as the case now. But...,it slows down the thing, I guess. Communication is slow. Can your system take that slow motion even when you want accurate time readings with small jumps intervals?
Hola: Este es un controlador de voltaje (iluminacion en este caso) desde la computadora construido con Arduino y Processing 1.5.1. El voltaje aplicado a las lamparas varia de 0 a 10V utilizando Modulacion de Ancho de Pulso (PWM), a traves de las salidas digitales 3,9,10,11 de Arduino.y analogWrite(). En el ejemplo mostrado,, se controla el voltage aplicado a las lamparas; pero en realidad es un controlador de voltaje que puede ser utilizado para otros tipos de cargas tambien. Las lecturas de voltaje indicadas por los Galvanometros, representan los valores de voltaje establecidos que se quiere aplicar a las lamparas. Estos no leen el voltaje real que esta siendo aplicado, lo cual es muy diferente a esto. El multimetro en la imagen esta conectado unicamente a la lampara manejada por Dim 1 y esta midiendo el voltaje aplicado a esa sola lampara como ejemplo. El voltaje aplicado a las otras lamparas, no esta siendo medido en el video. Gracias.
Hi: This is a computer dimmer built with Arduino UNO and Processing 1.5.1. The voltage applied to the Lamps is varied from 0-10V using PWM Arduino outputs 3,9,10,11. and analogWrite(). In reality it is a voltage controller that can be use to drive many other different loads. The voltage readings indicated in the Galvanometers on the screen, represent the voltage settings and they are not measuring the actual voltage applied to the Lamps, which is very different from that. The Multimeter in the image, is connected to the Lamp driven by Dim 1 only. It is measuring the voltage applied to that Lamp as example. The other Lamps voltages are not being measured. Thanks,
I know how it is man, I had the same questions not too long ago... It took me while to figure it out though, so I tried to save you some time . In very little you will realize, this kind of coding is even easier than BASIC and the others. The computer will save you a lot of time resolving the lines numbering and jumps (I don't know how) without you having to do it. I suggest you start by looking at some examples first ,to get a better idea about how to do it and not make the same mistakes I did, trying to program in Basic at first. A few days ago, I posted an example which might help you figuring it out: http://forum.arduino.cc/index.php?topic=217512.0 Good Luck with your Project.
Hola: Este es un nivel de burbuja (GUI) construido con Processing 1.5.1 para ser utilizado en Proyectos basados en Arduino. Las variables X, Y estan siendo manejadas por potenciometros conectados a las entradas analogicas A0 y A1 de Arduino. Las mismas estan expresadas en pulgadas (inches) lo mismo que la distancia (D). Construido con Processing 1.5.1 y Arduino UNO. Espero les ayude a encontrar ideas y soluciones para sus propios proyectos. Gracias.
Hi: This is a Bubble Level GUI built with Processing 1.5.1 to be used in Arduino based Projects. The X and Y variables are being driven by potentiometers connected as voltage dividers to the Arduino analog inputs A0 and A1. They are both expressed in inches, likewise the Distance (D). Built with Processing 1.5.1 and Arduino UNO. Thanks,