Help Help please 28x1 and lcd ???

Help Help please 28x1 and lcd MY FAULT SORRY

Hi all i am writing a small program for a project to monitor Disabled toilits alarms
The first test program works in the simulator and on my board. The second program works on the simulator BUT NOT on my board.

Pin 0 = high
prog 1 on the sim works ok, displays world news
prog 1 on my board works ok, displays world news

prog 2 on the sim works ok, displays world news
prog 2 on my board works ok, displays world news

Now the strange bit?????

Pin1 = high
prog 1 on the sim works ok, displays Bagage reclame
prog 1 on my board works ok, displays Bagage reclame

prog 2 on the sim works ok, displays Bagage reclame
prog 2 on my board NOT WORKING , displays .....................

no its not my board
no its not the display
no is not the psu

As you can see i have been removing symboles and trying to free up memory i will keep trying different things but would welcome any HELP

Thank you Andy Quirot (Jersey Channel Islands)

-----------------------------------------------prog1:----------------------------------
Main:
b9=b9+1 ' Display dot counter
if b9=<16 then
serout 7,T2400,(".")
else
b9=0
serout 7,T2400, (254,1)
pause 30
endif

if pin0 = 1 then gosub alarm1
if pin1 = 1 then gosub alarm2
if pin2 = 1 then gosub alarm3
if pin3 = 1 then gosub alarm4
if pin4 = 1 then gosub alarm5


pause 100
'low sounder
'low led

goto main

Alarm1:
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," WORLD NEWS ")
pause 1000
return

Alarm2:
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," BAGGAGE RECLAIM ")
pause 1000
return

Alarm3:
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," STARBUCKS ")
pause 1000
return

Alarm4:
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," ATM AIRSIDE ")
pause 1000
return

Alarm5:
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," DUTY FREE CP6 ")
pause 1000
return

------------------------------------------------prog2---------------------------

' alarm In 0 pin 11 World News
' alarm In 1 pin 12 Bagage Reclame
' alarm In 2 pin 13 Starbucks
' alarm In 3 pin 14 ATM Airside
' alarm In 4 pin 15 Duty Free CP6
' alarm In 5 pin 16 Gate 12
' alarm In 6 pin 17 Gate 6
' alarm In 7 pin 18 JLF 1St Floor
' Mute button on pin 02
' Pizeo Output 6 Pin 27
' led output 5 Pin 28
let dirsc = %00000000


'symbol World news alarm = pin0
'symbol Baggage Alarm= pin1
'symbol Starbucks = pin2
'symbol Atm Airside = pin3
'Symbol pin4 = pin4
'Symbol pin5 = pin5
'symbol pin6 = pin6
'symbol pin7 = pin7
'symbol 1 = 1
symbol ok = 0
symbol led = 5
Symbol Sounder = 6
Symbol worldnews = b0
Symbol Baggage = b1
Symbol Starbucks = b2
Symbol ATM = b3
Symbol Dutyfree = b4
Symbol Gate12 = b5
Symbol Gate6 = b6
Symbol JLF = b7
symbol Mutebutton = b8
#picaxe 28x1


Main:'*********************** MAIN PROGRAM *******************
b9=b9+1 ' Display dot counter
if b9=<16 then
serout 7,T2400,(".")
else
b9=0
serout 7,T2400, (254,1)
pause 30
endif

if pin0 = 1 then goto alarm
if pin1 = 1 then goto alarm
if pin2 = 1 then goto alarm
if pin3 = 1 then goto alarm
if pin4 = 1 then goto alarm
if pin5 = 1 then goto alarm
if pin6 = 1 then goto alarm
if pin7 = 1 then goto alarm



pause 100
low sounder
low led

goto main

alarm:' **************************** ALARM **************************
'high Sounder
pause 100
'readadc 0,mutebutton
if pin0 = 1 then gosub Alarmstate1
if pin0 = ok and Worldnews = 1 then goto asa1
if Mutebutton => 5 then mute
if pin1 = 1 then gosub Alarmstate2
if pin1 = ok and Baggage = 1 then goto asa2
if Mutebutton => 5 then mute
if pin2 = 1 then gosub Alarmstate3
if pin2 = ok and Starbucks = 1 then goto asa3
if Mutebutton => 5 then mute
if pin3 = 1 then gosub Alarmstate4
if pin3 = ok and ATM = 1 then goto asa4
if Mutebutton => 5 then mute
if pin4 = 1 then gosub Alarmstate5
if pin4 = ok and Dutyfree = 1 then goto asa5
if Mutebutton => 5 then mute
if pin5 = 1 then gosub Alarmstate6
if pin5 = ok and Gate12 = 1 then goto asa6
if Mutebutton => 5 then mute
if pin6 = 1 then gosub Alarmstate7
if pin6 = ok and Gate6 = 1 then goto asa7
if Mutebutton => 5 then mute
if pin7 = 1 then gosub Alarmstate8
if pin7 = ok and Jlf = 1 then goto asa8

