How do I set an output digital pin low by default?
16f15324 - pin PORTA.4
How do I set an output digital pin low by default?
16f15324 - pin PORTA.4
My dad never liked you...
this will do it
but i doubt its the actual problem, i suspect you are most likely driving the mosfet improperlyCode:ansela = ~ 16 lata = ~ 16 trisa = ~ 16
Warning I'm not a teacher
Electronically I am driving it correctly.. its actually only driving an npn transistor..
Somehow my program is restarting when I introduce an input.
My dad never liked you...
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.
My dad never liked you...
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
Warning I'm not a teacher
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
is a different story, a big heavy load needs a good power supply and adequate filteringSomehow my program is restarting when I introduce an input.
together with a proper layout to prevent noise affecting the logic circuits
Last edited by richard; - 31st May 2023 at 07:42.
Warning I'm not a teacher
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
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
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...
My dad never liked you...
ok - no insults please... - if someone wants to clean my code up for $ I'm all ears... - seriously...
16f15324PIC-SCHEM.pdf
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.
Last edited by pescador; - 31st May 2023 at 13:55.
My dad never liked you...
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
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
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.
My dad never liked you...
Your ANSELA statement is incorrect... you don't set it that way.
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).
Bookmarks