Connect with us

Detecting horizontal position

Discussion in 'Sensors and Actuators' started by tarun71gaur, Apr 9, 2020.

Scroll to continue with content
  1. tarun71gaur

    tarun71gaur

    9
    0
    Feb 12, 2018
    hi everyone. I am working on a project where I need a LED to light up if the arm of the platform is horizontal. Due to space constraints I can not use an accelerometer. The sensor needs to be small and just give a high or low value at 180 degrees only with minimal error range, I am using an arduino nano as the microcontroler on the platform say at a distance of 4-5 inches. can somebody please suggest a sensor or positioning switch which I can use.
     
  2. WHONOES

    WHONOES

    905
    225
    May 20, 2017
    Could go analogue and use a pointer.
     
  3. hevans1944

    hevans1944 Hop - AC8NS

    4,495
    2,092
    Jun 21, 2012
    Did you try Google with this search string: tilt sensor? Lots of results here. I bought a bag of a hundred ball-in-cylinder tilt sensors from Amazon recently, with the idea of throwing together a "toilet seat up" warning for my wife. If the toilet seat is up, the ball makes contact between two leads which is the criterion for sounding an alarm.

    The rest of my circuit is just bells and whistles to prolong battery life, i.e., a PIC microprocessor that stays in sleep mode until the tilt switch changes states. I discovered, after playing around with one of the tilt switches using my digital multimeter, that the switch is quite sensitive in the vertical position to off-axis alignment. So, for my application, it would be better to orient the switch so it is closed (internal ball is making connection between the two leads) when the toilet seat in down instead of when the seat is up. That way it would not be so tricky in alignment with the vertical when the seat is up. YMMV.
     
  4. Bluejets

    Bluejets

    4,093
    859
    Oct 5, 2014
    How much space is this..?
    A quick sketch would help.
     
  5. (*steve*)

    (*steve*) ¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd Moderator

    25,397
    2,777
    Jan 21, 2010
    Yeah, considering how small accelerometer chips are...
     
  6. tarun71gaur

    tarun71gaur

    9
    0
    Feb 12, 2018
    Its just a rod 8mm square. extending 3 inches from the platform joined to the platform with a hinge .
     
  7. Bluejets

    Bluejets

    4,093
    859
    Oct 5, 2014
    GoTo #4
     
  8. tarun71gaur

    tarun71gaur

    9
    0
    Feb 12, 2018
    Thanks hevans.
    Yes I have been looking at tilt switch . especially SW 520D. It comes both as a standalone and as a module where a potentiometer is added on the PCB to adjust the sensitivity. How ever I have a couple of questions.
    1) would the performance be consistent over a long time.
    2) Should I use the standalone type or the module.( keeping in mind the space constraints, standalone would be a better option.)
    3) Can I install the tilt sensor at the tip and run 2 lead wires to the PCB with potentiometer?
    4) Is there a method/code I can run on the arduino it self so as to ensure a higher sensitivity of the tilt switch.
     
  9. Bluejets

    Bluejets

    4,093
    859
    Oct 5, 2014
    I'd get the module, remove the sensor and install remotely with wiring back to the module.
    Sensitivity is a module adjustment and even at that, limited to whatever Arduino considers as a high or a low.
    You may find the mounting to actually be less than directly upright.
    Also be aware it has a particular orientation.
    Input is either on or off.
    As for lifespan, a quick Google ( always useful I find) shows it to have 50K plus switchings.

    Code etc. here....
     
  10. tarun71gaur

    tarun71gaur

    9
    0
    Feb 12, 2018
    Thanks bluejets and also for the vedio. The sensor in vedio can be adjusted really to a very small angle so I guess it works. I am a medical person and tinker around with electronics as a hobby so correct me if I am wrong. My understanding is that the actual sensor is just an on /off switch and it is the LM393 that acts as an amplifier and the potentiometer adjusts the resistance or in a way controls the amplification.
    Just for curiosity sake.
    If SW 520D is just a switch , is it possible to attach two SW 520 D switches on series at right angle to each other so as to convert the module into a dual axis switch.
     
  11. hevans1944

    hevans1944 Hop - AC8NS

    4,495
    2,092
    Jun 21, 2012
    1) Only time will tell.
    2)Follow @Bluejets advice and separate sensor from module.
    3)Probably; try it and see if it still works.
    4)No; a switch (by definition) is a binary device, either open or closed.

    More information here on the SW520D "ball in cylinder" tilt switch/sensor.
    There are tilt sensors that provide an analog signal output that is a function of device orientation, some on a single axis, others on two or more. The latter are generally based on MEMS accelerometers, sometimes with on-chip signal conditioning. Your late-model smart cell phone uses these, only partially accounting for the exorbitant expense of new smart phones. I DO NOT recommend trying to hack a cell phone. If you need a feedback signal that is a linear function of position on one or more axes, you need to do your homework to find out what is currently available at a price you can afford.
     
  12. Bluejets

    Bluejets

    4,093
    859
    Oct 5, 2014
    Series connection would require both to close to get a circuit.

    Parallel connection will give an OR contact. (one OR the other).
    Problem is, one cannot differentiate in logic as to which is which.
    Alternative is, if used as 2 inputs to a microcontroller, such as say an Arduino,then you can OR the connection in code and also detect which is which.
     
  13. tarun71gaur

    tarun71gaur

    9
    0
    Feb 12, 2018
    Yes that is what I was thinking a series connection will make it kind of a dual axis switch i.e the switch will work only if both X and Y axis are at 180 degrees . It may not be the best but it might work. By the way do you know of any IMU which can be installed in such a small space say not more than 1cm square. I have seen a couple of IMU from espon and also one from Mouser BMI 160 with I2C and SPI interface but don't know whether it is compatible with arduino or not and whether they can be installed independently with wire leads to the arduino.
     
  14. Bluejets

    Bluejets

    4,093
    859
    Oct 5, 2014
    Ah, ok....

    Worked mostly with Arduino as it is relatively straightforward with heaps of contribution to go to if ever in a pickle.
    Also did a bit with Picaxe but it was rather limited in what it was capable of.
    Then there were some with 8 pin microchip pic12F683 when we were doing the ignition systems but other than that , not much help there.

    Have to convert when you talk cm. As a construction electrical contractor I'm used to working in mm.
    Arduino pro mini modules are around 30mm long and 20mm wide. Use a usb to ttl adaptor to program. Cheap and quick.
    Then there are the ATtiny85 and although compatible with Arduino they are a bit different to program and I've had a few hiccups that were difficult to nail down as they are nowhere near as popular.
     
  15. bertus

    bertus Moderator

    750
    267
    Nov 8, 2019
    Hello,

    We still have not seen a drawing of the set-up.
    Can you have a sensor next to the rod?
    Then you could use an optical reflective sensor:
    https://uk.farnell.com/on-semiconductor/qre1113gr/opto-switch-reflective/dp/1471020
    When there is a reflective line on the rod, the sensor could detect the position.
    When you have room for two of those sensors, you can even tell of the rod is to high or to low with a pattern like this on the rod:

    high_low_pattern.png

    When both sensors are activated the level is OK.

    Bertus
     
  16. Bluejets

    Bluejets

    4,093
    859
    Oct 5, 2014
    Revisited a few details on the little ATtiny85 and it might just satisfy your requirements.
    Found a video(rather than explain everything here) where the bloke uses a Arduino UNO for programming.
    Essentially same programming arrangement for the code, just need to rename i/o's to suit the little fella.

     
    hevans1944 likes this.
  17. hevans1944

    hevans1944 Hop - AC8NS

    4,495
    2,092
    Jun 21, 2012
    Thanks for the video @Bluejets! What a neat way to program the ATtiny85/45 microprocessor! Just about everyone who plays with micros has an Arduino UNO on hand and a solderless breadboard, so no need to buy a PIC programming pod like I use for Microchip PIC micros. After I download the datasheet for the ATtiny, I might just order a few to see how they compare with the PICs.
     
  18. tarun71gaur

    tarun71gaur

    9
    0
    Feb 12, 2018
    Thanks Bluejets. ATtiny really looks promising in reducing the size . Ok here is the diagram of what I am trying to make
    Here is what I want to do.
    Rad the position of the base plate in X,Y,Z axis when the rod is horizontal to the floor. I have the arduino with a IMU and OLED screen which displays the position of the base plate . I want to freeze the display when the rod becomes horizontal to the floor . I plan to use the tilt switch as a switch which causes the display showing the position of the platform(C) to freeze when the rod is horizontal. something like a push button .
    I need help regarding what is the code for freezing the display, and also how can I use the tilt switch .
     

    Attached Files:

  19. Bluejets

    Bluejets

    4,093
    859
    Oct 5, 2014
    Why would you want to freeze the display?
    Any further movement would not show...o_O
    There are other ways such as sound an alarm or set a flag for some other hardware.

    Only thing I can offer without seeing any of your code is, if you have an update on your display, as you should for good practice, then just stop the update when certain condition is met.
     
    hevans1944 likes this.
  20. hevans1944

    hevans1944 Hop - AC8NS

    4,495
    2,092
    Jun 21, 2012
    I am gonna make a leap of faith here and assume you meant to write "Read the position..." But we still don't know WTF you are trying to DO with your base plate with a hinged rod attached to it. Can you enlighten us with an explanation, or is this some sort of secret you are withholding for whatever reason?
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-