Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

control dc motor using keypad

Status
Not open for further replies.

alaalwi11

Member level 1
Joined
Nov 30, 2010
Messages
32
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Al khurtum-Sudan
Activity points
1,626
hi gays,
i want to control in dc motor and h bridge using keypad
if i enter 1 motor move forword
and if ienter 2 the motor go reseve
and press 3 from keypad motor break
i begining my project by control in leds using keypad

char keypadPort at PORTD;
unsigned char keyPress;
unsigned char keyValue;

void main() {
TRISB=0X00;
Keypad_Init();
keyPress = 0x00;
keyValue = 0x00;

do
keyPress = Keypad_Key_Click();
while (keyPress != 0);

switch(keyPress)
{
case 1: keyValue = 0x01; break;
case 2: keyValue = 0x02; break;
case 3: keyValue = 0x03; break;
case 4: keyValue = 0x04; break;
case 5: keyValue = 0x05; break;
case 6: keyValue = 0x06; break;
case 7: keyValue = 0x07; break;
case 8: keyValue = 0x08; break;
case 9: keyValue = 0x09; break;
case 10: keyValue = 0x0A; break;
case 11: keyValue = 0x00; break;
case 12: keyValue = 0x0C; break;
}

PORTB = keyValue;
}I am using MikroC for PIC IDE and the keypad library
 

alaalwi11

Member level 1
Joined
Nov 30, 2010
Messages
32
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Al khurtum-Sudan
Activity points
1,626
hi,
i go step in my project and i add the second stage witch i changing the leds by
H bridge and DC motor my objective is:
control in position of dc motor using internal sensor -potentiometer-10 k ohm
i want to connecting the 10 k variable resistance mechanically with motor shaft
so when i press key 1 motor start move right side
press key 2 motor move left side 2
press key 3 motor brake
press key 5 motor move and brake at 90 degree for example
but i have two problems
1- the simulation circut can not response for the potensiometer sensor -see attached file-
2- i do not know how divide the vatage come from sensor

void Keypad_Init(void);
char Keypad_Key_Click(void);
char Keypad_Key_Press(void);
unsigned int t;
unsigned short kp;

char keypadPort at PORTB;

void initMain(){
ADCON1 = 0x80; // Configure analog inputs and Vref
TRISA = 0xFF; // PORTA is input

ADCON0 = 0x00;
TRISB = 0xFF;
PORTB = 0x00;
TRISD= 0x00;
PORTD = 0x00;
}

void main() {
initMain();
Keypad_Init();


do {
kp = 0; // Reset key code variable
// Wait for key to be pressed and released
do
kp = Keypad_Key_Click(); // Store key code in kp variable
while (!kp);
// Prepare value for output, transform key to it's ASCII value

switch (kp) {

case 1: PORTD = 0b00000001; break; // 1
case 2: PORTD = 0b00000010; break; // 2
case 3: PORTD = 0b00000011; break; // 3
case 4: PORTD = 0b00000000; break; // A
case 5: {
t = Adc_Read(2); // get ADC value from 2nd channel
if(t >= 0 & t <= 205){
PORTD= 0b00000001;
}
else if (t >= 206 & t <= 410 ){
PORTC= 0b00100011;
} } break;
}
} while(1);
}




thank.........
 

Attachments


mac231991

Newbie level 3
Joined
Jul 4, 2011
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,296
are you finished with this project? can you help me? im planning to do the same project..
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top