Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: Headless MX170 controller Post ReplyPost New Topic
<< Prev Page of 2
Author
Message << Prev Topic | Next Topic >>
TassyJim
Guru
Guru


Joined: 07 August 2011
Location: Australia
Online Status: Offline
Posts: 2538
Posted: 07 January 2018 at 11:06am | IP Logged Quote TassyJim

Bill7300 wrote:
and for some reason, I am unable to get the gerbers from that Drop Box link. It wont download, giving an error message every time I try. Is this peculiar to me or have others had this problem?

Bill

No problems downloading here.

Jim

__________________
It all started with the ZX81....
VK7JH
http://www.c-com.com.au/MMedit.htm


Back to Top View TassyJim's Profile Search for other posts by TassyJim Visit TassyJim's Homepage
 
Azure
Senior Member
Senior Member
Avatar

Joined: 09 November 2017
Location: Australia
Online Status: Offline
Posts: 291
Posted: 07 January 2018 at 11:37am | IP Logged Quote Azure

I downloaded shortly after it was posted. No problems, got ZIP file of folder and just checked contents are all good.

Edited by Azure on 07 January 2018 at 11:38am
Back to Top View Azure's Profile Search for other posts by Azure
 
MikeO
Senior Member
Senior Member


Joined: 11 September 2011
Location: Australia
Online Status: Offline
Posts: 177
Posted: 07 January 2018 at 5:58pm | IP Logged Quote MikeO

Thanks everyone.

Site is OK now was in the middle of a move to another server.

There is a link to the constructor files on the new site if drop box doesn't work.

I should have the boards by the end of the week.

Mike

__________________
Codenquilts
Back to Top View MikeO's Profile Search for other posts by MikeO Visit MikeO's Homepage
 
Bill7300
Senior Member
Senior Member


Joined: 05 August 2014
Location: Australia
Online Status: Offline
Posts: 116
Posted: 08 January 2018 at 3:30pm | IP Logged Quote Bill7300

My problem appears to lie in my use of a download manager. The browser apparently makes the first request, before the download manager takes over and remakes the request. Drop box apparently doesn't like duplicated download requests, so refuses to play ball. I need to doctor my download manager to overcome this but meanwhile, I'll try getting the gerbers from Mike's site.
Back to Top View Bill7300's Profile Search for other posts by Bill7300
 
MikeO
Senior Member
Senior Member


Joined: 11 September 2011
Location: Australia
Online Status: Offline
Posts: 177
Posted: 08 January 2018 at 9:27pm | IP Logged Quote MikeO

Hi Bill, If you still want the files there is a link on my site (working now) if you are still having problems with dropbox.

Mike

__________________
Codenquilts
Back to Top View MikeO's Profile Search for other posts by MikeO Visit MikeO's Homepage
 
Bill7300
Senior Member
Senior Member


Joined: 05 August 2014
Location: Australia
Online Status: Offline
Posts: 116
Posted: 09 January 2018 at 9:46am | IP Logged Quote Bill7300

Thanks Mike but now I am having trouble getting to your site. www.codenquilts.com.au defaults to codenquilts.synology.me/cms/ and gives a page not working error?

Bill
Back to Top View Bill7300's Profile Search for other posts by Bill7300
 
MikeO
Senior Member
Senior Member


Joined: 11 September 2011
Location: Australia
Online Status: Offline
Posts: 177
Posted: 09 January 2018 at 10:12am | IP Logged Quote MikeO

Hi Bill, I am really sorry you are having these issues. That redirect is missing the port number of my server (not sure why) it is certainly there and I can get there from my phone (different network).

The direct link is codenquilts.synology.me:2244/cms and the absolutely direct to the file you want is here

I am in the middle of building my site again on my local server and eventually will drop my hosting site , I hope this now works for you.

Mike

__________________
Codenquilts
Back to Top View MikeO's Profile Search for other posts by MikeO Visit MikeO's Homepage
 
Bill7300
Senior Member
Senior Member


Joined: 05 August 2014
Location: Australia
Online Status: Offline
Posts: 116
Posted: 09 January 2018 at 12:38pm | IP Logged Quote Bill7300

That certainly worked, Mike. Thanks

Bill
Back to Top View Bill7300's Profile Search for other posts by Bill7300
 
MikeO
Senior Member
Senior Member


Joined: 11 September 2011
Location: Australia
Online Status: Offline
Posts: 177
Posted: 10 January 2018 at 1:54pm | IP Logged Quote MikeO

PCBs arrived , built one and tested OK.






Made an error, annoying! , chose the incorrect pattern for the Flash, too small so redid the gerbers , made a couple of position changes and added some more functions.

Added SD Card support from the LCD assy
Added Battery/supply voltage divider to monitor voltage, useful if Solar powered.
Added Link selection for above functions plus the Flash, so can be isolated when not used.

New Layout and new gerbers





Edited by MikeO on 10 January 2018 at 6:02pm


__________________
Codenquilts
Back to Top View MikeO's Profile Search for other posts by MikeO Visit MikeO's Homepage
 
MikeO
Senior Member
Senior Member


Joined: 11 September 2011
Location: Australia
Online Status: Offline
Posts: 177
Posted: 13 January 2018 at 7:40pm | IP Logged Quote MikeO

A further update due to discovering a couple of trace errors anyway a further opportunity for an extra.

Console connector (was J1) increased from 3 to 8 pins, used to bring out the SPI and the I2C bus for expansion, now labeled J2.
Made a SOIC version as well as DIP for the MX170.








Version is now 1.3

Mike



__________________
Codenquilts
Back to Top View MikeO's Profile Search for other posts by MikeO Visit MikeO's Homepage
 
MikeO
Senior Member
Senior Member


Joined: 11 September 2011
Location: Australia
Online Status: Offline
Posts: 177
Posted: 20 January 2018 at 5:38pm | IP Logged Quote MikeO

Here is the first completed project for use with the 8 port controller pcb.
I have updated the original Irrigation controller here to use the new board and also made it so it will run optionally in the headless mode (it will detect No Display).

Listing of the main program is below and a complete hex file at the end which include the library and Options setup.







'http://www.codenquilts.com.au
  'Michael Ogden June 2016
  'screen functions Geoff Graham
  'water flow code - TassyJim
  'Greenhouse and Irrigation controller
  'v1.2 fixed problem with Run/Stop toggling itself.
  'Using MXWifi2.9 or 170MXwifi Library code
  'v1.4 Change to Headless controller, renamed Hwtixx.bas
  'Using MXWifi3.2 (no MX170 SD support)
  'removed I/O decoder Relay driver,  now using direct output drive
  'removed ntp support (RTC installed)
  'v1.5 added NTP correction
  'v1.6 add "reset" command
  'v1.7 chg normalised some ext command names
  'v2.00 Jan 2018 **** first version using optional display or Headless *****
  'add MM.STARTUP to allow setting of wifi variables sent to ESP8266
  'add setup page for 2 cycle times per zone
  
  Option Explicit
  Option Default Integer
  Option autorun On
  
sub MM.STARTUP
  'set Nowifi=1 if no ESP8266
  dim integer Nowifi=0
  dim w170name$="Your SSID"
  dim w170pass$="Your password"
  dim w170node$="ESP_8port"
end sub
  
  
  'Constants
  CONST STRB=24: SETPIN STRB,DOUT:PIN(STRB)=1 'CONFIGURE DISPLAY LATCH PIN
  'const node$="ESP_8port" 'this device
  const serv$="ESP_Svr"   'device to send to
  Const aux$=""           'some other device to send to
  const Sver$="Ver 2.1"
  Const NumofMonth$="JAN,FEB,MAR,APR,MAY,JUN,JLY,AUG,SEP,OCT,NOV,DEC"
  Dim wholedate$
  'Define I/O
  SETPIN 17, CIN     'House Flow
  SETPIN 18, CIN  'GHouse Flow
  '
  'Alarms Led relay 8
  
  
  'Global variables
  
  
  Dim Integer key_coord(5, 5)
  Dim String key_caption(5)
  Dim Integer c
  ''Flag Variable
  
  '0=err
  '1=timeout
  '2=Relay memory
  '3=display update (content)
  '4=Alarms On
  '5=Alarms Off
  '7=
  '8=ntp
  '9=busy
  '10=override
  '11=Watersensors
  '12=SaveToFlash
  '13=TankFill
  '14=Log
  '15=
  '20=Ready          'Ready flag
  relay(0) ' ensure all relays are off
  
  Dim Integer idpdata(10)                              'general array
  Dim string results(11)     length 10               'data results array
  '1=Ghouse temp
  '2=ghouse Hum
  '3=rain
  '4=Tank Level
  '5=House Flow
  '6=GHouse Flow
  '7=Tank Level
  '8=GHouse Flow
  '9=Total Tank Flow
  '10=24hr Usage
  
  Dim Secs
  dim preset,x,Errorflag
  dim ErrorMsg$
  dim AlarmTime,NO_CLS,backup
  
  
  'Print "Irrigation Ctrl "+sver$
  
  'cpu 48
  'intialise I/O
  
  Var Restore
  print "Backup status:";backup
  'intialise modules
  
  'Initialise Arrays
  
  ' restore the settings.  If this is the first time set the defaults
  
  If backup = 0 Then
    backup=1
    results(10)="0"
    'initial configuration
    'usage:port#,description,W=Water Cycle function/En=enabled other function,_
    '# of timed cycles,days of the week,Cycle On time,Cycle Off time, Next Cycle pair .., Next Cycle pair
    
    cfgdata(1)="Z1-Bed.1,W,0,0123456,08:00,08:20,00:00,00:00"
    cfgdata(2)="Z2-Bed.2,W,0,0123456,08:00,08:30,00:00,00:00"
    cfgdata(3)="Z3-Bed.3,W,0,0123456,00:00,00:00,00:00,00:00"
    cfgdata(4)="Z4-Bed.4,W,0,0123456,00:00,00:00,00:00,00:00"
    cfgdata(5)="Z5-Not assigned"
    cfgdata(6)="Z6-Not assigned"
    cfgdata(7)="Z7-Not assigned"
    cfgdata(8)="Z8-Not assigned"
    'end of Ports configuration next two lines are for other items and read by the system as required
    cfgdata(9)="9,Usage-House and Garden,0,0"
    cfgdata(10)="10,Max Daily Usage,500"
    Var Save backup,results(),cfgdata()
  EndIf
  
  
  for x=1 to 11
    print "Results:";x;" ";results(x)
  next
  for x=1 to 10
    print "Config:";x;" ";cfgdata(x)
  next
  
  
  'interupts
  Settick 1000 ,T1,1    'establish seconds "Tick Timer"
  'flag(3)=1 'content update REM  when **** No Display
  flag(8)=1 'NTP flag               Rem when *** RTC installed ***
  
  
  'debug=1
  '*** start main program loop
  flag(20)=1  'ready flag
  Do
    'StartTime = Timer
    Watchdog 60000  '1min
    
    '******* Display Addin *************
    'setup main screen and check for touch
    
    Do While Touch(x) <> -1
      
    Loop
    
    ' draw the main menu  options
    if nodisp=0 then  'OK when no display
      if NO_CLS=0 then CLS
      if preset=0 then
        Text 80, 10,"RLY1-8" , CM, 1,1, RGB(white)
        showrelays
        
        DrawButtonOnly 3, "ZONE",245,155,70
        
        if flag(10)=0 then
          DrawButtonOnly 0, "STOP!",5,155,90
        else
          DrawButtonOnly 0, " RUN ",5,155,90
        end if
        No_CLS=1
        
      else
        For x=1 To 8  'clear relay leds
          Circle 100+x*25,10, 5, 0, 1, 0, rgb(black)
        next
        Text MM.HRes/2, 10,"Menu " + parse$(cfgdata(preset),1) , CM, 1,2, RGB(white)
        
        DrawButtonOnly 4, "SET",245,105,70
        DrawButtonOnly 0, "<   ",5,155,70
        DrawButtonOnly 1, "ON",85,155,70
        DrawButtonOnly 2, "OFF",165,155,70
        DrawButtonOnly 3, "ZONE",245,155,70
      end if
      Line 0, 25, MM.HRes, 25, 1, RGB(210, 210, 210)
      Line 0, 175, MM.HRes, 175, 1, RGB(210, 210, 210)
      
      
      if errorflag=1 then
        Text MM.HRes/2,220, errormsg$,c , 1, 1, RGB(RED)
      else
        Text MM.HRES/2,220, "Irrigation Ctrl "+sver$,c , 1, 1, RGB(white)
      endif
      ' get the selected button and take action based on the button
      'print "main loop"
    end if
    
    if nodisp=1 then  'Ignore no display
      CheckButtonPress(0, 0)
    else
      Select Case CheckButtonPress(0, 4)
          if nodisp=0 then  'Ignore when no display
          Case 0
            if preset=0 then
              'print "case zero"
              if flag(10)=0 then 'if in free run
                relay(0)
                flag(10)=1  'set Override flag
              else
                flag(10)=0  'set Override flag
              end if
            else
              PReset=0
            end if
          Case 1
            if flag(10)=0 or preset=8 then relay(preset,1)  'relay on only in RUN or for Greenhouse Fan
          Case 2
            relay(preset,0)
          Case 3
            No_CLS=0  'clear CLS flag to allow clear screen
            preset=preset+1
            if preset>8 then
              preset=0
            end if
          case 4
            getoptions
        End Select
        flag(3)=1 'ensure screen update
      end if
      
      '******* Display Addin *************
      '    'Print "Loop elapsed time"; Timer-StartTime
      
    Loop
    '***** End main program loop
End
    
    
    ' get the first page of options
Sub GetOptions
    cls
    flag(3)=0
    local float s1,s2,nbr
    local ha$,hb$
    Do While Touch(x) <> -1 : Loop
    Do
      CLS
      Text MM.HRes/2, 10,"Set " + parse$(cfgdata(preset),1) , CM, 1,2, RGB(white)
      Line 0, 25, MM.HRes, 25, 1, RGB(210, 210, 210)
      Line 0, 175, MM.HRes, 175, 1, RGB(210, 210, 210)
      DrawOption 0, RGB(240, 240, 240), "Time On (24hr)",45, s1, "hrs"
      DrawOption 1, RGB(240, 240, 240), "Time Off (24hr)",105, s2, "hrs"
      
      DrawButtonOnly 2, "Cycle1",5,155,110
      DrawButtonOnly 3, "Cycle2",130,155,110
      DrawButtonOnly 4, "Exit",245,155,70
      
      'draw the FINISHED butt      on at the bottom of the screen
      
      
      
      ' get the selected button and take action based on the button
      Select Case CheckButtonPress(0, 4)
        Case 0
          s1=0
          GetFloat "Time On(hrs)", s1
          
          if s1>2400 then s1=0
          
        Case 1
          s2=0
          GetFloat "Time On(hrs)", s2
          
          if s2>2400 then s2=0
          
        case 2
          ha$=tohrs$(s1)
          hb$=tohrs$(s2)
          cfgdata(preset)=replaceitem$(cfgdata(preset),ha$,5)
          cfgdata(preset)=replaceitem$(cfgdata(preset),hb$,6)
          exit sub
        case 3
          ha$=tohrs$(s1)
          hb$=tohrs$(s2)
          cfgdata(preset)=replaceitem$(cfgdata(preset),ha$,7)
          cfgdata(preset)=replaceitem$(cfgdata(preset),hb$,8)
          exit sub
        case 4
          flag(3)=1 'ensure screen update
          exit sub
      End Select
    Loop
    
End Sub
    
function fromHrs(h$)as float
    fromhrs=val(left$(h$,2)+right$(h$,2))
    'print fromhrs
end function
    
function tohrs$(h4 as float)
    local h1$
    h1$=str$(h4,4,0,"0")
    tohrs$=left$(h1$,2)+":"+right$(h1$,2)
end function
    
function ReplaceItem$(s$,f$,FieldNumber,d$)
    Local String stringArg$
    Local Integer intOldY,intY,intX
    'print s$;" ";fieldnumber;" ";d$
    if d$="" then
      d$=","
    endif
    StringArg$ = S$ + d$
    intOldY = 1:intX=0:intY=0
    ReplaceItem$ = ""
    do While intY < Len(StringArg$) And intX < FieldNumber
      intY = Instr(intOldY, StringArg$, d$)
      intX = intX + 1
      If intX = FieldNumber Then
        replaceitem$ =left$(stringarg$,intoldy-2)+ ","+f$+","+ mid$(stringarg$,inty+1)
        print replaceitem$
      Endif
      intOldY = intY + 1
    loop
    'print s$; intx; inty; intoldy
    'print fieldnumber;" ";parse$
End function
    
    '************* CheckButtonPress Function ***********
    ' check if a button has been touch and animate the button's image
    ' returns the buttin number
