Simulator support for "ALL THE PINS"?!

BITMOVER

Member
I hoped the new Program Editor patches, updates, plasters, pasties or whatever would have added that much needed feature.

If you use more than 8 outputs, the simulator changes the inputs to outputs and there's no recovery other than a restarting the simulation.

Tell me if I've missed something!
Comments welcomed, and fixes are still hoped for!

Len
 

hippy

Ex-Staff (retired)
Which PICAXE are you simulating and can you give a short example code which demonstrates this happening ?
 

BITMOVER

Member
Hi Hippy,
Here's a quick sample. Portc 0-7 turns the input buttons 0-7 to outputs and they never return to inputs unless the simuator is restarted! It sure looks like the simulator is only suited for the smaller processors

Note: Simulator is set for 28x mode

for b0=0 to 7
high b0
pause 100
low b0
next
for b0=0 to 7
high portc b0
pause 100
low portc b0
next

Thanks,
Len
 

Technical

Technical Support
Staff member
The simulator is doing exactly what your program tells it to do!

high portc / low portc commands make the portc pins outputs. Nowhere in your program do you tell the pins to become inputs again!

Have a look at the 28X appendix at the end of manual part 1, and the 'let dirsc' command in manual part 2.
 

BITMOVER

Member
Hippy,
Quick afterthought...
Addding a dirs command to switch portc back to inputs seems to make it work.
It appears that since portc switches its I/O, on the fly, it doesn't switch back to its default. Is this an issue with the program writer, (me) the pic, or the simulator?

Len

for b0=0 to 7
high b0
pause 100
low b0
next
for b0=0 to 7
high portc b0
pause 100
low portc b0
dirsc=%00000000 <---------ADDED
next
 

Technical

Technical Support
Staff member
It's a problem with your (mis)understanding of how the commands operate. Once you tell a pin to become an output (e.g. with a high portc or low portc command) it will stay an output until you tell it to beome an input again... (e.g. with let dirsc=).
 

BITMOVER

Member
Technical:
Tell me what to do to fix this problem? The input pins on the simulatior are are overwritten by the port c output. If the dirsc is moved after the 'next' you lose the portc lights! It really seems that the simulator needs more I/O controls so they are not being used for both input and output purposes.

symbol test=b0

do
dirsc=%00000000
if pin0=1 then gosub teston
if pin1=1 then gosub testoff
loop

teston:
for test=0 to 7
high test
next
for test=0 to 7
high portc test
next
'dirsc=%00000000
do:if pin0=1 then loop:endif
return

testoff:
for test=0 to 7
low test
next
for test=0 to 7
low portc test
next
'dirsc=%00000000
do:if pin1=1 then loop:endif
return
 

hippy

Ex-Staff (retired)
Aha ! Now it makes sense to me.

The input pins on the simulatior are are overwritten by the port c output.
What you are saying is that the "input selector" shown in the simulator PICAXE diagram becomes an "output indicator" so you cannot later click on "Input Selector 0" to finish the turn on test.

1) You are right
2) It is doing what it should be doing
3) LET DIRSC=%00000000 does lose all the output indicators
4) LET DIRSC=%11111110 will do what you need

You will lose the "output indicator 0" as it becomes an input selector but that's the reality of the electrical world; an I/O line cannot be input and output at the same time.

Note : If you implement this with real hardware you will have to be careful not to destroy the PICAXE when the input button was pushed.
 

BITMOVER

Member
Hippy.
Why would hardware configuration be a problem?
The I/O's are all separate pins. Logical thinking says they cannot share circuitry as inputs and outputs at the same time. It's the simulator that doesn't know that :mad:
Len
 

Technical

Technical Support
Staff member
The I/O's are all separate pins.
Len
You have a complete misunderstanding here.
Portc pins can be inputs (the default) or outputs (set with high portc or 'let dirs =' type commands). It is the same physical leg of the chip. that chip leg can be input or output, but not both at the same time. Have a look at the pinout diagram of the chips again and then read through Hippys post with the pinout diagram in front of you, that should help clarify the issue.

'let dirsc =' addresses all 8 pins in portc. You can use a mixture of inputs and outputs within that 8.

The normal outputs (0-7) are completely different legs to the portc input/outputs
 
Last edited:
Top