![]() |
Microswitch problem
We have a problem with our micro switch. It doesn't work. We conncected it to the digital in/out, but it allways gets a '1' from the program no metter what, even when its disconnected. What is the problem?
|
Re: Microswitch problem
A few questions:
1. Do you have the digitalIO port you are using configured as an input? 2. What alias are you using to read the port(like rc_dig_in01)? Basedd on your answers I should be able to tell you what is wrong. Andrew |
Re: Microswitch problem
Quote:
2. Yes, we are using rc_dig_in01. This is the code we tried. if (rc_dig_in01 == 1) { relay1_fwd = 0; relay1_rev = 0; } |
Re: Microswitch problem
The digital inputs are designed to return 1 if the switch is open or disconnected. It returns 0 only when closed.
The code you posted never does anything if the switch is closed (rc_dig_in01 is 0). Try something like: Quote:
|
Re: Microswitch problem
oops I though it should give 1 xD
So if i change it to ==0 it should work? |
Re: Microswitch problem
Quote:
Relay1 will only change when we explicitly change it. The last thing we did will always be in effect. For example, in your original code the relay was set to: Code:
relay1_fwd = 0; relay1_rev = 0;Nothing ever changed it to 1. If you modify your code to use "==0" instead and change it to set the Relay to 1, then Relay1 will begin as 0 and change to 1 when you flip your switch, but nothing will ever change it back to 0 if the switch is flipped off again. |
Re: Microswitch problem
Ok i think i understand, tnx alot ;p
|
Re: Microswitch problem
$@#$@#$@#$@# it still doesn't work X_X
The rc_dig_in01 is allways 1 even when we press on the microswitch X_X what is wrong here? |
Re: Microswitch problem
If you are using the micro switch that came in the kit, then there are different ways of wiring it.
Choose the wrong way and it will never be 0. Let me see if I can find a picture.... |
Re: Microswitch problem
You may have the switch plugged in wrong(white where black sould be). Otherwise I would need to know how you are checking the value(LED or printf statement) and see the code you are using.
Andrew |
Re: Microswitch problem
Printf. And there are 3 plugins in the microswitch right? We connected the yellow one to the upper one, nothing to the middle one, and the red one to the lowest one
|
Re: Microswitch problem
Quote:
Use only the outer wires at the RC digital input side. The red is power and used only by devices that need power to work. A switch doesn't need power. It simply connects the signal wire (yellow) to the ground (black) or not to close or open the circuit. If you have a multimeter you can use it to test that the switch is wired correctly. |
Re: Microswitch problem
Thanks! We've got it working!:D
|
Re: Microswitch problem
Darn we now have a new problem :(
if (rc_dig_in01 == 0) { relay1_fwd = 0; relay1_rev = 0; } else { relay1_fwd = 1; relay1_rev = 1 ; } This is the code we are trying to use atm, but we have a problem. When the motor works foward, and i press the microswitch, it changes from 1 to 0 and the motor stops working. But when the motor is working backwards, and I press the microswitch, the microswitch turns to 0 but the relay1_rev remains 1 ;s Whats wrong? |
Re: Microswitch problem
What motor? You haven't mentioned a motor before.
Andrew |
Re: Microswitch problem
1 Attachment(s)
Here is a table of how to set the relay values to get the different results possible. It's from the IFI Spike document: http://www.ifirobotics.com/docs/spik...uide-sep05.pdf
We don't usually set both "rev" and "fwd" to 1 at the same time. Both fwd=0;rev=0; as well as fwd=1;rev=1; should mean the motor is off. This code will execute one section only as long as the switch is depressed and the other whenever the switch is not pressed. |
| All times are GMT -5. The time now is 23:49. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi