Show Posts
Pages: [1] 2 3 4
1  Forum 2005-2010 (read only) / Forum / Re: A home for neophytes on: April 23, 2010, 07:04:30 am
Thank you for the invite! I will put this meeting on the calendar for next month.
2  Forum 2005-2010 (read only) / Forum / Re: A home for neophytes on: April 22, 2010, 02:53:51 pm
Am I missing something? I seem to have lost track of the conversation.

3  Forum 2005-2010 (read only) / Forum / Re: A home for neophytes on: April 22, 2010, 09:06:46 am
Groove,

First, let me state outright you and others on this forum have been very helpful. In fact whenever I write about my projects I emphasize that the hard work is often already done for me. There are a number of times in my writing that I describe my good fortune as "standing on the shoulders of giants". I am not looking for handouts nor am I taking credit for things I barely understand.

Second,  for the record: I am neither lazy nor have I asked for someone to do the work for me. I am studying. I'm just not learning. I have no formal education. I am entirely self taught. Perhaps there will be limits to my capabilities due this consideration.

Third, my frustrations are my own problems and I am sorry for having offended anyone. Like I mentioned earlier, if I am the only one with these issues than there isn't any reason for us to continue beating a dead horse.  

Thank you and once again, my apologies.
4  Forum 2005-2010 (read only) / Forum / Re: A home for neophytes on: April 22, 2010, 07:32:07 am
I feel as though I have looked a "gift horse in the mouth"; my appologies.

I can only speak for myself regarding the fantastic Google search engine. Days of searching normally turns up two or three relevant  links. In most cases these links lead to three or four websites with the very same examples seen on the others (copied and pasted). The vast majority of the remaining links are people showing off their led waste basket or yet another iteration of the LED coffee table.

My problem is specifically the "delay" command. So easy to use, and yet nearly useless. The alternative is poorly documented (millis timing). This is, no doubt, due to the fact that it is very easily understood by those with backgrounds in programming. Two or three pages of various examples would seem silly to someone who already knows "how to tie their shoes". Those of us who have just seen their first pair feel a little differently.

I have read and followed the examples in one C text and I am now studying C++. As stated at other places in the forum I will not find one bit of help with millis timing in any of these text books in that it is an Arduino specific command. So rather than thousands of titles I have two or three pages to rely on.

After three months of searching for better examples. After posting to the forum a half dozen times I have just now begun to understand. Worry not, my problem is now solved. But I find it hard to believe I am alone. Most times I get good help trying to understand these problems. But many times I get 'this is so easy I don't understand why you can't get it'. Or better, I'll get less than one line, a link to the example that hasn't helped.

In that I am the only one with these problems it would be inappropriate to do anything. And you are probably correct, an area in the forum wouldn't make much of a difference. Frustrated, I tossed out my first idea without considering whether it was helpful or not. Here again, my apologies.




5  Forum 2005-2010 (read only) / Forum / Re: A home for neophytes on: April 21, 2010, 01:58:13 pm
I stand corrected then. And my apologies to anyone I've inadvertently offended. Perhaps a small list of applicable study material would be helpful.
6  Forum 2005-2010 (read only) / Forum / A home for neophytes on: April 21, 2010, 07:53:51 am
Though I have a solid background in electronics I have had no programming experience. It has been great fun learning via the Arduino and it's IDE.

Most often my questions (to the forum) are answered carefully and politely. However, there are times my simplistic inquiries irritate or amuse. I fully understand how frustrating a newbie can be. However, unlike main stream languages that offer hundreds of text books for you to learn from there is almost no documentation (relatively) for the Arduino environment and language.

What I suggest is a new comers corner. This would be a place to hide the irritating questions that more advanced members find so offensive of comical. Those visiting that area would either be newcomers or those patient enough to help without discouraging.

Please understand, most of my experiences here have been very positive. However, I feel that many new hobbyist with a thinner skin than mine might be scared off.
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: it's me, the millis moron on: April 24, 2010, 08:47:22 am
Good morning again,

Yes, Groove and Grumpy Mike helped me with 'machine state' and I managed to extend some of what they taught me. I had hoped to continue to add states and call them when needed but after a time I seem to have lost track of my own progress. I know, not too impressive.

A personal tragedy is effecting my ability to concentrate at the moment. I hope we will be able to pick up where we left off in a day or two. You have been very helpful and when I return I hope to have some examples of what I've learned with your help.

Thanks again and sorry for the interruption.
8  Forum 2005-2010 (read only) / Syntax & Programs / Re: it's me, the millis moron on: April 23, 2010, 10:39:14 am
Thank you! You have all added enough for me to go back and try again. However, I haven't made my goals well understood and I can add that before I go back to beating my head against the bench.

This is all aimed at obstacle avoidance for my living room bot.

1. I want the servo to move 0,90,180, and back to 0 degrees

2. I want to take a distance measurement at each point and I   understand that the way it's written I will only get ping info once (instead of at each of the positions) I was going to approach that after I got the timing thing worked out.

3. The distance information from each position will be compared to determine if I am 12 inches or closer to an object?  If yes move in the direction that will allow the most unobstructed movement (compare the three and take the largest distance ping).

