oy...
Thanks guys, you rock..
How I wish I could be using my Arduino for this project..
oy...
Thanks guys, you rock..
How I wish I could be using my Arduino for this project..
www.theLanguageBear.com - Multi-Lingual books for kids and adults of all skill levels.
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.
So I tried driving it with two pins but something else is screwy now....
This is what I have:
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...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
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.
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.
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.
+1 .....
Good answer from Henrik ...
Last edited by Acetronics2; - 23rd February 2010 at 09:44. Reason: I must RTFM !!!
Bookmarks