Home › Forums › Microcontrollers › PIC Microcontroller › PIC16F877A with DC Gear Motor
- This topic has 25 replies, 2 voices, and was last updated 7 years, 8 months ago by Ligo George.
-
AuthorPosts
-
June 18, 2015 at 8:21 am #11492Ligo GeorgeKeymaster
I think the problem is with type of switch you are using. You should use a micro switch, which will return to OFF state after the press. If you want to use ON – OFF switch you can add while(PORTD.F0 == 0); at end of if loop.
June 18, 2015 at 6:39 pm #11496ShengoParticipantHi, thanks for your advice. It works now with a micro switch and with a slight change in the code.
Sorry, keep bothering you with a question. Do you have any sample circuit or guide to interface an inductive proximity sensor with the PIC16F877A?
Thank you very much.
June 18, 2015 at 9:35 pm #11498Ligo GeorgeKeymasterSorry, I don’t have any circuit or tutorials for interfacing inductive proximity sensors. Which sensor you are using ?
June 19, 2015 at 6:44 am #11500ShengoParticipantIt is a Proximity Switch 18mm in size, Inductive (NPN NO), with 10mm sensing range, 6V – 36V DC, Non-flush. It is a product of Taiwan which comes with 3 wires, brown to positive, blue to ground, and black to output.
I have bought a 7805 to step down the voltage from the sensor to prevent the PIC from damage. Any idea how should I connect this to the PIC?
Should I use a pull down resistor?
Thanks.
June 19, 2015 at 11:02 am #11501ShengoParticipantEdit, when I have interface the PIC with my relay with LED as output, the circuit works perfectly with the program of my PIC.
But, when I change the output of the relay to motor, when I press the button, the motor would not turn on (the relay did not switch on also), but when I turn on the relay manually by connecting the input of relay to VCC, the motor works perfectly. It seems the input of my relay cannot detect anything from output of PIC when I switch the output of relay to motor, while when with LED it works perfectly.
Any solution to this?
June 19, 2015 at 7:53 pm #11502ShengoParticipantUpdate again, sorry. The PIC interfacing with relay and motor has no problem now, sorry about the hassle.
Now is just the interfacing my sensor with PIC, any suggestion how should I connect the proximity sensor to my PIC to allow it to have an output of 1 (into my PIC input 2) when sense something, and have an output of 0 (into my PIC input 2) when it does not sense anything?
The specification of my proximity sensor is as shown in the previous 2 post, in order for my output of my sensor to work, I need to connect the black wire(output) to the load and then to the brown wire(positive) as it is a NPN sensor.
Thanks.
June 21, 2015 at 1:35 pm #11511Ligo GeorgeKeymasterYou may use voltage dividing resistors and/or 5.1V zener diode to reduce the sensor output voltage down to 5.1V.
June 22, 2015 at 2:53 pm #11525ShengoParticipantDo you have any idea or suggestion how should I connect my sensor to my 2nd input of my PIC (RD1)? I am really confused with the three wires, I know positive to brown, negative to blue, but in the circuit shown in the sensor it says that after connecting the black wire to my load, I need to connect the other side of the load to the brown wire again. I am really confuse how should I connect this to the PIC.
Thanks.
June 24, 2015 at 7:58 am #11528Ligo GeorgeKeymasterThen connect a pull up resistor as a load. Connect one terminal of the resistor to positive and other terminal to black. And the same black terminal can be taken as output.
July 3, 2015 at 4:57 pm #11540ShengoParticipantHi again, just finished the presentation for the robot today and it was really successful.
Thanks again for all your guidance and help throughout this project. Cheers.
July 3, 2015 at 4:59 pm #11541Ligo GeorgeKeymasterYou are always welcome. Thanks for the feedback.
-
AuthorPosts
- You must be logged in to reply to this topic.