Show Posts
|
|
Pages: 1 ... 5 6 [7] 8
|
|
91
|
Using Arduino / Project Guidance / Re: Monitoring PWM- best way for newbie?
|
on: July 08, 2012, 12:29:52 am
|
Hm...not being an electronics expert, I assumed there was an easy way to get average voltage through some kind of component or filter. If not, you could try averaging it like this: // measure PWM voltage (duty cycle between 0.0 and 1.0) // connect a jumper from digital pin 3 to analog pin 2 // start serial monitor to see average voltage
float average, alpha=.99, newValue, oldValue=0.0, duty=.8;
void setup() { pinMode(3, OUTPUT); Serial.begin(9600); }
void loop() { analogWrite(3, 255*duty); newValue = analogRead(2); average = oldValue*alpha + (1-alpha)*newValue; Serial.println(average); oldValue = average; delay(50); } Play around with this - all you need is one wire. Try it for different duty cycles. The closer to 1.0 you make alpha, the better the average but the slower the response time. This shouldn't be a problem since you are only concerned with steady-state data.
|
|
|
|
|
92
|
Using Arduino / Project Guidance / Re: Monitoring PWM- best way for newbie?
|
on: July 07, 2012, 04:44:47 pm
|
|
Not sure this will help, but isn't "reading" a PWM signal the same as measuring the average voltage? If so, just read the PWM voltage. For a square wave, measuring the area under the curve is trivial. It's just average voltage * time.
If I understand your question correctly, you could measure the voltage at regular intervals and multiply by the interval (in seconds) to get a number proportional to the fuel consumed during the interval. Frequency of the PWM does not matter because you're reading the average.
|
|
|
|
|
95
|
Using Arduino / Programming Questions / Re: question about the makeKeymap function in the keypad.h library
|
on: July 05, 2012, 08:53:40 am
|
Is it possible to define the array as a 2d array of integers?? Sure, here is a sketch I wrote yesterday to light a seven segment LED with a 4x3 keypad. (edit) It may be easier to do what you want if you code it directly without using a library. (edit) // 7 segment LED display LSD3211-11 and 3X4 keypad // pin 13 to segment a of display, 14 to b, 15 to c, etc. // keypad plugged into Arduino using pins 0-6
int key, i, j, k; // a b c d e f g int seg[][7] = {{1,1,1,1,1,1,0}, // 0 {0,1,1,0,0,0,0}, // 1 {1,1,0,1,1,0,1}, // 2 {1,1,1,1,0,0,1}, // 3 {0,1,1,0,0,1,1}, // 4 {1,0,1,1,0,1,1}, // 5 {1,0,1,1,1,1,1}, // 6 {1,1,1,0,0,0,0}, // 7 {1,1,1,1,1,1,1}, // 8 {1,1,1,1,0,1,1}, // 9 {1,1,0,1,0,1,1}, // *, 10 {0,1,1,0,1,1,0}}; // #, 11
int pad[][7] = {{-1, 2,-1, 0,-1, 8, 5}, // keypad {-1,-1, 1,-1, 3,-1,-1}, {-1,-1,-1,10,-1, 7, 4}, {-1,-1,-1,-1,11,-1,-1}, {-1,-1,-1,-1,-1, 9, 6}}; void setup() { for(i=13; i<20; i++) // display uses digital pins 13-19 pinMode(i, OUTPUT); }
void loop() { for(j=0; j<5; j++) { // get one keypress pinMode(j, OUTPUT); digitalWrite(j, LOW); // set one pin LOW for(i=j+1; i<7; i++) { // check other pins pinMode(i, INPUT_PULLUP); // which are HIGH if(digitalRead(i)==LOW) { // if one found LOW key = pad[j][i]; // save i, j values for(k=0; k<7; k++) { digitalWrite(13+k, seg[key][k]); // show the keypress } } } digitalWrite(j, HIGH); // set back to HIGH } } The pad[][] array contains integers so I could use them to directly index the seg[][] array. The -1's are just placeholders because some pin combinations don't do anything.
|
|
|
|
|
96
|
Using Arduino / Installation & Troubleshooting / Re: When you burn out one pin...
|
on: July 03, 2012, 11:55:29 am
|
You shouldn't be, I have never seen anyone put down for asking a "dum" question. In my book there is no such thing, if you don't know then you don't know. Thanks for the encouragement. I think my perception of "put down" is probably different than yours. The main thing was I didn't want someone to point out something that I could have worked out for myself. So far I've been able to answer my own questions by looking it up on this forum (thank you all!) or performing some kind of test with the components or software.
|
|
|
|
|
97
|
Using Arduino / Installation & Troubleshooting / Re: When you burn out one pin...
|
on: July 02, 2012, 10:10:41 pm
|
Next time, turn the power off before rewiring. It can prevent the smoke from coming out smiley-grin Good advice. Maybe I'll do that when I have only a few good pins remaining  I have learned a lot and in this Computer Science you learn a lot and you continue always its never ending ,You are learning even on the day you Die, its so much Deep. You are right, I have learned a ton since I bought an Arduino 2 months ago. Much of what I learned was from YouTube and this forum. The rest was from figuring it out on my own because I was afraid to ask a question on the forum!
|
|
|
|
|
98
|
Using Arduino / Installation & Troubleshooting / Re: When you burn out one pin...
|
on: July 02, 2012, 10:32:33 am
|
|
No, I didn't, but thanks for asking. Sorry I misunderstood the question. The pump motor I'm using has a control board with it, so I only need to supply a 0-5 volt signal to the control board in order to run the motor from zero to full speed. In fact, being new to this sort of thing, I made sure the motor I bought came with a control board!
|
|
|
|
|
99
|
Using Arduino / Installation & Troubleshooting / Re: When you burn out one pin...
|
on: July 02, 2012, 10:16:42 am
|
How was the motor connected to the pins? The motor was connected to the board with 22 gauge jumpers. Actually, it wasn't properly connected at the time of the accident. I think I was trying to rewire something on my breadboard when the 24 VDC supply wire came loose and I was probably waving it around while trying to re-connect it. The actual damage happeded suddenly - literally in a flash!
|
|
|
|
|
100
|
Using Arduino / Installation & Troubleshooting / Re: When you burn out one pin...
|
on: July 02, 2012, 10:10:22 am
|
I'd replace the chip. No telling what collateral damage may have occurred that could cause future failures. Sounds like good advice, but the chip on this Osep clone board is surface mount. Replacing it would be too difficult for me. Good news is the other pins seem to be fine so far.
|
|
|
|
|
102
|
Using Arduino / Sensors / Re: accelerometer angle reading
|
on: July 02, 2012, 02:33:58 am
|
|
If one axis is parallel to the motor shaft and it reads full gravity (1 g) at zero degrees, it will read .707 g when tilted at 45 degrees. As long as you start with the accelerometer reading full gravity at zero degrees, the general formula for any other angle is: value = g* cos(angle), where g = earth gravity and angle is in radians. (1 degree = 0.01745 radians).
By the way, have you actually tried to do any of this? If so, what have you done? Have you looked into using servos?
|
|
|
|
|
103
|
Using Arduino / Installation & Troubleshooting / When you burn out one pin...
|
on: July 02, 2012, 01:38:53 am
|
|
I was working with an Arduino clone (Osep) controlling an electric pump, when I accidentally fried digital pin 9. It read zero volts no matter what I did. Since I needed to use PWM, I switched to pin 10 and continued on. After I got everything working OK, I noticed the motor would start briefly during program upload, and also whenever I opened the serial monitor. I tried a 10K resistor between pin 10 and ground, but it didn't change anything. I was new enough to the Arduino that I just assumed this was normal behavior.
Eventually I got tired of disconnecting the motor every time I wanted to use the serial monitor, so I started investigating. I found there was .35 volts on pin 10 even when it was set to LOW! Here's the strange part - the motor didn't run all the time (as one would expect) because this model has a brake functon that activates when the voltage is below .4 volts.
Moral: When you burn out a pin, get out your voltmeter and check the other pins! Happy troubleshooting!
Tom
|
|
|
|
|
104
|
Using Arduino / Programming Questions / Re: Tracking Distance on one Axis with an Accelerometer
|
on: June 27, 2012, 03:30:47 pm
|
|
Unfortunately, once the potato exits the barrel it will basically be in free-fall until it hits something. During free-fall, the accelerometer will experience "weightlessness" and should read zero. Not sure how to measure flight distance with an accelerometer. In the Olympics, they just walk over to the javelin and measure the distance it was thrown...
|
|
|
|
|