Page 1 of 1

SK40C + elevator program

PostPosted: Thu Dec 20, 2012 10:53 am
by jackie
can I straight plug supply 9V voltage to Vdd, MCLR pins and ground to ground pin?

anyone can help me with the coding?
i dunno y is it isn't working.


void main(void)
{
/////////////////////Main Program///////////////////////////////////

int time = 5000 ;
TRISB = 0xFF ;//define port B as input port
TRISC = 0xFF ;//define port C as input port
TRISD= 0xFF ;//define port D as output port
PORTD = 0;

if ( PORTB = 1 ) PORTD = 0b00000001 ; //push button1 on //motor go up
else if (PORTC = 0b00000001) //if limit lvl2 rch
if (PORTC = 0b00000100) //sensor rch grnd floor
PORTD=0b00000000 ; // motor stopped
else
PORTD = 0b00000010; //motor goes down
else
PORTD = 0b00000000; //stop motor
Vdelay_ms (time); //delay 5s
PORTD=0b00000010 ; //motor goes down

Re: SK40C + elevator program

PostPosted: Thu Dec 20, 2012 11:03 am
by zhenning
jackie WROTE:can I straight plug supply 9V voltage to Vdd, MCLR pins and ground to ground pin?


No. Its only 5V or 3.3V. 9V might just killed it.

jackie WROTE:if ( PORTB = 1 ) PORTD = 0b00000001 ; //push button1 on //motor go up
else if (PORTC = 0b00000001) //if limit lvl2 rch
if (PORTC = 0b00000100) //sensor rch grnd floor
PORTD=0b00000000 ; // motor stopped
else
PORTD = 0b00000010; //motor goes down
else
PORTD = 0b00000000; //stop motor
Vdelay_ms (time); //delay 5s
PORTD=0b00000010 ; //motor goes down


Do you know C? having one "=" is to assign the value to the PORT. It is not comparing. To compare you need: ==


For buttons, you need debouncing code that will clear the glitches due to the nature of the switch

Re: SK40C + elevator program

PostPosted: Thu Dec 20, 2012 7:35 pm
by robosang
Why you want to supply power to MCLR? and why 9V to VDD? Since you are using SK40C, directly supply that 9V to the DC jack input. Did you refer to the User's Manual before using it? I doubt it.

Re: SK40C + elevator program

PostPosted: Mon Dec 31, 2012 2:40 am
by kannan
jackie or robo i am doin a coding for elevator system as well cn u give me hand pls do borrow me ur full set coding having difficulties as i am not good in this subject still learning and my due date for the project is in 2 days time..
pls do help me fren :cry: