Let's Make Robots!

Why is portc high = low?

Using Picaxe "portc", I can get 16 outputs from a picaxe 28, which is neat.

But I allways wondered why you have to write "high portc 5" to get "portc 5" to be "low"??

I understand that since it on default is an input-port, it must be set on "high" on power up. But still you should set it to "low" by writing "low portc 5", and not "high portc 5"?

Gets quite confusing sometimes in my code; half of the outs has to be set low to be high!?!?!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
...but I want to know WHY it's like that. C'mon. What type is the chip?

...but I really dont KNOW which it is. I am not at home, cannot look, and we have taken over Google, look:

http://images.google.com/images?hl=da&q=PICAXE-28X1&um=1&ie=UTF-8&sa=N&tab=wi

blody half of the results point back to here anyway - if anyone knows, it should be us :D

LOL!! Jklug80: On page 2 on a Google search on Picaxe 28, is your face :D:D

http://images.google.com/images?um=1&hl=da&q=PICAXE-28X1&start=18&sa=N&ndsp=18

jgillick is on page 8:

http://images.google.com/images?ndsp=18&um=1&hl=da&q=PICAXE-28X1&start=126&sa=N

But no closeup of the darn Picaxe 28!

Note to self: make closeup of picaxe 28, the world is relying on us!

I PWN google... what do I win? 

 

LOL!! Jklug80: On page 2 on a Google search on Picaxe 28, is your face :D:D

http://images.google.com/images?um=1&hl=da&q=PICAXE-28X1&start=18&sa=N&ndsp=18

Krumlink; You are also on page 8..

Jip, me, mattmitch and Zalzar are all the way back on page 10

http://images.google.com/images?ndsp=18&um=1&hl=da&q=PICAXE-28X1&start=162&sa=N

jgillick you are also on page 4 on a search on SRF05! That makes you most famous!

http://images.google.com/images?ndsp=18&um=1&hl=da&q=srf05&start=54&sa=N 

No I tested on my own home-made project board, but it should be the same.

Did you remember to do the

let dirsc = ...

and set the port to be output? Maybe that has something to do with it...

- Jimmy

Manual says:


Information:
Some microcontrollers allow inputs to be configured as inputs or outputs. In
these cases it is necessary to tell the microcontroller which pins to use as inputs
and/or outputs (all are configured as inputs on first power up). There are a
number of ways of doing this:
1) Use the input/output/reverse commands.
2) Use an output command (high, pulsout etc) that automatically configures the
pin as an output.
3) Use the let dirs = statement.


I go for "2)" - just use it as output.. But I have to set it to "low" to get it "high", and it is not only the initiating / first time, it is just how it is..

However - I am not quite sure I understand the "dirsc" - command.. Do you? Reading other peoples code, it will just accept a binary string (or a variable or number between 0-255 that it will read as 8-digit binary) - and the 8 digits will just tell which ports should be high / low.

 

.. And then the pins and pinsc.. well all just the same as "taking it one pin at a time" with High / low.. But still "high" / "low" comands are reversed on the portC's no matter what, as far as I can tell?

 

Dont we agree: "high portc 1" should turn portc 1 to output and make it high? Well try it. And then try to set it low..

F. 

/ Frits 

I have used "let dirsc = blah blah" on Picaxe Pete and it seems to work the way I wanted it... but then again I'm using a 40X1 chip...

Yes you understood dirsc right... it is a configuration of the direction of all the 8 pins in port c... I can't remember if 1 is output or input though (I think 1 is output). I prefer using the "let dirs / let dirsc" command when the directions don't change during execution.

- Jimmy

I have used it on a 28x1. The 1's in the dirsc command set the pin to output, 0's to input. So let dirsc=%00000001 sets pin 1 on port C as output and 2-8 as input. I haven't had problems with reversed high/low commands. What do you have attached to the pin?

.. OK - just to make sure, try to run this:

 

main:

high portc 1

wait 4

low portc 1

wait 1

goto main

 

- and tell me then if the pin is low or high in 4 seconds?

Thanks, 

/ Frits