Show Posts
Pages: 1 ... 3 4 [5]
61  Forum 2005-2010 (read only) / Development / Boarduino question on: December 06, 2007, 03:34:56 pm
I posted this on the boarduino forum but no answer yet...
--------------------------------------------------------------------------------
 
I just received a boarduino so I attempted to load some code using the arduino tools and I received the following upload error:

======================
problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51
======================

With the boarduino USB cable, I have to select Com7 (which is the only new com port that is displayed when I plug the boarduino in..)

I also have an arduino diecemela which I am able to upload this code to but this is using a regular USB cable and I select Com7...

Do I have something set up wrong or need to load some other driver?

any ideas of what i might try next?

 Thanks
62  Forum 2005-2010 (read only) / Interfacing / Arduino base cable scan tester on: March 18, 2010, 07:57:48 am
I am considering creating an arduino based cable scan tester that can test up to 100 lines by first learning a good cable
and then testing subsequent cables. This will require sending data patterns across all 100 lines and reading them
back at the other end of the cable.

I am not sure what the best way to read and write up to 100 lines and could use some recommendations of what
parts external to the arduino would be best  to use.

Can anyone suggest the best way (with the least amount of parts) to be able to read & write to 100 lines with an arduino?

thank you
63  Forum 2005-2010 (read only) / Interfacing / Re: Question about servos on: February 24, 2009, 03:52:21 am
very, very subtle...  Servo::refresh();

Good eye! I didn't even see that  I had is as a small case "s"....

Thanks Digger450 & mem, I appreciate the help!
64  Forum 2005-2010 (read only) / Interfacing / Re: Question about servos on: February 23, 2009, 07:44:34 pm
Ok, I got a chance to try this and it will not compile clean due to an error stating that "servo is not declared..."
I am using the same servo.h file as before and it is choking on the "servo::refresh();"  line...

Here is the error that I received:
Quote
In function 'void flap(int, int)':
error: 'servo' has not been declared.


I added a few items to the code but other than that it is pretty much as you sent it.

Also, the servo.h file is stored in the folder c:\aduino-0010\hardware\libraries\servo as it was with my original bad code...

Here is the code:
Code:
#include <Servo.h>
#include <Wire.h>
#include <string.h>
#include <stdio.h>
#define Button   12      // action button is connected to d12
#define yada     10      // yadayadayada is connected to d10

Servo servo1;
Servo servo2;

void setup() {
  
 servo1.attach(14); //analog pin 0
 servo1.setMaximumPulse(2000);
 servo1.setMinimumPulse(700);
 servo2.attach(15); //analog pin 1
 pinMode(Button, INPUT);  // sets the digital pin 12 as input
 pinMode(yada, OUTPUT);         // sets the digital pin 10 as output
 digitalWrite(yada, HIGH);      // turns the yadayadayada off
 
} void flap(int nbrOfTimes, int flapRate){
  // routine cycles the servos back and forth
  
  while( nbrOfTimes--){
     for(int i=0; i < 180; i+= flapRate){
   servo1.write(i);
   servo2.write(i);
   servo::refresh();
   delay(20);    
     }  
 for(int i=180; i > 0; i -= flapRate){
   servo1.write(i);
   servo2.write(i);
   servo::refresh();
   delay(20);    
     }  
  }  
}void loop() {
   if (digitalRead(Button) == HIGH) {
      digitalWrite(yada, LOW);      // turns the yadayadayada on
      delay(100);
      digitalWrite(yada, HIGH);      // turns the yadayadayada off
      flap(5,15); // flap 5 times at a fast rate
   }
}  

What am I doing wrong?

thanks!




65  Forum 2005-2010 (read only) / Interfacing / Re: Question about servos on: February 23, 2009, 09:40:53 am
thanks mem-

I will give it a try when I get home tonight!
66  Forum 2005-2010 (read only) / Interfacing / Question about servos on: February 23, 2009, 07:30:33 am
I am new to servos and need some help interfacing an arduino to one...

I have a hitec hs-322hd of which I have not been able to find much useful information to program this device online, so bear with me.

I am building a simple animatronic chicken and I want the wings to flap up and down. I have the framework all figured out but need to know how to program the boarduino to cycle the servo from one extreme to the other 5 times.

I hooked up the servo to the boarduino and found that I can cycle it from one end to the other when a button is pressed but when I change from one extreme to the other, the servo only moves a small amount so I set this up in a loop to repeat the write a number of times to get to the other end of the servo travel... Also, I found that the two values that move the servo from one end to the other are 0 and 180...

Here is my code...

Quote
#include <Servo.h>
#include <Wire.h>
#include <string.h>
#include <stdio.h>
#define Button   13       // action button is connected to d13

Servo servo1; Servo servo2;

void setup() {

  pinMode(1,OUTPUT);
  servo1.attach(14); //analog pin 0
  servo1.setMaximumPulse(2000);
  servo1.setMinimumPulse(700);

  servo2.attach(15); //analog pin 1
  pinMode(Button, INPUT);            // sets the digital pin 13 as input
}

void loop() {

  static int v = 0;
  int j, k;
  int Abtn = 0;           // value read from Adam button
  int run =1;                // value to keep loop running
  int RS=0;               // value read from runstop switch
  
//      servo1.write(v);
  while (run == 1){
    Abtn = digitalRead(Button);    // get the current status of the button  
    if (Abtn == HIGH) {

        for (k = 0; k < 5; k++) {        
         if (v == 180)
         {
            v = 0;
         }
         else
         {
            v = 180;
         }
         for (j = 1; j < 13; j++) {
            servo1.write(v);
            delay (80);
           Servo::refresh();
         }
       }
    }
  }
  
}

There must be a better way to do this...

how can I improve this?

Thanks
67  Forum 2005-2010 (read only) / Interfacing / Re: Creating sine waves with an Arduino on: September 07, 2008, 08:41:30 am
If I also wanted to have a variable frequency ttl level square wave output, couldn't I just
turn one of the output lines on and off and change the frequency & duty cycle
by how often that I change either of these states on that line?

I suspect that might be easy to do with a timer to control the timing of this?
68  Forum 2005-2010 (read only) / Interfacing / Re: Creating sine waves with an Arduino on: September 05, 2008, 08:37:39 am
Quote
Quote
Would I create a PWM output with a 50% duty cycle and determine the  
frequency by how often I turn the PWM output on and off?

No the PWM duty cycle is set by the value in the look up table. This in effect sets an analogue level after the PWM has been passed through a filter. At the next sample time you fetch the next entry in the table and set the PWM duty cycle with that.
Think of the PWM duty cycle as being an analogue output (which it is).
So set the sample time at your basic rate say every 100uS. This will give you a maximum frequency of 5KHz.
Then at each sample time you increment the pointer into the lookup table by some value. This value determines the final frequency. As you only have a look up table of 32 entries you only need 5 bits to address this. Therefore use the top 5 bits of your pointer to actually address the look up table and output (set the duty cycle) the value.
For a second frequency output use a different pointer a different increment, different PWM output but the same look up table.

Thanks Grumpy Mike -

This is great information!

I will read up on how to do this.
69  Forum 2005-2010 (read only) / Interfacing / Re: Creating sine waves with an Arduino on: September 05, 2008, 05:09:05 am
Thanks Grumpy Mike.

Not sure if  I understand you correctly, so your patience ia appreciated...

Would I create a PWM output with a 50% duty cycle and determine the
frequency by how often I turn the PWM output on and off?

thanks
70  Forum 2005-2010 (read only) / Interfacing / Re: Creating sine waves with an Arduino on: September 04, 2008, 10:53:03 am
I like Grumpy Mike's suggestion to use a ramp table and output to the PWM outputs.

Can the Arduino produce more than one of these frequencies at one time?

