Show Posts
Pages: [1] 2 3 ... 12
1  General Category / General Discussion / Re: PCB diy on: February 05, 2011, 01:11:06 am
I highly recommend a perfboard like this: a circuit writer pen: It works great as long as you let the ink "cure" under a lightbulb for 20 min. No quicker way to prototype IMO
2  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Adding Streaming library to the Arduino core on: June 16, 2009, 06:41:57 pm
I know its nice to have it as default but it doesnt seem like that big a deal to insert
template<class T> inline Print &operator <<(Print &obj, T arg) { obj.print(arg); return obj; }
3  Forum 2005-2010 (read only) / Syntax & Programs / Re: Wierd math operations, am I just sleepy? on: August 07, 2009, 02:18:52 pm
thanks that did it. for some reason I thought that only the variable holding the end result of the math needed to be big enough, not every variable being multiplied. i think im getting rusty
4  Forum 2005-2010 (read only) / Syntax & Programs / Wierd math operations, am I just sleepy? on: August 07, 2009, 02:30:15 am
Alright so this problem has been bugging me for most of the night tho I just realized what exactly it was. Basically, multiplying a number by itself or any other number is not working. Take a look at the output Im getting
long yaw, pitch, roll;  //three axes
int joy_x_axis, joy_y_axis, accel_x_axis, accel_y_axis, accel_z_axis;
//in the loop
and Im getting the output
733      532      630      13001            -27971            -3260
736      533      633      17408            -18710            -928
736      533      633      17408            -18710            -928
733      532      632      13001            -25447            -3260

if you take a calculator you will see that 733^2=537289, 733^2+532^2+632^2=1219737, and 733*532=389956.
Why isnt anything coming out right? Nothing should have floating point problems. Im sure this is something Ill hit myself in the morning but for now its driving me mad. Please help!

Yes this is all from a nunchuck example.
5  Forum 2005-2010 (read only) / Syntax & Programs / Re: Need help on atmega32 for senior project asap on: August 04, 2009, 10:35:03 pm
yea, thanks madworm, he's gonna change that and test it tomorrow. would that cause it to perform as described or just erratically in general? Reading through this has made me see how much I like arduino IDE and also how much I am missing by using it-both good and bad
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: Need help on atmega32 for senior project asap on: August 04, 2009, 08:05:11 pm
The program seems to be not triggering the yellow led while it detects something (value lower than 230) but rather after it has detected something and is now going back above 230. It is supposed to trigger the yellow led and piezo after .5s of "seeing" less than 230 on the adc and trigger a red led and vib motor after 1.5s. It seems like the part in the first do while(state==1) loop is the problem. Is something flip flopped?

Also, Ive already said to change the interrupt variable to a volatile and am going to try expanding to the full adc value instead of the most significant 8 bits
7  Forum 2005-2010 (read only) / Syntax & Programs / Need help on atmega32 for senior project asap on: August 04, 2009, 04:09:11 pm
Sorry for posting something for a non-atmega 168 here but this is the forum I most frequent. I have a friend who is using an atmega 32 for his electrical engineering senior project. He is having some trouble with his code so I figured I'd ask here for any obvious mistakes.

The code is meant to light one of three leds and/or sound a piezo and activate a vib motor depending on the value of an analog sensor on port A0 and how long it has been below a threshold voltage(greater than .5s, greater than 1.5s). Also, no external crystal seems to have been used based on the schematic he sent me. Any help at all would be appreciated.

Here's the code:

#define GREEN  PORTB.0        // Output port designations
#define YELLOW PORTB.1
#define RED    PORTB.2
#define BUZZER    PORTB.3
#define MOTOR  PORTB.4

#define START    PINC.0        // Input pin designations
#define RESET  PINC.1

unsigned char buzzer_on;    // Declaration of variables
unsigned char adc_data = 0xff;

// ADC interrupt service routine      
interrupt [ADC_INT] void adc_isr(void)              
// Read the 8 most significant bits
// of the AD conversion result
ADCSRA=0xDE;   //start new conversion

interrupt [TIM0_OVF ] void ISR_TIMER0 (void)
    TCNT0 = 241;  //init count
    if(buzzer_on!=0)     //if buzzer on star tbuzzer at 1khz frec
        BUZZER = ~BUZZER;
void main (void)
   int i;  
// Declaration of variables
   char reset,state;

// Clear all ports
// Clear all memory

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
// Analog Comparator Output: Off

