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!?!?!

Did you remember to do

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

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 =

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.
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,

… 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

As expected, the pin went
As expected, the pin went high on the high command and low on the low command. What do you have attached to the pin?

I can not believe this.It

I can not believe this.

It has always been like that. Connected? anything!

I use the 28 pin project board, same for you?

/ Frits

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

What PIC
I may have an answer. Tell me what type of PIC is embedded.

Erh - picaxe 28 :slight_smile: Cant be

Erh - picaxe 28 :slight_smile: Cant be bothered to look up what that is :slight_smile: I’m cool thanks - I have learned that it is like that :slight_smile:

Maybe YOU’RE cool…
…but I want to know WHY it’s like that. C’mon. What type is the chip?

According to the manual from

According to the manual from sparkfu (see copy/paste below) it is either a PIC16F886 or a PIC16F872. I DO want to know why it is inverted. :slight_smile:

• PICAXE-08 PIC12F629
• PICAXE-08M PIC12F683
• PICAXE-14M PIC16F684
• PICAXE-20M PIC16F677
• PICAXE-18 PIC16F627(A)
• PICAXE-18X PIC16F88
• PICAXE-28X1 PIC16F886
• PICAXE-28X2 PIC18F2420
• PICAXE-40X1 PIC16F887
• PICAXE-40X2 PIC18F4420
• PICAXE-18A PIC16F819
• PICAXE-28A PIC16F872
• PICAXE-28X PIC16F873A
• PICAXE-40X PIC16F874A

 

GobliZ - Check out my robots

…but I really dont KNOW

…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 :smiley:

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!

Krumlink; You are also on

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

I PWN google… what do I

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

One of FOUR!

OKay, this is progress, but “Lazy-boy Frits” doesn’t say which chip he’s using. Could be one of four:

• PICAXE-28X1 PIC16F886
• PICAXE-28X2 PIC18F2420
• PICAXE-28A PIC16F872
• PICAXE-28X PIC16F873A

Do we know what the pin number is of the offending DIO bit? Is it literally port C bit 5?

PS - You posted your message, like 30 seconds after mine above!!! Quit your moaning in the shoutbox!

Can I moan here instead?
Can I moan here instead? Since this is way off topic I’ll try to steer the ship around… Is it actually setting the in to low which makes the out high or vise versa? In other words I’m not turning the light off I’m turning it “not on” or setting the ON status to low.

Someone talking about

Someone talking about setting a light on or off? I had a development board for some ARM chip once where there was 5V going to a test LED and through a resistor and finally into a pin. Then you had to set the pin to low to get the LED to light since of course you had to get the current flowing from 5V to GND… does this make sense to some of you? I might be in a totally different context or something :slight_smile:

Read the schematic for the development board in order to figure out if you have to set a pin high or low for something to turn on or off.

Correct!

You’re quite right. Most transistors can sink more current than they can source. Consequently, they’re more often used to “connect” to gnd (emitter side) than to connect to +V (collector side). (Yes, all you experts, I KNOW this is a simplification, but I’m pitching it for the audience. We’re not electronics engineers. That would be, like, geeky, or whatever.)

Various PICs have an open drain output, which means the output can never go “positive.” It can only be pulled to ground. I thought that might have been relevant, but on the 16F872, it’s port A bit 4 and on the 16F886, it’s port C bits 3 and 4 (but only in I2C mode). You can get a “logic high” out of them using a pullup resistor and switching the transistor “off,” but it’s not really the same thing as using a pull-up transistor.

So, I’m stumped. Even if I knew the chip, is the schematic for the development board available?