Loop Problem please help


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    I would say there is some form of hardware fault.

    From your code, I dont see how the relay could buzz as you only have code to turn it on if Adval is between 500 and 600. There is nothing in the code that I can se that will turn it OFF eg PortB.6 = 0.

    The buzzing could be due to the PIC resetting. Connect an LED to an unused pin and light it for 1 second then turn it off in the initialisation code. If you see the LED flashing or aapparently staying on then for some reason your PIC is resetting.

    From the code you have posted, the first time ADVAL is 500-600 the relay will operate and then stay that way forever.

    I notice that you update the LCD inside the loop and that LCD Enable is on B5.
    This pin will be going high and low as the LCD is updated.
    Do you have a short between B5 and B6 ?
    Keith

    www.diyha.co.uk
    www.kat5.tv

  2. #2
    Join Date
    Nov 2005
    Location
    Ontario Canada
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Loop Problem

    Thanks to all who responded. I have dug deeper and found that replacing the 16F88 with 16F84 or 16F628 works just fine. Not the ADC portion, just turning PORTB.6 on. With the 16F88 the LED would pulse. What is strange is that selecting the 16F88 in the device selection menu in MicroCode Studio Plus and then compile would give strange errors. To fix the errors I had to change the directory. I stripped the code to bare minimum because the issue was with holding the port pin on solid. As you can see, the code is very simple. With code below, the 84 and the 628 works as expected. I know the 88 is fine as I tried three. The problem could be with MicroCode Studio.

    loop:Lcdout $fe, 1 'Clear screen
    Lcdout "Testing 16F88"
    Pause 100 'Wait

    HIGH PORTB.6

    Goto loop ' Do it forever

    END

  3. #3
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default Disable the analogue inputs

    ANSEL = %00000000 ' Disable Analogue Inputs

    I had the same problem the first time I used a 16F88

    Oops, just realise that you NEED analogue inputs but disable the ones that are on the Port B pins that you are using

    Use ANSEL=%00000001 ' Enable AN0 only

    By default the analgue inputs are enabled. To update your LCD display the PortB data register is read, modified and written back to. Because B6 (your relay pin) by default is AN5, this is read as a ZERO rather than the ONE you set it to in your code. This means that when you initially set it it works OK but as soon as the LCD is updated again it gets rewritten as ZERO.

    HTH
    Last edited by keithdoxey; - 15th July 2006 at 13:39.
    Keith

    www.diyha.co.uk
    www.kat5.tv

  4. #4
    Join Date
    Nov 2005
    Location
    Ontario Canada
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Loop Problem

    Thank you. I will try that ansel in a few minutes and get back to post the results. Thank you very much on your observation about the LCD. I noticed you mentioned that before. I have always wondered why in all the examples I have seen in the DEFINES, the ports were not all the same. I could not find any explanation as to why that was. Thank you for being persistent in pointing that out and offering the explanation.

Similar Threads

  1. Controlsystem for compact sporting (clay shooting)
    By Fredrick in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 30th July 2009, 16:48
  2. Using input from Switch to control a loop
    By MrRoboto in forum mel PIC BASIC
    Replies: 9
    Last Post: - 2nd February 2009, 05:02
  3. Serin to Serin2 ??
    By Gixxer in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th January 2008, 03:56
  4. Serial Relays
    By tazntex in forum General
    Replies: 3
    Last Post: - 17th May 2007, 17:42
  5. Newbie question:
    By Izone in forum mel PIC BASIC
    Replies: 2
    Last Post: - 26th February 2006, 16:24

Members who have read this thread : 0

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