Show Posts
Pages: [1] 2 3
1  Community / Exhibition / Gallery / Re: Arduino as a Pic Programmer! on: May 03, 2012, 08:38:00 am
I wrote a similar sketch for the PIC18F2550 ( a slight modification can adopt it to almost all pic18F2/4 family). the sketch and the instruction can be found over here:

https://sites.google.com/site/thehighspark/arduino-pic18f
2  Using Arduino / General Electronics / DC TO DC convertor with arduino on: February 20, 2012, 01:22:48 pm
Hey, I've tried to build a DC to DC convertor using the arduino, based on the following schematic:



According to Wikipedia


Strangely my circuit doesn't follow this equation.The output voltage when I changed the frequency of the PWM, The inductor or the LOAD resistor.While it should be changed by the duty cycle

Moreover, I've used the following simulator to simulate this circuit and it was working the same as my circuit on a breadboard

http://www.falstad.com/circuit/

What am I doing wrong?
3  Using Arduino / General Electronics / ULN2003 and piezo buzzer on: February 17, 2012, 08:54:27 am
Hey, I'm using an AT89S52 which has internal pull-up resistor on all its port(according to the datasheet).When I attempt to control LEDs attached to ULN2003 it work perfectly.however,when I connect a piezo buzzer it doesn't work unless I connect a pull up resistor (I used 10Kohm) to the input of the ULN2003.As far as I understand the ULN is the one which provides the current for the piezo buzzer, not the uC.

Basically, my question is why an external pull up resistor required just for the buzzer?
4  Using Arduino / General Electronics / What transistor should I use? on: January 29, 2012, 10:26:06 am
Hey, Ive been looking for a transistor which will be able of switching (on and off) a current up to 700mA @ 5V ,frequency of +-50hz with a duty cycle of 20% on time . I'm not sure what to use, MOSFET or general amplifier and what are the differences between them?

5  Using Arduino / General Electronics / A question about Crystal's caps & reset pin on: November 18, 2011, 06:55:54 am
Hey,

As you know crystals are always connected with two caps next to it.I was wondering why, but i couldn't find the answer anywhere.

Next, there are some chips that their reset pin should go high in order to reset the device,

The following reset button for "LOW active RESET" is selfexplanatory


(perfectly drawn circuit)

However I've seen that the same circuit used for "HIGH active RESET" with a small modification (the resistor and the cap exchanged their position).
basicly, my question is: How it differs from an pull down resistor?  

6  Using Arduino / Microcontrollers / Program 89s52 with an Arduino on: September 20, 2011, 11:18:36 am
Is it possible to program 89s52 with an Arduino as ISP programmer, In case it is possible:
Can it be done with the Arduno IDE or I should use other program to do it.

Thanks
7  Using Arduino / LEDs and Multiplexing / Re: Help with LED Cube Programming on: August 13, 2011, 10:34:38 am
you can change all the arrays to BYTEs rather than INT(unless you are using numbers that are bigger than 255)
8  Using Arduino / Project Guidance / Re: GUI for Serial Data on: August 11, 2011, 02:55:45 am
Processing is really easy language, you can use it to get data of the serial port and display it graphically. Arduino IDE is baced on it.
there is a great tutorial that explains how to do it:
9  Using Arduino / Programming Questions / Re: Intteruption and GOTO on: August 10, 2011, 12:57:07 pm
Thanks yo coding badly I've managed to finished my project  smiley-lol
there is a video

10  Using Arduino / Project Guidance / Re: iPhone + Arduino bi directional comm (newbie question) on: August 10, 2011, 06:35:48 am
You can also transfer data between the arduino and the iphone using the mic/earphones jack. but assume it will be difficult to decode the data that send to the iphone using the mic input.
11  Using Arduino / Programming Questions / Re: Intteruption and GOTO on: August 10, 2011, 05:19:05 am
Yes.  Save the animation variable to EEPROM, use the Watchdog to reset the processor, then load animation from EEPROM in setup
As a nice bonus, the selected animation is "sticky".
Sounds like a good idea, I will try it.

How do you compile for an Attiny? It doesn't seem to be in my list of boards. (If I knew I could experiment a bit).

I used Arduino as ISP with this core : http://code.google.com/p/arduino-tiny/

You could save quite a few bytes of flash if you used "memset" and "memcpy"

I've managed to make a bit lither, just 1982 bytes. I'm pretty sure there is a way to compress the following with memcpy but i'm not quite sure how:

Code:
  for(int i=0;i<4;i++)
  {
    bin[i][0] = bin[i+1][0];
    bin[i][1] = bin[i+1][1];
  }

and this part as well

Code:
  for(int i=0;i<6;i++)
  {
    bin[3][0] = ser[i][0];
    bin[3][1] = ser[i][1];

    bin[2][0] = ser[(i+1)%6][0];
    bin[2][1] = ser[(i+1)%6][1];

    bin[1][0] = ser[(i+2)%6][0];
    bin[1][1] = ser[(i+2)%6][1];

    bin[0][0] = ser[(i+3)%6][0];
    bin[0][1] = ser[(i+3)%6][1]; 

    bin_prosses(12);
  }
12  Using Arduino / Programming Questions / Re: Intteruption and GOTO on: August 10, 2011, 02:49:03 am
Thanks for replaying, as you have mentioned changing the stuck pointer is dangerous.
I don't really get why, In case I fully understand what is in my stuck and how it works, why not to manipulate it if it may save me few Bytes of memory? Is there a danger of physical damage to the chip?

Nick Gammon, this method is good, but not in my case unless how some how managed to compress the code much more (Which i assume is all most impossible)
13  Using Arduino / Programming Questions / Re: Intteruption and GOTO on: August 09, 2011, 12:56:49 pm
For which you should grateful.

 smiley-eek ?
14  Using Arduino / Programming Questions / Re: Intteruption and GOTO on: August 09, 2011, 11:29:08 am
Quote
as I said before, there are too many for loop and the animation are goes 2 level deep ( the first function prosess what should be displayed and the deeper function display it to the LEDs)
So, use the && !interrupted in each loop. You only need to make the change once.

The bin_prosess i bing executed almost every milliseconds so i thought: to put there an IF statement that will change the STOCK so the next RETURN will return it to LOOP:

something like this:

Code:

if ( there_was_an innteruption )
{
delete_last_stock_recored();
return;
}



EDIT:
I googled 'stack pointer arduino' but i coudn't find how to change the stack pointer
15  Using Arduino / Programming Questions / Re: Intteruption and GOTO on: August 09, 2011, 11:18:48 am
as I said before, there are too many for loop and the animation are goes 2 level deep ( the first function prosess what should be displayed and the deeper function display it to the LEDs)

there is the full coded:
('bin_prosses' send to LEDs the bin[4][2])


Code:

#define LATCHPIN 12 // st_cp ( pin 12 )
#define CLOCKPIN 11 // sh_cp (pin 11)
#define DATAPIN  13 // DS (pin 14)

byte sequance[8]={
  0,1,2,3,3,2,1,0};

byte bin[4][2] = {
  {
    B00000000,B00000000        }
  ,{
    B00000000,B00000000        }
  ,{
    B00000000,B00000000        }
  ,{
    B00000000,B00000000        }
};

byte big_cube[4][2] = {
  {
    B11111001,B10011111        }
  ,{
    B10010000,B00001001        }
  ,{
    B10010000,B00001001        }
  ,{
    B11111001,B10011111        }
};

byte small_cube[4][2] = {
  {
    B00000000,B00000000        }
  ,{
    B00000110,B01100000        }
  ,{
    B00000110,B01100000        }
  ,{
    B00000000,B00000000        }
};

byte wall[4] = {
  B10001000,B01000100,B00100010,B00010001};
byte wall2[2] = {
  B11110000,B00001111};

byte ser[6][2] = {
  {
    B10000100,B00100001          }
  ,{
    B01000100,B00100010          }
  ,{
    B00100010,B01000100          }
  ,{
    B00010010,B01001000          }
  ,{
    B00000011,B11000000          }
  ,{
    B00001100,B00110000          }
};

volatile byte animation=0;
byte seed = 12;


