Serial data transmission period


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: Serial data transmission period

    It is my bad.
    (TimeM//6) may take another 2,3,4,5 minutes depending on the minute value

    You may want use "Second". Example;

    Code:
    SendFlag var bit
    
    Begin:
    
    Sendflag = 0
    
    Main:
    
    If (TimeM//5) = 0 then 
      if RTCsec = 0 and SendFlag = 0 then
         Hserout [hex2 RTCHour,":",hex2 RTCMin," ",DEC(TempC/10),".",#TempC dig 1,13,10]
         sendflag = 1
      ELSE
         If RTCsec > 0 then SendFlag = 0 
      ENDIF
    ENDIF
    or another way could be to use DIG ;

    Code:
    SendFlag var bit
    
    Begin:
    
    Sendflag = 0
    
    Main:
    
    SELECT CASE TimeM DIG 0
    
      Case 0,5    ' Every 5 minutes.
    
         if SendFlag = 0 then
            Hserout [hex2 RTCHour,":",hex2 RTCMin," ",DEC(TempC/10),".",#TempC dig 1,13,10]
            sendflag = 1
        ENDIF
    
      case 1,6    ' Reset flag 1 minute later.
        SendFlag = 0 
    
    END SELECT
    
    This one looks cleaner for my eyes.
    Last edited by sayzer; - 10th January 2018 at 17:53.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Serial data transmission period

    I've used the second example with the case statement, and that appears to be working as expected

    Can you comment the code so that I can understand why it works

    Thanks

    Malc

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default Re: Serial data transmission period

    Quote Originally Posted by Scampy View Post
    I've used the second example with the case statement, and that appears to be working as expected

    Can you comment the code so that I can understand why it works

    Thanks

    Malc
    CASE 0,5 will work on minutes 0,5,10,15,20,25,30,35,40,45,50,55 as the DIG 0 is always either 0 or 5.
    CASE 1,6 will work on minutes 1,6,11,16,21,26,31,36,41,46,51,56 as the DIG 0 is always either 1 or 6. And this gives you "1 minute pass" after your HSEROUT condition is executed.


    If you want to speed up the frequency of sending data, then change 0,5 to say 0,2,4,6,8 and 1,6 to 1,3,5,7,9. This way you can send data in every 2 minutes.
    If you want to slow down the frequency change 0,5 to 0 only and 1,6 to 1 only. This way you can send data in every 10 minutes.


    Hope this helps.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  4. #4
    Join Date
    Oct 2009
    Posts
    583


    Did you find this post helpful? Yes | No

    Default Re: Serial data transmission period

    Thanks for the explanation. I've copied and pasted it as notes in the code for use in later projects

Similar Threads

  1. serial in data needs nib
    By l_gaminde in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 4th June 2011, 12:20
  2. Transmission!
    By uaf5000 in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 25th August 2010, 04:39
  3. serial data to LCD
    By cunninghamjohn in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 25th November 2008, 15:50
  4. Replies: 7
    Last Post: - 6th February 2008, 05:38
  5. Multiplex serial data
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 19th May 2004, 00:28

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts