Continue to Site

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.

  • 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.

Intermittent working PICs

Status
Not open for further replies.
Bug2, I've tried all possible programming combinations I think.
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.)

Also I have extensively run a test program for the 18F2431 UART RXD function, the OERR and FERR are NOT a problem
Eric was this a simulation or actual hardware ?
 
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
 
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:
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:
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:
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
 
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 ?

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.
 
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:
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:
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:
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

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.
 
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.
 

Attachments

  • LINE 0184.jpg
    LINE 0184.jpg
    114.6 KB · Views: 379
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.
 

Attachments

  • line2.jpg
    line2.jpg
    150.6 KB · Views: 379
Hi C. Does your FTDI have a strap or pad option for 5v / 3.3 v operation ? G ...
 
Hi C. Does your FTDI have a strap or pad option for 5v / 3.3 v operation ? G ...

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:
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:
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
 
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
 

Attachments

  • Test2431_V5.txt
    5.3 KB · Views: 385
  • TestPrintOut.txt
    1.8 KB · Views: 352
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 ?
 
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

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
 

Attachments

  • TEST.jpg
    TEST.jpg
    67.5 KB · Views: 354
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 ?

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.
 

Attachments

  • REV.jpg
    REV.jpg
    56.1 KB · Views: 355
Last edited:
Hi Eric,

Two 'none working' PICs have started.

EDIT: Here's the log file:

C
 

Attachments

  • 130415LOG.txt
    22.9 KB · Views: 385
Last edited:
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'.
 

Attachments

  • AAesp01.gif
    AAesp01.gif
    5 KB · Views: 348
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top