Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 16:23 18 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Micromite - detect pin to GND?

Author Message
Modena
Newbie

Joined: 07/06/2014
Location: Australia
Posts: 10
Posted: 01:31am 18 Jun 2014
Copy link to clipboard 
Print this post

Hey all, is there a way to detect when a wire/circuit connected to a Micromite I/O pin is sent to ground?

Ben
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3678
Posted: 01:35am 18 Jun 2014
Copy link to clipboard 
Print this post

If it's set as an input, just read it. If it's an output then it better be open drain or may damage the chip!

If you need to know it's Gnd rather than a logic low, that's a bit more effort but try analog.

JohnEdited by JohnS 2014-06-19
 
Modena
Newbie

Joined: 07/06/2014
Location: Australia
Posts: 10
Posted: 01:48am 18 Jun 2014
Copy link to clipboard 
Print this post

thanks for the reply John, but surely if the pin is grounded it will read 0v, and if the circuit is open it will also read 0v?

Ben
 
Goeytex
Regular Member

Joined: 12/05/2014
Location: United States
Posts: 74
Posted: 02:34am 18 Jun 2014
Copy link to clipboard 
Print this post

  Modena said   thanks for the reply John, but surely if the pin is grounded it will read 0v, and if the circuit is open it will also read 0v?

Ben


Not necessarily. Ground may be defined a physical point used as reference for voltage levels.

A pin being grounded means it is physically connected to the ground reference point and not necessarily that it is taken "low" by an external device. So if a pin is grounded and the meter is referenced to ground, it will read 0 volts.

An open circuit, meaning absolutely nothing is connected to the Pin, will not necessarily read OV.

If the pin is an input and pull ups are NOT enabled, it will be floating and in an indeterminate high impedance state. There may or may not be voltage present. But the impedance of the meter might be enough to drive the pin down to near 0 volts when taking a reading. A high impedance meter or scope may read a voltage anywhere from 0V to near Vdd.

If the pin is an input and pullups ARE enabled, then with nothing connected to the pin, it will read the supply voltage minus a few hundred millivolts.

 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3678
Posted: 02:53am 18 Jun 2014
Copy link to clipboard 
Print this post

Don't have floating (*) pins! They sometimes read as 0 and sometimes as 1, and may flip between those or latch up in some nasty way.

(*) implies input pins

JohnEdited by JohnS 2014-06-19
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2294
Posted: 05:41am 18 Jun 2014
Copy link to clipboard 
Print this post

  Modena said   Hey all, is there a way to detect when a wire/circuit connected to a Micromite I/O pin is sent to ground?

Ben

the simple answer to your question:

yes. connect a 10k resistor from your pin to 3v3. this will ensure that reading the pin normally returns a '1'. if you now connect the pin to ground (0v) the pin will return '0'.

for example, the below code assumes you are using pin 2. 10k resistor from pin 2 to 3v3, and a switch from pin 2 to ground.

setpin 2, DIN

do
print pin(2)
pause 10
loop



rob :-)Edited by robert.rozee 2014-06-19
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024