SK40C + elevator program

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

SK40C + elevator program

Postby jackie » Thu Dec 20, 2012 10:53 am

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
jackie
Freshie
 
Posts: 5
Joined: Fri Nov 30, 2012 9:18 am

Re: SK40C + elevator program

Postby zhenning » Thu Dec 20, 2012 11:03 am

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
zhenning
Enthusiast
 
Posts: 351
Joined: Thu Dec 30, 2010 12:32 am

Re: SK40C + elevator program

Postby robosang » Thu Dec 20, 2012 7:35 pm

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.
robosang
Expert
 
Posts: 1239
Joined: Wed Jun 10, 2009 5:37 pm

Re: SK40C + elevator program

Postby kannan » Mon Dec 31, 2012 2:40 am

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:
kannan
Fledgling
 
Posts: 1
Joined: Mon Dec 31, 2012 2:35 am


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 2 guests

cron