Thread: help please?

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    14

    help please?

    im making an elevator for my HNC project but im useless at C programming, ive done some of the code and which way i want it to work, any help on functions or how to do this would be great.
    i want the elevator to be either an up elevator which only goes to the floors above the current, any floors below get added to a queue until a down elevator, and vice versa.

    Code:
    const int MAX = 5
    int data [MAX} = {0,1,2,3,4};
    
    
    // too many people in lift override stop motor and  sound alarm
    void Liftcontrol
    	if (weight = 1)
    	{
    		motor = 0;
    		alarm =1;
           }
    else
    {
    	Liftcontrol()
    	{
    		if(elevator = 1 //up elevator
    			{
    				if( input > current)
    					{ 
    					do
    					output to motor1 =1 for (input - current) seconds
    				       }
     				if(input< current)
    					{
    					do
    					ADD input to queue until down elevator
    				       }
    		       }
    		if (elevator = 0 //down elevator
    			{
    				if( input < current)
    					{ 
    					do
    					output to motor2 =1 for (current - input) seconds
    				       }
     				if(input > current)
    					{
    					do
    					ADD input to queue until up elevator
    				       } 
                        }
    	}

  2. #2
    Registered User
    Join Date
    Feb 2013
    Posts
    14
    as you can see i really have no idea haha so any help we would brilliant, the notes college gave me are a bubble sort programme, a 7 segment display , an averaging programme and to toggle an LED?

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Are you working with an embedded system, or a regular PC?

  4. #4
    Registered User
    Join Date
    Feb 2013
    Posts
    14
    im going to be using a 89s2051 controller if this is any help?

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > the notes college gave me are a bubble sort programme, a 7 segment display , an averaging programme and to toggle an LED?
    Have you studied these in detail?

    Have you tried to load them onto your micro-controller. Running the "toggle a LED" program is a really good idea if you haven't done so already. It will tell you a lot about the process of getting your code from your PC onto your hardware.

    So do you have a wired up circuit containing several switches, an electric motor and maybe some 7-segment displays to display the current floor?
    What about door sensors (open or closed), or sensors to tell you which floor the lift is at?

    Start collecting a number of simple routines together which achieve very specific steps, such as
    - start the motor winding up
    - start the motor winding down
    - stop the motor
    - display a number on the 7-seg display
    - using the 7-seg function, display a number corresponding to the selected lift call switch
    - using the 7-seg function, display a number corresponding to the selected lift door sensor
    - using the 7-seg function, display a number corresponding to the lift level sensor

    > im making an elevator for my HNC project but im useless at C programming
    How long have you got?
    First stop would be to go through C Tutorial - Learn C - Cprogramming.com, at least the "Introduction and Basic C Features" and some of "Pointers, Arrays and Strings" sections to at least familiarise yourself a little bit, and have a go at writing small bits of C code which are syntactically valid.

    To be honest, given the C you've posted so far, this is a really tough assignment.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Feb 2013
    Posts
    14
    Yeah I'm gonna be using switches for the inputs, led to display the current floor and a motor to simulate, no door or limit switches, it is pretty hard haha and it's due in a months time include the completed built rig, i haven't programmed anything yet just written some code as the college doesn't have that much available, I'll have a read through what you showed me and hopefully get to grasps with it this week haha

Popular pages Recent additions subscribe to a feed