Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Renewable Energy


Renewable Energy Discussion of Solar, Wind, Hydro and main stream renewable energy topics including RE projects.

Reply
 
Tools
Old 27th September 2009, 05:20 PM   #31
Default

Haven't looked at the menu code, but aren't the diodes backwards in the schematic. Ra6 wouldn't be able to tell which button is pushed, unless it's analog input with associated button resistors or'd together.

Last edited by nickelflippr; 27th September 2009 at 05:23 PM.
nickelflippr is offline  
Old 27th September 2009, 05:30 PM   #32
Default

Try changing the diodes for 10k resistors. Got to go to bed now but let me know how it goes.

Mike.
Pommie is offline  
Old 27th September 2009, 05:37 PM   #33
Default

ok sure will..
AtomSoft is offline  
Old 27th September 2009, 05:44 PM   #34
Default

Tried this and no good. I wish i understood your method heh

From what i can see... you are using a XOR to check the PORTB bits. I assume you are using this to check the current value and test it against a users press.

How do you know when a user presses a button. What happens when the user holds the button down then it will create a flag with the same bits to XOR and you will get no result.

I dont know lol can someone explain the way it works or supposed to in this case (my Proteus side)

Attached Thumbnails
A pic based Charge Controller-needbutt1.jpg  

Last edited by AtomSoft; 27th September 2009 at 05:44 PM.
AtomSoft is offline  
Old 27th September 2009, 05:47 PM   #35
Default

I have to go to bed now, 2:45AM here. We'll pick this up tomorrow. Thanks for your patience.

Mike.
Pommie is offline  
Old 27th September 2009, 05:50 PM   #36
Default

Ok no problem. Ill see ya tommorrow heh
AtomSoft is offline  
Old 28th September 2009, 12:40 AM   #37
Default

heh just though id post a AVI of a UART MENU i made as a test...

http://atomsofttech.info/code/UartMenu.avi

Its best to RIGHT CLICK the link and save the video then view it

Last edited by AtomSoft; 28th September 2009 at 12:43 AM.
AtomSoft is offline  
Old 28th September 2009, 04:19 AM   #38
Default

I must have been tired last night. Changing the resistors to 10k was silly, they should be 1k.

I see what you mean now about leaving A6 as output. I've changed the code and commented it.
Code:
#define KeyEn porta.6
#define KeyEnTris trisa.6
#define KeyTris trisb

#define KeyDelay 30
#define KeyRepeat 10

#define key_none    0
#define key_back    1
#define key_up      2
#define key_dw      3
#define key_enter   4

unsigned char keys=0,previous,edges,KeyCount;

char ReadKeyPad(){
char i;
    previous=keys;              //keep copy of previous state
    option_reg.7=0;             //WPUs on
    KeyTris|=0x3c;              //B2-B6 input
    KeyEnTris=0;                //A6 output
    KeyEn=0;                    //and low
    delay_us(10);               //see text below
    keys=(portb>>2)&0x0f;       //read keys
    keys^=0x0f;                 //invert them so 1=pressed
    KeyEnTris=1;                //switch en back to input
    KeyTris&=0xc3;              //switch b2-b6 back to output
    if(keys==0)                 //if no key pressed
        return(0);              //return zero

    //now do key repeat and delay stuff
    //keys xor previous gives us a 1 if a key has changed
    //ANDing this value with the new keys pressed gives
    //keys that were 0 last time and 1 now = new presses

    if(((keys^previous)&keys)==0){  //if no new presses
                                //must be repeating key
        if(--KeyCount!=0)       //decrement key count and
            return(0);          //return zero as time not up
        KeyCount=KeyRepeat;     //reset key timer
    }else{
                                //must be new key press
        KeyCount=KeyDelay;      //set initial delay  
        edges=((keys^previous)&keys);//see above
    }
    i=0;
    while((edges&(1<<i))==0){   //change bit pattern into 1 to 3
        i++;
    }
    return (++i);               //and return it
}
If it still doesn't work can you set a break point to see what is in keys when a key is pressed.

edit, maybe Proteus is taking pin capacitance into account. Try adding the line in red to see if it fixes it.

Mike.

Last edited by Pommie; 28th September 2009 at 04:24 AM.
Pommie is offline  
Old 28th September 2009, 10:59 AM   #39
Default

no luck. The lines are all high but getting a 0x00 in keys.

how about moving the resistors to the LCD lines instead of buttons?
AtomSoft is offline  
Old 28th September 2009, 11:10 AM   #40
Default

Yes it works with it on LCD lines!! nice menu dude! ill record it now
AtomSoft is offline  
Old 28th September 2009, 11:16 AM   #41
Default

RIGHT CLICK and save target or link as:

http://atomsofttech.info/code/Mike.avi
AtomSoft is offline  
Old 28th September 2009, 01:58 PM   #42
Default

Thanks Jason,

The video looks good. I may have to buy a copy of Proteus. It looks really useful.

I guess you can remove the resistors all together. However, on the actual hardware the diodes or 1K resistors are needed (in the original position) otherwise, when two buttons are pressed at the same time it shorts two of the LCD data lines. Not good.

Mike.
Pommie is offline  
Old 28th September 2009, 02:01 PM   #43
Default

Quote:
Originally Posted by nickelflippr View Post
Haven't looked at the menu code, but aren't the diodes backwards in the schematic. Ra6 wouldn't be able to tell which button is pushed, unless it's analog input with associated button resistors or'd together.
Sorry for ignoring you, only just noticed the post.

The way the keys are read is by pulling A6 low and reading the data pins therefore reading them all at once.

Mike.
Pommie is offline  
Old 28th September 2009, 02:06 PM   #44
Default

Mike quick fix for me would be to use RB0:RB4 for Buttons and RB5:RB7 for LCD.
i would just have to use diodes or resistor for RB6-7

or better yet use a Shift register with Latch 595 perhaps, since you wanted to save all INTx and ANx

Last edited by AtomSoft; 28th September 2009 at 02:10 PM.
AtomSoft is offline  
Old 28th September 2009, 02:15 PM   #45
Default

I did it the way it is to use the minimum number of pins and keep as much of the other hardware free. Don't know why it didn't work on the simulator.

Anyway, next step is to get some kinda boost converter working. Guess I should post a thread in the general section and see if one of the analogue guys can help.

Mike.
Pommie is offline  
Reply

Tags
based, charge, controller, pic

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Pic Based Servo Controller and Free Control Software! hvlabsdotcom Robotics Chat 12 27th December 2008 07:10 PM
PIC based PID controller Shohadawy Micro Controllers 1 24th September 2008 09:59 AM
Really Simple PIC Based IR (InfraRed) Controller deanbayley Electronic Projects Design/Ideas/Reviews 1 12th November 2007 03:00 PM
PIC based Intelligent Garden Light Controller dragonaga Electronic Projects Design/Ideas/Reviews 6 28th September 2005 10:28 AM
Project needed, Stepper motor controller PIC based lompa Electronic Projects Design/Ideas/Reviews 1 11th October 2004 07:57 PM



All times are GMT. The time now is 08:47 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker