Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronic Content > Electronic Theory


Electronic Theory Basic principles, ideas, concepts, laws, and formulas behind electronics.

Reply
 
Tools
Old 11th August 2009, 04:03 PM   #16
Default

Those are cool! but requires about 3 weeks wait in the mail heh.

Version 2 of this sounder would incorporate it. I will place a order tomorrow for the 3.3v version (LE33ABZ (1% version))

For now since its somewhat built and i can use a small RS(Radioshack) case i will not use it.

Its running perfect on 2 AA batteries tho. I might just use 3 AA alone and sleep mode.

Im off to print out some pages on the sleep mode of PIC micros (im using a 18F1320) at my job since we have a laser printer (fast) and boss says its ok for me to use it whenever i need.

Thats where i print my PCBs now Thanks guys!!!

P.S.

Can someone please post some tips on sleep mode and how to enable it and use it..
Also i have a new button on RA0 can i use this to wake up?
AtomSoft is offline  
Old 11th August 2009, 05:46 PM   #17
Default

Quote:
Originally Posted by AtomSoft View Post
cool.... How can i put a pic into sleep mode? Never tried.. also how do i wake it up?

Hi again,


Take a look at the data sheet for the PIC part you are using.
Look for the description of the 'sleep' instruction. That should
tell you most of what you need to know to use this. It's not
hard at all really.
I think you can have it wake on io change too, so you might be able
to set it up so that it doesnt do anything until a button is pressed,
then it wakes up and does whatever you want it to do (like play a
tone). This is nice because the kiddies cant forget to turn the
device off and run down the batteries as the PIC consumes very
little power in sleep mode.
If not you can wake it every half second or so and read the buttons
with the same power savings.
MrAl is offline  
Old 11th August 2009, 09:51 PM   #18
Default

ok cool i printed the stuff out and ill try it soon it looks too easy lol
AtomSoft is offline  
Old 12th August 2009, 01:30 AM   #19
Default

heh here we go:

Code:
#include <p18Cxxx.h>
#include <delays.h>
#pragma config WDT = OFF, LVP = OFF, OSC = INTIO2

#define button1 PORTAbits.RA3
#define button2 PORTBbits.RB2
#define button3 PORTBbits.RB3
#define button4 PORTBbits.RB4
#define button5 PORTBbits.RB5

#define WakeMe PORTBbits.RB0


char pos;
int time;
void PlayTone(char num);
void high_ISR (void) ;
void high_interrupt (void);
void NightTime(void);



#pragma code high_vector = 0x08
void high_interrupt (void){
_asm goto high_ISR _endasm
}
#pragma code

#pragma interrupt high_ISR
void high_ISR (void) {
    INTCONbits.INT0IF = 0;
    INTCONbits.RBIF = 0;
    LATAbits.LATA0 = 1;    
}

void main(void){
 int k,j,i;
    OSCCON = 0x72;              //8MHz clock
    while(!OSCCONbits.IOFS);    //Wait for OSC to become stable

    pos = 0;

    ADCON1 = 0xFF;
    TRISB = 0xFF;
    TRISA = 0x00;

    TRISBbits.TRISB1 = 0;
    TRISAbits.TRISA3 = 1;

    LATBbits.LATB1 = 0;

    INTCON  = 0b10010000;
    INTCON2 = 0b11110000;
    INTCON3 = 0x00;
    RCON    = 0b10000000;

    LATAbits.LATA0 = 1;
	while(1){
        if (button1)
            PlayTone(0);
        else if (button2)
            PlayTone(1);
        else if (button3)
            PlayTone(2);
        else if (button4)
            PlayTone(3);
        else if (button5)
            PlayTone(4);

        Delay10KTCYx(50);

        time++;
        if(time == 20){
            NightTime();
        }
	}

}
void NightTime(void){
    LATAbits.LATA0 = 0;         //Turn off LED
    OSCCONbits.IDLEN = 0;       //Clear he IDLEN and SCS1:SCS0
    OSCCONbits.SCS1 = 0;
    OSCCONbits.SCS0 = 0;
    Sleep();                    //Call Sleep instruction
}

