hell.p 20m2 pin c.7

late_voyager

New Member
Hi
I have a project looking at 3 inputs on a 20xm2.
checking c.4, c.5 and c.7... just run simple prog to check all inputs, all work but c,7.
tried new chip, solder joints etc even went direct to pin.. same all but c.7
am i missing something with the input of the chip?
if pinC.4=1 or pinc.5=1 or pinb.6=1 then high b.7
pause 50
low b.7
 

late_voyager

New Member
C.7 doesn't appear anywhere in your code. Could that be it? :)
hi sorry changed it to b.6 to see if that was working, thats ok.
returned code... same :(
Main:
debug
low B.5
if pinC.4=1 or pinC.5=1 or pinC.7=1 then high b.7
pause 50
low b.7
goto main
 

erco

Senior Member
If it worked using b.6 it clearly should work with c.7. Bad wiring? C.7 is adjacent to the Serial In programming pin, which is pulled low through resistors. Maybe a solder blob connecting?
 

erco

Senior Member
Run program while connecting C.7 to ground and +5V.

do
sertxd (#pinc.7,13,10)
loop
 

late_voyager

New Member
hmmm when i run this it works
Main:
debug


serout C.0,N2400,(254,128) ' move to start of first line
serout C.0,N2400,(#pinc.7,13,10)


if pinC.4=1 or pinc.5=1 or pinc.7=1 then high b.7
pause 50
low b.7
endif
goto main
 

late_voyager

New Member
but this it dont..
Code:
init:
pause 200
FVRSETUP FVR2048   'Set Fixed Voltage Reference = 2.048 Volts
ADCCONFIG %011     'Set ADC to FVR
Symbol batt = w1            ; Word variable for the calibadc10 reading
calibadc10 batt            ; Take the reference reading
pause 20


Main:   
debug
low B.5
if pinC.4=1 or pinc.5=1 or pinc.7=1 then high b.7
pause 50
low b.7
' relay 1 top B.5
' relay B.6


elseif pinB.1=1 and pinB.2=0 and pinB.3=0 and pinB.4=0  then
    serout C.0,N2400,(254,128)
    serout C.0,N2400,("relay            ")
    goto p_relay
elseif pinB.1=0 and pinB.2=1 and pinB.3=0 and pinB.4=0  then
    serout C.0,N2400,(254,128)
    serout C.0,N2400,("sensor            ")
    goto p_relay
else gosub volt
endif
goto main   


p_buzz:
high B.7
pause 50
goto main


Volt:
readadc10 B.0, batt '3.5v batt
    batt = batt *17
      bintoascii batt,b4,b5,b6,b7,b8
   
readadc10 C.2, batt ' 24v batt
        batt = batt  *27
      bintoascii batt,b12,b13,b14,b15,b16
    serout C.0,N2400,(254,128)
    serout C.0,N2400,( "PLUG IN CABLE.. "   )    
    serout C.0,N2400,(254,192)
    serout C.0,N2400,("Batt ",b13,b14,"v - ",b6,".",b7,"v ")

goto main

p_relay:
' relay 1 trigger B.5
' relay 2 trigger B.6

' relay s2 in C.4 centre pin NC
' relay s3 in C.7 bottom pin NO

serout C.0,N2400,(254,128)
    serout C.0,N2400,("RELAY TEST           ")
    serout C.0,N2400,(254,192)
    serout C.0,N2400,("     wait...     ")
    pause 50
if pinC.4 = 0 and pinC.7 = 0 then
    serout C.0,N2400,(254,192)
    serout C.0,N2400,(" *** a *** ")
    pause 20
    goto main
elseif pinC.4 = 1 and pinC.7 = 1 then
    serout C.0,N2400,(254,192)
    serout C.0,N2400,(" *** b *** ")
    pause 20
    goto main
elseif pinC.4 = 1 and pinC.7 = 0 then
    serout C.0,N2400,(254,192)
    serout C.0,N2400,(" *** c *** ")
    pause 20
    goto main   
   
elseif pinC.4 = 0 and pinC.7 = 1 then
    high B.5 ' relay 1 (top)   
    pause 2000
endif

if pinC.4 = 0 and pinC.7 = 1 then
    serout C.0,N2400,(254,192)
    serout C.0,N2400,("   PASS PASS    ")
    pause 1000
elseif pinC.4 = 0 and pinC.7 = 0 then
    serout C.0,N2400,(254,192)
    serout C.0,N2400,(" *** FAILED *** ")
    pause 20
elseif pinC.4 = 1 and pinC.7 = 1 then
    serout C.0,N2400,(254,192)
    serout C.0,N2400,(" *** FAILED *** ")
elseif pinC.4 = 1 and pinC.7 = 0 then
    serout C.0,N2400,(254,192)
    serout C.0,N2400,(" *** FAILED *** ")   
    pause 20   
low B.5
pause 500
endif

    goto main
 
Last edited by a moderator:

late_voyager

New Member
run this and dont work...

Code:
init:
pause 200
FVRSETUP FVR2048   'Set Fixed Voltage Reference = 2.048 Volts
ADCCONFIG %011     'Set ADC to FVR
Symbol batt = w1            ; Word variable for the calibadc10 reading
calibadc10 batt            ; Take the reference reading
pause 20

Main:   
debug

   
    serout C.0,N2400,(254,128)  ' move to start of first line
    serout C.0,N2400,(#pinc.7,13,10)


if pinC.4=1 or pinc.5=1 or pinc.7=1 then high b.7
pause 50
low b.7
endif
goto main
 
Last edited:

late_voyager

New Member
this works....
Code:
Main:   
debug

   
    serout C.0,N2400,(254,128)  ' move to start of first line
    serout C.0,N2400,(#pinc.7,13,10)


if pinC.4=1 or pinc.5=1 or pinc.7=1 then high b.7
pause 50
low b.7
endif
goto main
 
Last edited:

late_voyager

New Member
when i rem the calibadc10 batt ; Take the reference reading
it works??
Code:
init:
pause 200
FVRSETUP FVR2048   'Set Fixed Voltage Reference = 2.048 Volts
ADCCONFIG %011     'Set ADC to FVR
Symbol batt = w1            ; Word variable for the calibadc10 reading
'calibadc10 batt            ; Take the reference reading
pause 20
 
Last edited:

erco

Senior Member
Hmmm. Not sure about this one. Unlike C.4 and C.5, pin C.7 has ADC capability, possibly related. Is it an option for you to use input-only C.6 instead of C.7, or have you made a million of these PCBs already?
 

erco

Senior Member
He wants C.7 as input.


@ LATE_VOYAGER: Just for sport,, try INPUT C.7 after CALIBADC.
 

hippy

Technical Support
Staff member
Unlike C.4 and C.5, pin C.7 has ADC capability, possibly related.
Just for sport,, try INPUT C.7 after CALIBADC.
Right on the first, close on the second.

It appears that the CALIBADC is turning C.7 into an ADC Input and, once that's done, the C.7 digital input always then reads low.

Adding an "adcsetup=0" turns off the ADC settings, restores inputs back to digital usage, including the ADC on C.7. This works for me on a genuine 20M2 firmware 8.A chip -
Rich (BB code):
#Picaxe 20M2

Init:

  FvrSetup FVR2048
  AdcConfig %011
  CalibAdc10 w1

  adcSetup = 0 ; Restore C.7 to digital input use

MainLoop:
  Do
    If pinC.7 = 1 Then
      High B.7
    Else
      Low  B.7
    End If
  Loop
 

erco

Senior Member
Most excellent work, hippy! How nice that late_voyager, a new member, discovered a singularity in the fabric of space-time.
 
Top