Unstable 18f458


Closed Thread
Results 1 to 12 of 12

Thread: Unstable 18f458

  1. #1
    Join Date
    Sep 2011
    Location
    Brisbane
    Posts
    8

    Default Unstable 18f458

    Hi
    I am migrating from 16f887 to 18f458 in a motor control application. both chips work my dev board (labx 2) and also in my prototype rig
    until the motor is connected. then the 16f is ok but the 18f has random resets will run sometimes for 20 seconds others 1 second.
    I have determined that the problem is complete reset. I also checked with oscilloscope vss is good and no noise on vdd. Lower current to the motor seemed to lengthen run time. Very frustrating. What things can cause the pic to reset.
    regards Paul
    If I was just a bit smarter I would know how stupid I was!!!

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Unstable 18f458

    A voltage drop could cause a reset. Are the motors using the same power supply as the MCU?
    How are the configs set for the 18F?
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2011
    Location
    Brisbane
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: Unstable 18f458

    Thanks for the reply Mackrachit
    The only change to config was to change to HS in the inc file. The brown out is set to enable and 2 v. I tested with brown out disable with no effect. Testing for power drops shows no problem. I use a !2 v supply from a bench supply and a 7805 5v reg. A further problem has occurred on one occasion. The eeprom data for approx 32 registers changed to 00. See photo of my prototype set up. The bipolar stepper drivers are close to the pic. Are 18f very delicate compared to 16f
    regarding em interference. Please treat my as pic novice as only been playing for 12mths (lots of fun though)





    Name:  P1000337.JPG
Views: 509
Size:  163.0 KB
    If I was just a bit smarter I would know how stupid I was!!!

  4. #4
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Unstable 18f458

    If you have an scope, watch the ground for spikes. I expected to see some caps in the area of 47uF but cant make them out on your board. Stepper drives are NOISEY!!! You may be getting a spike on ground enough to cause the pic to reset.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Unstable 18f458

    Yup, what he said.
    A sprinkling of caps where ever you can fit them in. Most important have them as near to the MCU VSSs and VDDs as you can.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Sep 2011
    Location
    Brisbane
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: Unstable 18f458

    Hi
    see picture with suggested caps. thanks both for the advice. Now working fine. I did see the spikes on ground and moved my vss connection point to the ov pin on the 7805 before my post and had a small improvement. My scope showed this point to be clean.(it is a PC based scope. keep my good scope at work. May not be quick enough to trigger on the spike). But probably not clean enough. You can only find out what you don't know by doing something first and apparently circuit design isn't my strong point.



    cncmachineryguy How are you involved in with cnc. I make my living with cnc machines. look up my business at www.abcoprecision.com.au

    now to get the 40mhz osc to work


    Name:  P1000338.JPG
Views: 416
Size:  163.5 KB
    If I was just a bit smarter I would know how stupid I was!!!

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Unstable 18f458

    now to get the 40mhz osc to work
    Use a 10MHz crystal or resonator then set the config to HS4.
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: Unstable 18f458

    It would be better to use 100nF ceramic cap. They have much better(10X lower or even more ) ESR than elco.
    Last edited by pedja089; - 3rd October 2011 at 12:41.

  9. #9
    Join Date
    Sep 2011
    Location
    Brisbane
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: Unstable 18f458

    hi

    any problem using both 47uf and 100nf.

    also now am losing some data when loading map data to codespace from serial ( max 232) . going to bed . late here in oz. will test in lab-x2 to see if serial in is ok tomorrow and then chase down my proto board probs.
    good nite

    regards Paul
    If I was just a bit smarter I would know how stupid I was!!!

  10. #10
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Unstable 18f458

    also now am losing some data when loading map data to codespace from serial
    You need to post the code and clarify some.
    Dave
    Always wear safety glasses while programming.

  11. #11
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Unstable 18f458

    Paul, Can you please post the drive chip you are using for the steppers? I can't quite make out the part number. I think the 47uF caps should be as close to those chips as possible but would like to double check the datasheet.

    Side note - I have a small contract job shop. 4 VMC's and a lathe. But my true love is building machines and controlling them. My user name is a left over from a long time ago in another forum, so I just use it now for easy remembering to me.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  12. #12
    Join Date
    Sep 2011
    Location
    Brisbane
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Re: Unstable 18f458

    Hi again

    The stepper driver ic L298n with L297 controller ic.

    When upload if maps to pic method is as follows.
    1 send numeric value 1 to select case 1 load map data
    2 pc waits to receive "R" (pic ready)
    3 send first packet "AxxxxBxxxx" A= address B= data
    4 write data to eeprom or code space depending if A value < 128
    5 send "s" to PC
    6 wait for next packet
    7 if "A9999" received end of data transfer

    Sometimes upload is fine.
    There is 13 blocks of 256 words that make up the map data and when I view the pic memory I can see areas with rows of zeros and some 00001 and 00002 where a value of 55 should be. this fail area is for 4 memory rows and then comes good. When upload of map is in progress the stepper driver is set to disable and .12 amp of draw only from power supply in this state so noise at this time is unlikely.


    see picture taken from meProg The row with 11111 is a partition only and npt read. Below that the values should be progressively larger than the 45 values that are correct.

    Beginning to suspect the usb to serial adapter. This is difficult to see because if the data string is not AxxxxBxxxx then error occures. so the error is only in the values after B as the correct addresses are written . It is as if the charge pump runs out in the pic and then recovers. Also the defective area is mainly in a similar area. Tricky hey


    Name:  P1000343.JPG