void PlayTone(char num){
int k,j,i;
int len;
time = 0;
    switch (num){
        case 0:
            len = 100;
            break;
        case 1:
            len = 150;
            break;
        case 2:
            len = 200;
            break;
        case 3:
            len = 250;
            break;
        case 4:
            len = 0;
            break;
    }
    if(!len) goto skipit;

    for(k=80;k>0;k--){
        LATBbits.LATB1 = 1;
        for (i=len; i>0; i--);
        LATBbits.LATB1 = 0;
        for (i=len; i>0; i--);
    }
    goto doneit;
skipit:
if(pos){
        for(k=0;k<30;k+=1){
            for(j=0;j<70;j++){
                LATBbits.LATB1 = 1;
                for (i=k; i; i--);
                LATBbits.LATB1 = 0;
                for (i=k; i; i--);
            }
        }
        pos = 0;
} else {
        for(k=30;k>0;k-=1){
            for(j=0;j<70;j++){
                LATBbits.LATB1 = 1;
                for (i=k; i; i--);
                LATBbits.LATB1 = 0;
                for (i=k; i; i--);
            }
        }
        pos = 1;
}
doneit:
    Nop();
}
AtomSoft is offline  
Old 12th August 2009, 01:50 AM   #20
Default

I changed it to turn off in 15 seconds since there is a 250ms delay for each time it loops i went and chaged time to equal 15 * 4(250ms delays) = 60
AtomSoft is offline  
Old 12th August 2009, 02:14 AM   #21
Default

Quote:
Originally Posted by AtomSoft View Post
I might just take 2-3 AA batteries .. rechargable with a nice 2500mAH.. which would mean this would last about 125 hours on 1 full charge.Thats about 1 charge a month...
If you decide to go the NiMH rechargable route, go for the ones with a low self discharge. Panasonic calls it R2 technology. They have a lower capacity than regular NiMHs, but when used in low drain applications like yours, will last much longer.
__________________
Inside every little problem, is a big problem trying to get out.
kchriste is offline  
Old 12th August 2009, 04:45 AM   #22
Default

I have a LED using about 7-10ma when on (run mode) and my pic is taking about the same i suppose in run mode. So im using about 20mA of current + buzzer when in use.

Now in sleep mode im using almost no current so i suppose it will last a mighty long time while sleeping I will look into those batteries thanks.
AtomSoft is offline  
Old 12th August 2009, 08:11 PM   #23
Default

Hi again,


I am happy to hear you got the sleep mode working. I am always amazed
at how little power the PIC chips can use when powered down and how
useful this feature can be with todays battery operated devices.

I was using a wireless thermometer as a refrigerator monitor that used three batteries
about every two months. I got tired of changing the batteries, so with a $2
PIC chip and a cheap thermistor and a few tiny resistors and an LED i made a
monitor myself, and it powers down for 3 seconds at a time, waking only to
take a measurement and yell if something is wrong (temperature too high).
Now the predicted life of the batteries is about 2 years. Quite a difference :-)

Last edited by MrAl; 12th August 2009 at 08:12 PM.
MrAl is offline  
Old 12th August 2009, 09:25 PM   #24
Default

Nice work!

Smart thing to use batteries. Some might tap off the frig. itself. But wounder why it wont scream when the temp is high if power gets cut you cant take temp or warn user.

With batteries. Its on when it has to be and working with no external power...

I feel like making a wireless sensor now lol
AtomSoft is offline  
Old 13th August 2009, 01:18 AM   #25
Default

hey guys more fun for my son lol i found a older toy ... its a green bow and arrow thing plastic. Without the bow part. It kind looks like a shotgun. But green lol

I might mod it.... I made my buzzer make a cool laser shooting sound and i want to through it in it.