void setup() {

  //takes less memory
  DDRA = B00000011;
  DDRD = B00000111;
  DDRB = B00011100;



   /* //ecvivlent
   pinMode(4,INPUT); // interrupt
   
   pinMode(LATCHPIN, OUTPUT);
   pinMode(DATAPIN, OUTPUT); 
   pinMode(CLOCKPIN, OUTPUT);
   
   pinMode(0, OUTPUT);
   pinMode(1, OUTPUT);
   pinMode(2, OUTPUT);
   pinMode(3, OUTPUT);
   */

  attachInterrupt(0,interrupt,RISING);
 
 
}



void interrupt()
 {
 animation++;
 }


void loop() {

  //if( (millis()%240000)-((animation+1)*60000) > 60000 ) animation++;

  switch(animation)
  {
  case 0:
    rotate();
    break;
  case 1:
    rain();
    break;
  case 2:
    random_led();
    break;
  case 3:
    upndown();
    break;
  case 4:
    animation = 0;
    break;
  }


}

// Animations

void rain()
{
  for(int i=0;i<3;i++)
   bitSet(bin[3][rand()%2],rand()%8);


  bin_prosses(20);

  for(int i=0;i<4;i++)
  {
    bin[i][0] = bin[i+1][0];
    bin[i][1] = bin[i+1][1];
  }

  bin[3][0] = 0;
  bin[3][1] = 0;


}

void rotate()
{

  for(int i=0;i<6;i++)
  {
    bin[3][0] = ser[i][0];
    bin[3][1] = ser[i][1];

    bin[2][0] = ser[(i+1)%6][0];
    bin[2][1] = ser[(i+1)%6][1];

    bin[1][0] = ser[(i+2)%6][0];
    bin[1][1] = ser[(i+2)%6][1];

    bin[0][0] = ser[(i+3)%6][0];
    bin[0][1] = ser[(i+3)%6][1]; 

    bin_prosses(12);
  }



}

void random_led()
{
  bitSet(bin[rand()%4][rand()%2],rand()%8);
  bin_prosses(5);
  set_all(0);
  bin_prosses(5);
}


void upndown()
{

  for(byte j=0;j<3;j++)
  {
    for(byte i=0;i<8;i++)
    { 
      set_all(B00000000);
      bin[sequance[i]][0]= B11111111;
      bin[sequance[i]][1]= B11111111;         
      bin_prosses(8);
    }

  }

  for(byte j=0;j<3;j++)
  {
    for(byte i=0;i<8;i++)
    {
      set_all(wall[sequance[i]]);
      bin_prosses(8);
    }

  }

  for(byte j=0;j<3;j++)
  {
    for(byte i=0;i<8;i++)
    {
      set_all(B00000000);
      for(int z=0;z<4;z++)
        bin[z][(sequance[i]&2)>>1] = wall2[sequance[i]%2];
      bin_prosses(8);
    }

  }


  for(byte j=0;j<3;j++)
  {

    set_array(small_cube);
    bin_prosses(40);

    set_array(big_cube);
    bin_prosses(40);

  } 





}


/// Prossesing fucntions below

void bin_prosses(byte times)
{


  for(byte j=0;j<times;j++)
    for(byte i=0;i<4;i++)
    {


      PORTB = PORTB & B11110111; //digitalWrite(LATCHPIN, LOW);
      shiftOut(DATAPIN, CLOCKPIN, MSBFIRST, bin[i][0]);
      shiftOut(DATAPIN, CLOCKPIN, MSBFIRST, bin[i][1]);
      PORTB = PORTB | B00001000; //digitalWrite(LATCHPIN, HIGH);

      digitalWrite(i, HIGH);     

      delayMicroseconds(2000);

      digitalWrite(i, LOW);   


    } 


}

int rand() // random() is too big
{
  seed = ((seed*16476549 +millis())/16)%256;
  return seed;
}

void set_all(byte data)
{
  for(byte j=0;j<4;j++)
    for(byte i=0;i<2;i++) 
      bin[j][i]= data;
}

void set_array(byte array[4][2])
{
  for(byte i=0;i<4;i++)
    for(byte z=0;z<2;z++)
      bin[i][z] = array[i][z];
}





Pages: [1] 2 3