Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Send to closest unoccupied space

  1. Oct 13, 2015 #1
    Hi

    I'm undertaking a mechanical project whereby I wish to send an object (crate etc.) to an array of shelf spaces. Each space will have a button, so that when the object is put into the space, the button will be pressed by the weight of the object.

    So, I want to start from having all shelves free, press a 'send' button and the object will be taken to the closest space, the next object to the 2nd closest space etc. I then want to retrieve an object from any space too. The idea is that I want to have one 'send' button (sends to nearest space) and I will use a potentiometer and button to retrieve from the desired space I select.

    Does anyone have an idea where to begin? Has anyone done anything similar? I'm using CCS compiler and C code.


    Thanks
     
  2. jcsd
  3. Oct 13, 2015 #2

    berkeman

    User Avatar

    Staff: Mentor

    Sounds like a school project. What are you going to use for the mechanical actuators, transport mechanism, switch sensors, etc.?
     
  4. Oct 13, 2015 #3
    No, it's not a ''school project''. The actuators are irrelevant to this question, but they are a combi of DC's and steppers. Switches are micro switches.

    Oh how I love the unhelpful responses on this forum. I'm sure if it was a simple ''school'' project then you'd give me a simple ''school'' answer, wouldn't you?
    :)
     
  5. Oct 13, 2015 #4

    berkeman

    User Avatar

    Staff: Mentor

    Not sure why you're offended, but whatever. First, using a potentiometer to select which bin to fetch from sounds very much like a low-end intro schoolwork project. And I asked for clarification, because as you know, schoolwork questions go in the Homework Help forums, and you need to show your work before we can offer tutorial assistance.

    Anyway, I don't see how you can say that the mechanical part of this doesn't matter. Is this just a paper design? Or is it just the programming part that you are going to do, with stubs for the parts that would be your I/O routines? How many I/Os would you have if this were a real system?
     
  6. Oct 14, 2015 #5

    jim mcnamara

    User Avatar

    Staff: Mentor

    Berkeman is correct. But, what you want is a linear search algorithm. You are working in an embedded system - like a microcontroller, so you have limited memory. I would consider a bit-array, where bit=1 == full, bit=0 == empty. This will not work if there are implied differences in contents of the bin.
    Use 16 bit words, uint16_t, you need to map each bin to one and only one bit in the array.

    Note: I got the 16 bit suggestion from reading what CCS supports, you should know that cold. I would have used whatever the native word size for the microcontroller is otherwise.

    See: https://graphics.stanford.edu/~seander/bithacks.html
    Code (Text):

    // return -1 all bins are full, else return bin #
    int ff_empty(uint16_t *arr, int arrlen)
    {
       int i=0;
       int j=0;
       for(i=0; i<arrlen; i++)
       {
           if( arr[i]< 0xffff)
             return (i *16 + ffs( arr[i] ^ 0xffff) );
       }
       return -1;
    }
     
    If this does not appear to be simple, get some more help. Bit hack every 'algorithm' this way - find first empty, find first full, mark bin empty, mark bin full. Also this does not handle the issues surrounding the number of bins not evenly divisible by 16.
     
    Last edited: Oct 14, 2015
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Send to closest unoccupied space
  1. Sending UDP Packet (Replies: 6)

  2. Print space (Replies: 8)

  3. Win API - Send To (Replies: 1)

Loading...