Show Posts
|
|
Pages: [1] 2
|
|
2
|
Using Arduino / Project Guidance / Re: Measuring a very fine wire with 10 µm precision
|
on: January 21, 2013, 05:01:28 pm
|
Hello, I think the weapon of your choice would be a so called 'micrometer' http://en.wikipedia.org/wiki/MicrometerPlus: If you want to measure in such small dimensions, be aware of the fact that even the warmth of your hand and also the atmosphere around the wire has an impact on the extension of the wire. I'm going with vasquo's oppinion. //edit: With what I want to say: If you're going to measure a wire by applying voltage, it will expand slightly due to warming up slightly (electrons colliding inside the copper), so I assume you can basically forget that...
|
|
|
|
|
3
|
Using Arduino / Project Guidance / Re: Letting a sensor value decay over a 3ms period
|
on: January 21, 2013, 04:41:29 pm
|
Alright then. I think I need some more philosophy here though, I can't really make something out of your words. I could get it to work a bit better by changing the code as follows: else if (holdmodeX == true && lockmode == false) { clock = digitalRead(clockin); if (clock == true) {xhold = false; analogWrite(xoutpin, xout); } else if (clock == false) {xhold = true;} } But I don't know, that's maybe not what you meant. Do you think you could enlighten me? Thank you so much for time really!
|
|
|
|
|
4
|
Using Arduino / Project Guidance / Re: Letting a sensor value decay over a 3ms period
|
on: January 21, 2013, 03:21:00 pm
|
|
Okay. Hey, I'm sorry but I don't think this will solve my problem. I actually do specify them as global variables, no?
My main problem is that I can only sense the leaving of the finger, after it had happened. Of course, because the machine can't look into the future. But then I would need to take the value that has been there like 5ms ago.
|
|
|
|
|
6
|
Using Arduino / Project Guidance / Re: Letting a sensor value decay over a 3ms period
|
on: January 21, 2013, 12:56:28 pm
|
It's not easy to relate the sequence you describes to what the code does.
Alright, if there's anything to make that clearer then please let me know how I can do it. The code currently looks as if it captures the value (does not change it) while the screen is touched and then stops holding it (returns to reading the sensor value) afterwards when yhold goes false. That doesn't seem unreasonable but presumably isn't what you want.
What it does now is: The screen is being touched and TouchTest() checks that because it is checking if on the whole screen something is going on. If there is, it makes the clock go high. If in 'momentary' mode then Read_y() (resp. Read_x()) looks if the clock is high (screen is touched) and does what it does best: Process the data and send them out on a pin. But as soon as the clock goes low (finger left the screen), it stops checking for new data and simply sends out the last value that is still stored in yout (xout). Alright? So what I want is that when you lift your finger of the TS the machine 'remembers' where you lift it of, so that it holds those last two variables, you understand? The problem is that I can only know that the finger is gone ... well ... when it's gone already  So at that point the value always is zero! But if I could hold the X-Y variables for a very short (unnoticable) time AFTER the clock went low (finger gone!) then it would be perfect. Because like I said, I can see on my oscilloscope that it takes ~3ms from the value that you had last until the clock goes low, i.e. the µC 'notices' that your finger is gone. Do you understand? Any ideas?
|
|
|
|
|
7
|
Using Arduino / Project Guidance / Re: Letting a sensor value decay over a 3ms period
|
on: January 21, 2013, 10:34:19 am
|
Sure thang! It's quite something though that's why I stripped it down for you. /*TODO: - Manual Triggers/Gates und die Lengths according to the X and Y value */
int X_LED = 0;
int xholdbutton = 2; //Pin for the X Hold Button int HMholdbutton = 3; //Pin for Hold Mode Button int yholdbutton = 4; //Pin for the Y Hold Button
int xoutpin = 5; //X-Out pin int youtpin = 6; //Y-Out pin
int clockout = 7; int clockin = 8;
int Y_LED = 9; int HM_LED = 10;
boolean xhold; boolean yhold; boolean HMhold = false;
int xval = 0; //Variable for X-Axis reading int yval = 0; //Variable for Y-Axis reading
int xout = 0; //Conditioned X-Output Value int yout = 0; //Conditioned Y-Output Value
//For X - Hold Pushbutton state changer: int statex = LOW; // the current state of the output pin int readingx; // the current reading from the input pin int previousx = HIGH; // the previous reading from the input pin
long timex = 0; // the last time the output pin was toggled long debouncex = 2000; // the debounce time, increase if the output flickers
//For Y - Hold Pushbutton state changer: int statey = LOW; // the current state of the output pin int readingy; // the current reading from the input pin int previousy = HIGH; // the previous reading from the input pin
long timey = 0; // the last time the output pin was toggled long debouncey = 2000; // the debounce time, increase if the output flickers
//And the Lock Mode Pushbutton state changer: int stateHM = LOW; // the current state of the output pin int readingHM; // the current reading from the input pin int previousHM = HIGH; // the previous reading from the input pin
long timeHM = 0; // the last time the output pin was toggled long debounceHM = 2000; // the debounce time, increase if the output flickers
/* So, my Pins are like this:
.D0 - X-LED .D1 - MIDI Out .D2 - Hold Pushbutton für X .D3 - Hold Mode Pushbutton .D4 - Hold Pushbutton für Y .D5 - Output X .D6 - Output Y .D7 - 'Internal' Clock Out .D8 - Clock In .D9 - Y-LED .D10 - HM-LED D11 - nix - kann PWM D12 - nix D13 - nix
.A0 - Touchscreen .A1 - Touchscreen .A2 - Touchscreen .A3 - Touchscreen A4 - nix A5 - nix
*/
//TouchScreen ts = TouchScreen(A2, A3, A0, A1, 300);
void setup() { //Serial.begin(57600); //MIDI: 31250 pinMode(xoutpin, OUTPUT); //X Out pinMode(youtpin, OUTPUT); //Y Out pinMode(1, OUTPUT); //MIDI Out pinMode(xholdbutton, INPUT); //X Hold Button pinMode(yholdbutton, INPUT); //Y Hold Button pinMode(HMholdbutton, INPUT); //Hold-Mode Button pinMode(X_LED, OUTPUT); pinMode(Y_LED, OUTPUT); pinMode(HM_LED, OUTPUT); pinMode(clockout, OUTPUT); pinMode(clockin, INPUT); TCCR0B = TCCR0B & 0b11111000 | 0x01; //Clockdivider Clock0 = 1 -> Clockspeed = 62,5KHz TCCR1B = TCCR1B & 0b11111000 | 0x01; //Clockdivider Clock1 = 1 -> Clockspeed = 31,25KHz }
void loop() { //boolean touch = false; int yout = Read_y(); boolean lockmode = checkLockMode(); boolean holdmodeX = checkHoldModeX(); boolean holdmodeY = checkHoldModeY(); boolean clock = TouchTest();
//X-HOLD Checking if (holdmodeX == true && lockmode == true) { //this is locked X xhold = true; analogWrite(xoutpin, xout); } else if (holdmodeX == true && lockmode == false) { //this is momentary X boolean clock = false; analogWrite(xoutpin, xout); clock = digitalRead(clockin); if (clock == true) {xhold = false;} else if (clock == false) {xhold = true;} } else if (holdmodeX == false && lockmode == true) { //free X xhold = false; analogWrite(xoutpin, xout); } else if (holdmodeX == false && lockmode == false) { //free X xhold = false; analogWrite(xoutpin, xout); } //Y-HOLD Checking if (holdmodeY == true && lockmode == true) { //this is locked Y yhold = true; analogWrite(youtpin, yout); } else if (holdmodeY == true && lockmode == false) { //this is momentary Y boolean clock = false; analogWrite(youtpin, yout); clock = digitalRead(clockin); if (clock == true) {yhold = false;} else if (clock == false) {yhold = true;} } else if (holdmodeY == false && lockmode == true) { //free Y yhold = false; analogWrite(youtpin, yout); } else if (holdmodeY == false && lockmode == false) { //free Y yhold = false; analogWrite(youtpin, yout); }
// int lsb, msb = 0; // int pitchbend = 224; // MIDImessage(pitchbend, lsb, xout/2);
}
void MIDImessage(int command, int data1, int data2) { Serial.write(command);//send command byte Serial.write(data1);//send data byte #1 Serial.write(data2);//send data byte #2 }
int Read_x() { //Processing X: To hold or not to hold - that is the question! if (xhold == true) { int holdxout = xout; return xout; } else { //Reading X pinMode( A1, INPUT ); pinMode( A3, INPUT ); pinMode( A0, OUTPUT ); digitalWrite( A0, LOW ); pinMode( A2, OUTPUT ); digitalWrite( A2, HIGH ); // int readings[10]; // int i; // for(i=0; i<10; i++){ // readings[i] = analogRead( 1 ); // } // // int xval = (readings[0] + readings[1] + readings[2] + readings[3] + readings[4] + readings[5] + readings[6])/7;
xval = analogRead(1); xout = map(xval, 160, 850, 0, 255); //will ich eigentlich noch weg - AA vs VA if (xout < 0) {xout = 0;} else if(xout > 255) {xout = 255;}; return xout; } } int Read_y() { // //Processing Y: To hold or not to hold - that is the question! if (yhold == true) { return yout; } else if (yhold == false) { //Reading Y pinMode( A0, INPUT ); pinMode( A2, INPUT ); pinMode( A1, OUTPUT ); digitalWrite( A1, LOW ); pinMode( A3, OUTPUT ); digitalWrite( A3, HIGH );
// int readings[7]; // int i; // for(i=0; i<7; i++){ // readings[i] = analogRead( 0 ); // } // // int yval = (readings[0] + readings[1] + readings[2] + readings[3] + readings[4] + readings[5] + readings[6])/7;
yval = analogRead(0); yout = map(yval, 100, 800, 0, 255); if (yout < 0) {yout = 0;} else if(yout > 255) {yout = 255;}; return yout; } } int TouchTest(void) { pinMode(A1, OUTPUT); digitalWrite(A1, LOW); pinMode(A0, OUTPUT); digitalWrite(A0, HIGH); digitalWrite(A3, LOW); pinMode(A3, INPUT); digitalWrite(A2, LOW); pinMode(A2, INPUT); int z1 = analogRead(A3); int z2 = analogRead(A2);
boolean touch; float rtouch; rtouch = z2; rtouch /= z1; rtouch -= 1; rtouch *= Read_x(); rtouch /= 1024; if (rtouch < 3) { //touched touch = true; digitalWrite(clockout, HIGH); } else { //untouched touch = false; digitalWrite(clockout, LOW); } return touch; }
boolean checkHoldModeX() { readingx = digitalRead(xholdbutton); if (readingx == HIGH && previousx == LOW && millis() - timex > debouncex) { if (statex == HIGH) { statex = LOW; digitalWrite(X_LED, LOW); } else { statex = HIGH; digitalWrite(X_LED, HIGH); }
timex = millis(); }
previousx = readingx; return statex; }
boolean checkHoldModeY() { readingy = digitalRead(yholdbutton); if (readingy == HIGH && previousy == LOW && millis() - timey > debouncey) { if (statey == HIGH) { statey = LOW; digitalWrite(Y_LED, LOW); } else { statey = HIGH; digitalWrite(Y_LED, HIGH); }
timey = millis(); }
previousy = readingy; return statey; }
boolean checkLockMode() {
readingHM = digitalRead(HMholdbutton);
if (readingHM == HIGH && previousHM == LOW && millis() - timeHM > debounceHM) { if (stateHM == HIGH) { stateHM = LOW; digitalWrite(HM_LED, LOW); } else { stateHM = HIGH; digitalWrite(HM_LED, HIGH); }
timeHM = millis(); }
previousHM = readingHM; return stateHM; }
|
|
|
|
|
8
|
Using Arduino / Project Guidance / Letting a sensor value decay over a 3ms period
|
on: January 21, 2013, 09:17:55 am
|
Hello fellas, I'm at a project with a touch screen where I experience slight troubles: I want to program a 'momentary hold' function and I do this as follows (in order of time). 1) I read the values of the touch screen 2) I check if the hold switch boolean is true or false 3) If it's false, no problem, continue... 4) If it's true (i.e. we are now in momentary hold mode), check if the screen is pressed above a certain value. If it is, then I generate a clock signal which goes to a normalled minijack (so I can also feed ext. clocks into it) and then back into the Atmega again. Internally I handle this as a clock boolean. 5) If there is a clock signal present on that pin I just continue reading the screen and writing the values. 6) If the clock signal goes low, I lock up the value (simply stop reading the sensor) so therefore a hold mode is achieved. I hope this is understandable. Now the problem is that the clock always goes low AFTER the touch screen isn't touched anymore (because that's the condition to make the clock high in the first place) so in 90% of the cases I end up with a 0 reading of the screen in that point of time. I can see on my Rigol that the clock goes low roughly 3ms after the sensor value decreases. Sometimes I have a lucky catch and it holds the value (for reasons unknown actually). So now I think if I could make a tini tiny delay on my sensor reading, like 5ms, I could avoid this problem right? How would that work? Or any other suggestions? Thanks for your help!! //edit: Oh and here's the (relevant) code pieces: My main loop: int yout = Read_y(); boolean lockmode = checkLockMode(); boolean holdmodeX = checkHoldModeX(); boolean holdmodeY = checkHoldModeY(); TouchTest();
//Y-HOLD Checking if (holdmodeY == true && lockmode == true) { //this is locked Y yhold = true; analogWrite(youtpin, yout); } else if (holdmodeY == true && lockmode == false) { //this is momentary Y analogWrite(youtpin, yout); clock = digitalRead(clockin); if (clock == true) {yhold = false;} else if (clock == false) {yhold = true;} } else if (holdmodeY == false && lockmode == true) { //free Y yhold = false; analogWrite(youtpin, yout); } else if (holdmodeY == false && lockmode == false) { //free Y yhold = false; analogWrite(youtpin, yout); }
The sensor reading (pretty standard): int Read_y() { // //Processing Y: To hold or not to hold - that is the question! if (yhold == true) { return yout; } else if (yhold == false) { //Reading Y pinMode( A0, INPUT ); pinMode( A2, INPUT ); pinMode( A1, OUTPUT ); digitalWrite( A1, LOW ); pinMode( A3, OUTPUT ); digitalWrite( A3, HIGH );
yval = analogRead(0); yout = map(yval, 100, 800, 0, 255); if (yout < 0) {yout = 0;} else if(yout > 255) {yout = 255;}; return yout; } }
And this is the touch test: int TouchTest(void) { pinMode(A1, OUTPUT); digitalWrite(A1, LOW); pinMode(A0, OUTPUT); digitalWrite(A0, HIGH); digitalWrite(A3, LOW); pinMode(A3, INPUT); digitalWrite(A2, LOW); pinMode(A2, INPUT); int z1 = analogRead(A3); int z2 = analogRead(A2);
boolean touch; float rtouch; rtouch = z2; rtouch /= z1; rtouch -= 1; rtouch *= Read_x(); rtouch /= 1024; if (rtouch < 3) { //touched touch = true; digitalWrite(clockout, HIGH); } else { //untouched touch = false; digitalWrite(clockout, LOW); } return touch; }
I left out the switch check, it is a simply boolean being slammed around by a pushbutton...
|
|
|
|
|
9
|
Using Arduino / Programming Questions / Need to install bootloader first before setting different clock speeds works
|
on: November 27, 2012, 06:56:36 am
|
Hello guys, I have a question: In one of my patches I am setting the clocks to higher speed because I need a fast PWM output. I use the code proposed on the Arduino page itself: TCCR0B = TCCR0B & 0b11111000 | 0x01; //Clockdivider Clock0 = 1 -> Clockspeed = 62,5KHz TCCR1B = TCCR1B & 0b11111000 | 0x01; //Clockdivider Clock1 = 1 -> Clockspeed = 31,25KHz
I am working with an Attiny44PU-A and everything runs without problems but I always have to install the bootloader before the Attiny will take the clock changes. Otherwise the PWM outputs are normal speed. I need to do 250 of those Attinys and I'm looking for a way to avoid burning the bootloader to all of them before I can upload the (fully working) code. What am I missing here?
|
|
|
|
|
10
|
Using Arduino / Displays / Re: Switch Videos on a TV
|
on: July 10, 2011, 06:16:30 pm
|
As far as interfacing with your sensor, it seems possible that you could interface that directly to your computer and you wouldn't need an Arduino at all.
OTOH, you could do it entirely with Arduino and no computer if you want to make a video noise-generator. Then it would be simply a matter of turning it on or off.
How can you imagine that? I think I found my way now with SuperCollider where I both could open up a video file or create the picture by myself. Nevertheless I'm interested in these two ideas of yours as I can't imagine really what you're talking about. In my case the TV screen, the sensor and the laptop will be on a stage that is in the middle of a room where people can go all around the scenery so I don't really have the opportunity of sitting somewhere hidden and pressing buttons (although that would maybe also be worth a 'worst case scenario': taking the remote control and simply turn up the brightness  ). Thanks for your efforts, KE7GKP.
|
|
|
|
|
11
|
Using Arduino / Displays / Re: Switch Videos on a TV
|
on: July 09, 2011, 10:50:50 am
|
|
Thanks for your reply. I thought the easiest approach would maybe be to have arduino open a program/script/even SuperCollider to open a video file on the computer and simply show it on the TV screen then as the second monitor. But as I don't know if that is possible (let Arduino open a video file) I thought I was asking here first. Since one video file is only black color and the other one should be this old-fashioned 'snowy noise' screen that would be the easiest way I can imagine getting this task done. So I'm very open for any suggestions.
|
|
|
|
|
12
|
Using Arduino / Displays / Switch Videos on a TV
|
on: July 09, 2011, 09:28:07 am
|
|
Hello!
I'm looking for the easiest way to switch between two videos on a TV screen that is hooked up to the laptop. The basic idea is this: I run a video A all the time. In a theater scenerey there is a distance sensor with a very small range (10cm) which should give the Arduino a signal to switch to switch to video B for 5 minutes and then back to A.
The hardware part is not really the problem, I'm just not very experienced in doing video things with Arduino so any hint in the right direction will be greatly appreciated! Thanks a lot!
|
|
|
|
|
14
|
Using Arduino / Sensors / How can I create 4 cases out of one analog input??
|
on: June 30, 2011, 04:41:37 pm
|
|
Hi!
It's maybe a simple question but I can't figure it out: I have four transistors driving 4 different banks of leds. I have one potentiometer hooked up to the analog input A0. I want to switch through the colours as I sweep the pot. So e.g. 0 - 255 = Transistor 1 high, others low, 256 - 511 Transistor 2 high, others low and so on.
Thank you so much for your help!!!
|
|
|
|
|
15
|
Forum 2005-2010 (read only) / Interfacing / Re: Question about imprecision of Analog Input
|
on: February 15, 2010, 07:58:14 pm
|
I think that'll fall back to the fact that you can never get perfect voltage reference, etc. Are these 1% resistors? Yup they are. As I let the program running I know have 21... Maybe if I'm funny tomorrow I'll try with a battery... //edit Even though, now I realize that it shouldn't matter in this case what kind of tolerance the resistors have...
|
|
|
|
|