2 quick noob Q's

Protolisk

Member
Just 2 quick questions.

How do I have an input give power instead of being ground like normal? For example. I have pin--------switch--------ground. How do I make it so that when the switch is pressed the pin detects it.

How do I have no connection to something? Like its not giving a Low signal or a high signal its just disconnected.
pin----LED------ground.
........|
........|
some over thing sending positive to the LED

See if I send a low signal then the LED stays off no matter what. But if I send a high it stays on. how do I make it so that its just no connected so that it can be used by the other thing.
 

evanh

Senior Member
How do I have an input give power instead of being ground like normal? For example. I have pin--------switch--------ground. How do I make it so that when the switch is pressed the pin detects it.
The usual way is to use a pull-down resistor instead of a pull-up. Section 3 page 25 of the Picaxe manuals has the instructions. I would also add a small ceramic capacitor to the input pins for reliability.

How do I have no connection to something? Like its not giving a Low signal or a high signal its just disconnected.
pin----LED------ground.
........|
........|
some over thing sending positive to the LED

See if I send a low signal then the LED stays off no matter what. But if I send a high it stays on. how do I make it so that its just no connected so that it can be used by the other thing.
Change the pin's mode to an input pin - assuming it can be.


Evan
 

BCJKiwi

Senior Member
@ proto,
1. If you want to detect when a switch is pressed or not then it needs to be high in one state and low in the other. Currently you have pin --- sw ---0V. Change the circuit around to look like the one in Manual3, Page 25.

Suggest a 10k to the Pin and a 100k to 0V. The R and the Sw can be swapped over but it revesrese the 'sense' of the switch.

2. output to an LED requires an output, not an input. Connect up like Manual3 page 8
High pin will light the LED, low pin will turn it off. Make sure the R is around 330R to start with - or check the calculators for LED R's on the net to ensure the LED & PICAXE port are not drawing too much current!

If you want to use the same port for both 1 and 2, then it gets a little more complicated. if you could explain when the LED needs to be on in relation to when the switch is on/off then that should be straightforward. If the LED is an independent output from the switch position input then another port is the simplest way to go.
 

Dave-nz2

New Member
LED lit by either input

How do I have an input give power instead of being ground like normal? ...
If you want to power an LED from a picaxe output pin, as well as from an external input, then you can use two diodes (acting as 1-way valves for current).

They each have their stripey end (cathode) connected to the resistor.

With this diode-OR arrangement, if either input (pin, external, or both) is high then the LED lights, and the LED is off with both inputs Low.

Just to check: Is the external input voltage the same as the voltage that the picaxe is powered at? If so - sweet. If not, then the circuit could be modified to work.
 

Attachments

Protolisk

Member
Oh ok. I thought it was like a command like instead of high or Low its disconnect or something. I was just wondering code wise. So both of those aren't possible code wise.

Thanks anyways.
 

BCJKiwi

Senior Member
It's still not really clear what is intended.

Maybe tri-stating is what you're thinking of.
This works on a port that can be both in an input or an output.

As an output;
High delivers current out.
Low receives current in.
e.g. can be used to turn a LED on or off.

As input, no current flow but able to sense the state of the voltage on the pin - also referred to as hiZ.
e.g. able to tell if a switch is on or off.
 

Dave-nz2

New Member
Could well be possible in code, depends ...

Several thoughts come to mind, and to narrow it down you could give more info of what you are trying to achieve. I find myself asking the same questions as Michael, Evan & BCJ.
 

Protolisk

Member
Ok Say I have something thats common ground. So when I push the switch it completes the circuit. The input pin would have to be on the positive side of the switch. Normally you would put it on the Negative side. But now I dont have a positive on that side of the switch since I connected a input to it. Then if I connect a positive at the same time as the input then it would always be recieving a high signal. Would making it so that it detects on Low not high work? Cause if you pressed it it would still get a high signal.

Is there a way to just break the circuit in code. As in like a High code or a Low except it doesn't give positive or ground?
 

Dippy

Moderator
Post a picture. I thought I had it for a second. It'll save everyone else having to polish their C.Balls and trying to guess what you mean. PLEASE make it easy if you want a quick answer this side of Christmas :)
 

manuka

Senior Member
As a Trans-Tasman Kiwi I usually manage to interpret 'Strine OK, but this is confusing me too. All those Olympic medals won by Aus. must be clouding the poster's mind!

Let's start simply & work up. The manual extract below shows the classic PICAXE reading circuitry - here it's checking switch state at pin0, but just change this to your reading pin (pin2 etc) That 10k value is not critical but ensures a weak but firm pull-down. Had you understood this setup-is it close to your initial needs?
 

Attachments

Last edited:

Charlie_M

New Member
Just 2 quick questions.

How do I have an input give power instead of being ground like normal? For example. I have pin--------switch--------ground. How do I make it so that when the switch is pressed the pin detects it.

How do I have no connection to something? Like its not giving a Low signal or a high signal its just disconnected.
pin----LED------ground.
........|
........|
some over thing sending positive to the LED