readadc 0,mutebutton
if Mutebutton => 5 then mute
low Sounder
'untitled
'tune 6, 8,($40,$44,$50,$55,$57)
pause 500
goto alarm


goto main

Alarmstate1:
Worldnews = 1
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," WORLD NEWS ")
pause 1000
return
Alarmstate2:
Baggage = 1
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," BAGGAGE RECLAIM ")
pause 1000
return
Alarmstate3:
Starbucks = 1
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," STARBUCKS ")
pause 1000
return
Alarmstate4:
ATM = 1
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," ATM AIRSIDE ")
pause 1000
return
Alarmstate5:
Dutyfree = 1
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," DUTY FREE CP6 ")
pause 1000
return
Alarmstate6:
Gate12 = 1
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," GATE 12 ")
pause 1000
return
Alarmstate7:
Gate6 = 1
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," GATE 6 ")
pause 1000
return
Alarmstate8:
Jlf = 1
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," JLF 1ST FLOOR ")
pause 1000
return





reset1:
low sounder
low led
goto main

mute:' ******************** MUTE *********************************
low Sounder ' turn buzz off
high Led ' turn led on
if pin0 = 1 and Worldnews = ok then reset1
if pin1 = 1 and Baggage = ok then reset1
if pin2 = 1 and Starbucks = ok then reset1
if pin3 = 1 and Atm = ok then reset1
if pin4 = 1 and Dutyfree = ok then reset1
if pin5 = 1 and Gate12 = ok then reset1
if pin6 = 1 and Gate6 = ok then reset1
if pin7 = 1 and Jlf = ok then reset1
if pin0 = ok and Worldnews = 1 then goto as01
if pin1 = ok and Baggage = 1 then goto as02
if pin2 = ok and Starbucks = 1 then goto as03
if pin3 = ok and Atm = 1 then goto as04
if pin4 = ok and Dutyfree = 1 then goto as05
if pin5 = ok and Gate12 = 1 then goto as06
if pin6 = ok and Gate6 = 1 then goto as07
if Jlf = ok and Jlf = 1 then goto as08

if pin0 = 0 and pin1 = 0 and pin2 = 0 and pin3 = 0 and pin4 = 0 and pin5 = 0 and pin6 = 0 and pin7 = 0 then goto Allok
if pin0 = 1 then
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," WORLD NEWS ")
pause 1000
endif

if pin1 = 1 then
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," BAGGAGE RECLAIM ")
pause 1000
end if

if pin2 = 1 then
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," STARBUCKS ")
pause 1000
end if

if pin3 = 1 then
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," ATM AIRSIDE ")
pause 1000
end if

if pin4 = 1 then
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," DUTY FREE CP6 ")
pause 1000
end if

if pin5= 1 then
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," GATE 12 ")
pause 1000
end if

if pin6 = 1 then
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," GATE 6 ")
pause 1000
end if

if pin7 = 1 then
serout 7,T2400, (254,1)
serout 7,T2400,(254,1," JLF 1ST FLOOR ")
pause 1000
end if
pause 100
low Led
pause 100
goto mute

as01:
Worldnews = ok
goto mute
as02:
Baggage = ok
goto mute
as03:
Starbucks = ok
goto mute
as04:
ATM = ok
goto mute
as05:
Dutyfree = ok
goto mute
as06:
Gate12 = ok
goto mute
as07:
Gate6 = ok
goto mute
as08:
Jlf = ok
goto mute

asa1:
Worldnews = ok
goto reset1
asa2:
Baggage = ok
goto reset1
asa3:
Starbucks = ok
goto reset1
asa4:
ATM = ok
goto reset1
asa5:
Dutyfree = ok
goto reset1
asa6:
Gate12 = ok
goto reset1
asa7:
Gate6 = ok
goto reset1
asa8:
Jlf = ok
goto reset1

Allok:
if pin0 = ok and pin1 = ok and pin2 = ok and pin3 = ok and pin4 = ok and pin5 = ok and pin6 = ok and pin7 = ok then goto reset1
goto alarm
 
Last edited:

Chavaquiah

Senior Member
Congratulations! You won first prize for spaghetti code. Left all competition in the dust. :D

For how long does pin1 stay high? Unless it holds high for more than 100ms, the alarm2 routine will not pick the signal.

Rather than working on saving memory, I'd suggest you try to rewrite your program in a more structured way. And, BTW, removing symbols will do nothing to save memory. A few other things will. For instance, instead of
Code:
if pin0 = 1 then goto alarm
if pin1 = 1 then goto alarm
if pin2 = 1 then goto alarm
if pin3 = 1 then goto alarm
if pin4 = 1 then goto alarm
if pin5 = 1 then goto alarm
if pin6 = 1 then goto alarm
if pin7 = 1 then goto alarm
try a simple
Code:
if pins > 0 then goto alarm
Try to think of what path code should follow when pin2 is high and place some debugging info (output short messages) along the way, so you can see at what point it deviates from the expected behaviour.
 
Pin 1 stays high till somebody goes to the place where the alarm is trigered could be up to 10 miniuts
as for the inputs this was ritten like this for testing and not how the orignal program looks.