With a nice RBG LED for when he presses the trigger it hits the button and plays the laser sound and flashes the led cool colors...

here is the sound part i got so far...(also includes the sleep code too!

Code:
#include <p18Cxxx.h>
#include <delays.h>
#pragma config WDT = OFF, LVP = OFF, OSC = INTIO2

#define button1 PORTBbits.RB0

#define MainButton PORTBbits.RB0
#define MainButtonT TRISBbits.TRISB0
#define MySec 3

char pos;
unsigned long time;


void ShootLaser(void);
void high_ISR (void) ;
void high_interrupt (void);
void NightTime(void);



#pragma code high_vector = 0x08
void high_interrupt (void){
_asm goto high_ISR _endasm
}
#pragma code

#pragma interrupt high_ISR
void high_ISR (void) {
    INTCONbits.INT0IF = 0;
    INTCONbits.RBIF = 0;
    LATAbits.LATA0 = 1;
    ShootLaser();    
}

void main(void){
 int k,j,i;
    OSCCON = 0x72;              //8MHz clock
    while(!OSCCONbits.IOFS);    //Wait for OSC to become stable

    pos = 0;

    ADCON1 = 0xFF;
    TRISB = 0x00;
    TRISA = 0x00;

    MainButtonT = 1;


    INTCON  = 0b11010000;
    INTCON2 = 0b11110000;
    INTCON3 = 0x00;
    RCON    = 0b10000000;

    time = 0;
	while(1){
        time++;
        if(time == (MySec * 200000)){     //x seconds @ 8 MHz
            NightTime();
        }
	}

}
void NightTime(void){
    LATAbits.LATA0 = 0;         //Turn off LED
    OSCCONbits.IDLEN = 0;       //Clear he IDLEN and SCS1:SCS0
    OSCCONbits.SCS1 = 0;
    OSCCONbits.SCS0 = 0;
    Sleep();                    //Call Sleep instruction
}

void ShootLaser(void){
 int k,j,i;
        for(k=0;k<80;k+=1){
            for(j=0;j<5;j++){
                LATBbits.LATB1 = 1;
                for (i=k; i; i--);
                LATBbits.LATB1 = 0;
                for (i=k; i; i--);
            }
        }

time = 0;
}
AtomSoft is offline  
Old 14th August 2009, 02:40 AM   #26
Default

Hi again,


Just wondering, did you measure the chip current while it is in the sleep mode?
Just to make sure it really went to sleep...i guess you read up on all this by
now though anyway.
MrAl is offline  
Old 14th August 2009, 02:42 AM   #27
Default

heh never really checked it. Will do! thanks
AtomSoft is offline  
Old 15th August 2009, 07:41 PM   #28
Default

hey this is the outcome of my latest toy mod lol i find it cool! It was just a normal plastic gun nothing electronic inside. (not anymore)

Toy Gun Mod
AtomSoft is offline  
Old 16th August 2009, 10:54 AM   #29
Default

Hello Jason,
Here is a simple formula to use for finding the V-junction between 2 resistors

V-junc = V x resistor B / total resistance of A & B

where resistor A is connected to V+ and B is connected to ground.

I found this formula in an electronics book.

Cheers Bryan
__________________
" The only way to avoid human error is to avoid the use of humans"
bryan1 is online now  
Reply

Tags
divider, voltage

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Voltage divider Electronics4you General Electronics Chat 15 28th October 2009 06:23 PM
voltage divider for oscilloscope. fugrammer General Electronics Chat 3 13th November 2008 11:58 AM
Voltage Divider Question. shaneshane1 General Electronics Chat 9 13th May 2008 03:47 AM
voltage divider samtheboxer Electronic Projects Design/Ideas/Reviews 3 25th July 2007 02:19 PM
Voltage divider raphaelriv General Electronics Chat 11 26th July 2006 09:13 PM



All times are GMT. The time now is 04:07 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker