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