i have tryed adding debug comands all ove the program and it dose not help it should see pin1 high and go someware like program 1.
I was removing sumbols and labels to try to free up storage verbile space.

Regards Andy Quirot
 
Hi there
Changing to
if pins > 0 then goto alarm
did not make any diffrence But thanks for the tip

Regards Andy Quirot
 

lanternfish

Senior Member
Like Chavaquiah I find the posted code very difficult to follow. If your original program is better structured then you should use that for testing.
Some of your symbols seemed unnecessary e.g. SYMBOL pin0 = pin0 and are essentially redundant. However something like SYMBOL WorldNewsTrigger = pin0 better identifies the purpose of the input or output.
Is it a hardware fault? Do you have a pull-down resistor on your input? A full schematic and/or good photo of the circuit can help greatly.
 
Last edited:
Hi there
The line symbol pin0 = pin0 normaile reads Symbol Wna=pin0
very musc like your surjestion (SYMBOL WorldNewsTrigger = pin0)
as i said it have been modefied for testing.

Q you say Do you have a pull-down resistor on your input?

yes the board is correct and all inputs have pulldown resistors , Input pin0 works all others dont on the second program but do on the first so it must be a software isue.
Regards Andy Quirot
 

Svejk

Senior Member
Your main problem seems to be too many goto's.

Just to make it clear: when a contact is closed on any of the toilets, an LED should lit, a buzer should sound and a message on LCD should display where the alarm is. The buzzer is muted by a readadc (I didn't exactly get it) and the gadget is reset by?

Am I right? If yes, the program can be made about 10% of the orginal code. I can help you with that. I'm more concerned about hardware as it seems to have long lines exposed to interferences [I know there are plenty in commercial buildings] and doesn't take in account cable breakage.
 

Chavaquiah

Senior Member
Input pin0 works all others dont on the second program but do on the first so it must be a software isue.
That may well be true, but I wouldn't automatically rule out a hardware issue. For one, the second program seems to be checking for more inputs than the first.

As I suggested before, filling the code with a few debug messages at strategic points would allow you to check that the Picaxe is seeing the inputs it's supposed to.

On the other hand, the current code is very convoluted and difficult to follow. I'd accept Svejk's help to streamline it. Otherwise, debugging will be a nightmare.
 

hippy

Ex-Staff (retired)
My advice would be strip the code back to a much smaller program for testing; detect and clear one alarm. Get that working reliably, solving hardware and software issues, and then extend it to include another alarm, test that, and then add more alarms testing as you go.

Problems in a much smaller program will be easier to spot and such code will be more understandable to others who are looking over it.
 
Yes i have striped the code back to a small seition ie the test program.
if you run the first one on the picaxe simulator you can follow what hapens when you make pin1 high.

If ou run the second program on the simulator you can see that when you make pin1 high it works.

On the board program 1 works ok
on the board program 2 dont work

I am going to try to pos a circuit

Regards Andy Quirot
 

Attachments

hippy

Ex-Staff (retired)
So how exactly do your buttons connect to the PICAXE ?

From the circuit diagram they appear to connect to pins 11 through 18, you appear to pass 0V to the buttons on the 'molex' connection, yet you have pull-downs on the inputs - how do you get a positive signal in as a button push ?

You need to have pull-ups and active low signalling or keep pull-downs and pass +V to the buttons - the first is arguably better as 0V to buttons can be the screen of a cable.

Your 10K/10K input buffering acts as a potential divider; it would be far better to put the pull-up / pull-down on the molex inputs, then feed that signal via a 10K to the PICAXE input pins.
 
Last edited:
hi there the molex conector has 0 volts on it if i require it.
the buttons are conected to the 5 volt power rail and conect to the inputs.
the 10K inline resistor is a link 0k0 at the moment they may be added later as the input may be 12 volts

Regards Andy Quirot

P.S. As i said in the first post the board works ok with program 1, but not program 2
 
Thanks for the advice about the input ressistors i have changed them around on the drawing and re routed them on the pcb for the next pcb i make

Regards Andy Quirot
 

hippy

Ex-Staff (retired)
Have you got stripped-down versions of code which don't work and do work we can look at ?
 
Hi the code at the top of the post is the striped down version that will work if i make any of the input pins high on the sim AND the board

The second program will work ok on the sim but WONT work on the same board

i have just altered some of the gosubs to goto's and will need to try at home tonight on the board.


Regards Andy Quirot
 

hippy

Ex-Staff (retired)
Stripped-down is indeed subjective but I wouldn't call near 300 lines of source code stripped-down.

Perhaps you can provide code which runs in the simulator but fails on the board that just handles button 1 with all else removed on the principle that 'all other buttons won't be used so no need to have any code to handle them'. Otherwise there's just too much for casual readers unfamiliar with it to get their heads around and help if they could.
 
My sincere apologies to all that tryed to help me with this problum i will admit it was MY FAULT.
I was holding the mute line high not low pin2 adc0 on the chip.

Regards Andy Quirot
 
Top