|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
Re: Toggle switches to Analog board?
It should look like this...
|
|
#2
|
||||
|
||||
|
Re: Toggle switches to Analog board?
If I am looking at this correctly, does this mean I can't use a SPST switch to do what I want to do? I need a SPDT?
|
|
#3
|
|||||
|
|||||
|
Re: Toggle switches to Analog board?
If you are going to the analog board, it does not have pull up resistors so you have to use the SPDT to switch between +5 and zero volts. If you use a digital input, the pullup would allow you to simply open or close a connection to the common to give two states.
|
|
#4
|
|||||
|
|||||
|
Re: Toggle switches to Analog board?
Quote:
Last edited by Alan Anderson : 04-02-2011 at 10:28. Reason: fixed name |
|
#5
|
||||
|
||||
|
Re: Toggle switches to Analog board?
Quote:
|
|
#6
|
|||||
|
|||||
|
Re: Toggle switches to Analog board?
Yes, You guys are right. I have to stop answering these questions while I am working on interfaces here. Alan, can you add something about programming so that switch bounce doesn't confuse the readings?
|
|
#7
|
|||||
|
|||||
|
Re: Toggle switches to Analog board?
Switch bounce would affect switches connected to a digital input at least as much as it would analog inputs. Most of the time, the programming is going to be such that it simply doesn't care whether the switch gets detected several times in quick succession.
For reading a switch on an analog input, the WPILib "analog trigger" function is what you want. That rejects glitch-type noise as part of its implementation. |
|
#8
|
||||
|
||||
|
Re: Toggle switches to Analog board?
Edit: Looks like I need to type faster if I am going to post in the same threads as Al and Alan. But what I posted may still be usefull so I will leave it up.
Quote:
Psuedo Code Create Counter- Initialize to Zero Assuming Switch sampling occusr every ~1ms If (Software_representation of switch = not-pressed) If switch is not pressed Reset Counter Set Software representation of switch to not-pressed else (switch is pressed) increment counter end if if counter > 10 Set software representation of swtch to pressed end if Then you can reverse the switched/not-switched cases for then the butto is pressed if you need to detect the release as well. |
|
#9
|
||||
|
||||
|
Re: Toggle switches to Analog board?
Cool discussion, I am happy I can use my SPST switches. I already had a bunch purchased and laying around. I also appreciate the pseudocode. Thanks again.
|
|
#10
|
|||||
|
|||||
|
Re: Toggle switches to Analog board?
Darren,
Sorry I led you down the rosy path earlier. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|