Thread: vehicle position system

  1. #1
    Registered User
    Join Date
    Feb 2022
    Posts
    73

    vehicle position system

    please see the picture given in following link i need to write a code for similar situation whose logic i am not able to understand

    Vehicle Positioning System “AND-VPS”, Ahmedabad, Gujarat, India

    I understand that to find the correct position, the first and third sensor should be low and the middle sensor should be high as show the image show in link.

    I don't understand how logic would be used for a public declaration that instructs the driver to the correct position.
    If the truck has stopped on the first sensor then it should be announced to go forward, if it is ahead a lot at third sensor , then it should be told to go back.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Draw out a truth table

    0 0 0 - "please drive onto the weigh bride"
    0 0 1
    0 1 0
    0 1 1
    1 0 0
    1 0 1
    1 1 1

    As the truck drives onto the platform, you're going to see a sequence of state changes from the three sensors.
    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.

  3. #3
    Registered User
    Join Date
    Feb 2022
    Posts
    73
    Quote Originally Posted by Salem View Post
    Draw out a truth table

    As the truck drives onto the platform, you're going to see a sequence of state changes from the three sensors.
    This is my truth table

    0 0 0 - " The truck is not on the weighbridge "
    0 0 1 -" Please go ahead"
    0 1 0 " You are in the right place"
    0 1 1 " Please go ahead"
    1 0 0 " Please go back"
    1 0 1 " Not possible conditions "
    1 1 1 " Not possible conditions

    Looking at the sequence, it seems that while loop should use

    Code:
     main()
    {
       while (1) 
       {
             while (IR1 == 1) 
              {
                   printf( " Please go ahead" ) 
    
                    while (IR1 == 1 && IR2 == 1) 
                    {
                         printf( " Please go ahead" )
                           while (IR1 == 0 && IR2 == 1)
                          {
                               printf( " You are on right position" )
                           }
    
    
                    }
           
             }
    }
    
    }
    Last edited by Dadu@; 05-20-2022 at 12:18 PM.

  4. #4
    Registered User
    Join Date
    Feb 2019
    Posts
    1,078
    Let say your sensors are connected to bits 0 to 2 of a register called IR:
    Code:
    // Do something... (here I'll pass sensors data to the functions).
    extern void not_in_weightbridge(unsigned int);
    extern void go_ahead(unsigned int);
    extern void go_back(unsigned int);
    extern void right_place(unsigned int);
    extern void not_possible(unsigned int);
    
    // Get sensors data.
    extern unsigned int getSensors( void );
    
    extern int terminated;  // flag to terminate main loop.
    
    void main_loop( void )
    {
      unsigned int sensors;
    
      // Table to functions sorted by the sensors data.
      static const void (*actions[])(unsigned int) = {
        not_in_weightbridge,
        go_ahead,
        right_place,
        go_ahead,
        go_back,
        not_possible,
        not_possible,  /* 110 missing! */
        not_possible
      };
    
      while ( ! terminated )
      {
        unsigned int sensors = getSensors() & 0x7;
    
        actions[sensors](sensors);
      }
    }

  5. #5
    Registered User
    Join Date
    Dec 2017
    Posts
    1,628
    I don't understand how we know there are three sensors from the picture.
    What are the little white squares and red dotted lines on the ground?

    vehicle position system-vehicle-positioning-system-jpg

    And if there's three sensors, why does Dadu's code only mention two?
    And what's up with the freaky nested while loops?
    Last edited by john.c; 05-20-2022 at 03:44 PM.
    A little inaccuracy saves tons of explanation. - H.H. Munro

  6. #6
    Registered User
    Join Date
    Feb 2022
    Posts
    73
    Quote Originally Posted by john.c View Post
    What are the little white squares and red dotted lines on the ground?


    And if there's three sensors, why does Dadu's code only mention two?
    And what's up with the freaky nested while loops?
    The white square is the transmitter and receiver of the sensor. When the transmitter detects an object, it sends it to the receiver and the receiver sends it to the micro-controller. So we have a total of three transmitters and three receivers

    imagine the situation when the vehicle is stopped at the sensor. The condition says instruct the driver to proceed as long as sensor one is active. Looks like there should be a while loop to check sensor status

  7. #7
    Registered User
    Join Date
    Feb 2019
    Posts
    1,078
    I suppose that these "sensors" are lasers which have the beam interrupted by the object... But this isn't a good project and something is missing... with 6 pilars you should have 5 sensors:

    Code:
    -> beam from LED (other side is receiver).
             E
    A->------|-------B
    |        V       |
    V        |       |
    |        |       |
    |        |       ^
    |        |       |
    C--------|-----<-D
             F
    The question is: Is it acceptable if the object is in one of these positions?

    Code:
             E                   E
    A->------|-------B  A->------|-------B
    |        V       |  |        V       |
    V  xxxx  |       |  V        |       |
    |  xxxx  |       |  |        |  xxxx |
    |        |       ^  |        |  xxxx ^
    |        |       |  |        |       |
    C--------|-----<-D  C--------|-----<-D
             F                   F
    
             E                   E
    A->------|-------B  A->------|-------B
    |        V       |  |      xxxx      |
    V        |       |  V      xxxx      |
    |        |       |  |        |       |
    |      xxxx      ^  |        |       ^
    |      xxxx      |  |        |       |
    C--------|-----<-D  C--------|-----<-D
             F                   F
    Last edited by flp1969; 05-21-2022 at 05:53 AM.

  8. #8
    Registered User
    Join Date
    Dec 2017
    Posts
    1,628
    Why can't it just be something like this.
    Code:
    L1--------L2--------L3    Lasers
    |         |         |
    |         |         |
    |         |         |
    |         |         |
    |         |         |
    S1--------S2--------S3    Sensors
     
    while (1) {
        if (S1)
            go forwards
        else if (S3)
            go backwards
        else
            correct position
    }
    A little inaccuracy saves tons of explanation. - H.H. Munro

  9. #9
    Registered User
    Join Date
    Feb 2022
    Posts
    73
    Quote Originally Posted by john.c View Post
    Why can't it just be something like this.
    Code:
    L1--------L2--------L3    Lasers
    |         |         |
    |         |         |
    |         |         |
    |         |         |
    |         |         |
    S1--------S2--------S3    Sensors
     
    while (1) {
        if (S1)
            go forwards
        else if (S3)
            go backwards
        else
            correct position
    }
    It make sense, But it is not understood that when the vehicle stops at sensor 2 after crossing sensor 1, so what is the need to check sensor 3 first.

    When the vehicle stops at sensor 2, the vehicle's weight is measured

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    What happens if S1 negates before S2 asserts?
    - Did the vehicle reverse and leave the weighbridge?
    - Is the vehicle shorter than the gap between S1 and S2?

    What happens if S1 and S2 are asserted?
    - Is it a really long vehicle?
    - Are there two vehicles on the weighbridge?

    Finite-state machine - Wikipedia
    - You have events - S1, S2, S3
    - You have states - entry, stop, weigh, leave
    You need to make sure the event you receive is consistent with the state you're in.
    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.

  11. #11
    Registered User
    Join Date
    Dec 2017
    Posts
    1,628
    @Dadu, My example was not meant as a full solution.
    It was just meant to show you that the nested while loops were incorrect.
    A little inaccuracy saves tons of explanation. - H.H. Munro

  12. #12
    Registered User
    Join Date
    Feb 2022
    Posts
    73
    Quote Originally Posted by Salem View Post
    What happens if S1 negates before S2 asserts?
    - Did the vehicle reverse and leave the weighbridge?
    - Is the vehicle shorter than the gap between S1 and S2?

    What happens if S1 and S2 are asserted?
    - Is it a really long vehicle?
    - Are there two vehicles on the weighbridge?.
    System checks if S1 and S2 are high then system announces publicly, go forward

    If the driver stops the vehicle at S2, the machine measure weight loaded on vehicle.

    If vehicle stops at S2 and S3 without weighing loaf, system announce, go backwards

    Something like this

    vehicle position system-position-jpg

    Quote Originally Posted by Salem View Post
    Finite-state machine - Wikipedia
    - You have events - S1, S2, S3
    - You have states - entry, stop, weigh, leave
    You need to make sure the event you receive is consistent with the state you're in.
    I am trying to make FSM
    Last edited by Dadu@; 05-23-2022 at 06:23 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. downwind vehicle, can it go faster than the wind
    By rcgldr in forum General Discussions
    Replies: 18
    Last Post: 05-16-2013, 07:10 AM
  2. to calculate parking for three different vehicle..
    By leo240791 in forum C++ Programming
    Replies: 8
    Last Post: 12-04-2012, 04:39 PM
  3. Replies: 8
    Last Post: 04-15-2008, 01:57 PM
  4. Class vehicle with virtual function
    By silicon in forum C++ Programming
    Replies: 8
    Last Post: 12-24-2003, 10:42 AM
  5. Vehicle file attached.
    By RJstuff1 in forum C++ Programming
    Replies: 8
    Last Post: 09-22-2001, 01:56 PM

Tags for this Thread