See if I send a low signal then the LED stays off no matter what. But if I send a high it stays on. how do I make it so that its just no connected so that it can be used by the other thing.
First
Inputs don't "give" or source power they sink it or recieve it. To see if a input is high or low you do something like this

IF pin x = 1 then
do something
end if
where x is the input you are using. 1 is for a 5v and use 0 for gnd. depending if the switch is connected to 5v or gnd.

Second - a output can only be one of two states.... either low (0) volts or high (5) volts. connect the led so that either a logic 1 or a logic 0 will make it come on. thats all you can do.

Hope this helps. I hope I understand the question.
 

Dippy

Moderator
I guess Charlie has understood the questions? Congrats to Charlie :)

As Charlie says an 'Input' can only sense a high or low. So, as previously said, you stick a resistor between your input pin and positive so that it defaults high (and will be sensed in code as 1 so you can use IFs etc). You connect your normally-open push-button from input pin to ground. When you press the button it connects to pin to ground and sensed in your code as 0.
One resistor (say 10K) and one push-button switch. Easy?

"How do I have no connection to something?"
- leave it disconnected?

"See if I send a low signal then the LED stays off no matter what. But if I send a high it stays on."
- obviously. Thats its job.

"how do I make it so that its just no connected so that it can be used by the other thing."
- connect it to the 'other thing' and not to the PICAXE.

Apologies, but that last bit made no sense at all. Sorry. This is where a drawing would help. And I really don't think you're going to get a proper answer until you've posted one.

Even a clue as to what you are connecting to PICAXE would help. We are not clairvoyant. We do not know your intended circuit. We cannot help (unless just plain guessing) without the information.
 

Michael 2727

Senior Member
What He ^^^^^^^^^ said,,and which chip are you trying this with.
I could mention tri-state but I won't till we get some better feedback to work with.





Thread #7296 needs a revamp. ;)
 
Last edited:

BeanieBots

Moderator
While we are all playing the guessing game, thought I'd have a go.
Firstly, the outputs can be more than just high or low. They can also be tri-state (as mentioned twice already in this thread). The tri-state condition is basically "not connected" to anything, alowing "the LED" to be connected and controlled by "the other thing".
To make an output tri-state, it needs to be made into an input. Only certain PICAXEs on certain pins have the ability to do this.

As stated in most of the replies, tell us in detail what you are actually trying to do. That is, the WHOLE picture of your problem and if possible, a diagram.
 

Protolisk

Member
Ok from now on I'll try and include a pic or a diagram with all of my threads.



See the little diagram in the bottom right hand corner is that what you mean by making high instead?
picture of LED connected wire
Close up

Tell me more abou this tri state. ALso thanks for all the help so far.
 
Last edited:

BeanieBots

Moderator
OK, that's clear and the solution is simple.
It's already been described but I'll do it again.
Put a diode between the 08M pin 7 and the LED (pointy end towards the LED).
Put another diode between "other controller" and the LED (pointy end towards LED).
Now, if EITHER the 08M OR the "other" controller go high, the LED will come on but neither the 08M or the "other" controller will be destroyed. When either is low, the diode will not conduct and thus no current will flow. This is known as "diode OR".

Pin 7 (serout/op0) is output only so it cannot be tri-stated. Even if it could, I would not suggest its use for your application because you do not know when the "other" controller wants to turn on the LED.
 
Last edited:

Michael 2727

Senior Member
Or LED see attached .gif

The drawing package is Free and lives on this site-
http://www.picaxeforum.co.uk/showthread.php?t=7822
Only simple but better than nuthin.

As BeanieB pointed out, pin 0 /Leg 7 on an 08M can only be an output,
pin 3 /Leg 4 on an 08M can only be an input, but pin 1/Leg 6, pin 2/Leg5 and
pin 4 /Leg 3 are programmable I/O pins.
That is why I asked in the very first post what chip are you using ???
Any programmable I/O pin can be made Hi, Low or Tri-State.

Tri-State is simply setting the pin as an "input" it is looking for either a High or Low,
so doesn't matter what it sees.
But programming accidents can and do occur, when you accidently program
a pin to what it shouldn't be. This is called a No-State pin or smoke machine.
So be carefull.
When booting up all pins are set as "high impedance" or input states.

PS: As Hippy points out, a couple of posts further on, use a current limiting resistor on the LED.
Also note a standard diode has a 0.6V to 1V forward drop, in most csaes this won't matter.
( a current limiting resistor is included in the attachment, it's not obvious as a thumbnail though )
 

Attachments

Last edited:

Protolisk

Member
oooooooo ok. Well what type of diode should I use. Also is it ok if I just put one on the PICAXE side not the "other" controller side. The controller side doesn't go off as usually as the PICAXE side so when it does I want to give priority to that one.
 

hippy

Technical Support
Staff member
Any diode should work. I'd use 1N4148 which are quite commonly available.

You need two diodes or you can damage the other's hardware.

You cannot 'give priority'; both have equal control over the LED, it comes on when either wants it on.

Also, don't forget to include a current limiting resistor in series with the LED. Start at 330R or there about.
 
Top