// ADC initialization
// ADC Clock frequency: 125.000 kHz
// ADC Voltage Reference: AVCC pin
// Only the 8 most significant bits of
// the AD conversion result are used

   DDRB = 0x1F; //outpus// Sets ports to output
   DDRC = 0x00; //inputs// Sets pin inputs

       /***init Timer0***/
    TCCR0 = 0x04;  //prescaler  256
    TCNT0 = 241;  //init count
    TIMSK |= 0x01; //unmask timer 0 overflow interrupt
   SREG |= 0x80;

   PORTB = 0x00;
   reset = 0;

      YELLOW = RED = buzzer_on = MOTOR = 0;  
// Sets all to 0 (Green is go!)
      GREEN = 1;
      state = 0;

         while(adc_data > 230);    //wait eye to lose if not green led on
         delay_ms(110);        //test if is not a tab

         if(adc_data > 230)  //in eye still closed  go to green
            state = 1;
            state = 0;

    }while(state == 0);
// Eye closes, interrupts green

      GREEN = 0;        //gren led off
      YELLOW = buzzer_on = 1;  //buzzer on
      reset = 0;
           while(!RESET); //wait reset
           reset = 1;    //indicate has been a reset

      }while(!reset && i <100);  
// reset routine

     if(reset != 1 )  //if reset don't wait
         YELLOW = 0;
         RED = MOTOR = 1;

         while(RESET);     //wait reset
8  Forum 2005-2010 (read only) / Syntax & Programs / Re: 'Hard' Serial Interrupts? on: June 15, 2009, 10:45:35 pm
aside from checking Serial.available() every so often, you could connect the rx pin to an interrupt pin with a resistor and just use a basic interrupt. Check the sleep example to see what i mean:
I hope thats what you meant
9  Forum 2005-2010 (read only) / Syntax & Programs / Re: Decoding an IR remote on: May 04, 2009, 12:08:40 pm
^this code works great as a starting point
10  Forum 2005-2010 (read only) / Syntax & Programs / Re: First Library; works, but error with use on: April 06, 2009, 09:33:38 pm
make sure you put #include "WProgram.h" in the header file as well as the cpp OR at the beginning of each sketch that includes the new lib. The tutorial is incorrect as far as I can tell. That fixed my problem (which i believe was the same one)
11  Forum 2005-2010 (read only) / Syntax & Programs / Re: Problem with first library on: April 05, 2009, 12:31:01 am
nevermind, fixed both problems with help of a more code savvy friend. #defines needed to be in header, not .cpp. same with #include "WProgram.h"
12  Forum 2005-2010 (read only) / Syntax & Programs / Problem with first library on: April 04, 2009, 04:12:50 pm
Alright so i have been having a few problems with my first library. It is entitled Isobot and emulates IR codes through an IR led. My first problem is that it wont compile without putting #include<WProgram.h> into each sketch even tho #include "WProgram.h" is in the .cpp part of my library like the lib tutorial said to do. It seems to be a common problem but is it because I didnt write the library right or just a quirk i should get used to?

Second, the biggest reason I wrote this library for was to clean up my code and make it less cumbersome to modify. The core of each code/the library is a #defined list of an unsigned longs which represents each button code. I wanted to just be able to say Isobot.buttonwrite(rpunch) and the code translate that rpunch means the unsigned long which is #define rpunch 988160 without having to list 152 #defines at the beginning of each sketch. Any help?
13  Forum 2005-2010 (read only) / Syntax & Programs / Question about tabs on: March 24, 2009, 04:59:42 pm
I have a question about how tabs work in the arduino ide. I am trying to clean up my main code by moving close to 200 lines of #defines and some longwinded functions to another tab. #defines on the second tab are not seen in the first (main) tab upon compiling resulting in an error. Do #defines have to be at the top of the main tab? Anything else to note about tabs? It is my understanding that multiple tabs are just copied into the main one upon compile time. Is this correct?
14  Forum 2005-2010 (read only) / Syntax & Programs / Re: Problem with Binary Array to Integer conversion on: February 14, 2009, 01:11:43 pm
well that pretty much answers it. thanks a lot for your help. now i know firsthand the dangers of floating point math
15  Forum 2005-2010 (read only) / Syntax & Programs / Re: Problem with Binary Array to Integer conversion on: February 14, 2009, 11:40:32 am
i created my own power2 function and that works perfectly. it shouldnt be the holding class thats the problem becayse unsigned long should be overkill for 22 bits. my power2 function gives the correct output which is :
0  3
0  2
2  1
3  0

0 17
65536 16
98304 15
98304 14
106496 13
110592 12
110592 11
111616 10
112128 9
112384 8
112384 7
112384 6
112384 5
112384 4
112384 3
112384 2
112386 1
112387 0
which is what it should be

if you compare them, the pow()'s are off by one in each the 2^16, 2^14, 2^13, and 2^12.
Pages: [1] 2 3 ... 12