Picaxe 28x

pillow face

New Member
I notice on the data sheet for the PICAXE 28X chip it says that the 8 inputs on the chip can be converted into 8 digital outputs. I can not find any info on how this is done. I presume it is some how done on the programming software PIC Logicator? Please can you help!?

Thanks.
 

hippy

Ex-Staff (retired)
As best as I can tell from a quick experiment with Logicator for PIC(R) micros, you need to drag "BASIC" blocks from the Common section of the Command List and edit those to the appropriate "LET DIRSC=" and "LET PINSC=" commands.

The BASIC blocks cannot be simulated but will appear as entered when converted to a Basic Program.
 

pillow face

New Member
this is my first programme that i have writen in PICAXE programming Editor and im not realy sure what im doing. I have posted my code below, i have tryed simulating but i am having some trouble with the if commands im not sure how to use the endif command, but when having a look in logicator there arnt any endif when i convert the flowsheet into basic. i will probably have to put my basic commands into a basic box in logicator because that is the only software my school has, will that work?
Code:
label_1:
		let b0=0
		let b1=0
		let b2=1
		let b3=1
		let b4=3
		let b5=0
		let b6=1
		high 4
		high 5
		high 6
		high 7
		high 8
label_2:
		if b0=0 then let b2=1
		if b1=0 then let b3=1
		if b0=7 then let b2=-1
		if b1=5 then gosub label_27
		let b0=b0+b2
		let b1=b1+b3
		if pin3 = 1 then let b4=b4+1
		if pin4 = 1 then let b4=b4-1
		if b4=0 then let b4=1
		if b4=6 then let b4=5
		if pin1 = 1 then goto label_8
label_35:	
		if b5=10 then gosub label_9
		if b1=1 then gosub label_10
		if b1=2 then gosub label_11
		if b1=3 then gosub label_12
		if b1=4 then gosub label_13
		if b1=5 then gosub label_14
		if b0=1 then gosub label_15
		if b0=2 then gosub label_16
		if b0=3 then gosub label_17
		if b0=4 then gosub label_18
		if b0=5 then gosub label_19
		if b0=6 then gosub label_20
		if b0=7 then gosub label_21
label_30:	if b4=1 then goto label_22
label_31:	if b4=2 then goto label_23
label_32:	if b4=3 then goto label_24
label_33:	if b4=4 then goto label_25
label_34:	if b4=5 then goto label_26
		if b6=1 then let b7=500
		if b6=2 then let b7=450
		if b6=3 then let b7=400
		if b6=4 then let b7=350
		if b6=5 then let b7=300
		if b6=6 then let b7=250
		if b6=7 then let b7=200
		if b6=8 then let b7=150
		if b6=9 then let b7=100
		pause b7
		goto label_2
label_8:
		pause 1000
		if pin1 = 1 then goto label_35
		goto label_8
label_9:
		let b5=b5-10
		if b6=9 then goto label_2
		let b6=b6+1
		high 16
		low 16
		return
label_10:
		low 4
		high 5
		return
label_11:
		high 4
		low 5
		high 6
		return
label_12:
		high 5
		low 6
		high 7
		return
label_13:
		high 6
		low 7 
		high 8
		return
label_14:
		high 7
		low 8
		return
label_15:
		low 0
		low 1
		low 2
		return	
label_16:
		high 0
		low 1
		low 1
		return
label_17:
		low 0
		high 1
		low 0
		return
label_18:
		high 0
		high 1
		low 2
		return
label_19:
		low 0
		low 1
		high 2
		return
label_20:
		high 0
		low 1
		high 2
		return
label_21:
		low 0
		high 1
		high 2
		return
label_22:
		high 9
		high 10
		high 11
		low 12
		goto label_30
label_23:
		low 9
		high 10
		high 11
		high 12
		goto label_31
label_24:
		low 10
		high 11
		high 12
		high 13
		low 14
		goto label_32
label_25:
		low 11
		high 12
		high 13
		high 14
		low 15
		goto label_33
label_26:
		low 12
		high 13
		high 14
		high 15
		goto label_34
label_27:
		let b8=b0+3
		if b0<b4 then goto label_28
		if b8>b4 then goto label_28
		let b2=-1
		let b5=b5+1
		high 17
		low 17
		return	
label_28:
		if pin2 = 1 then goto label_1
		goto label_28
 

lbenson

Senior Member
Pardon my using this thread to bring this up, but I am unable to scroll down in the code listing above, and was unable to scroll down in another one a couple of hours ago. Is is just me, or are others having the same difficulty.
 

westaust55

Moderator
IF...THEN program structure

A few comments:

1. Can I suggest that you use more meaningful label names. For example, in place of
label_1: use Initialise:
label_2 use Main:
label_3: use Check:

2 With respect to the IF &#8230; THEN statement,
As a single line statement, you can only put a flow redirection after the THEN keyword.
So, GOTO and GOSUB followed by a label name are okay.
You can use a colon as a new line indicator.

Hence you lines like this are okay:
Code:
label_35:	
		if b5=10 then gosub label_9
		if b1=1 then gosub label_10
		if b1=2 then gosub label_11
		if b1=3 then gosub label_12
		if b1=4 then gosub label_13
		if b1=5 then gosub label_14
But for the lines like this they need reworking:
Code:
label_2:
		if b0=0 then let b2=1
		if b1=0 then let b3=1
		if b0=7 then let b2=-1
Two ways to rework them:
Code:
IF b0 = 0 THEN
  b2 = 1
ENDIF
or

Code:
IF b0 = 0 THEN :   B2 = 1 : ENDIF
 
Last edited:

Jeremy Leach

Senior Member
(Hi Ibenson, I raised the same issue a while back. It's a strange quirk which seems to be browser related. I'm using IE7 and get the same problem, but bizarrely if you refresh the page you'll probably find you can scroll)
 

westaust55

Moderator
scrolling code sub windows

Scrolling in code windows works without a problem for me.
Using Windows XP with SP3 and IE7 and/or Mozilla.
 

pillow face

New Member
How do i use the "LET DIRSC=" and "LET PINSC=" commands? How exactly do they work? Would i just put them at the beginning of the programme?

Also just checking that each comand takes a negligable time to execute?

Cheers.
 

eclectic

Moderator
@pillowface.

Here is a short program to get you started.
Code:
#picaxe 28x

main:
for b0 = 0 to 7

high b0
	pause 500
low b0
	pause 500
next


for b0 = 0 to 7

high portc b0
	pause 500
low portc b0
	pause 500
next

pause 1000
goto  main
Run it in the Programming Editor Simulator.
Increase the pause values, if you need to slow it down.

Then please read Manual 2, pages 58 and 102.

Then try your own simple program, and post it for people to check.

e
 

lbenson

Senior Member
Same scrolling problem today, but refreshing the page (IE7) makes it work--thanks Jeremy. Sorry again for the OT issue.
 
Top