This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Usage of Microswitch an GPIO PIN on Tiva Board

Dear all,

I'm completely new in developing on a tiva board. Till now, I've only used booster packs with some chicks (e.g. altitude click)..

Now I want to use a microswitch together with my microcontroller:



Can anyone tell me where i can find some kind of example or tutorial to use such a thing. at best from hardware view (how to connect the switch with the board) to software view (how do i have to use the gpio pins)?

Thanks in advance and br,
Patrik

  • Hello Patrik,

    A data sheet for the microswitch would be a good place to start for us to see how to interface and decided on the software requirement.

    Regards
    Amit
  • It would be helpful too for poster to insure the availability of "DVM" and several current-limiting resistors. Both prove vital during the debug & test/verify process. (relying upon internal pull-ups - or pull downs - if glitched/missed - can short the (full MCU supply) when the µSwitch closes!) Series resistor (few K) in series w/ground or supply - then connected to the switch - prevents (ok reduces) such misfortune.
  • Hello Patrik,

    Can you please describe the application requirement of the MicroSwitch (I had to find the English version of the same) and the TM4C microcontroller?

    Regards
    Amit
  • sorry for the german version of the data sheet.
    what i want to do: on every "click" on the switch i want to get information into my task - just like an GPIO interrupt of a button on by board. it doesn't have to be a interrupt, it's also ok for me to check the "state" of the switch on a (very) regular basis to get the state.

    Br
  • Hello Patrik

    No problem on the document language, it was technical information I was looking for along with the SI Units.

    Now the switch, I believe based on the 2 page datasheet is being used in a high voltage application? And that you want to sense the trip?

    Regards
    Amit
  • It doesn't have to be this switch.
    I just need something that has this characteristic. the switch has to be activated by a smooths contact, so that e.g. a car on a carrera track can trigger it by brushing it.
    Do you know any other hardware i can use which is more suitable for a microcontroller?
  • Patrik Szabo said:
    Do you know any other hardware i can use which is more suitable for a microcontroller?

    Modulated IR (infra-red) Led paired assemblies prove superior.   (i.e. avoid "smooth" or more likely "unsmooth" contact w/the vehicle)  

    These devices often are installed along conveyor lines - signal the presence of objects - without in any way interfering w/their motion or progress!   The detection initiates various actions.   Commercial versions are better designed, more complete, more robust.   For hobby usage - think of devices (perhaps) targeting TV/Audio remote control.   The IR signals are modulated to (somewhat) deaden them to ambient light - and frequency filtering offers more robust "presence/passage" detection...

    Such devices - when sold as a mated pair - usually output at/around 5V signal levels - which should be easily divided to MCU (i.e. 3V3) voltage levels.

  • Hello Patrik,

    As cb1 said, modulated IR is a better solution. Ultrasonic sensors may be useful if distance based decision need to be made.

    Regards
    Amit
  • Hi Amit,

    May I (carefully/respectfully) suggest that "Ultrasonic" may not prove as accurate - nor able to recover quickly enough - should multiple vehicles pass in quick succession.

    Note that the cb1/firm designed vehicle will (most always) ARRIVE LAST in that succession. (and that poster Luis' vehicle will be FIRST!)

  • Hello cb1,

    "Ultrasonic sensors may be useful if distance based decision need to be made."

    should have been

    "Ultrasonic sensors may be useful in conjunction if distance based decision need to be made."

    Regards,
    Amit
  • Agreed, Amit.

    As a side-note (aren't most?) firm/I designed such a system for large US charity-based group. That "IR" system (suggested) as well as ultrasound may fail when the track is multi-lane - and the race is tightly contested! (i.e. how then does the sensor know "who" tripped it?)

    In such case - poster's "intrusive" sensor proves best. (but is likely to prove a nightmare to adjust/maintain - and inevitably will require a "trip-device" to be installed upon each/every vehicle! (Ugh!)

    In our case - we programmed the MCU to best operate the vehicle - constantly checking for acceleration vs. "wheel-spin" and adjusting the throttle (quickly/accurately) accordingly! End result - the kidz could NOT beat the computer. (how popular was cb1 that day?)

    I still have the tracks & at least one car...   (and pics of the "tomato bashed," cb1 sportscar...)

  • Hello cb1,

    Go vertical. Tracks with a small slot on the bottom, will allow for reflections to be captured for each of the cars, and synchronized timers may be used for snapshot of the time....

    Regards
    Amit
  • If there's demand I've got photos (of such tracks). The individual lanes are (usually) installed - side by side - upon a sectional, plywood base - some such tracks may exceed 15 meters in length.   Under those circumstances - access to the bottom of the track (i.e. the plywood base) is rarely an option.   (and exhausting)

  • Hello cb1

    But over the track an installed IR sensor or the path is still an option!!!

    Regards
    Amit
  • You are correct re: "Over the track." But - now the tradeoff is (likely) placing "reflector" w/in the track - and duplicate set up in each/every race lane.

    Often these tracks are "stacked" and shipped from venue to venue. Anything not properly installed & "locked down" w/in the track base will not be long - "for this world."

    Our past system monitored "all lanes" (via a single sensor - spanning all lanes - and horizontally oriented) and reported each vehicle's arrival & departure at/from each sensor - provided the vehicle bodies did not overlap during the sense event.

    As always - minus a properly "guided post" - we're left to [blank into the wind] forcing excess time/effort upon hapless helpers.

    Our "Klein Tools" 1:32 scale, "Indy" car - powered/launched/controlled by LX4F231 MCU - emerged untied and undefeated during a 4 day weekend.  (and achieved that w/ NO/Zero human intervention!)

  • You can also get pre-aligned tuning fork type setups as well, depending on how large your car is.

    Robert