Looking at the link that BroHogan mentions in his post, the example there (as shown below) uses a table and
outputs this to the Port D lines which are connected to a DAC. Also it appears that the frequency is based upon
a value placed in the timer TCNT2.

 
Quote
/*
  Copyright 2007 Richard Cappels used with his permission
  www.projects.cappels.org
  This assumes an R/2R DAC (or other DAC) connected to PORTD, and
  Arduino 16mhz clock
  The frequency measured at the output of the DAC is 1.007 kHz.
  ported to arduino by hotcarrier
  output to pd7-pd2 with 6 bits- needs high order pd7 to work
  correctly
  */
 
 #include <avr/interrupt.h>
 #include <stdlib.h>
 
 char sinetable [32];
 int  i ;
 
 void ioinit (void)
 {
   //Initialize output ports
   PORTD = B11111111;
   DDRD  = B11111111;
 
 }
 
 void timer_setup(){
   TCCR2A = 0;
   TCNT2=455;    //455 outputs 1.007khz
   TCCR2B = B00000010;
   //Timer2 Overflow Interrupt Enable
   TIMSK2 = 1<<TOIE2;
 }
 void setup(){            
 
   ioinit();
   arraysetup();
   cli();
   timer_setup();
   i = 0;
   sei();
 
}
 
 
 ISR(TIMER2_OVF_vect) {
 
   PORTD=(sinetable[i++]);
   TCNT2=455;
   if(i==32){
     i=0;
   }
 
 }
 void arraysetup(void){
   sinetable[0]=127;  // Put 32 step 8 bit sine table into array.
   sinetable[1]=152;
   sinetable[2]=176;
   sinetable[3]=198;
   sinetable[4]=217;
   sinetable[5]=233;
   sinetable[6]=245;
   sinetable[7]=252;
   sinetable[8]=254;
   sinetable[9]=252;
   sinetable[10]=245;
   sinetable[11]=233;
   sinetable[12]=217;
   sinetable[13]=198;
   sinetable[14]=176;
   sinetable[15]=152;
   sinetable[16]=128;
   sinetable[17]=103;
   sinetable[18]=79;
   sinetable[19]=57;
   sinetable[20]=38;
   sinetable[21]=22;
   sinetable[22]=10;
   sinetable[23]=3;
   sinetable[24]=0;
   sinetable[25]=3;
   sinetable[26]=10;
   sinetable[27]=22;
   sinetable[28]=38;
   sinetable[29]=57;
   sinetable[30]=79;
   sinetable[31]=103;
 }
void loop()
 {
 
   while (1)
   {
 
   }
 
}


Is there more than one timer available where I could potenitally send out more than one frequency onto seperate PWM outputs?

Where can I learn more on how to do this?

thanks

71  Forum 2005-2010 (read only) / Interfacing / Re: Creating sine waves with an Arduino on: September 02, 2008, 09:10:47 am
Ultimately, I would like to be able to have two variable frequencies under 4 kHz
but to start,  I would like to be able to rpocude two sinewaves in the 100 Hz to 500 Hz range
with some pretty good accuracy ( +1 Hz)

Is this doable with an Arduino ?
72  Forum 2005-2010 (read only) / Interfacing / Re: Creating sine waves with an Arduino on: September 01, 2008, 07:59:41 pm
Thanks for the ideas guys!

I will have to try the 1kHz code and play around with how to change this to the frequencies that I am interested in creating.

best regards!
73  Forum 2005-2010 (read only) / Interfacing / Creating sine waves with an Arduino on: September 01, 2008, 01:42:29 pm
Has anyone successfully interfaced an Arduino to a DAC or any other circuitry to create sine waves?

I have an application where I would like to produce two sine waves and was looking for suggestions and ideas of how to accomplish this with an arduino.

thanks
74  Forum 2005-2010 (read only) / Frequently-Asked Questions / Not declared in this scope? on: December 21, 2008, 04:28:47 am
I have the following code and I am getting
the following message when I compile:


Quote
In Function 'void loop()':
error: 'If' was not declared in this scope

Here's my code:
Quote
#include <Wire.h>
#include <string.h>
#include <stdio.h>

int RS = 0;

void loop ()
{
     If (RS < 127)  RS = 0;
}
--------------------
What am I doing wrong?

thanks
Pages: 1 ... 3 4 [5]