Function CheckButtonPress(startn As Integer, endn As Integer) As Integer
    Local Integer keydwn, xt, yellowt, n,r
    keydwn = 0
    flag(1)=30     'set flag if not in main page waiting for input
    '' keep looping while waiting for a press and release
    Do
      'print "buttonpress loop"
      
      '***** mxWiFi Hook ****
      if userprocessflag=1 then
        print "Userprocess"
        StartTime = Timer
        UserProcess
        UserProcessFlag=0
        xbsend "udp.send:|"+from$+"|"+chr$(4)+"|"
        Print "Processing elapsed time"; Timer-StartTime
        Watchdog 60000   'ensure watchdog is set to long time out again
        continue do 'skip to a new loop immediately , there may be more external processing to do
      endif
      '***** End mxWiFi Hook ****
      
      'check flags
      'print "checkbutton loop"
      if flag(4)=1 then   'Alarms On
        testalarms(0)
        FLAG(4)=0
      end if
      
      if flag(5)=1 then   'Alarms Off
        testalarms(1)
        FLAG(5)=0
      end if
      
      'return to main page
      If flag(1)=0 and nodisp=0 Then
        PReset=0     'switch to main page after pressflag period
        flag(3)=1 'ensure screen update
        checkbuttonpress=-1
        print "checkbuttonpress:";checkbuttonpress
        exit function
      end If
      
      if flag(13)>60 then   'Tank Fill delay reached so (60 sec delay)
        relay(3,1)            'enable tank fill relay
      end if
      
      if flag(12)=1 then
        SaveToFlash
        flag(12)=0   'single write to flash only
      end if
      
      
      if flag(11)=1 then   'watersensors
        WaterSensors
        FLAG(11)=0
        print "24Hr Water usage/Limit:";Val(results(10));"/";Val(parse$(cfgdata(10),2))
      end if
      
      If Val(results(10))>Val(parse$(cfgdata(10),2)) Then
        'set overuse flag
        flag(10)=1
      end if
      
      
      if flag(14)=1 then
        addtolog bin$(flag(2),8)+","+results(7)+","+results(8)+","+results(9)+","+results(10)+","+str$(flag(10)),"6"
        flag(14)=0
      end if
      
      'check page presets for screen updating etc are done here
      if flag(3)=1 and nodisp=0 then
        select case preset
          case 0
            updateMain
          case 1
            updatecycle(1)
          case 2
            updatecycle(2)
          case 3
            updatecycle(3)
          case 4
            updatecycle(4)
            'etc ports added here
            '
        end select
        if preset=0 then showrelays
      end if
      '************** End of Flags ****
      
      
      
      if nodisp=0 then
        'Touch pad processing
        If Touch(x) <> -1 And Not keydwn Then
          ' we have a touch
          xt = Touch(x)
          yellowt = Touch(y)
          ' scan the array key_coord() to see if the touch was within the
          ' boundaries of a button
          For n = startn To endn
            If xt > key_coord(n,0) And xt < key_coord(n,0) + key_coord(n,2) And yellowt > key_coord(n,1) And yellowt < key_coord(n,1) + key_coord(n,3) Then
              ' we have a button press
              ' draw the button as pressed
              
              DrawButton n, 1
              keydwn = 1
              Exit For
            EndIf
          Next n
        EndIf
        
        ' if a button is currently down check if it has been released
        If Touch(x) = -1 And keydwn Then
          ' yes, the button has been released
          ' draw the button as normal (ie, not pressed)
          DrawButton n, 0
          CheckButtonPress = n
          ' return with the button's number
          print "checkbuttonpress:";checkbuttonpress
          Exit Function
        EndIf
      end if
    Loop
End Function
    ******* End of CheckButtonPress function ************
    
    
    
    'T1 - 1second Tick interrupt
    'set up some time flags
Sub T1
    local x
    secs=secs+1   'update seconds timer
    if secs => 86400 then     '24 hrs reached
      secs = 0                'reset counter
      results(10)="0" 'reset 24hr usage
      FLAG(8)=1   'set NTP flag , for RTC correction
    EndIf
    If flag(1)>0 Then flag(1)=flag(1)-1
    if Flag(13)>0 then flag(13)=flag(13)-1  'count down tank fill timeout delay
    Text 105,35, wholedate$ + "  " + time$,L , 1, 1, RGB(green)
    
    if secs mod 25 = 0 Then    'every 25 secs
      if flag(8)=1 then
        print "Try to get NTP data"
        xbsend "time:" 'try to get NTP time data
      end if
    end if
    
    if secs mod 5 = 0 Then
      'FLAG(3)=1   'content update
    endif
    
    if secs mod 10 = 0 Then
      FLAG(11)=1   'read water sensors
    EndIf
    
    if secs mod 30 = 0 Then
      FLAG(14)=1   'Log update
    endif
    
    if secs mod 7200 = 0 then  'every 120 mins
      FLAG(8)=1   'set NTP flag , have RTC
      FLAG(12)=1   'set SaveToFlash flag
    endif
    
    if secs mod 15 = 0 then  'every 15 secs
      if flag(4)=0 then FLAG(4)=1   'Check Alarms On
    endif
    if secs mod 17 = 0 then  'every 17 secs
      if flag(5)=0 then FLAG(5)=1   'Check Alarms Off
    endif
End Sub
    
    
    
    '***************  Specific Subs/Functions  **********
    
    'update the main screen data
sub updatemain
    Text 5,55, "Tank "+ results(7)+ "L" ,L , 1, 1, RGB(green)
    Text 5,75, "Usage - House/Garden "+ results(9)+ "L" ,L , 1, 1, RGB(green)
    Text 5,95, "Usage - Greenhouse "+ results(8)+ "L" ,L , 1, 1, RGB(green)
    
end sub
    
sub updatecycle(cz)
    local bin$="1,2,4,8,16,32,64,128"
    Text 5,55, "Days of Week (Sun=0)  " + parse$(cfgdata(cz),4),L , 1, 1, RGB(White)
    Text 5,75, "Cycle1 On:"+ parse$(cfgdata(cz),5) + " Off:" + parse$(cfgdata(cz),6),L , 1, 1, RGB(green)
    Text 5,95, "Cycle2 On:"+ parse$(cfgdata(cz),7) + " Off:" + parse$(cfgdata(cz),8) ,L , 1, 1, RGB(green)
    'Text 5,115, "Cycle1 On:"+ parse$(cfgdata(cz),9) + " Off:" + parse$(cfgdata(cz),10) ,L , 1, 1, RGB(green)
    if (val(parse$(bin$,cz)) and flag(2)) >0 then
      Text 5,135, "Watering NOW!  "
    else
      Text 5,135, "Watering Off "
    end if
end sub
    
SUB WaterSensors
    local integer flow1,flow2,range1
    flow1=PIN(17)
    flow2=PIN(18)
    'flow2=19003  'bench testing
    print "Flows   ";flow1;" ";flow2
    results(8)=str$(val(results(8))+(flow1/330 MOD 1000000),3,0," ")' ghouse
    results(9)=str$(val(results(9))+(flow2/330 MOD 1000000),3,0," ")' tank
    results(10)=str$(val(results(10))+(flow2/330 MOD 1000000),3,0," ")' 24hrs use
    'reset flows
    SETPIN 17, CIN     'House Flow
    SETPIN 18, CIN  'GHouse Flow
    range1=DISTANCE(10,16)' house tank
    results(7)=str$(((270 - range1)*42),3,0," ")  '~10080 full
END Sub
    
sub usage
    results(8)=parse$(cfgdata(9),2)
    results(9)=parse$(cfgdata(9),3)
end sub
    
Sub SavetoFlash
    Print "Saving to Flash"
    Var save cfgdata(),results()
End Sub
    
    'Test Alarms against time and weekday
sub TestAlarms(Off%) As integer
    local Integer MinuteTime,z,cr,nr
    local day$
    print "Local Date/Time is ";date$;" ";time$
    StartTime = Timer
    'Get first two letters of weekday to compare
    day$=str$(GetDOW(SDT("","","DT")))
    MinuteTime = sdt("","","m")
    'print day$;" ";minutetime
    '    TestAlarms
    'if off%=1 then increment times pos by 1 for off time
    print "test for alarms"
    if flag(8)=1 then exit sub  'dont test if Time flag is set
    For z=1 to 8
      prelay(8,50) 'Alarms Led
      select case parse$(cfgdata(z),2)
        case "W"  'watering alarm cycles
          cr=0
          Print cfgdata(z)
          nr= Val(parse$(cfgdata(z),3))
          print "repeats:";nr
          Do while cr<nr          'cycle through start and finish times upto the # of cycle repeats
            if instr(parse$(cfgdata(z),4),day$)>0 then
              'check On Time for 00:00 if so then exit
              If sdt("",parse$(cfgdata(z),5+(cr*2)+0),"m") =0 Then
                print "Zero time alarm , Time Alarm OFF"
                relay(z,0)
              else
                print "time Now?Alarm Time:";minutetime;"/"; sdt("",parse$(cfgdata(z),5+(cr*2)+off%),"m") 'offset is position+(repeats*2)+on or off(0 or 1)
                If MinuteTime = sdt("",parse$(cfgdata(z),5+(cr*2)+off%),"m") Then
                  if off%=0 And flag(10)=0 Then     'if not in override
                    print "Time Alarm ON"
                    relay(z,1)
                  else
                    print "Time Alarm OFF"
                    relay(z,0)
                  end if
                end if
              end if
            end if
            cr=cr + 1      'increment repeat counter
          Loop
        case else
          'if not using watering cycles set specific actions for each relay
          'these are added here
          
      end select
      
      
    Next
    Print "Alarm Loop elapsed time"; Timer-StartTime
    
