PDA

View Full Version : I/O pin default low.



pescador
- 31st May 2023, 01:54
How do I set an output digital pin low by default?

16f15324 - pin PORTA.4

richard
- 31st May 2023, 02:58
this will do it


ansela = ~ 16
lata = ~ 16
trisa = ~ 16


but i doubt its the actual problem, i suspect you are most likely driving the mosfet improperly

pescador
- 31st May 2023, 03:55
Electronically I am driving it correctly.. its actually only driving an npn transistor..

Somehow my program is restarting when I introduce an input.

pescador
- 31st May 2023, 04:26
this will do it


ansela = ~ 16
lata = ~ 16
trisa = ~ 16


but i doubt its the actual problem, i suspect you are most likely driving the mosfet improperly


you are correct - with transistor out, it works - the transistor turns on the fet which has a load. With no load the code works - with load the program resets because the PIC output pin cant drive it on startup. Once its on and a load is then applied it works...

So I guess the question is how do I get the PIC to work with load already on.

richard
- 31st May 2023, 04:32
So I guess the question is how do I get the PIC to work with load already on.


provide more detail and a schematic to begin with

pescador
- 31st May 2023, 05:07
attached pdf

richard
- 31st May 2023, 06:35
that's a fairly standard sort of high-side switch that I would expect to be ok.

given that pic i/p leakage current is typically 100nA~ish MAX either R4 is not what is depicted
or your code is not as described [bootloader maybe].
you could try a smaller R4

Thats about all i can see



Somehow my program is restarting when I introduce an input.
is a different story, a big heavy load needs a good power supply and adequate filtering
together with a proper layout to prevent noise affecting the logic circuits

Acetronics2
- 31st May 2023, 07:16
Hi,

Please ...

- provide your full config section ( ports config included )
- provide your full schematics ( Pic + Supply + Power sections )

No way to give you a decent answer without those infos ...

Alain

pescador
- 31st May 2023, 12:13
I'll give more infor in a bit - but my guess while sleeping is filtering - I need a few caps on inputs and output - which are next to the reset pin. I'll try that tonight. - and maybe a larger one on the PIC itself.

I'll provide a better schematic and my code for ports etc later today.. I'm sure my code is different than what the good programmers use. I didnt use LAT for example - just ports.


thanks ahead of time...

pescador
- 31st May 2023, 12:33
ok - no insults please... - if someone wants to clean my code up for $ I'm all ears... - seriously...

16f153249435

schematic says it s 16f616 - its not - its a 16f15324 ********************

#CONFIG
__config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_ON & _FCMEN_OFF
__config _CONFIG2, _MCLRE_ON & _PWRTE_ON & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON
__config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_ON & _WDTCWS_WDTCWS_6 & _WDTCCS_SC
__config _CONFIG4, _BBSIZE_BB512 & _BBEN_OFF & _SAFEN_OFF & _WRTAPP_OFF & _WRTB_OFF & _WRTC_OFF & _WRTSAF_OFF & _LVP_OFF
__config _CONFIG5, _CP_ON
#ENDCONFIG


OSCCON1=%00000011
OSCCON2=%00000011
INLVLA = %11111
INLVLC = %1111111
TRISC = %11111111


DEFINE OSC 4
OSCFRQ_4MHZ

ANSELA = PORTA.2
ANSELC = %00000

OUTPUT PORTA.1 ' FAULT LED
OUTPUT PORTA.0 ' TIMING LED
OUTPUT PORTA.4 ' FET
INPUT PORTA.5 ' IGNITION
INPUT PORTC.5 ' V UNDER TRIP POINT - 11 OR 11.75
input PORTC.4 ' CHOICE BIT OF HOW THIS TURNS ON


SW1 - SW6 are inputs
green and red - outputs to leds
"Battery sense" is an analog in
"I sense" is a 12V in (broken down to <5v)
FET - output


whats happeing is when IG comes on the program resets when there is a load on FET - with no load it works. (I'm trying more filtering on IG AND FET output and make sure C3 is .1)

btw - insult it all you want...

Again - I'm all ears on someone helping me - lmk I'll giv emy email and set it up.

Acetronics2
- 31st May 2023, 15:14
Top secret electronic ignition ??? .... ;)
MC3334P clone ?

- ADC inputs have a maximum input feed impedance to respond as fast as required ... see Pic datasheet for details.

so, I presume @ first sight your current detection is wayyyy too slow, and your coil enters saturation ...

add to that your IPB protection is wayyy too weak and slow !!! be prepared for in-use failures, after some running time.

Now, automotive circuits need lots of filtering to avoid pic supply surges ...

Alain

pescador
- 31st May 2023, 15:31
Top secret electronic ignition ??? .... ;)
MC3334P clone ?

- ADC inputs have a maximum input feed impedance to respond as fast as required ... see Pic datasheet for details.

so, I presume @ first sight your current detection is wayyyy too slow, and your coil enters saturation ...

add to that your IPB protection is wayyy too weak and slow !!! be prepared for in-use failures, after some running time.

Now, automotive circuits need lots of filtering to avoid pic supply surges ...

Alain


No current detection - just if IG is on (12V) and monitors battery voltage - this all working for past 5 years. Discovered the issue of no load it starts right up - with load it resets program. In other words I can turn it on with Ignition and then apply load - works. But I can tell the program gets reset because I put a turn on/off red led before the main and it comes on when IG is applied. I'll try caps later tonight on signals.

I also do not think code is correct setting up registers. Thats what I want help on.

pescador
- 31st May 2023, 15:32
Top secret electronic ignition ??? .... ;)
MC3334P clone ?

- ADC inputs have a maximum input feed impedance to respond as fast as required ... see Pic datasheet for details.

so, I presume @ first sight your current detection is wayyyy too slow, and your coil enters saturation ...

add to that your IPB protection is wayyy too weak and slow !!! be prepared for in-use failures, after some running time.

Now, automotive circuits need lots of filtering to avoid pic supply surges ...

Alain


no - not a clone of MC3334P - it just turns on a load if IG is present.
by the time I get the IG signal its been filtered.

What coil?

IPB?

tumbleweed
- 31st May 2023, 18:01
Your ANSELA statement is incorrect... you don't set it that way.

pescador
- 31st May 2023, 20:27
Your ANSELA statement is incorrect... you don't set it that way.


ok - please elaborate..

tumbleweed
- 31st May 2023, 22:04
ANSELA is an 8-bit register... you set it just like any register, 0-255

If you want RA2 to be analog but all others digital then ANSELA = %00000100

You have something very different... ANSELA = PORTA.2, which will read the value of the port pin and assign it to ANSELA (whatever that results in).