Automatic Toilet Flusher - Page 3


Closed Thread
Page 3 of 3 FirstFirst 123
Results 81 to 99 of 99
  1. #81
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    I got it to work!!!!!!!!!

    Although I got to adjust the ms because it only moves like 3mm but it should be done soon!


    Ps I found out what was wrong

    The servo was not connected right to the pic
    I had the postive going to the pic pin and the signal was going to positive
    I got the new servo in and now all I have todo is make some adjustments in the software

    So you will here from me soon

  2. #82
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Can't figure out the delay for the servo

    Here's my program


    IRLED1 var PORTB.0
    Servo var PORTB.1

    TRISB=%00000001
    Loop:
    If IRLED1 =1 then
    Pulsout Servo,110
    pause 10
    Pulsout Servo,150
    else
    Pulsout Servo,110
    endif
    Goto Loop

    End
    I Want it to move the servo to the right to it's most and delay for two seconds and
    then come back to center.

    If anyone can help me out
    it would be much appreciated
    Last edited by Techbuilder; - 27th February 2008 at 12:19. Reason: .

  3. #83
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Does this work?
    Code:
    x var byte
    IRLED1 var PORTB.0
    Servo var PORTB.1
    
    PORTB = 0 ' setup for high-going pulsout
    TRISB=%00000001
    
    Loop:
     If IRLED1 = 1 then
       goto Flush ' flush
     else           ' else center
      for x = 1 to 20
        pulsout Servo,150
        pause 20
      next x
     endif
      goto Loop
    
    Flush:
      for x = 1 to 20
       Pulsout Servo,200
       pause 20
      next x
      pause 2000
      Goto Loop
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #84
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Thanks for the code bruce
    I appreciate it

    Although it didn't work
    instead of not moving enough like my code
    this code twitches every two seconds unless it makes contact which it just go's to center
    and the twitches are just a little more then mine was at last time
    Last edited by Techbuilder; - 28th February 2008 at 04:48.

  5. #85
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    (A long-lasting project).

    Your room mates will very soon say:
    OK, we will flush the toilet but you turn off the light at night so we can sleep!

    Seriously, what they think about your efforts?

    Best regards,

    Luciano

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Luciano View Post
    Hi,

    (A long-lasting project).

    Your room mates will very soon say:
    OK, we will flush the toilet but you turn off the light at night so we can sleep!

    Seriously, what they think about your efforts?

    Best regards,

    Luciano

    Luciano,

    I think they will soon say, "let us help you with your Automatic Toilet Flusher Project".



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

  7. #87
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    lol well I have a sleeping disorder so they are used to me up

    I just want this thing to work.



    I will get it though

  8. #88
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Funny that should work. Here's a few things to check.

    Make sure you're using a separate power supply for your servo, and you have a common ground between them. Running a servo from your controller power supply can cause problems if you aren't using a hefty bench type power supply with a lot of filtering to remove motor noise.

    Make sure you're using the correct voltage for your servo. These normally run on 4.8 to 6V. If you're trying to operate your servo from 9V that may be a problem. Most hobby type servos can't handle 9V, and a 5V control pulse from the PIC is going to look pretty weak to a servo operating at 9V.

    I tested the above code example, and it works as expected with a Hitec HS311 servo operating at 5V with a 16F627. Note some servos will move 90 degrees right or left, so you can tweak the value in the Flush routine between 200 to 250 to extend the rotation range.

    My HS311 moves full right with 250, and centers with 150.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  9. #89
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Funny that should work. Here's a few things to check.

    Make sure you're using a separate power supply for your servo, and you have a common ground between them. Running a servo from your controller power supply can cause problems if you aren't using a hefty bench type power supply with a lot of filtering to remove motor noise.
    Yep I am using a separate power supply for both and each is filtered

    Make sure you're using the correct voltage for your servo. These normally run on 4.8 to 6V. If you're trying to operate your servo from 9V that may be a problem. Most hobby type servos can't handle 9V, and a 5V control pulse from the PIC is going to look pretty weak to a servo operating at 9V.
    Yep I used 5volts and I even tried it with 6



    I tested the above code example, and it works as expected with a Hitec HS311 servo operating at 5V with a 16F627. Note some servos will move 90 degrees right or left, so you can tweak the value in the Flush routine between 200 to 250 to extend the rotation range.

    My HS311 moves full right with 250, and centers with 150.
    I am using a hi-tec HS-322HD

    And I used another servo which was a futaba S3003
    but it was modified for continues rotation but it was rotating in 90% degree section
    but that was when it was not in contact but when it was in contact it didn't move just like the hs-322HD

  10. #90
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Techbuilder View Post
    but that was when it was not in contact but when it was in contact it didn't move just like the hs-322HD
    You mean in contact with the handle? If so, maybe the servo is not strong enough?
    Dave
    Always wear safety glasses while programming.

  11. #91
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    You mean in contact with the handle? If so, maybe the servo is not strong enough?
    No contact with the IR led


    Although I figured out that I have to modify the servo to do 180 degrees
    because mine only does 60 degrees, still doesn't explain why it is only going off when it is not in contact with the IR led.

  12. #92
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Actually if I spin it by hand it spins enough
    so I don't believe that's the problem.

  13. #93
    Join Date
    Jul 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    It is not connected
    the only thing that it is connected is to the IR receiver which it needs to be

  14. #94
    Join Date
    May 2008
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Hey everyone, I've been working on a very similar project (also my first PIC only project), before I even discovered this thread. I'm having a problem getting my servo to move 90 degrees. I'm using a parallax standard servo (left over from my Basic Stamp days), which is based on a futabu (http://www.parallax.com/dl/docs/prod...s/stdservo.pdf).

    I tried using the code that Bruce posted, but the servo only moves about 10 degrees each time the move loop is called. I also tried using a modified version of the BS2 code in the pdf I linked, but I get the same result. How can I get my servo to move the full 90 degrees?

    Here is the code I'm using:

    Code:
    @ __config _INTOSC_OSC_NOCLKOUT &_WDT_ON &_PWRTE_ON &_MCLRE_OFF &_BODEN_ON &_CP_OFF &_DATA_CP_OFF &_MCLRE_OFF
    
    
    servo1 var Porta.0
    x var byte
    
    		low servo1
    		HIGH PORTB.3
    	
    loop:	pause 500
    		low portb.3
    		pause 500
    		high portb.3
    		GOTO move
    		pause 2000
    		low portb.3
    		GOTO loop
    
    move:	for x = 200 to 1200
       		pulsout servo1,x
       		pause 18
    		next x
      		pause 2000
      		return
    I have the LED blink so I can be sure that I know the program is working properly and I can tell when the servo should be moving.

    Thanks for the help in advance!

    BTW, I'm making the project because I have a cat that is toilet trained, not because room mates don't flush
    Last edited by JohnnyV; - 20th May 2008 at 00:27.

  15. #95
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    And the PIC you are using is ______________________(fill in the blank).
    Kinda handy to have that sort of info, dontcha think?

    Servo pulse width is GENERALLY centered around 1.5ms...which means that there's probably something wrong here:
    Code:
    move:	for x = 200 to 1200

  16. #96
    Join Date
    May 2008
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    I'm using a 16F627A

    and yes, I've tried changing those numbers and I've tried using the numbers that Bruce posted, but I still get the same result regardless. I've also tried using a different servo (another parallax one)

  17. #97
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by JohnnyV View Post
    I'm using a 16F627A
    and yes, I've tried changing those numbers and I've tried using the numbers that Bruce posted, but I still get the same result regardless. I've also tried using a different servo (another parallax one)
    So, you're running at 4Mhz (INTOSC). The PBP manual tells us that at 4Mhz, pulsout has a granularity of 10us. Your loop runs from 200 to 1200, meaning 2000us (2ms) to 1200 (12ms). A bit out of the range of a normal servo ya think? Unless you've got one of the oddball ones...

    Also, try turning off the WDT and Brown-Out reset for grins... You might be killing the battery voltage when the servo tries to move and causing a reset.

  18. #98
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Use GOSUB VS GOTO if the routine you're going to uses RETURN to get back.

    Disable onboard comparators with CMCON=7 before trying to use a pin that
    has the comparator feature.

    Give this a shot;
    Code:
    @ __config _INTOSC_OSC_NOCLKOUT &_WDT_ON &_PWRTE_ON &_MCLRE_OFF &_BODEN_ON &_CP_OFF &_DATA_CP_OFF &_MCLRE_OFF
    
    
    servo1 var Porta.0
    x var byte
    CMCON=7 ' <-- disable analog comparators
    
        low servo1
        HIGH PORTB.3
    	
    loop:	
        pause 500
        low portb.3
        pause 500
        high portb.3
        GOSUB move   ' <-- use GOSUB VS GOTO
        pause 2000
        low portb.3
        GOTO loop
    
    move:
        for x = 200 to 100 STEP -1 ' 2mS to 1mS pulse
          pulsout servo1,x
          pause 18
        next x
        pause 2000
      		
        for x = 100 to 200 ' 1mS to 2mS pulse
          pulsout servo1,x
          pause 18
        next x
        pause 2000
        return
      		
       END
    This should cycle your servo from one side to the other. Tested with a
    Parallax servo.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  19. #99
    Join Date
    May 2008
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Bruce, works beautifully, thank you!

Similar Threads

  1. Automatic 240V / 110V selector
    By The Master in forum Off Topic
    Replies: 5
    Last Post: - 13th October 2008, 00:33
  2. LCD automatic management?
    By ruijc in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th September 2008, 11:24
  3. Automatic VB6 to pic serial connection
    By arniepj in forum Code Examples
    Replies: 13
    Last Post: - 10th January 2008, 07:57
  4. Automatic turn off
    By AMay in forum Schematics
    Replies: 22
    Last Post: - 6th February 2006, 12:31

Members who have read this thread : 1

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