18f4431 PORT.5 Problem Large automated machine


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Jan 2010
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: 18f4431 PORT.5 Problem Large automated machine

    I usually use meCONFIG.exe just because it's so much faster when I'm writing code and it has the chips in it I use. Here is the long form of the same file. The weird thing is that this program was working just fine. And playing around with HSERIN with and interrupt routine is what messed things up. I had the interrupt working fine and just change a little bit of code and then it stopped working. I've tried the original code without interrupt that's been working for a month just fine and it won't run portb.5 now. Could something have gotten screwed up with the programming software? I"m using the melabs U2 USB programmer. It's just odd, nothing was hooked to the pin but my scope.

    Code:
    ;----[18F4431 Hardware Configuration]-------------------------------------------
    #IF __PROCESSOR__ = "18F4431"
      #DEFINE MCU_FOUND 1
    #CONFIG
      CONFIG  OSC = XT           ; XT oscillator
      CONFIG  FCMEN = ON         ; Fail-Safe Clock Monitor enabled
      CONFIG  IESO = ON          ; Internal External Switchover mode enabled
      CONFIG  PWRTEN = OFF       ; PWRT disabled
      CONFIG  BOREN = ON         ; Brown-out Reset enabled
      CONFIG  BORV = 20          ; Reserved
      CONFIG  WDTEN = ON         ; WDT enabled
      CONFIG  WDPS = 512         ; 1:512
      CONFIG  WINEN = OFF        ; WDT window disabled
      CONFIG  PWMPIN = OFF       ; PWM outputs disabled upon Reset (default)
      CONFIG  LPOL = HIGH        ; PWM0, 2, 4 and 6 are active-high
      CONFIG  HPOL = HIGH        ; PWM1, 3, 5 and 7 are active-high
      CONFIG  T1OSCMX = ON       ; Low-power Timer1 operation when microcontroller is in Sleep mode
      CONFIG  FLTAMX = RC1       ; FLTA input is multiplexed with RC1
      CONFIG  SSPMX = RC7        ; SCK/SCL clocks and SDA/SDI data are multiplexed with RC5 and RC4, respectively. SDO output is multiplexed with RC7.
      CONFIG  PWM4MX = RB5       ; PWM4 output is multiplexed with RB5
      CONFIG  EXCLKMX = RC3      ; TMR0/T5CKI external clock input is multiplexed with RC3
      CONFIG  MCLRE = ON         ; Enabled
      CONFIG  STVREN = ON        ; Stack full/underflow will cause Reset
      CONFIG  LVP = OFF          ; Low-voltage ICSP disabled
      CONFIG  DEBUG = OFF        ; Background debugger disabled; RB6 and RB7 configured as general purpose I/O pins
      CONFIG  CP0 = OFF          ; Block 0 (000200-000FFFh) not code-protected
      CONFIG  CP1 = OFF          ; Block 1 (001000-001FFF) not code-protected
      CONFIG  CP2 = OFF          ; Block 2 (002000-002FFFh) not code-protected
      CONFIG  CP3 = OFF          ; Block 3 (003000-003FFFh) not code-protected
      CONFIG  CPB = OFF          ; Boot Block (000000-0001FFh) not code-protected
      CONFIG  CPD = OFF          ; Data EEPROM not code-protected
      CONFIG  WRT0 = OFF         ; Block 0 (000200-000FFFh) not write-protected
      CONFIG  WRT1 = OFF         ; Block 1 (001000-001FFF) not write-protected
      CONFIG  WRT2 = OFF         ; Block 2 (002000-002FFFh) not write-protected
      CONFIG  WRT3 = OFF         ; Block 3 (003000-003FFFh) not write-protected
      CONFIG  WRTC = OFF         ; Configuration registers (300000-3000FFh) not write-protected
      CONFIG  WRTB = OFF         ; Boot Block (000000-0001FFh) not write-protected
      CONFIG  WRTD = OFF         ; Data EEPROM not write-protected
      CONFIG  EBTR0 = OFF        ; Block 0 (000200-000FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTR1 = OFF        ; Block 1 (001000-001FFF) not protected from table reads executed in other blocks
      CONFIG  EBTR2 = OFF        ; Block 2 (002000-002FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTR3 = OFF        ; Block 3 (003000-003FFFh) not protected from table reads executed in other blocks
      CONFIG  EBTRB = OFF        ; Boot Block (000000-0001FFh) not protected from table reads executed in other blocks
    #ENDCONFIG
    
    #ENDIF
    
    ;----[Verify Configs have been specified for Selected Processor]----------------
    ;       Note: Only include this routine once, after all #CONFIG blocks
    #IFNDEF MCU_FOUND
      #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
    #ENDIF

  2. #2
    Join Date
    Aug 2011
    Posts
    458


    Did you find this post helpful? Yes | No

    Default Re: 18f4431 PORT.5 Problem Large automated machine

    CONFIG PWM4MX = RB5 ; PWM4 output is multiplexed with RB5

  3. #3
    Join Date
    Jan 2010
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: 18f4431 PORT.5 Problem Large automated machine

    Yep I tried that as well. My first post shows CONFIG PWM4MX = RD5 The second post I was just showing the output for meConfig one line of code. Still stumped. Tomorrow I'll try another board with a fresh pic, unless there is something setup in the programming software I'm unaware of.

  4. #4
    Join Date
    Jan 2010
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: 18f4431 PORT.5 Problem Large automated machine

    Plot thickens . I went to my shop today and programmed this simple code to the board and it works fine. I then try and program the same code from my laptop even after uninstalling and reinstalling U2 programming software. Nothing now it won't work. It's got to be some setting that got messed up. I need to be able to program it from my laptop though in the field. Any thoughts?


    Code:
    DEFINE OSC 8          ' DEFINE OSCILATOR SPEED
    OSCCON = %01111000
    
    '---[CAPTURE COMPAIR MODUALS]---------------------------------------------------
    CCP1CON = %00000000      
    CCP2CON = %00000000
    '-------------------------------------------------------------------------------
    '---[ANALOG CHANELS TO DIGITAL]-------------------------------------------------
    ANSEL0 = %00000000       
    ANSEL1 = %00000000       
    ADCON0 = %00000000      
    
    
    MAIN:
    SOUND PORTB.5,[100,20]
    PAUSE 1000
    GOTO MAIN
    END

  5. #5
    Join Date
    Jan 2010
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: 18f4431 PORT.5 Problem Large automated machine

    Ok I found it, there were a couple of configuration bits that for some reason the config setting I originally had didn't work when I launched the programmer. I changed them with the U2 software before programming and now all is well. I guess this is one of those moments where you've been staring at the screen for hours and you mind is starting to get tunnel vision. Thanks for you help

  6. #6
    Join Date
    Jan 2010
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: 18f4431 PORT.5 Problem Large automated machine

    Oh yeah as soon as I get the machine done I'll post some pictures and video of the project as well.

  7. #7
    Join Date
    Jan 2010
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: 18f4431 PORT.5 Problem Large automated machine

    Well I finished up the machine and delivered it. My client is thrilled and has more automated machines he wants me to get started on. But like I said I'd post a little about this project. This machine is for a very progressive framing company that is automating every aspect of their business. This machine will except window and door water proofing seal from 4" to 30" wide and interface with their software over USB. They have an in house software engineer that writes all their custom software to break a job down and minimize waist. Every aspect of their framing is maximized through automation. I worked with him over the internet interfacing my control with his software and after a handful of emails and a couple calls we had it debugged and running. Minus my original post here which was a late night, frustration and a wrong configuration bit. It bites us all at some point. So here is the youtube video of the project in front of my shop.


    Also the main PCB and secondary interface PCB for using the DYN4 AC servo drive and all inputs and outputs. I'm using a pic18f4431 on the main board because it's a handy controller with and easy to use quadrature encoder. It's one of my basic boards I always use designed in diptrace. Here are some pictures.
    Name:  mainboard.png
Views: 2805
Size:  68.9 KB
    Name:  breakout.png
Views: 1194
Size:  66.7 KB
    Last edited by microcnc05; - 29th May 2020 at 23:45.

Similar Threads

  1. problem with LCD large Numbers
    By ozarkshermit in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th December 2017, 18:15
  2. Replies: 4
    Last Post: - 17th May 2014, 18:24
  3. 18F2520 - problem configuring fuse for port B as digital port.
    By hwhisperer in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th October 2010, 12:41
  4. Replies: 18
    Last Post: - 24th January 2008, 23:44
  5. A/D conversion problem on 18F4431
    By ttease in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th April 2007, 00:03

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