1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Intermittent working PICs

Discussion in 'Oshonsoft' started by camerart, Mar 21, 2015.

  1. granddad

    granddad Active Member

    Joined:
    Jan 18, 2015
    Messages:
    762
    Likes:
    76
    Location:
    Worcestershire UK
    Hi C did this include tying PGM pin 26 to GND ? G Not happy about 'floating pins' :( as they possibly are all inputs ? MC recommend making unused pins outputs and writing '0' to them. or unused pins TRIS d as inputs and grounding them. (messy.)

    Eric was this a simulation or actual hardware ?
     
  2. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi G,
    Both.
    I did previously build a fully copy working version of all the hardware for this project with the exception of the H-bridge.
    The programs have all been tested in simulation and hardware, no RS232 serial problems were observed.

    For background information, when I ran my own electronics company I designed a range of Horizontal and Vertical scanning laser bearing units, both manually and automatically controlled, so I am not new to this type of application.

    Eric
     
  3. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi C,
    Bit more checking of your STRVEN basic.
    Every time you get a POSCNT to CAP2BUF match interrupt you are switching the QEB pin [PORTA.4] Low/High.??? why?

    Code (text):
    On High Interrupt
    Save System
    'interrupt on INDEX pulse PORTC.4 input.
    pir3.ic2qeif = 0  'clr in s/w, poscnt=maxcnt or indx
    PORTA.4 = 0
    ''Hserout "Ix=", #azimval, " ", #poscnt, CrLf
    PORTA.4 = 1
    pie3.ic2qeie = 1  'qei intr enb

    Resume

    Also why are you switching PORTC.5.?

    Code (text):
    If poscnt < azimval Then
    If azimval - poscnt >= 1800 Then
    PORTC.5 = 1  'rev passes thru 000 > 3599 index
    Else
    PORTC.5 = 0
    Endif
    Gosub pwm_cont
    Goto get_count  'keep reading cap2buf [poscnt]
    Endif
    Also what is 'forn' and 'revn' for, I thought you had agreed to hardware the transistors on the HBridge.?

    Code (text):
    If PORTC.5 = 0 Then  'FWD PWM
    revn = 0  '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
    ASM:        bcf CCP2CON,DC2B0
    ASM:        bcf CCP2CON,DC2B1
    ASM:        movlw 0x00
    ASM:        movwf CCPR2L
    PWMduty 1, duty1
    forn = 1  '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
    Endif
     
    Eric
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,420
    Likes:
    11
    Location:
    Dorset UK.

    PGM is wired to ground in the 'programming socket' we use, also the ZIF programming board. if Jumper is set.

    All unused pins are outputs.

    I'll soon look at wiring all the other pins to GND soon. I will try writing 0 to them all.

    C.
     
  6. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,420
    Likes:
    11
    Location:
    Dorset UK.
    Hi Eric,

    I think the PORT4 was the old pin for sending signals to the 18F4520. I notice that this is now on the QEB pin. Has this been the problem all of the time.

    I always 'try' to mark any changes I make to your programming with '>>>>>>>>>><<<<<<<<<<< So from memory I can only assume it must have been from you. I think I didn't spot all of these changes when I made the circuit board, which added a complication.

    I think the PORTC.5 may have been and OLD enable switch for the HBridge, but not sure.

    Likewise I think you might have been working with an idea, that when there is a POSCNT to CAP2BUF match, it send a signal to the 18F4520 PORTA.4 perhaps to send the next AxxxExxx signal.

    [Also what is 'forn' and 'revn' for, I thought you had agreed to hardware the transistors on the HBridge.?] The HBridge switching has always been a bit of a puzzle, and I made a 4X input bridge in case of later braking requirements. At the start we switched both sets of FETs together, but this only worked when set to over 150 ish PWM. I added the 'forn' and 'revn' pins so that the forward and Reverse NFETs could be switch independently, and this brought the PWM down to 30, before it was too slow to turn the motor. I did mention it, but it must have got lost in the saga:rolleyes:

    I always 'try' to mark any changes I make to your programming with '>>>>>>>>>><<<<<<<<<<< So from memory I can only assume that any without <<<<< must have been from you. I think I didn't spot all of these changes when I made the circuit board, which added a complication. Sorry if I haven't kept things as accurate as I should, I try my best:)

    C.
     
  7. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,420
    Likes:
    11
    Location:
    Dorset UK.
    Hi, Just tried a test where there is an 'Hserout "LINE 0xxx", CrLf' at that LINE, instead of the TOGGLE LED. Here's the result, including after sending AxxxExxx to the 18F2431. So the program appears to stall after LINE 184.

    Hserget hdr1 'remote Azimuth from 18F4520 PIC, it expects AxxxExxx in ASCII format
    Hserout "LINE 0184", CrLf

    If hdr1 <> "A" Then Goto clr_azim 'wait for 'A' sync character
    Hserout "LINE 0186", CrLf

    This was with a 'None working' PIC. Does this point to the Input signal levels from the Terminal/FTDI?

    C.
     

    Attached Files:

  8. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,420
    Likes:
    11
    Location:
    Dorset UK.
    Hi,

    Did the same TEST with the 'good' PIC and here's the result:

    It appears that this 1x PIC is the only one of 15x other PIC that is tolerant to the FTDI signal, whatever the difference is?

    C.
     

    Attached Files:

  9. granddad

    granddad Active Member

    Joined:
    Jan 18, 2015
    Messages:
    762
    Likes:
    76
    Location:
    Worcestershire UK
    Hi C. Does your FTDI have a strap or pad option for 5v / 3.3 v operation ? G ...
     
  10. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,420
    Likes:
    11
    Location:
    Dorset UK.
    Hi G,

    Yes, there is a jumper that switches between 3.3V and 5v. I'm sure I mentioned that I tried the 5V jumper and it had no affect. Someone replied, that it wouldn't make any difference.

    I'm pretty sure the problem is around this aea though. This is why I programmed an 18F4520 that outputs ony AxxxExxx at 1 Second intervals, to get round this.

    I have tried both, with thesame result:(

    C.
     
    Last edited: Apr 11, 2015
  11. granddad

    granddad Active Member

    Joined:
    Jan 18, 2015
    Messages:
    762
    Likes:
    76
    Location:
    Worcestershire UK
    C. The 2431 RX pin is a schmitt trigger input , Data sheet 'says' (pg 339) Vin high is .8 of Vdd so if Vdd = 5v a high (1) would need to be at 4v your FTDI needs to be set to 5V .and a use blocking diode / pullup on the RX to prevent the FTDI trying to power the pic . G.
    Edit the FTDI GND should always be comoned to pic Vss ( worth a MM check on all GND connections for continuity .)
     
    Last edited: Apr 11, 2015
  12. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    ONLINE
    Hi C,
    For some reason my 18F2431 are playing up on the comms.?? I have just programmed one using the PICKIT3 set up.

    I will resume debugging later today and tomorrow, let you know what I find.
    Its a sunny day so its gardening later today.!:woot:

    Eric
     
  13. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    ONLINE
    hi C,
    I was using a USB/UART converter which I recently bought from China, I could get data from the PIC 18F2431 to PC OK, but not from PC to PIC.
    The data to the PIC input from the converter appeared corrupted in some way.
    So I reverted back to my MAX232 for the UART comms, it works as before without any problems, see attached print out.

    Attached is known working copy of the Test program for the 18F2431 comms, use it to test your prommer and PIC's.
    Let me know your results.

    Eric

    NOTE:
    I have used a different bin to ascii conversion subr in place of the '#' prefix, it makes the print out easier to read.

    You can change the poscnt=0 in program listing, if you wish to test for different start up headings.

    There is NO PWM drive output, its internally counting
     

    Attached Files:

  14. granddad

    granddad Active Member

    Joined:
    Jan 18, 2015
    Messages:
    762
    Likes:
    76
    Location:
    Worcestershire UK
  15. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,420
    Likes:
    11
    Location:
    Dorset UK.
  16. granddad

    granddad Active Member

    Joined:
    Jan 18, 2015
    Messages:
    762
    Likes:
    76
    Location:
    Worcestershire UK
    Well I can only assume , guess, conclude, the PICs have a different revision level are you able to check this via PK3 2 pics have the same code ?
     
  17. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,420
    Likes:
    11
    Location:
    Dorset UK.
    Hi Eric,

    First test showed: See attachment.

    Second test, I added:
    Hserout "line 0107", CrLf

    If hdr1 <> "A" Then Goto clr_azim 'wait for 'A' sync character
    Hserout "line 0110", CrLf

    Terminal showed LINE 0107, but not LINE 0110

    C
     

    Attached Files:

  18. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,420
    Likes:
    11
    Location:
    Dorset UK.
    Hi G,

    There are two different batches of 18F2431.
    How do I check the revision?

    EDIT: Found it, and they're both the same.

    C.
     

    Attached Files:

    • REV.jpg
      REV.jpg
      File size:
      56.1 KB
      Views:
      112
    Last edited: Apr 13, 2015
  19. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,420
    Likes:
    11
    Location:
    Dorset UK.
    Hi Eric,

    Two 'none working' PICs have started.

    EDIT: Here's the log file:

    C
     

    Attached Files:

    Last edited: Apr 13, 2015
  20. granddad

    granddad Active Member

    Joined:
    Jan 18, 2015
    Messages:
    762
    Likes:
    76
    Location:
    Worcestershire UK
    So the $64000 question is what changed ?
     
  21. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,240
    Likes:
    645
    Location:
    Ex Yorks' Hants UK
    ONLINE
    I did notice the program listing that 'C' posted had the CONFIG set for LVP enabled, so I changed it back to what is was originally.

    Nothing has been changed in the UART routines, only the addition of the internal Poscnt and output formatting, so that 'C' could test his 18F2431's
    Also specified that PORT2,3,4 pins must be tied high or low, else the 18F's internal Poscnt QEA/B pins can pick up 'noise'.
     

    Attached Files:

Share This Page