see below

2010/3/27 Rob Conway <rjcon...@bigpond.com>

>  Oops sorry, I read BNE as branch if negative however on review its Brand
> Not Equal so sorry for my Q1 below. And I assume AIX was a typo for AIS
> Could I replace the first couple of lines with CMP.L   RTC, L_USERN.
>
no, CMP require immediate operand2, you need to use the stack.



>
I would of liked to be able to still turn the output on even if I missed the
> time when RTC=ON time.  I know this complicates matters however as my light
> is on for 10-12 hours during the day if I reload the firmware or restart the
> slave and miss the exact on time the output will not turn on for another
> day.
>
if the chip is reset or powered cycled, RTC will restart to zero and will
require master attention for RTC reinitialisation.
You may during init, put an alarmed flag to allows master conditional search
to know the the device require attention.
On the master side, monitor alarmed directory to update chip if needed: RTC
as well as force initial state.
Alternatively, you may want to put some battery backup circuit.

if you want to calculate an end time based on start time (long) + duration
(word):
PUSH.L L_USERN  //start time in the stack
PUSH.W 0  //hi part of operand 2 is zero
PUSH.W W_USERL // second part of operand 2
ADD.L // pop both longs, add them and store resulting long in the stack
then you may know if end time is reached or not:
PUSH.L L_RTC
SUB.L // calculate endduration-RTC
AIS -4 // free stack
B... skiplabel //conditional branch depending of last compare (SUB)

hope this clarify...

