Input problems


Closed Thread
Results 1 to 7 of 7

Thread: Input problems

  1. #1
    Join Date
    Feb 2006
    Posts
    20

    Question Input problems

    Hello, I am having some trouble geting simple data into my PIC16F767. I have writen a program that goes somthing like this.

    TRISB = %11111111
    TRISA = %00000000
    ADCON1 = %00001111

    Start: IF PortB.0 = 1 THEN HIGH PortA.0
    LOW PortA.0
    PAUSE 1
    GOTO Start

    I wrote this to clarify some problems I was having in a much larger aplication where the PIC is monitoring sensor inputs on a mobile robot.
    The hardware that I have built seems to work fine in that when I program the PIC to output data to motors LEDs ect it works fine but when I tell the PIC to read the status of an I/O line it does nothing. The above program produces the following output; When PortB.0 through PortB.5 goes high, PortA.0 through PortA.3 or so goes high for about 5 seconds. When PortB.6 or PortB.7 go high the I/O lines on the above PortA lines breifly go high but this only works twice. ???? this is completly bazar and I have no idea what I could be doing wrong as I have some previous experience with PICs.
    Thanks for any ideas or sugestions!!

    note: I tried the program on a PIC18F252 with the same problems.
    I also looked at the oscillator signal with my oscope and it is fine.

  2. #2
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Have you got a 10k pullup resistor on MCLR and a pulldown resistor, such as 4k7, on PORTB.0?

  3. #3
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by ALFRED
    Hello, I am having some trouble geting simple data into my PIC16F767. I have writen a program that goes somthing like this.

    TRISB = %11111111
    TRISA = %00000000
    ADCON1 = %00001111

    Start: IF PortB.0 = 1 THEN HIGH PortA.0
    LOW PortA.0
    PAUSE 1
    GOTO Start
    ADCON1 = %00000111

  4. #4
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default

    Alfred,

    I'm not one of the experts on the forum but it looks like if PortB.0=1 then you are going to put PortA.0 high for a very small amount of micro seconds. By the way the program looks, PortA.0 will always be low no matter what PortB.0 is. If that's the case, I would adjust the program to use an If/Then/else, like this:


    Start:
    IF PortB.0 = 1 THEN
    HIGH PortA.0
    Else
    LOW PortA.0
    PAUSE 1
    GOTO Start

    Chris

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Thumbs up

    Chris is right on the money.

    You could simplify this even more with PORTA.0 = PORTB.0 and drop the IF
    statement altogether.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Feb 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Hey guys, thanks for the ideas. Although what Chris said seems to make sense, I was able to run this code on a PIC16F88 with no problems at all. I also wrote a similar program that uses portc.4 as the input and ran it in the dark. Without the light on I could see the LED I had on the output light dimly when I brought the input high and turn off when I disconected the input. I am sure the LED was flickering and that is why it looked dim. I am not sure if this would also work on other I/O lines if I looked at them it the dark. I am now going to try your ideas and see what I get.
    Thanks again!!

  7. #7
    Join Date
    Feb 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Talking

    It worked!! thanks for the idea Chris. I am still not exactly clear on why it didn't work the first time but hey, it works now so no complaints. again thanks for all the help.

Similar Threads

  1. Input problems with 12F629?
    By achilles03 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 24th April 2018, 07:25
  2. PIC18f2423 two 12bit adc input problems
    By Brandon in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 16th December 2007, 10:47
  3. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 02:50
  4. Input problems with PortD on Pic16F874A
    By Petter in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 26th August 2006, 12:30
  5. Problems with variables
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th December 2004, 19:37

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts