Do I need a pause?


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1

    Default Update

    I've added a 250ms pause after high one and it seemed to be a little better, then I add a 500ms pause and it does not stick so much although this is not a cure.
    oop3:
    if mydata1=%01011001 then
    high 1 'portb.1 is on
    pause 500
    else
    low 1 'portb.1 is off
    endif
    GOTO loop

    Loop2 does fine its just noticable in loop3. I thought there might me something with PICBASIC PRO 2.50, i've already installed the A patch and went there today and they have a 2.50b patch. I didn't see anything that might affect what I am trying to accomplish here. I know there are a lot of people here on this forum with much, much more experience with microcontrollers than I'll ever have. I have search time and again to see if anyone has had similar problems but have not not found anything revelant to this type. Certainly someone sees what I have missed. Thank you
    Last edited by tazntex; - 26th August 2008 at 02:37. Reason: grammar

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166

    Default

    tazntex, That is not the way you would access a port pin (atleast I have never done it that way), You should access it by the way of "portb.0" or referencing everything from porta.0. Just saying "HIGH 0" would lend me to believe it would be accessing porta.0. Also I see you are turning off all of port b by the syntax "if mydata1=%01010110 then portb=0 'master relay turn off". Is this what you want to do? Why not just use an alias for the relay output like "Relay var Portb.0". Then all you need to do is use the syntax "Relay = 0 or Relay = 1" I would investigate your use of the port syntax before I placed any pauses into the code....

    Dave Purola,
    N8NTA

  3. #3

    Default

    Thank you Dave, an excellant suggestion. I will update my program to reflect on your advice. I will report back on how this worked out.

    73

  4. #4

    Default

    Ok, I have changed my program as recommend before but it is still doing the same. As I said earlier everything works the way I planned it BUT, every so often about the fourth or fifth time I press and release the tx button, the output selected will stay on instead of going back off and by datagood led is still lit so I am convinced mydata1 has not cleared. Like I said everything works great except when that little gremlin decides to pop up.

    I have most likely spent more time on this than most people so I may take my sons advice and fix it, with a hammer

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166

    Default

    Tazntex , Can I please see a listing of the modified code?

    Dave Purola,
    N8NTA

  6. #6

    Default

    Here is the revision Dave,
    INCLUDE "MODEDEFS.BAS"
    @ DEVICE PIC16F628a,XT_OSC
    @ DEVICE pic16F628a, WDT_OFF
    @ DEVICE pic16F628a, PWRT_ON
    @ DEVICE pic16F628a, MCLR_OFF
    @ DEVICE pic16F628a, BOD_ON
    @ DEVICE pic16F628a, LVP_OFF
    @ DEVICE pic16F628a, CPD_OFF
    @ DEVICE pic16F628a, PROTECT_OFF
    DEFINE OSC 4
    mydata1 VAR byte
    mydata2 var byte
    address1 var byte
    address2 var byte
    checksum var byte
    chk_sum var byte
    master var portb.0
    vacuum var portb.1
    datagood VAR porta.2
    serpin VAR porta.1 'serial input pin
    PORTA = 0
    PORTB = 0
    trisa = %00000010
    trisb = %10000000
    CMCON=%00000111
    PAUSE 50

    loop:
    mydata1=%00000000
    gosub loop1
    CheckSum = (address1 + address2)
    CheckSum = CheckSum + (mydata1 + mydata2)
    IF checksum != chk_sum THEN loop
    IF mydata1 != mydata2 THEN loop
    IF address1 != address2 THEN loop

    IF (mydata1>0) && (checksum = chk_sum) THEN
    datagood = 1 'mydata1 > 0 so I know whether or not mydata1 has returned to %00000000 if 1 then my led will come on
    else
    datagood = 0 'If mydata1 is %00000000 then var mydata1 is 0, my led is off
    endif
    if mydata1=%01010110 then loop2
    if mydata1=%10101111 then loop2
    if portb.0=1 then loop3
    goto loop

    loop2:
    if mydata1=%10101111 then master=1 'master relay turn on
    pause 50

    if mydata1=%01010110 then master=0 'master relay turn off
    pause 50
    goto loop

    loop3:
    if mydata1=%01011001 then
    vacuum=1 'portb.1 is on
    else
    vacuum=0 'portb.1 is off
    endif
    GOTO loop


    loop1:
    SERIN2 serpin,16780,[wait(254),address1,address2,mydata1,mydata2,chk_su m]
    Return
    Last edited by tazntex; - 27th August 2008 at 04:53.

  7. #7

    Default

    Not much has changed since my last posting, I haven't taken the hammer out of the toolbox just yet. The rf modules are capable of 5000bps so I did move up from 2400. I've been over under and through this forum, and saw a post where bruce had use a 100k to pull down the data, if I read this correctly, line coming in to reduce noise on the input. I have monitored my data on the serial input of the 628a, looks pretty clean. I haven't had any luck getting rid of the little gremlin who pops up every now then and holds the output pin high. Anyhow I am open to criticism, constructive preferred

Similar Threads

  1. Delayed output 10 secs
    By lilimike in forum mel PIC BASIC Pro
    Replies: 37
    Last Post: - 14th October 2011, 07:28
  2. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 16:23
  3. Replies: 11
    Last Post: - 12th July 2008, 03:36
  4. Fade out LEDs question
    By Sam in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 22nd June 2008, 11:50
  5. Help Quick Need to make code smaller
    By Programmednew in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 25th January 2005, 04:46

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