>  -----Original Message-----
> *From:* Rob Conway [mailto:rjcon...@bigpond.com]
> *Sent:* Saturday, March 27, 2010 10:39 PM
> *To:* 'OWFS (One-wire file system) discussion and help'
> *Subject:* Re: [Owfs-developers] BAE0910 AE Timed output code
>
> Pascal,  Thanks I understand the concept of starting another process to
> handle the relay and duration.
>
>
> I do have a couple of questions:
>
> 1)  I think though that whilst RTC is greater than the ON time the "main:"
> will always be writing the duration to UserI thus never alowing
> loop_till_end1: to decrement the value to 0 again ?
>
> 2) I have tried to read the manual again with regards to stack pointer and
> why AIS -4, however I am still lost on this one.
>
> 3) I assume AIX -4 is required in my first example as the CMP.L uses the
> stack for calculations and the result of the compare is at position -5 on
> the stack ?
>
>
> rob
>
>  -----Original Message-----
> *From:* Pascal Baerten [mailto:pascal.baer...@gmail.com]
> *Sent:* Saturday, March 27, 2010 9:18 PM
> *To:* OWFS (One-wire file system) discussion and help
> *Subject:* Re: [Owfs-developers] BAE0910 AE Timed output code
>
> here is the sample: I found this approach easier to have better control
> from the master.
> Don't hesitate for any questions.
>
> // AutomationEngine assembly source.
>> // Used for Temperature and Light Control of Reef Tank
>> // March 2010 by Rob Conway
>> //
>> // BAE0910 Direct Connected to Futurlec 4 channel opto Realy Board
>> // Channel 0 & 1 Relay has been replaced with a Mosfet IRF540
>> //
>> // RELAY Ch#   BAE0910 Ch#   Ribbon Cable    USAGE
>> // Output 0    PWM1          (Brown)         Cooling Fan
>> // Output 1    PWM2         (Orange)        Heater
>> // Output 2    PIO           (Yellow)        Main Light
>> // Output 3    OUT           (Blue)          Refugium Light
>> //
>> //
>> // VARIABLES:
>> //  ON / OFF TIMES  (Seconds)
>> //   L_UserN  ON time for Relay1   Seconds since Midnight
>> //   W_UserL  Duration for PIO       Duration for relay ON time, seconds
>> //   W_USERI  decrementing variale with time remaining until realy1 is
>> turned OFF
>>
>>
>> #include "bae0910.inc"
>>
>> #eeprom 0, 0      // start_page, end_page
>> #org  $00      // Code generated at address specified.
>>
>> begin:
>>     NOP     // Allow auto start of process #0 on poweron, first byte of
>> page0 should be a NOP
>> init:
>>
>>     //your initialisation code here
>>     SET.B    B_TPM1C,4    // Pre Scaler (1us resolution)
>>     SET.W    W_PERIOD1,10000    // 10,000us = 100Hz
>>     SET.W    W_DUTY1,10001    // Set PWM1 Output OFF
>>     START 1, relay1process   // this independant process will monitor
>> USERI for action
>> main:
>>     PUSH.L    L_RTC
>>     PUSH.L  L_USERN
>>     SUB.L             //compare current time with sheduled time
>>     AIS    -4             //restore stack
>>     BNE notnow1         // if strictly equal, start cycle (may be true
>> twice within the same second, but this is harmless)
>>     SET.W  W_USERI, W_USERL // set duration to decounting variable USERI,
>>                             // this will invite process1 to turn on for
>> duration
>>                             // this approach allows master check remaining
>> time
>>                             // and also start/interrupt actions.
>> notnow1:
>>     //similar code for relay2
>>
>>
>>     WAIT    10    //not too long to ensure that each seconds are seen by
>> the loop
>>     JMP main
>>
>> relay1process: // asynchronous process for relay1 control, the input is
>> USERI variable representing duration in seconds
>>     SET.W    W_DUTY1,10001  // turn off relay1
>>     WAIT    1
>>     CMP.W    W_USERI,0
>>     BEQ        relay1process
>>     CLR.W     W_DUTY1 // turn on relay1
>> loop_till_end1:
>>     WAIT     16          //wait one second
>>     DEC.W    W_USERI
>>     BGR        loop_till_end1  // master may set directly to 0 to stop
>> relay action, in this case USERI may become negative
>>     CLR.W    W_USERI // set to zero in case of -1
>>     BRA        relay1process
>>
>
>
>
>
> 2010/3/27 Rob Conway <rjcon...@bigpond.com>
>
>>  I thought it would be easier having the ON time in seconds since
>> midnight so I can compare direct to RTC.
>> The length of time the output is ON needs to be able to vary between 1
>> minutes to 12 hrs.  I know I could hard code the ON / OFF time into the
>> stack however whilst I still have user variables I may as well use them.
>>
>>   -----Original Message-----
>> *From:* Pascal Baerten [mailto:pascal.baer...@gmail.com]
>> *Sent:* Saturday, March 27, 2010 6:59 PM
>> *To:* OWFS (One-wire file system) discussion and help
>> *Subject:* Re: [Owfs-developers] BAE0910 AE Timed output code
>>
>> Hi Rob,
>> Sorry, I was busy to unexpeted work during this week and worked very late
>> everyday.
>> You have to use the firmware I sent earlier.
>>
>> I would create a main process that evaluate start conditions and initate
>> sub process that handle the action until duration.
>>
>> some comments in your code below.
>>
>> I will write you a sample skeleton later today.
>>
>> Pascal
>>
>>
>>
>> 2010/3/27 Rob Conway <rjcon...@bigpond.com>
>>
>>>  Hi,
>>>
>>> I was hoping to get some feedback on the AE engine and creating some
>>> simple output timers based upon energizing outputs based on time of day.  I
>>> can already set the RTC from the HOST and it resets at midnight, so the RTC
>>> represents seconds since midnight.
>>>
>>> This is what I am trying to achieve on the stack
>>>
>>>     IF RTC > ON_TIME and RTC <(ON-TIME+DURATION)
>>>     then DUTY1,0
>>>     else DUTY1,10001
>>>
>>> This is some rough code I thought I could use however not tested, I
>>> wanted to know if I was on the correct track and if the stack can handle
>>> maths results that go negative.
>>>
>> yes,
>> for Byte, values above 127 are considered negative
>> for Word, values above 32767 are considered negative
>> for Long, values above 2147483647 are considered negative
>>
>>
>>>
>>  //  ON / OFF TIMES  (Seconds)
>>> //   L_UserN  ON time for Relay1   Seconds since Midnight
>>> //   W_UserL  Duration for PIO       Duration for relay ON time, seconds
>>>
>> what's the max duration? ,maybe fit in 255 range or 65535  to use B or W
>> instead variable.
>>
>>>
>>>
>>> relay1_ctl:
>>> CMP.L    L_RTC,L_USERL
>>> BLE        relay1_off
>>>
>>> PUSH.L    L_RTC          //Get time since midnight
>>> PUSH.L   L_USERN      //  get user ON time in seconds since midnight
>>> SUB                             // Find out how many seconds difference
>>> between RTC and on time
>>> CMP.W     @-1, W_USERL    // See if difference is less than Duration, if
>>> so the output should be ON
>>>
>> as operands are L_ types, use CMP.L, also, @-4 needed for the L_ type who
>> require 4 bytes
>> important to retore stack pointer to inital value  after stack operation
>> AIX -4
>>
>>>  BGR        relay_off
>>> BLE         relay_on
>>> END
>>>
>>> relay1_on
>>> SET.W    W_DUTY1,0
>>> BRA Relay2_ctl
>>>
>>> Relay1_off
>>>  SET.W    W_DUTY1,10001
>>>  BRA Relay2_ctl
>>>
>>>
>>>  relay2_ctl:
>>> ~ code similar to relay 1
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Download Intel&#174; Parallel Studio Eval
>>> Try the new software tools for yourself. Speed compiling, find bugs
>>> proactively, and fine-tune applications for parallel performance.
>>> See why Intel Parallel Studio got high marks during beta.
>>> http://p.sf.net/sfu/intel-sw-dev
>>> _______________________________________________
>>> Owfs-developers mailing list
>>> Owfs-developers@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/owfs-developers
>>>
>>>
>>
>>
>> --
>> Pascal
>> www.brain4home.eu
>>
>> No virus found in this incoming message.
>> Checked by AVG - www.avg.com
>> Version: 9.0.791 / Virus Database: 271.1.1/2772 - Release Date: 03/27/10
>> 06:33:00
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel&#174; Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Owfs-developers mailing list
>> Owfs-developers@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/owfs-developers
>>
>>
>
>
> --
> Pascal
> www.brain4home.eu
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.791 / Virus Database: 271.1.1/2772 - Release Date: 03/27/10
> 06:33:00
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.791 / Virus Database: 271.1.1/2772 - Release Date: 03/27/10
> 06:33:00
>
>
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Owfs-developers mailing list
> Owfs-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/owfs-developers
>
>


-- 
Pascal
www.brain4home.eu
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Owfs-developers mailing list
Owfs-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/owfs-developers

Reply via email to