Forum Replies Created
-
AuthorPosts
-
ShengoParticipant
Hi 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.
ShengoParticipantDo 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.
ShengoParticipantUpdate 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.
ShengoParticipantEdit, 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?
ShengoParticipantIt 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.
ShengoParticipantHi, 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.
ShengoParticipantWhat I meant was, I just want the whole program just to run once, what’s happening in the program now is that after the 5 seconds delay and RB1 becomes low, and then the program itself will go back to the initial part again, which is detect the push switch status (by this time it will turn on the RB1 because I haven’t turn off my switch), and turn on RB0 again. The program keeps repeating and repeating the whole sequence by itself.
Any way just to only let it run only once, without repeating itself? After each time it finishes running, everything will just switch off without running back to the first part of the program again. And when I press the push switch again, the program will run again just ONCE. I don’t want it to be keep running in an infinite loop.
I hope I explain myself well this time, thanks.
ShengoParticipantOkay, I finally get the program now. Tried it with push button today.
Can you please suggest a way to make the program only loop by one time? Afterwards if I press the push switch again then the program run again, I just want it to only run once, each time is only start by myself but not automatically by the infinite loop.
Your help is really important and appreciated. Thanks.
ShengoParticipantNo, sorry. Because I am just using wire connect directly to both RD0 and RD1 to test my circuit, when I connect RD0 to ground, LED1 lights up, when I connect RD1 to +5V, LED1 turns off then LED 2 lights up for 5 seconds then turn off.
The thing is the repeating part is not the “if” part at the push button, it is the second “if” part of the code, which is the 5 seconds turn on then off the LED2. Must I use a push button to test the circuit? Because I’m planning to use a sensor for RD1 though, only push button for RD0.
Or is there any problem with my code?
Thanks.
ShengoParticipantHi there, sorry to disturb you again. I have tested the above code with my PIC16F877A, when I have input for RD0, LED 1 turns on (I replace motor with LED first for testing). Then when I have input for RD1, the LED 1 turns off then LED 2 turns on for 5 seconds and turn off, but once it has turned off, LED 2 lights up again, then after 5 seconds it turns off again and this loop keeps on repeating.
I wonder if those code you posted in your website is all on looping? If I just want all the sequence above just to happen once, and then when I press the push button again, the sequence happens again, I don’t want them to be repeating by themselves, shall I just remove the part “do while”?
Or should I use any “return” command for my code in order for them to return to all original state after the sequence finish?
Thank you for your advice. Your quick reply is very much appreciated.
ShengoParticipantCould you please check if the code I posted is sensible and correct?
My circuit working principle is like this,
Press switch, RD0 become zero and sends a signal to RB0 to become 1, then RB0 sends signal to my L293D input 1 to turn the motor clockwise. Then, when the sensor is triggered, RD1 will be 1, thus it sends signal to RB1 to become 1, which RB1 sends to input 2 of L293D to turn the motor anti clockwise. Then after 10 seconds, the motor is stopped.
Is the coding above correctly matched with what I have describe?
Furthermore, is there any other H bridge circuit IC you can introduce to me that can provide output current up to 1.5A?
Thanks for taking your time reading this.
ShengoParticipantHi there, below is the code I tried to write according to your tutorials:
void main() { TRISD.F0 = 1; //RD0 as Input PIN 1 TRISD.F1 = 1; //RD1 as Input PIN 2 TRISB.F0 = 0; //RB0 as Output PIN 1 TRISB.F1 = 0; //RB1 as Output PIN 2 PORTB.F0 = 0; //Motor clockwise direction flow OFF PORTB.F1 = 0; //Motor anticlockwise direction flow OFF do { if(PORTD.F0 == 0) //If Switch is presseed { delay_ms(100); //Provides required delay if(PORTD.F0 == 0) //If Switch is still pressed { PORTB.F0 = 1; //Motor turns in clockwise direction if(PORTD.F1 == 1) //If Signal is sent from proximity sensor { PORTB.F0 = 0; PORTB.F1 = 1; delay_ms(10000); PORTB.F1 = 0; //After 10 seconds the motor is turned off } } } }while(1); }
The part where the proximity sensor sends a signal, if(PORTD.F1 == 1), the input should be 1 right?
Also, do you need a constant flow of current from input, in order for the output to be able to work constantly? Like if I press the switch once, the motor turns clockwise, but if I cut off the current from the switch, will the motor still keep turning or it will stop??
Furthermore, will this code works in MPLAB or Hi-tech? I know the code is almost similar with just a slight modification, just need to know about this, if I want to program them in other software, anything else to add to the code?
One more question, the voltage of the signal sent from my proximity sensor is quite high, which my PIC16F877A couldn’t stand the voltage as the maximum is 5V, so any solution to this to lower down the signal voltage from my proximity sensor? I’ve searched the internet, I found something about opto-isolator, can I use that?
Your help is greatly appreciated as this is a very urgent project, thanks.
ShengoParticipantCan you show me how should I connect my circuit and an example of code with 2 input to control 2 output should be please? Thanks
I know those 2 outputs should be connected to my L293d, just confused how the input should be connected and how the code should be, cause once if I turn on the switch, it will send signal to input 1 and the motor turn forward (clockwise direction), but what if I need to send another signal from sensor 1 to input 2 to turn the motor anti clockwise? Will those 2 signal overlap? By overlapping I mean both input is high.
Thanks very much.
-
AuthorPosts