C Code - Send to closest space

Discussion in 'The Projects Forum' started by Rob35099, Oct 13, 2015.

  1. Rob35099

    Thread Starter New Member

    Sep 22, 2015

    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. I'm using a pic microcontroller.

    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.

  2. KMoffett

    AAC Fanatic!

    Dec 19, 2007
    Looks like the mechanical part would be the starting point. That's what the programs needs to control. How are the crates individually identified for pickup? How (details) are the crates moved from the the original space to the closet space?

  3. Rob35099

    Thread Starter New Member

    Sep 22, 2015
    I don't need help at all programming the steppers and DC motors I am using. I have all the mechanical side done. I'm just need some guidance on a send to closest space option. A stepper motor gives full x-y plane control and DC linear actuator moves the 'crate' up+down. A final DC linear actuator moves in/out. The crates I described are very small - this is just a scale model.

    There is no identification of the crates - they are all the same - they just need to be sent to the closest space (for efficiency of time). The user can then retrieve any specific crate he desires (I know that sounds strange but that's the way it is).
  4. BReeves


    Nov 24, 2012
    I would create a bool array of the spaces. When a space has a crate set the corresponding array location to true, when it is removed set it to false. Search the array for the closest empty space.