Picaxe 28x problem

taesoon737

New Member
I have made my programming for my picaxe 28x 1 to count up to 7 hours but i realised that picaxe 28x 1 has 7 outputs where the 4511b(which i need to connect the picaxe 28x 1 into so i can display it on the seven segment displays) has only 4 inputs. is there any commands i can use so b0 equals to 4 outputs (ie only 4 outputs controlling the counting part so the other three can be connected to other components like the LED or the buzzer) and not all of them? Or is there any ic which has seven inputs and can covert binary into numbers?
This is my programming. If there is any mistake or any areas to improve on please tell me. This will display the time in hours and minutes.

Code:
if input5 = 1 then goto sub0
goto main 

sub0:
setint %00000001,00000001
for b0 = 0 to 59
let pins = b0 
high portc 1
pause 250
high portc 2
pause 250
high portc 3
pause 250
wait 59
pause 250
next b0
goto sub1

sub1:
setint %00000001, %00000001
for b0 = 100 to 159
let pins = b0
high portc 1
pause 250
high portc 2
pause 250
high portc 3
pause 250
wait 59
pause 250
next b0
goto sub2

sub2:
setint %00000001, %00000001
for b0 = 200 to 259
let pins = b0
high portc 1
pause 250
high portc 2
pause 250
high portc 3
pause 250
wait 59
pause 250
next b0
goto sub3

sub3:
setint %00000001, %00000001
for b0 = 300 to 359
let pins = b0
high portc 1
pause 250
high portc 2
pause 250
high portc 3
pause 250
wait 59
pause 250
next b0 
goto sub4

sub4:
setint %00000001, %00000001
for b0 = 400 to 459
let pins = b0
high portc 1
pause 250
high portc 2
pause 250
high portc 3
pause 250
wait 59
pause 250
next b0
goto sub5

sub5:
setint %00000001, %00000001
for b0 = 500 to 559
let pins = b0
high portc 1
pause 250
high portc 2
pause 250
high portc 3
pause 250
wait 59
pause 250
next b0
goto sub6

sub6:
setint %00000001, %00000001
for b0 = 600 to 659
let pins = b0
high portc 1
pause 250
high portc 2
pause 250
high portc 3
wait 59
pause 250
next b0
goto sub7

sub7:
setint %00000001, %00000001
b0 = 700
let pins = b0
high portc 1
pause 250
high portc 2
pause 250
high portc 3
pause 250 
low portc 1
pause 250
low portc 2
pause 250
low portc 3
pause 250
let pins = 0
goto sub8

sub8:
setint %00000001, %00000001
for b1 = 1 to 60
let pin7 = 1
pause 1000
next b1
goto sub8


interrupt:
let pins = 0
low portc 1
low portc 2
low portc 3
wait 5
goto main
 
Last edited by a moderator:

nick12ab

Senior Member
Hippy has previously written some code as part of his famous (but old) 4-bit PICAXE LCD interfacing routines. This part of the code enables the user of his routines to use the two remaining output pins to be used without interference.
Code:
SendInitCmdByte:

        PAUSE 15                        ; Delay 15mS at 4MHz

    SendCmdByte:

        PEEK $30,rsbit                  ; Recover Out0 and Out1
        rsbit = rsbit &              ; Send to Command register
        GOTO SendCmdOrDataByte

    SendDataByte:

        PEEK $30,rsbit                  ; Recover Out0 and Out1
        rsbit = rsbit &  | RSDATmask ; Send to Data register

    SendCmdOrDataBye:

        pins = byte & 110000 | rsbit ; Put MSB out first
        PULSOUT E,1                     ; Give a 10uS pulse on E
        pins = byte * 010000 | rsbit ; Put LSB out second
        PULSOUT E,1                     ; Give a 10uS pulse on E

        RETURN
The readoutputs command can be used in place of the PEEK command.

Can you adapt the code yourself or is assistance required?

Edit: Please go to the linked source and copy and paste the code from there as the forum has removed the %xxes from the code.
 

geoff07

Senior Member
As a beginner you are discovering that one of the problems with troublesome code can be a lack of clarity. This makes it hard to follow. One of the key aspects of software engineering is the ability to write code that can be maintained and adapted over time. As you learn this new skill you might consider some ideas:

If you create a small main do/loop structure and call everything else as subroutines the logic will be clearer to you and others.

Including code between code] and /code] tags is helpful in the forum. (precede each with a square bracket)

Setint should be called once in the main program and then reset at the end of the interrupt routine, it isn't necessary to keep resetting.

Some symbol names instead of numbers or bytes would help!

There seems to be a lot of repetition thast could be simplified by use of variables.

Ideally, it should be possible to read the code and understand much of what is happening, without having to analyse it deeply. Good luck with the learning curve!
 
Last edited:

nick12ab

Senior Member
Can I ask why the link is in Mexico? Can it be that I am not the only member in this part of the woods?
Hippy used to have his own Freeserve site but a few months ago it dissapeared (Hippy's written about it in this thread). Therefore, the site is only available on the Wayback Machine or any other site that has a copy of it. As the Mexican site loads much faster than the Wayback Machine, that's the one I keep bookmarked.

Hippy's actually in the UK and works at Rev-Ed.
 

westaust55

Moderator
So then, where did you get the code from?
A link to the original project if it is on the web/Internet might help us understand the requirements.

Seem that it will be a good idea to merge your two threads so all the details are together in one "place".
 

DocZaf

Member
Hiya Taesoon737,

Simply having a look at your code....
reveals your using a BYTE variable b0...

Byte varibales can only reach a maximum value of 255
For values higher than 255 one should use WORD variables!

Taking this code for example....
From your subroutine3....
Code:
  for b0 = 300 to 359
    let pins = b0
    high portc 1
    pause 250
    high portc 2
    pause 250
    high portc 3
    pause 250
    wait 59
    pause 250
  next b0
If you enter that in your programming environment and run it...
You will notice that b0 ACTUALLY starts at 40-something....
NOT at 300

This is I think becuase when the variable reaches its maximum value capacity,
it rolls over BACK to 0 (zero) and continues from zero upwards around to 255 again (in the case of a BYTE variable).


DocZaf

[EDIT]
Its probably better to use one variable for the pins..... b0
And other vars for the counters... w1 or w2 etc
but NOT w0 as w0 is b0 + b1
[/EDIT]
 
Last edited:

hippy

Ex-Staff (retired)
Code:
interrupt:
let pins = 0
low portc 1
low portc 2
low portc 3
wait 5
goto main
You cannot GOTO out of the interrupt routine, you need to use RETURN.

It's not entirely clear why you have an interrupt routine and exactly what your hardware is or your requirements are. It is always best to post a circuit diagram of what you have and also start with simpler code; get that working before getting more complicated.
 
Top