Hairy Animal
Member
Hello ever helpful experts. I'm totally baffled by what should be a really simple circuit/software using a centre-off toggle switch to select up in one direction and down in the other. Basically, the 'Down' direction of the switch works fine but not the 'Up', using the serial-in pin, C.5.
This is the relevant bit of the circuit and (being short on pins as ever because I like the 08M2 and have lots of them) I've had to use the C.5-Serial In pin as one of my inputs. I discovered some time ago that it's vital to use DISCONNECT in the code when doing this but it still doesn't work.
These are the relevant bits from the code:
And to make sure I wasn't doing anything silly, I tried a simulation (v.6.0.6.2 running in Windows XP Pro) with this code:
and of course it runs perfectly doing exactly what I expected the live code to do.
I assumed that maybe the hardware was at fault but putting a meter on pin 2 confirms that it's getting a logic high when the switch is up and low otherwise.
Having ruled out a hardware problem I assume that it's my software but I'd be most grateful if someone could please point out what I'm doing wrong?
Thanks.
This is the relevant bit of the circuit and (being short on pins as ever because I like the 08M2 and have lots of them) I've had to use the C.5-Serial In pin as one of my inputs. I discovered some time ago that it's vital to use DISCONNECT in the code when doing this but it still doesn't work.
These are the relevant bits from the code:
Code:
; Version 1 using a PICAXE 8M2+ on an AXE092 board.
; Displaying on a 2-line x 16 chr. LCD.
;
#picaxe 08M2
PAUSE 2000
DISCONNECT
#NO_DATA
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Outputs
SYMBOL LCDout = C.0
; C.1 - I2C SCL to RTC board with DS3231 & 24C32 memory.
; C.2 - I2C SDA to RTC board with DS3231 & 24C32 memory.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Inputs
SYMBOL tdown = pinC.3
SYMBOL tempsensor = C.4
SYMBOL tup = pinC.5
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main:
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IF tup = 1 THEN
SEROUT LCDout,N2400,(254,143,"U") ; "U" at end of line one.
ELSE
SEROUT LCDout,N2400,(254,143," ") ; " " at end of line one.
ENDIF
IF tdown = 1 THEN
SEROUT LCDout,N2400,(254,143,"D") ; "D" at end of line one.
ELSE
SEROUT LCDout,N2400,(254,143," ") ; " " at end of line one.
ENDIF
GOTO main
END
Code:
; Version 1 using a PICAXE 8M2+ on an AXE092 board.
; Displaying on a 2-line x 16 chr. LCD.
;
#picaxe 08M2
PAUSE 2000
DISCONNECT
#NO_DATA
; 640/2048 bytes
; Last save date 29/11/2020
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Outputs
SYMBOL LCDout = C.0
; C.1 - I2C SCL to RTC board with DS3231 & 24C32 memory.
; C.2 - I2C SDA to RTC board with DS3231 & 24C32 memory.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Inputs
SYMBOL tdown = pinC.3
SYMBOL tup = pinC.5
main:
IF tup = 1 THEN
sertxd("Up",cr,lf)
; SEROUT LCDout,N2400,(254,143,"U") ;
ELSE
sertxd("Not up",cr,lf)
; SEROUT LCDout,N2400,(254,143," ") ;
ENDIF
IF tdown = 1 THEN
sertxd("Down",cr,lf)
; SEROUT LCDout,N2400,(254,143,"D") ;
ELSE
sertxd("Not down",cr,lf)
; SEROUT LCDout,N2400,(254,143," ") ;
ENDIF
GOTO main
I assumed that maybe the hardware was at fault but putting a meter on pin 2 confirms that it's getting a logic high when the switch is up and low otherwise.
Having ruled out a hardware problem I assume that it's my software but I'd be most grateful if someone could please point out what I'm doing wrong?
Thanks.