End sub
    
    
    'External command processing sub Routine if required
sub extCmd
    local temp$,ext$,rl%
    print "External Commands:";from$;" ";cmd$;" ";cfg$;" ";strin$
    select case cmd$
      case "reset"
        secs = 0                'reset counter
        results(10)="0" 'reset 24hr usage
        FLAG(8)=1   'set NTP flag , for RTC correction
        print "Reset counters and RTC correction"
      case "ntp"
        wholedate$=parse$(strin$,1," ")+" "+parse$(strin$,3," ")+" "+parse$(strin$,2," ")+" "+parse$(strin$,5," ")
        if wholedate$<>"" then
          flag(8)=0   'reset NTP flag
          on error skip
          time$=left$(parse$(strin$,4," "),5)
          print time$
          print wholedate$
          temp$=ucase$(parse$(strin$,2," "))
          date$=parse$(strin$,3," ")+"-"+Str$(moy(temp$),2)+"-"+parse$(strin$,5," ")
          print date$
          If IsDST()=1 Then IncTime
          'time$="23:59:00" 'test for midnight
        end if
      case "Log"
        if flag(20)=0 then exit sub  'not ready
        results(1)=parse$(strin$,9)
        results(2)=parse$(strin$,10)
        results(3)=parse$(strin$,5)
      case "uMsavetoflash"
        SavetoFlash
      case "uMusage"
        usage
      case "uMconfig"
        For res=1 To cfgnum
          Print cfgdata(res)
          xbsend "udp.send:|"+from$+"|Config|"+cfgdata(res)
          WaitforReady
        Next
      case "uMwconfig"
        cfgdata(val(cfg$))=strin$
      case "uMrconfig"
        xbsend "udp.send:|"+from$+"|Config|"+cfgdata(val(cfg$))
        WaitforReady
      case "uMmrconfig"
        print "Send Msg Read Config "
        WaitforReady
        xbsend "msgsend:"+ cfgdata(val(cfg$))+":"
        WaitforReady
        'relays
      case "uMstop"
        relay(0)    'turn off all relays
        print "All relays off"
        'prelay(7,500)
      case "uMon"
        rl%=val(cfg$)
        select case rl%
          case 1,2,4,5,6,7,8
            relay(rl%,1)
            print "Relay ";rl%;" on"
            'prelay(8,500)
        end select
      case "uMoff"
        rl%=val(cfg$)
        select case rl%
          case 1,2,4,5,6,7,8
            relay(rl%,0)
            print "Relay ";rl%;" off"
            'prelay(8,500)
        end select
    end Select
end sub
    
    
    'i/o EXT relay driver p=port#, o=1=On, default no value=off
sub relay(p,o)
    local J
    local bin$="1,2,4,8,16,32,64,128"
    if p=0 then
      flag(2)=0   'reset all relays and relay memory flag
    else
      if o=1 Then     'switch relay On
        flag(2)=flag(2) or val(parse$(bin$,P))  'add new relay
      Else       'switch relay Off
        flag(2)=flag(2) and (flag(2) xor val(parse$(bin$,P)))   'minus relay
      end if
    end if
    'switch relay
    SPI OPEN 500000,0,8
    PIN(STRB)=0
    PAUSE 1
    j=SPI(Flag(2)) 'switch relays
    SPI CLOSE
    PIN(STRB)=1
end Sub
    
    'Usage prelay(port#,pulse in ms), pulse min 0 = 30ms(execute time)
sub prelay(p,l)
    local bin$="1,2,4,8,16,32,64,128"
    if (val(parse$(bin$,p)) and flag(2)) >0 then  'toggle low
      relay(p,0)
      pause l
      relay(p,1)
    else        'then toggle high
      relay(p,1)
      pause l
      relay(p,0)
    end if
end sub
    
Sub ShowRelays
    Local p
    local bin$="1,2,4,8,16,32,64,128"
    For p=1 To 8
      if (val(parse$(bin$,p)) and flag(2)) >0 then
        Circle 100+p*25,10, 5, 0, 1, 0, RGB(green)
      else
        Circle 100+p*25,10, 5, 0, 1, 0, rgb(red)
      end If
    next
