Stupid simple question.....


Closed Thread
Results 1 to 19 of 19

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Posts
    16


    Did you find this post helpful? Yes | No

    Default Another dumb ass problem

    I really hate this stuff.... it makes me want to stab myself in the eyeball with a fork.

    I'm measuring 3v from Pin1 (GP1) on my 12F683.
    I'm using a 3v coin cell. It measures 3v.
    I connect a LED to Pin1, it lights.
    YAY! Next frickin challenge....

    I connect a small vibe motor to my 3v battery, it vibrates like crazy. Yay.
    I connect my small vibe motor to Pin1 (measuring 3v) It does absolutely nothing.
    I connect the LED to Pin1.. it lights..
    I connect the motor to Pin1 ... it does nothing
    I punch stuff... that doesn't help.

    I don't know what else to try...
    The vibe motor draws about 35-40mA

    I see that the IO pins supply 25 mA but the GPIO can supply 90mA...
    What's the difference?
    www.theLanguageBear.com - Multi-Lingual books for kids and adults of all skill levels.

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by chien_fu View Post
    The vibe motor draws about 35-40mA

    I see that the IO pins supply 25 mA but the GPIO can supply 90mA...
    What's the difference?
    A single pin can put out a max of 25mA, but the entire GPIO (all output pins) can put out a max of 90mA. You could use a transistor, or you could have two pins control the motor (and hope start current would not be too high).

  3. #3
    Join Date
    Jun 2008
    Posts
    16


    Did you find this post helpful? Yes | No

    Default

    So I tried driving it with two pins but something else is screwy now....

    This is what I have:

    Code:
    OUTPUT Pin1
    output Pin2
    
    Startup:
    
    for startupalarm = 1 to 4
    high 2 
    high 1 
    pause 5000
    low 2 
    low 1 
    pause 5000
    next startupalarm
    It seems that "high 2" does not actually switch the pin high, but just ticks it high for a split second. "high 1" switches the pin high and it is held high for 5 seconds until it is switched low...

    This is the same regardless of which pins I use. The line of code immediately preceding the pause command works, all others do not. Nothing else is connected to the chip, it's all by itself on a breadboard.............
    www.theLanguageBear.com - Multi-Lingual books for kids and adults of all skill levels.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default

    Hi,
    You're suffering from what is called a RMW problem (read-modify-write). The way the PIC works when setting a single bit in a register, like the GPIO-port in this case, is to first read the whole register, then set the bit in question and finally writing the whole register "back".

    Because your motor presents a large a load to the pin (especially at startup) the voltage on the pin will sag or be low. So what is happening is this:
    First you have the High 2. This reads the port (as a byte), sets bit 2 and writes the whole byte back to the port.
    Now you have High 1 which does the same thing but because pin2 is heavily loaded it will read as 0 when the port is read, the PIC then sets bit1 and write back to the port resulting in bit 2 now being reset to 0.

    The best bet is to use a transistor to drive the motor. If that's not an option then write to the port directly, setting both pins at the same time. You do this in the same way as Darrel showed you how to write to CMCON etc - look up the physical adress of GPIO and use POKE to write to it.

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Remember also, you must treat your Motor as an INDUCTOR or RELAY. The back emf could destroy your PIC pin or Transistor switching it. Put that all important Diode reverse-biased across the Motor.

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Post

    +1 .....

    Good answer from Henrik ...
    Last edited by Acetronics2; - 23rd February 2010 at 08:44. Reason: I must RTFM !!!

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Default

    Nah, if you look at section 9.1 of the mid-range manual you'll find the following:
    All write operations (such as BSF and BCF instructions) are read-modify-write operations. Therefore a write to a port implies that the port pins are read, this value is modified, and then written to the port data latch.
    So I'll stick to my theory ;-)

Similar Threads

  1. Really simple question for you experts :)
    By lew247 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th June 2008, 01:43
  2. SIMPLE question
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th February 2008, 18:27
  3. Stupid question
    By Meriachee in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 20th July 2007, 05:47
  4. really simple, dumb question
    By picster in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 3rd March 2007, 22:02
  5. really simple adcin question
    By kitcat in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 21st April 2006, 09:06

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