Help for Fatigue testing controller - Page 3


Today 12:49
Forum: New devices and techniques
Starter: normnet
Views: 0
Replies: 0
Today 09:17
Forum: Absolute Beginners Section
Starter: amod
Views: 0
Replies: 23
Yesterday 20:44
Forum: SnapShot
Starter: towlerg
Views: 0
Replies: 54
+ Reply to Thread
Page 3 of 3 FirstFirst 123
Results 21 to 24 of 24

Thread: Help for Fatigue testing controller42 days old

  1. #21
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    445
    Thumbs Up
    Received: 33
    Given: 7
    Total Downloaded
    2.43 GB

    1 Not allowed!

    Default Re: Help for Fatigue testing controller

    It would help people if you could be a little clearer with your description of the problem...
    "what is wrong with my code,all leds on PORTA lights up" is unclear as it does not give us much to go on, does it mean that...
    a) All three LEDS connected to PORTA0:2 light up at the same time which is what you appear to be telling it to do so where is the problem? or
    b) That LEDs connected to PORTA3:5 are also lighting up as a result of the commands in your IF-Then conditional test or
    c) LEDs connected to PORTA3:5 are also lighting up but at power up rather than as a result of the commands in If-Then conditional test

    If your problem is C then you do not appear to have set an initial known condition for the PORTA outputs, so if the PIC/compiler default is output Low then the all PORTA LEDs will come on so try inserting PORTA = $FF 'Set All Output High (LED's off) before your main code. I always set my output pins to an initial condition when the power on default is either not what I want or unknown.

    If your problem is B then George may be correct in regard to it being a read/modify/write timing issue, personally where I have to set multiple bits on a single port as a result of a condition I never use individual commands for each bit as it is inefficient in both code space and instructions cycles try the following instead...
    Code:
    Main:
    If PORTB.0 = 0 then
    PORTA = PORTA & $F8  'Set PORTA.0:2 Low by logically ANDing PORTA output bits with 0
    Else
    PORT = PORTA | $03   'Set PORTA0:2 High by Logically ORing PORTA output bits with 3
    End If
    GoTo Main
    If none of the above works then try removing the ALL_Digital = true command. The compiler now does that automatically and as I recall that command does not work reliably with some devices. You can always do it manually by writing the appropriate value to the ADCON1 register just to be certain, I do it manually anyway (where applicable) as I like to be able to see in my code that is has been done.

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #22
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    82
    Thumbs Up
    Received: 85
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Help for Fatigue testing controller

    My problem is point A.All leds light up on PORTA.0,PORTA.1,PORTA.2,PORTA.3,PORTA.4,PORTA.5 when power on.And No input works which is on portB.0.

    Pls tell me adcon1 settings for all output
    Last edited by amod; Yesterday at 16:06.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #23
    Junior Member amod's Avatar
    Join Date
    Mar 2018
    Posts
    82
    Thumbs Up
    Received: 85
    Given: 4
    Total Downloaded
    5.95 MB

    0 Not allowed!

    Default Re: Help for Fatigue testing controller

    After writing PORTA=$FF, PORTA.4 gets on after some time

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #24
    Senior Member Stephen Moss's Avatar
    Join Date
    Jan 2006
    Posts
    445
    Thumbs Up
    Received: 33
    Given: 7
    Total Downloaded
    2.43 GB

    0 Not allowed!

    Default Re: Help for Fatigue testing controller

    Quote Originally Posted by amod View Post
    My problem is point A.All leds light up on PORTA.0,PORTA.1,PORTA.2,PORTA.3,PORTA.4,PORTA.5 when power on.And No input works which is on portB.0.

    Pls tell me adcon1 settings for all output
    It is boring and you might have to do it several times to understand it but try reading the data sheet, it is as I said the compiler now automatically sets all pins to digital but if you want to do it yourself the required value for ADCON1 can be found on Page 128.

    You said that you have the resistors for the LEDs tied to 5V, therefore a Low (0) output would turn them on, if you look at page 43 you will see that 0 is the default state of PORTA at power up/reset which is probably why your LEDs come on at power up. You need to add code to turn them off at the start of your code, it is always a good idea to try a simple LED flash test to see if things are working so try...
    Code:
    Device = 16F877A
    TRISA = $00  'Set to Output
    PortA = $FF  ' Turn off all LEDs
    DelayMS 5000  'Wait 5 seconds - check LED's are off.
    
    Main:
    PortA = $00   'Turn on all LED's
    DelayMS 1000 'Wait 1 second
    PortA = $FF   'Turn Off all LED's
    DelayMS 1000 'Wait 1 second
    goto Main   'Repeat
    As for no input on PortB.0 it can be configured as an external Interrupt pin (page 44), by default it should be operating in I/O mode as the power on status of the INTCON (interrupt control) register (page 24) is $00 (page 21), it is possible that when the compiler configures the I/O pins as digital it accidentally changes this so the pin is operating in Interrupt input mode or that you have changed it to Interrupt mode somewhere in your Include file.

    Try a simple program by replacing the code within in the Main loop in the example above to PORTA = PORTB and adding TRISB = $FF before the Main loop, if you are providing a changing input to PortB.0 and the pin is configures in I/O mode then the LED on PORTA.0 should go on an off as PORTB.0 changes from high to low.
    If it does not try adding INTCON.4 = 0 somewhere before Main to ensure PortB.0 pin is in I/O mode, if that still make no difference then are you certain your input signal is reaching the PortB.0 pin?

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Testing Bits of a register.
    By pic-ignorant in forum The Lounge
    Replies: 2
    Last Post: 16th May 2017, 17:36
  2. Any in the mood to do some beta-testing?
    By hadv215 in forum hadv215's Feedback Forum
    Replies: 0
    Last Post: 14th December 2016, 12:50
  3. CE Marking / Mains Testing
    By rpm26 in forum The Lounge
    Replies: 4
    Last Post: 9th February 2013, 16:45
  4. Debugging/Testing/Emulating
    By t0pP8uZz in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 5th November 2009, 20:23
  5. PCB Trace Testing
    By ohararp in forum The Lounge
    Replies: 1
    Last Post: 20th November 2007, 18:04

Posting Permissions

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