Welcome to Cockpitbuilders.com. Please login or sign up.

May 12, 2024, 01:38:03 AM

Login with username, password and session length

PROUDLY ENDORSING


Fly Elise-ng
501 Guests, 0 Users
Members
Stats
  • Total Posts: 59,641
  • Total Topics: 7,853
  • Online today: 515
  • Online ever: 831
  • (May 03, 2024, 12:39:25 PM)
Users Online
Users: 0
Guests: 501
Total: 501

COUNTDOWN TO WF2022


WORLDFLIGHT TEAM USA

Will Depart in...

Recent

Welcome

What resistors for 1 pole 12 position rotary switch ladder

Started by kurt-olsson, January 08, 2016, 01:02:51 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

kurt-olsson

Hi.

I am trying to make a rotary switch ladder out of resistors and read the voltage on each switch position.

right now all my positions return 1023 which is full +5V.

I think that even a small resistor of like 150ohm should give me another value. decreased with some small numbers?
or do i need to start with a 10K resistor each just to get different readings?


727737Nut

Can you give a schematic of how you have it wired.  Sounds like you have it wired wrong.  Resistor size is not a huge issue as long as they are different.   
737 Junkie

Ridgenj

Excuse my ignorance  and please educate me. Where in the cockpit do you need this setting?
Cheers
Luis

Sent from my SM-N910T using Tapatalk


iwik

Kurt,
Resistor string should be connected between +5v and Gnd.
Output between ground and junction of resistors.
Les

kurt-olsson

Quote from: Ridgenj on January 08, 2016, 06:03:06 PM
Excuse my ignorance  and please educate me. Where in the cockpit do you need this setting?
Cheers
Luis

Sent from my SM-N910T using Tapatalk

Hi.

I am using this for the Range-switch on the EFIS panel. it has 8 position, and i don´t want to use 8 pins on my teensy, just read what position the switch is on by reading the analog value of the current flowing to each pin on the switch.

kurt-olsson

It was bad wiring...


i skipped the 5+V cable to the circuit and now it works with only rhe ground on the pins with resistors and the analog read on the switch common pin.

i don´t understand why i need to do

digitalWrite(A0,HIGH) to get this to work, if i set my pin to LOW i get bad readings when going back on the switch.

I know this is basic with digitalWrite, but if someone understands this please tell me. =)

It works not with HIGH perfect, but LOW is giving strange values.

KyleH

This is a common technique to increase usable pins on a microcontroller.
I've attached the schematic I use.

Resistors R1 to R5 are typically 5k to 10k to keep the power draw to a reasonable level.
I do not connect any of the pins of the rotary switch to 5V. Instead I have R6 (typically 10k) on the microcontroller pin to 5V.
This is so that when the switch is in between positions and not making contact with anything, the input to the microcontroller is pulled to 5V and I ignore any full on value in the code.

The capacitor C1 is to help remove any noise on the input to the microcontroller analog input pin. Be careful with this value though. You need to read the datasheet for the microcontroller you are using to understand how capacitance on the analog input will affect the reading. If you don't need it for noise best to leave it off.

Code is then just reading the analog level, and comapring with the expected values. Check for a range, not a specific value; With a 8bit analog converter, position 5 would be anything less than 20, position 4, between level 20 and 75, position 3 between level 75 and 125, etc...


Kyle

Chief Pilot
Worldflight Team USA
http://www.worldflightusa.com

727737Nut

I use this method on my start switches and wipers sw.  Works nicely.
737 Junkie

Ridgenj

Many thanks to all. In order to save pins I use Bodnar's two pin PCB and BBI32.

Any how, this method seems to be definetely more cost effective and I/O card independent.
Thanks for educating me.
Cheers
Luis

Sent from my SM-N910T using Tapatalk


kurt-olsson

#9
Wow! This is cool!!! Only two inputs for map and range. And the 7 buttons can be solved in the same way!!!

Off topic!

737Nut, do tou have anymore videos of your sim? Would be cool to see a "cold and dark startup" :)

Like the Website ?
Support Cockpitbuilders.com and Click Below to Donate