Page 1 of 1

READDING A VALUE ON A PORT

Posted: Tue Mar 27, 2007 1:15 pm
by PINTO
Helo Benj,

I'm having a bit of a problem with reading the state of a pin on a port.
I'm outputing a value 1 to port D7 that lights an LED and than I want to read the state of D7. I used an input Icon and stote the value into a variable "ash" next I used an decision Icon to check the variable and than decide what to do.
When I run the program in flowcode it simulates ok, but when I run it in my simulator it make D7 as an input and switches OFF the LED. It's obvious that pin D7 become an input!! I than inserted an output icon and made D7 1 again to light the LED this works in flowcode but not in the simulator.

What am I doing wrong?

How can I read tge state of a Port Pin if it's high or low with flowcode.

Thanks

Pinto

Posted: Tue Mar 27, 2007 3:59 pm
by PINTO
Hi Ben,
I think I've got it.
Instead of using an INPUT Icon I created a variable that I pre-load with a 1 if it's true and with a 0 if false'
When I want to switch the LED I load the variable on RD7 with the output icon. That enable me to make further decision on RD7 later on.
Whwn I simulate on my simulator it works. :lol:
I was considering taking back my real state job again!! :twisted:

By the way do you know off hand were I can get a good circuit for a PT100?

Regards


Pinto

Posted: Wed Mar 28, 2007 9:23 am
by Benj
Hello Pinto

Another way you can do the read of the pin is to use a piece of C code. Unfortunately the input flowchart icon configures the pin back to being an input and therefore destroys the logic level being sent out. The C code that would do this would be

Code: Select all

test_pin(portb.0);    //tests logic level of B0
However this C code will also not simulate. I think the method you have adopted is probably the way forward. :)

Also here is an application note from Microchip referring to the PT100.
http://ww1.microchip.com/downloads/en/D ... 51607a.pdf