
PhG
Hi DJ,
I'd like to read the position of a switch. So, when a button is pushed, I get a Boolean that becomes true (or an integer that becomes 1). As soon as the button is released the values changes back to 'false' or 0.
My line of code so far goes like this :
ImpactSensLeft = (EzB_Connect1.EZB.Digital.GetDigitalPort(EZ_B.Digital.DigitalPortEnum.D15))
But this always returns 'true' doesn't really matter if the button gets pushed or whatever. What am I missing here ? Where can I put this code for optimal results (form Load event ?? etc...). I want to read out and interact with the switch all the time while other code is processed. The switch acts as an emergency switch that shuts down the motors of my robot as soon as the switch is pushed. When released, the motors start running again. I'm really looking forward to this.
Best regards,
PhG
if you have ever hooked up the battery directly to the ez-b, then you may have blown the digital port transistor.
Can you try running my program with nothing attached to the ez-b. absolutely NO peripherals. Then run your finger along the digital input line. it also helps if you lick your finger
Serious haha.. But anyway. if you do that, the eletricity from your body will flip the i/o ON and OFF while they float
Guess what.... it works ! Well, at least I do get response. In the mean time I also found out that the RC ESC that I use (Graupner) are interferring. As soon as I switch the main power on (= for the drive motors powerd by the ESC's), I get a HIGH on those digital inputs. I removed all peripherals and licked my finger and indeed, I can make the digital port flip between on and off. However, I'm still puzled... the timer is set to 250 ms and the port filps back between on and off every 3 to 4 seconds. So it does respond, but rather with a delay. For the next coming days, I'll swap the Graupner ESC's and try those from Robbe and see if that makes any difference. All the above I carried out on my desktop with Visual Studio 2005. On the laptop (Win7 and VS 2008) I get an error message but the thing works. Also with delays up to 4 seconds before the digital switches back to 'low'. I always put a reference control like a servo on the form to verify that the connection works. It's just the reading of a digital switch that's acting a little strange. I attachted a screenshot with the error message.
If the ESC is causing interference, then the line must be floating. You will need a 10K resistor across the Digital I/O Signal and GND (as a pull-down resistor). That will hold the signal low until the switch is flipped.
The compiler warnings are not errors, nothing to worry about
DJ,
I'm a happy man ! It works ! The 10K resistor does the job perfectly and the interference can be reduced by adjusting wires etc. Next thing now is to tidy it up a little bit and send you some pictures.
Btw, happy holidays and best whishes for a wonderfull new year.
Best regards,
PhG
Thanx dude