I am soooo very stuck with this project.
I did a lot of study to make this thing, but it was all during a time where I was on slow release morphine patches. The result is I now have absolutely no idea what it does and how it does it.
I understand there is a fair chance that if I put another patch back on, it will all come back to me, but I'd rather eat a glass sandwich.
So...
I have a board with some stuff on it. It has another little board that was to house some buttons and a power switch.
What I'm hoping for is a local who is willing to have a look at it and try to help me figure out what is going on. I've spent many many hours just staring at it. I could also use a lesson in how to go about working out what something does.
So if anyone is feeling generous, knows electronics, and lives in Adelaide, can you let me know 
It looks like this...
Attachment:
120 Things in 20 years - Electronics - demand fish feeder mess.JPG [ 186.85 KiB | Viewed 4392 times ]
As far as I can remember, I think all I had to do was cut some tracks, connect the blue wires to their pins on the chip, and build the front add-on board that creates the front panel, holds the switches. I think there was a switch for "feed now", one as a mode button to switch between different things to adjust eg feed amount, number of feeds per day, and a power switch.
One of my problems is I dont undertsand what I've done any more, so I cant tell where the tracks should be cut, and other is that I cant follow the design enough to see what I should be doing with the front switches.
The software on the other hand looks a lot better.
I cant remember if it works, but at least it has some comments.
The code runs in 3 parallel streams - Main:, Start1:,and Start2:. One line from each is executed in turn to create pseudo multitasking. The latest version looks like this (but there is an earlier version marked "stable" so this might be full of holes...
Code:
'
'Demand Fish Feeder 14M2 ver 4 2011-11-08-2025
{
'----------------------------------------------------------------
'NO RIGHTS RESERVED
'----------------------------------------------------------------
'This project is an open source demand fish feeder.
'All aspects of the project are open source, including software, and hardware (both
'electronics, and actual PVC delivery device) and are given freely to the world to do with as you wish.
'The fish recieve feed when certain conditions have been met.
'Features include....
'* Fish trigger a lever to get fed, but can only do so when a LED is lit indicating
' to the fish that feed is avalible
'* Minimum delay between feeds calculated on ramainder of day and number of feeds
' still availible for the day
'* User set maximum feeds per day (1 - 24)
'* User set feed size
'* The "Day" resets at dawn regardless of actual time so that fish run
' on a natural cycle
'* LED's flash reports for...
' Feeds so far today (External)
' Feed size (Internal LED reports only when being adjusted)
' Maximum feeds per day (Internal LED reports only when being adjusted)
'* "Feed now"button to override forced delay time so you can trigger the feeder at will
}
#NO_DATA
#PICAXE 14M2
#SIMTASK 1
'------------ Symbols ------------------------------------------
{
'Pins ----------------------------------------------------------
Symbol Motor = c.0
Symbol ReportFeedsTodayLED = c.1
Symbol FishLever = PinC.2
Symbol ModeButton = pinC.3
Symbol FishLeverLED = c.4
Symbol FeedNowButton = PinC.5
Symbol FeedsPerDayLED = B.0
'Symbol DawnPhotoresistor = B.1
Symbol FeedSizeLED = B.2
Symbol DawnPot = B.3
Symbol FeedsPerDayPot = B.4
Symbol FeedSizePot = B.5
'Constants------------------------------------------------------
Symbol OneMinute = 2 'in seconds - for debug change from 60 (seconds) to 1
Symbol DayLength = 1440 'in minutes
Symbol LongReportPause= 1000 'recommend 15000 = 15 seconds between TodaysFeeds reports
Symbol ShortReportPause = 1000
symbol MaxModes = 4 'sets the number of modes the mode button cycles through
'---------------------------------------------------------------
'word variables--------------w1 and up -------------------------
Symbol DayRemain = w1
Symbol FeedWait = w2
Symbol FeedSize = w3
Symbol ReportPause = w4 'used in Start2
'----------------- do not overlap ---
symbol i = b16 'as localised counter - reuse at will
Symbol PotVariable = b17
Symbol LED2Variable=b18 'used in Start2 to select LED to use for report
Symbol LEDVariable =b19 'used in Start2 to select LED to use for report
Symbol ReportVariable = b20 'used in Start2 To Select PotData to report
Symbol FeedsRemain = b21
Symbol FeedsPerDay = b22
Symbol Counter2 = b23
Symbol Counter1 = b24
Symbol TodaysFeeds = b25
Symbol LastFeed = b26
Symbol CurrentMode = b27
'byte variables ^^^-^^^-^^^-- b27 and down ---------------------
'bytes b0 and b1 as flags -- bit 0 -----------------------------
Symbol AdjustMode = bit0
Symbol AllowFeed = bit1
Symbol FeedNow = bit2
'--------------------------- to bit 15 -------------------------
'---------------------------------------------------------------
'===============================================================
}
'000000000000000000000000000000000000000000000000000000000000000000
'TODO: debug only delete at will--------------------------------
'Populate some variables for debug only as these will be set with trim pots
let FeedSize = 3
let FeedsPerDay =255 'large number for testing only as I cant wait all day
'000000000000000000000000000000000000000000000000000000000000000000
'------------------------------------------------------------------
'
Main:'=============================================================
{
Do
GoSub NewDayInit 'initialize everything required to reset for a new day
GoSub OngoingChecks 'main program loop that checks everything continuously
Loop
end
}
'-- Main Subs -----------------------------------------------------
'------------------------------------------------------------------
BootTest: 'Flash the lights at startup so you know something is happening
{
'high ReportFeedsTodayLED
'pause 300
'low ReportFeedsTodayLED
'return
}
'------------------------------------------------------------------
NewDayInit: 'used at the beginning of each new day
{
'let FeedNow = 1
'let LeverLED = 1
'if LeverLED = 1 then' TODO: not sure why this is needed but I was seeing some strange results
'High FishLeverLED
'endif
'get each pot setting (check MaxModes value)
'Gosub Mode1 ' not required as not a pot setting
Gosub Mode2 'Feed Size
Gosub Mode3 'Feeds Per Day
Gosub Mode4 'Dawn
let CurrentMode = 1
let DayRemain = DayLength
let FeedsRemain = FeedsPerDay
let FeedWait = DayRemain / FeedsRemain
let TodaysFeeds = 0'FeedsPerDay - FeedsRemain ' for Start2 report feeds
let time = feedwait 'set time to feed now
return
}
'------------------------------------------------------------------
OngoingChecks: 'main program loop that checks for unusual events continuously
{
Do
Gosub CreateMinutes: ':TODO
#rem
'I wonder if this should be based, rather than on minutes, on a day devided by the number of feeds.
'this way we reduce the errors gained each time we say ...
if Time > 60 then
OurMinutes = OurMinutes + 1
end if
this could lose up to .99 of a second each time it runs. It would probably average out, but it might be better to do...
if Time > DayInMinutes / FeedsPerDay then
Our Minutes = something or another
just a thought, but as I'm thinking it I worried about what it would do when someone changed the number of feeds per day
halfway through a day. And worried about what pressing the FeedNow button might do.
I think all that worry means we need a concrete way of measuring time. Perhaps we could use 5 or 10 minute segments to cut down
on errors, or perhaps we should just run it and see if it averages out to a reasonable error over 24 hours.
#endrem
'TODO: fix this bit
'Gosub CheckForDawn ' 'TODO get those electronics working and work out some code to read the light levels
'GoSub NewDayInit ' perhaps this should be in the CheckForDawn Gosub???????
'loop
'check for button press - give them an extra feed override
Gosub CheckForFeedNowButton
Let FeedNow = 1 'TODO : check to see if FeedNow is actually used properly, and check to see if this line would be over-ridden
Loop
return 'only seen at dawn to bail out and go back to main for a new day init
}
'------------------------------------------------------------------
CreateMinutes:
'code for taking Time, and turning it into minutes must be run at least every second
Return
'------------------------------------------------------------------
CheckForFeedNowButton:
{
if FeedNowButton = 1 then
Gosub WaitForFeedNowButtonRelease
endif
return
}
''------------------------------------------------------------------
WaitForFeedNowButtonRelease:
{
high b.1
high b.2
High b.4
Do while FeedNowButton = 1 :Loop
low b.1
low b.2
low b.4
return
}
'============== End Main ==========================================
'
Start1:'======= check for feed status==============================
{
Pause 1000 'for Init
Do
let LastFeed = time/OneMinute 'calculate and store the number of minutes since last feed
if FeedsRemain = 0 then
goto Start1 ' bail out of the loop if they cant have any more feeds
endif
if LastFeed < FeedWait then
goto Start1 ' bail out of the loop if time isnt up
endif
let feednow = 1
if FeedNow = 1 then
high FishLeverLED
Gosub CheckForLeverPress 'fish are not allowed to feed
end if
Loop
}
'-- Start1 Subs ---------------------------------------------------
CheckForLeverPress:
{ Do
Do Until FishLever = 1 :Loop
GoSub WaitForFishLeverRelease
GoSub NewFeedPeriodInit
GoSub Feed
return
Loop
}
'------------------------------------------------------------------
WaitForFishLeverRelease:
{
high b.1
high b.2
High b.4
Do while FishLever = 1 :Loop
low b.1
low b.2
low b.4
return
}
'------------------------------------------------------------------
NewFeedPeriodInit: 'Used after each feed
{
let FeedsRemain = FeedsRemain - 1
let FeedWait = DayRemain/FeedsRemain
let FeedNow = 0 ' dont feed the greedy things just yet
let TodaysFeeds = TodaysFeeds + 1 ' for Start2 report feeds
low FishLeverLED '0 switch off the lever LED
let time =0'reset time to reset minutes since last feed
return
}
'------------------------------------------------------------------
Feed:' Delivers feed
{
High Motor 'PWMOUT
Pause FeedSize
Low Motor
Return
}
'
'============= End Start1 =========================================
'
Start2:'=== LED reports and end mode switching to adjust pots =====
{ 'TODO: get rid of the gotos
Let CurrentMode = 1
do
Gosub GetCurrentModeData
if ModeButton = 1 then 'increment to next mode
gosub WaitForModeButtonRelease
gosub GetCurrentModeData
endif
pause ReportPause 'pause for the desired time between each report
if ReportVariable = 0 then
goto FlashZero
endif
Counter2 = ReportVariable/10 'isolate tens
for Counter1 =1 to Counter2 'flash tens
if Counter2=0 then
goto Remainder
exit
end if
high LEDVariable
high LED2Variable 'LED on
pause 800
low LEDVariable
low LED2Variable 'LED off
pause 40
high LEDVariable
high LED2Variable
pause 40
low LEDVariable
low LED2Variable
Pause 780
next Counter1
Remainder:
Counter2 =ReportVariable//10 'isolate remainder
for Counter1 =1 to Counter2 'flash units
if Counter2=0 then
goto FlashZero
end if
high LEDVariable
high LED2Variable
pause 200
low LEDVariable
low LED2Variable
pause 200
next Counter1
FlashZero:
high LEDVariable
high LED2Variable
pause 40
low LEDVariable
low LED2Variable
loop
}
'-- Start2 Subs ---------------------------------------------------
GetCurrentModeData:
{
if CurrentMode = 1 then
gosub Mode1
end if
if CurrentMode = 2 then
gosub Mode2
end if
if CurrentMode = 3 then
gosub Mode3
end if
if CurrentMode = 4 then
gosub Mode4
endif
if CurrentMode > MaxModes then 'if you have run out of modes
let CurrentMode = 1 'go back to the first mode
end if
return
'------------------------------------------------------------------
'Mode# code
{
Mode1:
let ReportVariable = TodaysFeeds
let LEDVariable = ReportFeedsTodayLED
let LED2Variable = ReportFeedsTodayLED
let ReportPause = LongReportPause
Return
'------------------------------------------------------------------
Mode2:
Readadc FeedSizePot,ReportVariable 'poll a number between 0 and 255 from the pot and store it in ReportVariable
ReportVariable = ReportVariable / 5 'give it a human scale to chunk it into noticable differences
let LEDVariable = FeedSizeLED 'set the LED to use
let LED2Variable = FeedSizeLED 'Dawn requires 2 LED's so code expects a 2nd LED. In this case its just the same as the first
let ReportPause = ShortReportPause 'chooses the time it should wait between each flashing out of the value.
return
'------------------------------------------------------------------
Mode3:
Readadc FeedsPerDayPot, ReportVariable
ReportVariable = ReportVariable / 20
LEDVariable = FeedsPerDayLED
LED2Variable = FeedsPerDayLED
ReportPause = ShortReportPause
return
'------------------------------------------------------------------
Mode4:
Readadc DawnPot, ReportVariable
ReportVariable = ReportVariable / 5
LEDVariable = FeedSizeLED
LED2Variable = FeedsPerDayLED
ReportPause = ShortReportPause
return
}
'------------------------------------------------------------------
WaitForModeButtonRelease:
{
CurrentMode = CurrentMode + 1 'increment to next mode
high b.1
high b.2
high b.4
Do Until ModeButton = 0 :Loop
low b.1
low b.2
low b.4
return
}
'
'==============End Start2 =========================================
'
'--------------NOTES ONLY -------------------------------
{
'TODO: change all notifications to single bit based flags
'TODO: check to see if double allow is just because there are the same number of feeds as minutes
'TODO: I've doubled up on the variables and methods for defining remaining feeds
'I think IsFeedOK also doubles up on some stuff
'TODO:in NewDayInit DayRemain isnt refreshed in any way
'TODO: work something out to counter switch bounce if required
}