Re: Analog ports and using switches
- The reason it doesn't go to zero is the resistance of the switch. The switch and the pull-up resistor form a voltage divider circuit. When the switch is closed the voltage of the signal is the voltage measured between the pull-up resistor and the switch.
When there is nothing driving the signal, such as a pull-up resistor, its voltage will float to an unspecified value. The exact voltage depends on minor details of the circuitry. There are small differences in how the analog ports are implemented on the two boards which results in the unspecified behavior being different.
The RidgeSoft Team
--- In firstname.lastname@example.org, "njhsarobot" <njhsarobot@y...> wrote:
> Worked fine. Interesting 1023 is 1023 but 0 is 15. Any idea why?
> Why do the expansion ports need to a pullup resistor and the ones on
> the main board don't?
> --- In email@example.com, "RidgeSoft" rs1@r... wrote:
> > Are you enabling the pull-up resistor?
> > IntelliBrainAnalogInput input =
> > input.setPullUp(true);
> > When you use a switch you need to use a pull-up to pull the pin to
> the high voltage when the switch is open. The switch should be
> connected between siganl and ground.
> > The RidgeSoftTeam
> > --- In firstname.lastname@example.org, "njhsarobot" njhsarobot@y...
> > >
> > > I attached a switch to Analog 7 and as I expected got a value of 0 or
> > > 1023. When I attached the switch to Analog 15 I got a value of 0 or
> > > between 200 and 300. Why is it not 1023 like on 7? Is it because it
> > > is being switched?
> > > Thanls
> > >
- We are using a different configuration for on/off switches: the switch
is between the signal and +5V, and there is a pull-down resistor
between the signal and the ground. Of course in this case we don't
enable the pull-up resistor by software. Are there any disadvantages
in using the pull-down configuration?
The way you have connected the switches is reasonable provided you are drawing the +5V from the IntelliBrain board. The microcontroller chip can be damaged if a signal pin is driven by an external +5V source that is actually at a slightly higher voltage than the IntelliBrain's +5V power. If you are drawing power from the port's power pin there shouldn't be a problem.
One advantage of using the internal pull-up is you don't need the external resistor, you can simply connect the swtich to the signal and ground pins.
The RidgeSoft Team
--- In email@example.com, "cacarreto" <ccarreto@i...> wrote:
> We are using a different configuration for on/off switches: the switch
> is between the signal and +5V, and there is a pull-down resistor
> between the signal and the ground. Of course in this case we don't
> enable the pull-up resistor by software. Are there any disadvantages
> in using the pull-down configuration?