Elevator_sytem

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Hi All

I need quick help on implementing a simulation on VB.net for an elevator system.

The basic requirements are attached...
I'd like to do something similar to these:
http://www.youtube.com/watch?v=CYSMKa9J0cA


I am started by the user interface (UI) using Visual Studio then will do the coding (vb.net)...Is that the way to proceed? I first started to come up with a state machine diagram but got a little confused...Software programming is not my thing yet!

My UI is incomplete but I'm using a picture box to model the elevator and thinking of using 2 colors (black = door closed and green = door open).
Still have to add the 'up' and 'down' arrow for the floor and number, fill those picture box bars showing the limits of the floor...
I'm doing my UI referring to the other attachment I saw on the web...

Any guidance...
 

Attachments

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Well I am working on it... got a very good book 'Programming in Visual Basic 2010' but I don't really have the time to read as I got to be done with it by Monday...but well...

Edit: reading time...Will post my progress.
 
Last edited:

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
A little algorithm I have in mind when the user presses a floor button inside the elevator...
This is just a pseudo code. does it make sense to you?


if (current location > destination location)
move down
if (current location = destination location)
stop moving
ElseIf (current location < destination location)
move up
if (current location = destination location)
stop moving
Else
don't move ; that means the user has pressed a floor button = the current location
End If

Looks like I will use a while loop for the first two condition to check if the condition is still true, huh?
 
Last edited:

THE_RB

Joined Feb 11, 2008
5,438
I would simplify that to two conditions;
1. does the elevator need to move
2. which direction does it move

Like this;
Rich (BB code):
if(current != dest)     // if elevator needs to move
{
  if(current < dest)    // if moving UP 
  {
    blah;
  }
  else                  // else is moving DOWN 
  {
    blah;
  }  
}
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
I like it! It's simpler. Thanks The RB!:)

But I will have to check in the 'blah' if the elevator has reached the destination and if so then stop moving...
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
When dealing with MCUs, instructions are executed at the speed set in the internal/external clock...

Just want to know about the speed at which instructions are executed in software programming? Is it based on the PC processor (CPU) speed or what?

Will post a small code soon...
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
I am looking for some animations for: an elevator door open, an elevator door closing.

If you have or can find some good one please let me know...I will need that as well thanks!
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
I wrote a code and it seems to works just fine but I think I need to include a timer to slow down the motion. it's a bit too too fast...

Although it works you may find something wrong so have a look... also I think I need to share the even procedure for all these buttons that act the same way ie G,1,2,3,4,5,6,7

I attached it coz it says it too long to put it in {
Rich (BB code):
Rich (BB code):
} and I still can't format code.
 
The code below move the elevador from any floor to foor4 
 
Your comment please! Merci!:)
 

Attachments

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Having a hard time creating a 10 second delay using Timer and swiping images ...I can't find a bug in my code...

Rich (BB code):
Dim NumberOfTicks AsInteger = 0
Dim Timer2EnableBoolean AsBoolean

PrivateSub Timer2_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
' This routine creates a delay of 10 seconds based on Timer2's interval property of 1000
If NumberOfTicks < 10 Then
   NumberOfTicks += 1
Else
   Timer2.Stop()
   Timer2EnableBoolean = True
EndIf
EndSub
 
PrivateSub OpenDoor()
 Timer2.Start()
 Timer2EnableBoolean = True
 Do While Timer2EnableBoolean
   ElevatorDoor.Image = ElevatorOpen.Image
 Loop
 ElevatorDoor.Image = ElevatorClosed.Image
EndSub

I thought this way should be much easier but ain't working...
There is another way but that would be complicating...I been able to use another timer to do other stuff but do know what's wrong with this one...

Attached is its property setting...
 

Attachments

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
I guess you are right...

It should be 'Timer2EnableBoolean = False' right after Timer2.Stop

Ima give it a shot ... I am using this Boolean variable as a flag...I am coding this thing the same way as MCUs...


 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
I changed but still nothing...maybe It's the other function the problem...still debugging...
 
Last edited:

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
For testing purposes I change '10' to '3' (10 seconds is too long to wait) and combine I can see that the timer is working...ie start and stop after 3 seconds. but I included the swaping inside the routine...
Well now that timer working I can carry on...

Rich (BB code):
PrivateSub Timer2_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
   If NumberOfTicks < 3 Then
     NumberOfTicks += 1
     ElevatorDoor.Image = ElevatorOpen.Image
   Else
     Timer2.Stop()
     ElevatorDoor.Image = ElevatorClosed.Image
     NumberOfTicks = 0
   EndIf
EndSub

PrivateSub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
  Timer2.Start()
EndSub
 
Top