I will be back to let you know how I did with your current suggestions. Thanks again!
9  Forum 2005-2010 (read only) / Syntax & Programs / it's me, the millis moron on: April 23, 2010, 08:26:33 am
Good Morning (here anyhow)!

I don't know why I am having so much difficulty with this :-[

I don't want this done for me

I will include code that I hoped will turn a servo 0,90,180 degrees and back to 0 again. The servo hosts a ping ultrasound sensor that I query for distance info. All works splendidly when I use the irksome  delay command. However when I try to implement millis timing I have problems.

Perhaps if someone could look at this they would see where my logic fails. I am trying to follow advice I've been given but I just don't seem to understand how to implement it.

In the example, the code for the 0 degree position is what I would like to do (millis timing?). The next sections of code (for 90,180) have been left the way I originally wrote it (meaning copied and pasted) to help explain what I am trying to accomplish.

Code:
#include <Servo.h>
#include <Ping.h>

Ping ping = Ping(8,74,19);
Servo myservo;  // create servo object to control a servo

unsigned long currentTime = 0;
unsigned long previousTime = 0;
int pos = (0);    // variable to store the servo position
int outputPin = 12;
int outputPin2 = 13;
int outputPin3 = 11;

void setup()
{
Serial.begin(9600);  
myservo.attach(9);  // attaches the servo on pin 9 to the servo object
pinMode(outputPin, OUTPUT);
pinMode(outputPin2, OUTPUT);
pinMode(outputPin3, OUTPUT);
}

void loop()
{
  
  currentTime = millis(); //get current time?
  unsigned long millisPassed = currentTime-previousTime;

  //declare a variable = current time - previous
  
  ping.fire();
  Serial.print("Microseconds: ");
  Serial.print(ping.microseconds());
  Serial.print(" | Inches ");
  Serial.print(ping.inches());
  Serial.println();

        
    myservo.write(0); //turn servo to 0 degrees
    Serial.print(0);  //print 0
    Serial.println(" "); //print space
    if (millisPassed >= previousTime +1500)

//if time passed is greater than or equal to
//previous time plus 1500 milsec then...
  
    digitalWrite(outputPin2, HIGH);  // turn on light at pin2
    if (millisPassed >= previousTime +35)

 //if time passed is greater than or equal to
 //previous time plus 35 milsec then...
    
digitalWrite(outputPin2, LOW);  // turn off light pin2
    
                                  
    myservo.write(90);              
    Serial.print(90);
    Serial.println(" ");                         //the next examples work
    digitalWrite(outputPin3, HIGH);     //as written
    delay(1000);
    digitalWrite(outputPin3, LOW);
    delay(35);                        
                                
    myservo.write(180);              
    Serial.print(180);
    Serial.println(" ");
    digitalWrite(outputPin, HIGH);
    delay(1000);
    digitalWrite(outputPin, LOW);
    delay(35);
                                
    myservo.write(90);              
    Serial.print(90);
    Serial.println(" ");
    digitalWrite(outputPin3, HIGH);
    delay(1000);
    digitalWrite(outputPin3, LOW);
    delay(35);                        
  
}


10  Forum 2005-2010 (read only) / Syntax & Programs / Re: can't get millis delay to work on: April 20, 2010, 11:43:06 am
PaulS, indeed. And so without the help of other more knowledgeable folks like yourself, I'd get no where. Thanks again!  smiley

Imahilus, Yes! I think I get that. I will get back to this string and let you know if I've finally learned this or not. I do believe I've gotten it.  smiley-grin

And to the rest of you who have suffered through this with me... thank you for your patience.  :-[
11  Forum 2005-2010 (read only) / Syntax & Programs / Re: can't get millis delay to work on: April 20, 2010, 10:20:43 am
PaulS, thank you for responding so quickly.

First question. What are the curly braces ({}) for?

I don't know. Residue from a cutting pasting misunderstanding no doubt. I will remove them.

Second question. You set blinkTimer2 to a value, turn off the output pin you just turned on, and the set blinkTimer2 to a new value. Yet, you never use blinkTimer2 anywhere else. What are you trying to do?

I write to the servo four times. Once (in the first instance) I attempted to replace the "delay" seen the following three instances:

It was my intention to move the servo to 0,90,and180 degrees and then back again. To send the position of the servo back via serial port. The servo hosts a ping ultrasound sensor.  I want to collect the ping info at each of three servo positions and compare them to adjust course. The ping info is also collected and sent via serial port.

If I write each instance like this:

myservo.write(90);              
     Serial.print(90);
     Serial.println(" ");
     digitalWrite(outputPin3, HIGH);
     delay(1000);
     digitalWrite(outputPin3, LOW);
     delay(35);  

all is well. However, I need to replace the delay as it pauses the entire program in each instance it's used. I had tried this:

myservo.write(0);  
    Serial.print(0);
    Serial.println(" ");
    digitalWrite(outputPin2, HIGH);
    blinkTimer2 = millis() + 1500;
    digitalWrite(outputPin2, LOW);
    blinkTimer2 = millis() + 35;

I thought I had copied it from previous code that had worked for me. It's frustrating because I thought I had this millis delay thing down. I appreciate your "for dummies" explanation. Thank you for taking the time to help. I'll let you know if this gets me going.

In fact I just finished "C programming for dummies" in attempt to understand the code I've been "copying" and make it work in various ways. Not one thing is mentioned about millis timing in all 500 plus pages. On to the next text book which I have been told is more useful. It looks a little bit over my head but I have time to study.
12  Forum 2005-2010 (read only) / Syntax & Programs / can't get millis delay to work on: April 20, 2010, 08:51:22 am
First, you've helped me and dozens of others to understand "blink w/o delay". I have employed it a number of times but struggle with it each time. Delay is easy to use, you want an action to continue for a set period of time you write delay(time in ms). So very easy.  "blink w/o delay" is not as easy to implement (at least for me).

In the first instance I write to the servo using the millis timing method as I have used it in the past. It does not work. I have obviously missed something.

What I want to do is indicated by the three other servo processes. The code follows:

Code:
#include <Servo.h>
#include <Ping.h>

Ping ping = Ping(8,74,19);
Servo myservo;  // create servo object to control a servo

long blinkTimer2;
int pos = (0);    // variable to store the servo position
int outputPin = 12;
int outputPin2 = 13;
int outputPin3 = 11;


void setup()

{
Serial.begin(9600);  
myservo.attach(9);  // attaches the servo on pin 9 to the servo object
pinMode(outputPin, OUTPUT);
pinMode(outputPin2, OUTPUT);
pinMode(outputPin3, OUTPUT);
}

void loop()

{
  ping.fire();
  Serial.print("Microseconds: ");
  Serial.print(ping.microseconds());
  Serial.print(" | Inches ");
  Serial.print(ping.inches());
  //Serial.print(" | Centemeters: ");
  //Serial.print(ping.centemeters());
  Serial.println();
  
  
   {                                  
    myservo.write(0);  
    Serial.print(0);
    Serial.println(" ");
    digitalWrite(outputPin2, HIGH);
    blinkTimer2 = millis() + 1500;
    digitalWrite(outputPin2, LOW);
    blinkTimer2 = millis() + 35;                      
   }
  
    {                                
     myservo.write(90);              
     Serial.print(90);
     Serial.println(" ");
     digitalWrite(outputPin3, HIGH);
     delay(1000);
     digitalWrite(outputPin3, LOW);
     delay(35);                        
    }
 
     {                                
      myservo.write(180);              
      Serial.print(180);
      Serial.println(" ");
      digitalWrite(outputPin, HIGH);
      delay(1000);
      digitalWrite(outputPin, LOW);
      delay(35);
      }
  
  
       {                                
        myservo.write(90);              
        Serial.print(90);
        Serial.println(" ");
        digitalWrite(outputPin3, HIGH);
        delay(1000);
        digitalWrite(outputPin3, LOW);
        delay(35);                        
       }
  
  
  
}


13  Forum 2005-2010 (read only) / Syntax & Programs / Re: student C question on: January 08, 2010, 09:38:37 am
Thank you all very much!  smiley-grin

It drove me crazy for a while. It's these little things that get ya sometimes.

I can't tell you how thankful I am that you guys are out there for all of us. Teaching yourself can be difficult. Without you guys, maybe for me, impossible.

Thanks for the answer, and being there to make this form of education possible.
14  Forum 2005-2010 (read only) / Syntax & Programs / student C question on: January 08, 2010, 08:17:15 am
Good day friends!

As promised I have begun my studies in earnest. I have begun to study C and have had a great deal of fun learning. It is much easier to understand what I am doing with the Arduino now that I've gotten a little background. Enough blabber...

For all I can determine the operators +1 and ++ are interchangeable. Is that a correct assumption? I have not found an answer in two days of study. The code follows:

Code:
#include <stdio.h>

#define START 65
#define END 90

int main()

{
 long int humongous;
 char chuck;

 for(humongous=START;humongous<=END;humongous++)
 {
     chuck = (char)humongous;
     putchar(chuck);
 }
 putchar('\n');
 return(0);
}

As the code stands it prints the English alphabet to the screen (holly cow!) This is what it was intended to do (I hope). However, if you change the ++ after humongous to a +1 you get the letter A printed continuously. Can someone help me understand why?

Thanks in advance to all of you kind folks that come to my rescue!

Scott
15  Forum 2005-2010 (read only) / Syntax & Programs / Re: millis() to stop motor on: December 29, 2009, 09:21:33 am
First I am a newbie. Anything I say here needs to be taken with that in mind.

Next, it seems your problem is similar to one I(we) just solved and you and I are using the same driver (solarbotics h-bridge)

I had been using 'delay' to pause or time motor on and off. Though that worked well for these intial experiments stopping the program long enough for an action to complete was going to add problems down the line.

Anyhow, enough background. I was directed to investigate "finite state machines". Do a search in the playground. It has changed how I look at coding.

Please forgive me if I am out of place making suggestions so early in my education. Perhaps I've helped (that would be very cool), but either way I wish you luck.
Pages: [1] 2 3 4