Comparator not working properly when external supply is on EasyPIC7

jayanthd

Joined Jul 4, 2015
945
Hello Jayanthd.
I found out that during the rising of current (and voltage on shunt) there's a drop in gnd value.
So, if you take into account this (see enclosure) the voltage on RA3 drops really when it is equal to value set on pot (RA0).

Remains to me to understand why I have this drop in gnd, if it is due to inductor, to mosfet, or what else cause.
For the moment I do not know.
Then how does it work fine when EasyPIC v7 is powered from USB cable from PC ? When powered from USB there is no dip in GND voltage ?
 

Thread Starter

roxi60

Joined Sep 2, 2018
73
Enclosed find the two connection cases with wire connections.

1. when the grounds are connected with black wire: both with USB and external power I have gnd drop like diagrams enclosed.

2.when the grounds are not connected (no black wire): with USB no gnd drop (OK), with external power does not work.
 

Attachments

Thread Starter

roxi60

Joined Sep 2, 2018
73
It seems that the problem was the connection of the ground of the voltage probe to the ground of the circuit.
When I disconnect it, the signals are as expected.
Strange because using a tester to check continuity all 4 grounds show continuity.

Anyway that's all.

Thank you jayanthd.
 

Attachments

jayanthd

Joined Jul 4, 2015
945
Okay.

This ISR is not triggering. Can somebody tell how to fix it. This code I wrote using OshonSoft PIC Simulator IDE.

Code:
    #include <P16F877A.INC>
   
    ORG     0000H
    GOTO     START
   
INT0CHK:
    GOTO INT0_ISR
   
    ORG    0004H
INT0_ISR:   
    BCF    INTCON,INTF
    BSF    PORTB,5
       
    RETFIE
   
START:
    MOVLW    04H
    MOVWF    CMCON
   
    CLRF    CVRCON
   
    MOVLW    04H
    MOVWF    ADCON0
   
    MOVLW    82H
    MOVWF    ADCON1
   
    MOVLW    09H
    MOVWF    TRISA
   
    MOVLW    03H
    MOVWF    TRISB
   
    CLRF    TRISC
    CLRF    TRISD
    CLRF    TRISE
   
    CLRF    PORTA
    CLRF    PORTB
    CLRF    PORTC
    CLRF    PORTD
    CLRF    PORTE
       
    BSF    OPTION_REG,INTEDG
    BCF    INTCON,INTF
    BSF    INTCON,INTE
   
    BSF    INTCON,PEIE
    BSF    INTCON,GIE       
LOOP       
    BTFSS    CMCON,C1OUT
    GOTO    L1
    BCF    PORTB,5
L1:
    BTFSS    PORTB,1
    GOTO     L2
    GOTO    EXIT
L2:
    GOTO LOOP
EXIT:       
    SLEEP
    END
 

Thread Starter

roxi60

Joined Sep 2, 2018
73
As far as I know you have to jump properly through the banks of 16F877A:
Code:
    #include <P16F877A.INC>
  
    ORG     0000H
    GOTO     START
  
INT0CHK:
    GOTO INT0_ISR
  
    ORG    0004H
INT0_ISR:
   
    BCF    INTCON,INTF
    BSF    PORTB,5
      
    RETFIE
  
START:
    banksel TRISB
    MOVLW    04H
    MOVWF    CMCON
    MOVLW    82H
    MOVWF    ADCON1
   
    MOVLW    09H
    MOVWF    TRISA
  
    MOVLW    03H
    MOVWF    TRISB
  
    CLRF    TRISC
    CLRF    TRISD
    CLRF    TRISE
   
    BSF    OPTION_REG,INTEDG
    BCF    INTCON,INTF
    BSF    INTCON,INTE
  
    BSF    INTCON,PEIE
    BSF    INTCON,GIE  
   
    CLRF    CVRCON
   banksel PORTB
    MOVLW    04H
    MOVWF    ADCON0
  
    CLRF    PORTA
    CLRF    PORTB
    CLRF    PORTC
    CLRF    PORTD
    CLRF    PORTE
      
      
LOOP 
    banksel TRISB
    BTFSS    CMCON,C1OUT
    GOTO    L1
    banksel PORTB
    BCF    PORTB,5
L1:
    banksel PORTB
    BTFSS    PORTB,1
    GOTO     L2
    GOTO    EXIT
L2:
    GOTO LOOP
EXIT:     
    SLEEP
    END
To Moderator: I can not find the tag mpasm to format the code, where is it?
Thank you
 

jayanthd

Joined Jul 4, 2015
945
Okay.

mpasm tag =

code=mpasm
/code

then two lines enclosed in [ ] each like this

Code:
#include <P16F877A.INC>

    ORG     0000H
    GOTO     START


INT0CHK:
   GOTO INT0_ISR


   ORG    0004H
[*]INT0_ISR:
   
    BCF    INTCON,INTF
    BSF    PORTB,5
     
   RETFIE


START:
   banksel TRISB
   MOVLW    04H
   MOVWF    CMCON
   MOVLW    82H
   MOVWF    ADCON1
   
   MOVLW    09H
   MOVWF    TRISA


   MOVLW    03H
   MOVWF    TRISB


   CLRF    TRISC
   CLRF    TRISD
   CLRF    TRISE
  
   BSF    OPTION_REG,INTEDG
   BCF    INTCON,INTF
   BSF    INTCON,INTE


   BSF    INTCON,PEIE
   BSF    INTCON,GIE 
   
   CLRF    CVRCON
   banksel PORTB
   MOVLW    04H
   MOVWF    ADCON0

   CLRF    PORTA
   CLRF    PORTB
   CLRF    PORTC
   CLRF    PORTD
   CLRF    PORTE
    
     
LOOP
    banksel TRISB
    BTFSS    CMCON,C1OUT
    GOTO    L1
    banksel PORTB
    BCF    PORTB,5
L1:
    banksel PORTB
    BTFSS    PORTB,1
    GOTO     L2
    GOTO    EXIT
L2:
    GOTO LOOP
EXIT:   
    SLEEP
    END
 
Top