what am i doing wrong with inputs?

#1
just got my 14M's today and started playing around. I don't know what I am doing wrong but something must not be right. if i write something small to turn an output high or low with pauses in a loop it works fine. but i try something like what is below to turn all the outputs high when input 0 is high I get nothing. I even put the debug in there and when i push the button b0 = 1 shows in the debug screen and she b0 = 0 when i let off. this should mean my button is working but the outputs never go high. I tried with two different 14M's with the same result.

I am using 3 AAA batteries to power my board and i have the button inbetween +V and pin0 and 10k resistor between 0V and pin0.

main2:
b0 = pins
debug b0
if pin0 = 1 then
high 0
high 1
high 2
high 3
high 4
high 5
else
low 0
low 1
low 2
low 3
low 4
low 5
end if
goto main2

Edited by - orko007 on 16/08/2007 18:27:29
 
#3
That shouldn't make any difference. The code 'should' work.
b0=pins could potentially be any value if unused inputs are not tied down.
How is a high output detected? LED maybe wired wrong?

Does it work OK if the input test is removed?
eg
main2:
high 1
pause 500
low 1
pause 500
goto main2
 

Technical

Technical Support
Staff member
#4
If you are using the AXE117 project board (as supplied in the 14M starter pack) make sure the LEDs are between V+ and the output (not output and 0V) as the board has a darlington driver buffer chip.
 
#5
"Change the line if pin0=1 then to if b0=1 then."

I did this and it works. changed back to pin0=1 and it does not work




"That shouldn't make any difference. The code 'should' work.
b0=pins could potentially be any value if unused inputs are not tied down.
How is a high output detected? LED maybe wired wrong?

Does it work OK if the input test is removed?
eg
main2:
high 1
pause 500
low 1
pause 500
goto main2"

the Output is tested by LED and also i am testing with a multimeter. If I remove the input test like you said it works fine, it will flash all day long so i know it's not the LED. and doing as suggested above works as well with If b0=1.
I am not sure what is going on. I tried using "debug pins" thinking it would display at the top of the debug screen 0000001 if input 0 was high but i do not get anything so maybe that is not the correct use.

Also this is not a purchased project board it is my own creation but all that is there is the serial download which works find. one button on input 0 and LED's on the outputs.
 

hippy

Technical Support
Staff member
#6
It does seem odd. here's something else you can try ...<code><pre><font size=2 face='Courier'>#picaxe14m

SetFreq M8
Do

Pause 500

b1 = pins
bit0 = pin0
bit1 = pin1
bit2 = pin2
bit3 = pin3
bit4 = pin4
bit5 = pin5

SERTXD(#bit13,#bit12,#bit11,#bit10,#bit9,#bit8,CR,LF)
SERTXD(#bit5,#bit4,#bit3,#bit2,#bit1,#bit0,CR,LF)
SERTXD(#pin5,#pin4,#pin3,#pin2,#pin1,#pin0,CR,LF,CR,LF)

Loop </font></pre></code> Fire up the Terminal Window at 9600 baud and the bits in each colum should be the same in all blocks. There may be a few discrepancies due to noise and the fact they do not read all the inputs at the same time, but anything with a pull-up/down and a button should be consistent while the button is held or released.
 
#7
Might also be a good idea to state programming editor version and 14M revision.
I don't have any 14Ms but maybe somebody could try to duplicate your issue using the same versions.
 
G

Guest

Guest
#8
OK Program editor is 5.1.5 and 14M firmware is 9.A hopefully im getting that in the right place. it is what it says after a download.
I am in the U.S and purchased these from a retailer on ebay as that is the only place i have been able to find them here.

I tried what hippy suggested and it wasn't working. i removed pin5 as there are only 5 inputs 0-4. still did not work. finally worked with just inputs 3 and 4 like below.

#picaxe14m

SetFreq M8
Do

Pause 500

b1 = pins
bit3 = pin3
bit4 = pin4


SERTXD(#bit13,#bit12,#bit11,#bit10,#bit9,#bit8,CR,LF)
SERTXD(#bit5,#bit4,#bit3,#bit2,#bit1,#bit0,CR,LF)
SERTXD(#pin5,#pin4,#pin3,#pin2,#pin1,#pin0,CR,LF,CR,LF)

Loop

results:
button to input 0
000001
000000
001000

button to input 1
000010
000000
010000

button to input 2
000100
000000
100000

button to input 3
001000
001000
000000

button to input 4
010000
010000
000000

to me that mean input 0 is reading as pin 3. looking at the advanced layout pin0 also = portc pin3. So i changed my program to if portc pin3 = 1 and it works. same goes for inputs 1 and 2 if I use portc pin 4 and 5 those work as well. pins 3 and 4 work as they should but still do not register correctly in the bottom line of the serial output.

I don't beleive that i should have to use the portc commands to to use these pins i thought that was reserved for advanced use. I am glad I can actually use this pin now but i do not think it is 100% correct. if anyone has any additional info based i what i have provided that would be great.

Thanks again Hippy and beaniebots you guys are great.
 

Wrenow

Senior Member
#9
ORKO - just so you know, there are 2 sources for the chips in the US - check the distributors list. Note I said sources for the chips, not technical support. The technical support is here. Some people expect the suppliers to be able to answer all their questions, and that is not realistic in this situation.

I have bought from both with no problems whatsoever. Both carry the 14M and starter kits. There is also a supplier in Canada, by the way.

Check the distributors linked from the Rev-Ed Home Page.

Cheers,

Wreno
 
#10
I've not played with a 14M myself yet so cannot speak from first hand experience but have a look at pages 70 - 71 of manual 1 for further insights.

Which physical leg is your input connected to?

My understanding (which may be wrong) is this:-
pin0 is physical leg 7
portc pin3 is also physical 7
portc pin0 is physical leg 10

 

Technical

Technical Support
Staff member
#11
One of the issues with your original program is that you are corrupting the serial out pin (used for debug and sertxd) as it is also output 0. So high 0, low 0 commands at the same time confuse the computer and stop the serial commands functioning correctly. Hence debug etc won't show on screen correctly.

We've tried this program (high 0 / low 0 commented out) with a 14M firmware .C and it works ok (as did Hippy's test program). We'll hook out a firmware .A and test on that aswell.

main2:
b0 = pins
debug b0
if pin0 = 1 then
'high 0
high 1
high 2
high 3
high 4
high 5
else
'low 0
low 1
low 2
low 3
low 4
low 5
end if
goto main2


Edited by - Technical on 17/08/2007 10:11:39
 
#13
THis still did not work for me addressing the pin as &quot;pin0&quot; but all works fine when using &quot;portc pin3&quot;. If is fine for now and in the future i will purchase from suppliers listed on the wesite and hopefully get a later version chip.

thanks for the help.
 
Top