FIREMANJIM
New Member
I am reading the manual on the 14M2 Chip and it says a interrupt can be set on inputs 1,2,and 3. Does that mean c1, b1 or what??? Really confused because I am new at this. Thanks in advance for any help
symbol CDSPwr = b.0
symbol CDSRead = b.1
symbol SlavePwr = b.2
symbol PTPwr = b.3
symbol PTInput = pinb.4
symbol LED = b.5
symbol DIP5 = pinc.0
symbol DIP4 = pinc.1
symbol DIP3 = pinc.2
symbol DIP2 = pinc.3
symbol DIP1 = pinc.4
symbol DayStatus = bit0
symbol SlaveOn = bit1
symbol PTPwrOn = bit2
symbol DayLevel = b4
symbol DaySetting = b5
symbol NightSetting = b6
symbol Counter = b7
symbol SlaveOnTimer = w3
symbol SlaveOnTime = w4
symbol SlaveRefreshTime = w5
symbol SlaveRefreshTimer = w6
symbol CheckCDSTime = w7
symbol CheckCDSTimer = w8
disablebod
low CDSPwr
low SlavePwr
low PTPwr
low LED
' set input pins as inputs
Input b.4
Input c.0
Input c.1
Input c.2
Input c.3
Input c.4
' set default variable settings
SlaveOn = 0
PTPwrOn = 0
DayStatus = 1
DaySetting = 128
NightSetting = 117
CheckCDSTime = 19350 '2.5 minutes 1 second = 129
SlaveOnTime = 3225 '25 seconds 1 second = 129
SlaveRefreshTime = 61921 '7.0 minutes 1 second = 129
nap 5
High LED
Pause 1000
High SlavePwr
SlaveOn = 1
Pause 30000
Low SlavePwr
SlaveOn = 0
SlaveRefreshTimer = 0
Pause 1000
Low LED
Pause 2000
High CDSPwr ' apply power to CDS sensor
nap 5 ' allow power to settle
readadc CDSRead, DayLevel
low CDSPwr
if DayLevel <= NightSetting then
DayStatus = 0
pause 500
endif
if DayLevel >= DaySetting then
DayStatus = 1
pause 500
endif
Pause 1000
GoSub Flash
Pause 1000
GoTo MainProgramLoop
Flash:
for Counter = 1 to 10
high LED
pause 200
low LED
pause 200
next Counter
return
MainProgramLoop:
If DayStatus = 1 Then
GoTo DayProgram
Else
High SlavePwr
SlaveOn = 1
High PTPwr
PTPwrOn = 1
GoTo NightProgram
EndIf
DayProgram:
If DayStatus = 1 Then
sleep 131
high CDSPwr ' apply power to CDS sensor
nap 5 ' allow power to settle
readadc CDSRead, DayLevel
low CDSPwr
if DayLevel >= DaySetting then
DayStatus = 1
CheckCDSTimer = 0
If PTPwrOn = 1 Then
Low PTPwr
PTPwrOn = 0
EndIf
If SlaveOn = 1 Then
Low SlavePwr
SlaveOn = 0
EndIf
EndIf
if DayLevel <= NightSetting then
DayStatus = 0
CheckCDSTimer = 0
If PTPwrOn = 0 Then
High PTPwr
PTPwrOn = 1
EndIf
If SlaveOn = 0 Then
High SlavePwr
SlaveOn = 1
EndIf
Pause 500
GoTo NightProgram
endif
pause 500
EndIf
Nap 3
GoTo DayProgram
NightProgram:
If DayStatus = 0 Then
If PTInput = 1 Then
High SlavePwr
SlaveOn = 1
SlaveOnTimer = 0
EndIf
if SlaveOn = 1 then
SlaveOnTimer = SlaveOnTimer + 1 'increment temporary counter for leaving the slave on
if SlaveOnTimer >= SlaveOnTime then 'flash recharge set to about 25 seconds no
Low SlavePwr ' turn slave off
SlaveOn = 0
SlaveOnTimer = 0
SlaveRefreshTimer = 0
pause 500
endif
endif
CheckCDSTimer = CheckCDSTimer + 1
If CheckCDSTimer >= CheckCDSTime then
high CDSPwr ' apply power to CDS sensor
nap 5 ' allow power to settle
readadc CDSRead, DayLevel
low CDSPwr
if DayLevel <= NightSetting then
DayStatus = 0
CheckCDSTimer = 0
If PTPwrOn = 0 Then
High PTPwr
PTPwrOn = 1
EndIf
pause 500
endif
if DayLevel >= DaySetting then
DayStatus = 1
CheckCDSTimer = 0
If PTPwrOn = 1 Then
Low PTPwr
PTPwrOn = 0
EndIf
If SlaveOn = 1 Then
Low SlavePwr
SlaveOn = 0
EndIf
pause 500
GoTo DayProgram
endif
EndIf
SlaveRefreshTimer = SlaveRefreshTimer + 1
if SlaveRefreshTimer >= SlaveRefreshTime then
high LED '************************************************
pause 500
high SlavePwr
SlaveOn = 1
pause 10000
low SlavePwr
SlaveOn = 0
SlaveRefreshTimer = 0
pause 500
Low LED '**************************************************
EndIf
EndIf
Goto NightProgram
I believe that the 'confusion' arises in the PICAXE manual2 (has been modified in online command pages) because under the SETINT command the "Restrictions" for 14M/14M2 mention inputs 0, 1 and 2"Welcome to the PICAXE forum.
Please accept our apologies for any confusion and if you can tell us where the confusing information is we can see what we can do about improving that.
On the 14M2 the pins which can be used to trigger interrupts using the SETINT command are pins C.0, C.1 and C.2
A PICaxe (core) running at 4 MHz consumes about 600 uA (i.e. no more than 3 mW), is that a problem? If so, then you have presumably designed all the rest of the hardware to use a comparable average power?in night mode I can not put in the nap 3 because it misses the flash firing so it has to run at a straight 4mhz. I am thinking I need to use a SETINT for the PT sensor instead of what I am doing now. I think a SETINT will monitor the PTInput pin more allowing me to use a nap 3
this is the question, essentially yes - if you don't want them to wake the system using a M2 chip. using the interrupt will allow you to check for daylight in a continuous loop, the interrupt iirc will be checked by the picaxe between every command execution. hardware interrupts are generally accepted to be faster.When the chip is in sleep mode it is daytime and the PT Input is not even powered on. It is simply waiting for night time to arrive. When the CDS sensor sees it is night it Powers on the PT sensor and turns on the slave for 30 seconds to charge it all the way up. So sleep is not the issue. I can redesign the board have more made for less than $50.00 so that is fine. I guess what I need to know is a interrupt the best way for me to accomplish what I need???
Have you tried to measure any current values under various conditions.I finally got this thing working perfectly using the interrupt running at 4mhz. Has not missed a beat in 3 days. How much greater will the battery drain be running it at a straight 4mhz without a nap 3 at the bottom of the code than it would be at 4mhz with a nap 3 at the bottom of the code??? I am assuming that it won't be that significant. And help appreciated.