Views: 380
Size:  166.0 KB



    Code:
    
    
    '-------------Main Code------------
    DEFINE HSER_RCSTA 90h 
    DEFINE HSER_TXSTA 24h 
    DEFINE HSER_BAUD 76800
    DEFINE HSER_EVEN 1 
    DEFINE OSC 20
    
    
    INTCON2.7=0    ' Enable PORTB pull-ups 18f458
    
    
    TRISB = 110000
    PORTB = 000001
    
    
    loadlamp1 var word
    loadlamp2 var word
    mapflag var byte
    data1 VAR word
    location VAR word
    computercontrol var byte
    computerpos VAR word
    connect var byte
    
    
    '------------------------------------------------------------------------------------------------------
    mainloop:
    
    
    if RCSTA.1 then  ' Overrun error? used to reset input ready to recieve
        RCSTA.4=0     ' clear it
        RCSTA.4=1
        endif
    
    
    if PIR1.5 then gosub loaddata    'if a chaeacter has arived at serial in the  PIR1.5 will = 1
    
    
    goto mainloop:
    
    
    '------------------------------------------------------------------------------------------------
    Loaddata:
     
    hserin [dec1 data1] 'read case number from pc 1 = load 2 = computer control  4 = connection extablished 5 = disconnect
    select case   data1
    
    
    case 1
    loadlamp1 = 0
    loadlamp2 = 6
    HSEROUT ["R"]  'pic ready to recieve
    
    
    Load2:
    HSERIN 5000,TimeOut2,[WAIT("A"),hex4 location,WAIT("B"),hex4 data1] 'if next packet not recieved in 5 sec then go timeout 2
    
    
    loadlamp1 = loadlamp1 + 1          'led flash while data transfer in progress
    if loadlamp1 > loadlamp2 then PORTB=PORTB << 1
    if loadlamp1 > loadlamp2 then loadlamp2 = loadlamp1 + 6
    IF PORTB.3 THEN PORTB = 000001
      
    if location = 9999 then goto TimeOut2  'when A9999B0000 sent from pc data transfer finished
    if location > 128 then goto cs 'codespace addresses are always greater than 128    
    write location , data1.lowbyte
    write location+128 , data1.highbyte       
    HSEROUT ["S"] 'please send next data packet
    GOTO Load2:
          
    cs: 
    Writecode location ,data1
    HSEROUT ["S"]  'please send next data packet
    GOTO Load2
    
    
    TimeOut2:
    if location = 9999 then 
    HSEROUT ["Recieve ok"]
    else
    HSEROUT ["F"] 'fail load set to pc
    endif
    HSERIN 20,TimeOut3,[WAIT("recieve nill")] 'this is needed to final clear PIR1.5 and stops main loop jump to loaddata
    TimeOut3:
    PORTB = 000001
    RETURN
    
    
    case 2
    HSEROUT ["R"]
    computercontrol=1
    HSERIN 5000,TimeOut2,[WAIT("P"),dec3 computerpos]
    location = 9999
    goto TimeOut2
    
    
    case 3
    HSEROUT ["R"]
    computercontrol=0
    location = 9999
    goto TimeOut2
    
    
    case 4
    HSEROUT ["C"]
    connect=1
    location = 9999
    goto TimeOut2
    
    
    case 5
    HSEROUT ["D"]
    connect=0
    location = 9999
    goto TimeOut2
    end select
    return
    
    
    
    
    end
    If I was just a bit smarter I would know how stupid I was!!!

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