pause puts me in sleep mode
Its Edward again, with yet another problem.
i have a solenoid being driven by a NPN transistor. the base of the NPN is conneted to portc.2 if i make portc.2 output high it will turn on the solenoid as expected. i also have a push button connected to portb.0.
the goal is to turn on the solenoid for a short deley then turn off.
now comes the problem
when i use the PAUSE command it puts my pic 16f73 into low power mode or something, cause i only read ~3.5 volts on the vdd.
below are the two codes.
both codes work when led+resistor unit replace solenoid (no solenoid)
one works the other does not when solenoid is connected (solenoid)
'works
TRISC=235 'set PORTC as output on needed pins
TRISB=251 'PORT B INPUT EXCEPT on uneeded
'------------------------------------
MAIN:
PORTC=%00010000 'PWR LOCK-ON & solenoid data low
IF PORTB.0=1 THEN 'BUTTON 2 IS PRESSED ACTIVATE SOLENOID
GOTO SHOOT
ENDIF
IF PORTB.4 = 1 THEN 'BUTTON 1 IS PRESSED THEN EXIT
GOTO EXIT
ENDIF
GOTO MAIN
'---------------------------------------------------
EXIT:
PORTC = %00000000 'LOW PORTC all PWR OFF
END
'---------------------------------------------------
SHOOT:
PORTC.2 = 1 'SOLENOID ACTIVE
GOTO MAIN
'-------------------------------------------------
'doesnt work below
TRISC=235 'set PORTC as output on needed pins
TRISB=251 'PORT B INPUT EXCEPT on uneeded
'------------------------------------
PORTC=%00010000 'PWR LOCK-ON
MAIN:
IF PORTB.0=1 THEN 'BUTTON 2 IS PRESSED ACTIVATE SOLENOID
GOTO SHOOT
ENDIF
IF PORTB.4 = 1 THEN 'BUTTON 1 IS PRESSED THEN EXIT
GOTO EXIT
ENDIF
GOTO MAIN
'---------------------------------------------------
EXIT:
PORTC = %00000000 'LOW PORTC all PWR OFF
END
'---------------------------------------------------
SHOOT:
PORTC.2 = 1 'SOLENOID ACTIVE for 1/5 seconds
PAUSE 200 '<- RIGHT HERE RIGHT HERE RIGHT HERE IS PROBLEM!
PORTC.2 = 0
GOTO MAIN
'-------------------------------------------------
lastly when i disonnect the solenoid everything works fine again without a need to reset the pic. so the working model only alows the solenoid active AS LONG AS IM HOLDING BUTTON 2 DOWN. not a desired function i want the solen active for x number of seconds then off.
2 things come to mind.
1. if it was a hardware problem, why would it work just fine without the pause command.
2. when i tell portc.2 = 0 could that effect anyother pin on the portc?
u should also know that i have a "power on" command. becaue my boards power button is momentary button, the board was desgned that as long as portc.4 is high the vdd will be 5+. the board basically works like this.
1 press and hold pwr momentary button.
2 that sends 5+ to the pic and it starts the program
3 in the program I put portc.4 = 1 so that the vdd Locks-On
4 to power off pic just portc.4 = 0 or all of portC=0
5 that makes a transistor somewhere "off"
sory if i made this one too long.
1 Attachment(s)
schematic for solenoid/driver
ok i tried to make a shcematc for ya. disregard the black box around the circuit if any.
Im not sure if the (B) PNP transistor is in fact a PNP, it could be some weird 3 pin device.
also its werid how there is a 5+ going into the solenoids RED supply and 4.2+ going into the solenoid on the BLACK supply. when i drive the npn base high (portc.2) the solenoid gets "stuck on" the 4.4 that was present on the BLACK is now 0vdc. and the RED is at 3.5 vdc, meaning the vdd is at 3.5.
even if i drive the portc.2 LOW the transistor stays on cause the board has "crashed". now i cant read the voltage at the transistor base because when i put the (my multimeter) black probe on the battery ground and the red probe
on the NPN base it drives the base Low making te solenoid turn off, and putting 5+ back on the VDD, thereby reseting the pic to the top of the program. if i disconnect the solenoid, i get all the expected reading at the expected times, e.g. portc.2 will actully out a 5+ vdc when i tell it to and 0vdc when i tell it too.
lastly, im telling you there is not a harware problem, power supply problem, solenoid problem. i have tested all my parts on another board, that still has the old code, and they work.