End Sub
    
    
    
sub AddToLog(msg$,cnt$)
    if cnt$="" then cnt$="0"
    print "AddtoLogMsg:";msg$;" Count:";cnt$
    'xbsend "udp.send:|ESP_Irrig|Log|"+cnt$+"|"+date$+","+TIME$+","+ msg$
    xbsend "udp.cast:|"+serv$+":|"+w170node$+"|Log|"+cnt$+"|"+msg$
    WaitforReady  'reset flag
    pause 1000    'settle time
    xbsend "msgsend:|"+serv$+":|"+w170node$+"|Log|"+cnt$+"|"+msg$
    WaitforReady                'reset flag
end sub
    
CFunction DISTANCE(integer, integer) float
  0000002D 27BDFFF8 AFBF0004 00852023 03E42021 ACC40000 8FBF0004 03E00008
  27BD0008 27BDFFE0 AFBF001C 00002021 3C059D00 24A50040 27A60010 0411FFF1
  00000000 8FA30010 3C029D00 8C4200BC 3C049D00 24840310 0040F809 00832021
  8FBF001C 03E00008 27BD0020 000410C0 00041A00 00621823 00031180 00431823
  00641821 00031980 3C029D00 8C420000 3C047735 34849400 8C420000 0082001B
  004001F4 00002012 0064001B 008001F4 03E00008 00001012
  27BDFFD8 AFBF0024 AFB40020 AFB3001C AFB20018 AFB10014 AFB00010 00809021
  3C029D00 8C420000 8C430000 3C020098 34429680 0062102B 10400003 00A08821
  0411FFCA 00000000 8E220000 14400003 3C109D00 8E420000 AE220000 8E020010
  8E240000 24050002 0040F809 2406000E 8E02001C 8E440000 0040F809 24050005
  8E020010 8E440000 24050008 0040F809 00003021 8E02001C 8E440000 0040F809
  24050006 8E020004 0040F809 24040014 8E02001C 8E440000 0040F809 24050005
  8E020004 0040F809 24040032 8E020010 8E240000 24050002 0040F809 2406000E
  8E020004 0040F809 24040032 0411FFB1 24040005 00409821 0000A021 40944800
  00008021 10000005 3C129D00 40104800 0270102B 1440001E 24050002 8E420020
  0040F809 8E240000 1440FFF8 24040064 10000025 00000000 40104800 0270102B
  14400013 24050002 8E420020 0040F809 8E240000 1040FFF8 24040020 1000001F
  00000000 40104800 0270102B 14400008 24050001 8E420020 0040F809 8E240000
  1440FFF8 00000000 1000001A 3C119D00 00052823 3C029D00 8C420080 00A02021
  0040F809 00052FC3 8FBF0024 8FB40020 8FB3001C 8FB20018 8FB10014 8FB00010
  03E00008 27BD0028 0411FF7A 00000000 00409821 1000FFDC 3C129D00 0411FF75
  00000000 00409821 40944800 1000FFE1 3C129D00 8E320064 8E220000 3C037735
  34639400 8C420000 0062001B 004001F4 00001012 72028002 24021696 0202001B
  004001F4 00002012 8E220080 0040F809 00002821 00408021 8E220080 2404000A
  0040F809 00002821 02002021 0240F809 00402821 1000FFD5 8FBF0024
  20555043 65657073 6F742064 6F6C206F 000A0D77
End CFunction
  



Complete Hex file





__________________
Codenquilts
Back to Top View MikeO's Profile Search for other posts by MikeO Visit MikeO's Homepage
 
MikeO
Senior Member
Senior Member


Joined: 11 September 2011
Location: Australia
Online Status: Offline
Posts: 177
Posted: 21 January 2018 at 4:56pm | IP Logged Quote MikeO

I have 10 of the ver 1.2 boards of the 8 port uMite controller available if anyone wants one. Ver 1.2 had 3 silly mistakes, two of which are easily fixable with a simple cut and wire the third just remove a component leg. I would hate to see them go to waste , I am happy to send them anywhere for AU$3.00 per shipment. PM me if you want one or more.




I have also made a Pin Out Matrix to assist in pin usage for the board.
The real PDF is on my server here




Mike


__________________
Codenquilts
Back to Top View MikeO's Profile Search for other posts by MikeO Visit MikeO's Homepage
 


If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Search the forums using Google.
<< Prev Page of 2
In the news...
 
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.1406 seconds.
Privacy Policy     Process times : 0, 0, 0, 0.14