08m2 input test (simple newb question)

PersonX99

New Member
I am trying to test the picaxe 08m2 using input pins. Here is my program:

input c.3
main:
sertxd ("input value ", #pinc.3, cr, lf)
goto main

I also tried a couple of the other pins as well, all with the same results.

I download the program and bring up the terminal window. I have a "floating" wire on the picaxe pin that I switch between floating, +4.5, and ground (all from the picaxe power supply which is 3-AA batteries).
No matter how I connect the wire, I always see a value of "0" on the terminal window.

Can anyone tell me how to configure the picaxe 08m2 to use a pin as an input and correctly monitor it's state via the terminal window?

Thanks.
 

Jamster

Senior Member
Your code is fine :)

Have a look at manual 3 pg 26 which shows how to wire a switch, the resistors are used to protect the PICAXE pin as applying 4.5v directly can damage it permenantly. :)

Jamster
 

nick12ab

Senior Member
Are you connecting the wire to pinC.3 or leg 3 on the IC? Please double check that you are doing this right by looking at the pinout.

Also make sure you have a decoupling capacitor fitted.

applying 4.5v directly can damage it permenantly. :)
Not when the power supply voltage is also 4.5V or more.
 

jaka

Member
Input is only read once. Will always give you 0.
Put main before the input.
Also a delay will make it easyer to read. Say pause 500.

Jim
 

nick12ab

Senior Member
Input is only read once. Will always give you 0.
Put main before the input.
The input command sets the pin as an input, it does not read the input. The posted code is correct and works on a PICAXE-14M2 (and 08M2 in the simulator) so it must be either an 08M2-specific issue or a hardware issue.

@OP: Another thing to try is disconnect the Serial In connection (whilst keeping the Serial Out and 0V connections connected) as if using the RS232 download cable the negative voltage present on that pin might interfere with the input pins, however it won't normally have this much of an effect unless the download circuit is not assembled correctly in the first place.
 

jaka

Member
nick.
Ok I see, but being an occasional, useless programmer, can you explainto me how that works.

Jim
 

nick12ab

Senior Member
nick.
Ok I see, but being an occasional, useless programmer, can you explainto me how that works.
How what works? The input command?

It simply turns the pin specified into an input pin (instead of an output pin). It will only work on bidirectional pins and not output-only pins.

It usually isn't needed since all bidirectional pins are inputs by default so it's only really needed if you want to change a single pin that is currently an output pin into an input pin.
 

jaka

Member
Nick.

I think I have got it.
I wasn't aware that it was possible to read a value in a sertxd command.
Learn something new every day.

Thanks

Jim
 

SD70M

Senior Member
I wasn't aware that it was possible to read a value in a sertxd command.
The code
#pinc.3​
in the sertxd line writes the value of c.3 to the terminal window. C.3, in the OP's code is either 0 = off or 1=on.

Angie
 

PersonX99

New Member
I wired a switch according to manual 3: page 26. Using the program listed in my original post, I continued to only get a value of '0' in the terminal window.

I am using the AXE021 proto board with the pins listed on the circuit board themselves. They seem to work as outputs in other tests I have tried so I assume the connections are ok.

I also tried an external 5-volt source with the ground tied to the 08m2 ground. Same results.
I measured the voltage across the resistors and they look ok. I believe it was about 3.8v at the input pin.

Any ideas as to what I am missing or what I could try?

One idea I had was to expand the program to set another pin's output to high when the input reads '1'. If this were to work, then the problem would point to something related to the serial IO. BTW, I leave the jumper on the AXE021 to "PROG' and not "OUT" otherwise I do not see any output in the terminal window.

Thanks for any feedback. :)
 

nick12ab

Senior Member
One idea I had was to expand the program to set another pin's output to high when the input reads '1'. If this were to work, then the problem would point to something related to the serial IO.
Excellent idea. A way you can do this is to simply set the output pin (e.g. C.1) to the input pin:
Code:
output C.1
do
        pinC.1 = pinC.3
loop
BTW, I leave the jumper on the AXE021 to "PROG' and not "OUT" otherwise I do not see any output in the terminal window.
I was referring to the Serial In connection - to break this connection only you will have to desolder the 22k programming resistor. But try the above idea first.
 

PersonX99

New Member
I will give that a try tonight. I have another 08m2 that I can put directly in a breadboard to try disconnecting the SerialIn connection.
If none of these work, I will try the 18M2 that I just received.
 
Top