|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
How do I set the digital inputs to low on default?
I'm using an optical sensor that inputs voltage when it senses an object, I'm using this on the EDU Mini RC, so is there a solution to setting it low? the sensor doesn't work like a switch so it doesnt short the Sig to Gnd. Also how do you printf the Analog inputs? I have 3 analog channels and this is how I printf mine:printf("rc_ana_in01 %3d, rc_ana_in02 %3d, rc_ana_in03 %3d\n",(int)rc_ana_in01,(int)rc_ana_in02,(int)rc_a na_in03), Is this correct? because im getting readings that look like this: rc_ana_in01 135, rc_ana_in02 143, rc_ana_in03 151 so please help me out. Thanks! |
|
#2
|
|||||
|
|||||
|
Re: Set Default Digital inputs to Low? How? bad Analog value?
Wait, is this an analog or a digital sensor? Is it perchance one of the banner sensors that we got in the kits in 2004?
|
|
#3
|
||||
|
||||
|
Re: Set Default Digital inputs to Low? How? bad Analog value?
Nope, not that sensor, its a reflective object sensor. this sensor is analog, its ouput voltage varies with different refletive surfaces. I was thinking of putting a resistor to keep the gate closed, and if the sensor picked something up, it would have opened the gate due to a weak resistor.
|
|
#4
|
||||
|
||||
|
Re: Set Default Digital inputs to Low? How? bad Analog value?
Quote:
As far as the analog inputs, those variables are actually addresses used by a function to sample the ADC, this function is Get_Analog_Value(). It should used like this: Code:
printf("rc_ana_in01 %d, rc_ana_in02 %d, rc_ana_in03 %d\n",Get_Analog_Value(rc_ana_in01), Get_Analog_Value(rc_ana_in02), Get_Analog_Value(rc_ana_in03));
EDIT: Also, Get_Analog_Value() returns the value of the ADC you choose, so you can store the information in a variable for use later like this: Code:
unsigned int sensor_var; sensor_var = Get_Analog_Value(rc_ana_in01); Last edited by Matt Krass : 03-01-2007 at 22:16. Reason: Added something to the usage of Get_Analog_Value() |
|
#5
|
||||
|
||||
|
YAY! I've just tried that and works like a charm, thanks!
The inverters sounds like a good invesment. I will consider that option. |
|
#6
|
||||
|
||||
|
Is there still a way to make the Digital Inputs default to low? Because the Sensor im using has very little collecter-emitter voltage, as high as 0.4Volts, the NOT gates need a minimum of 1.5 Volts input for it to declared a high input. Any other ways to make this work? I've googled up the Not gates but nothing to my specifications.
It would be best if the Mini RC could do a pull down by default. The other way to do this is...making them all analog? would that work? |
|
#7
|
||||
|
||||
|
Re: Set Default Digital inputs to Low? How? bad Analog value?
Quote:
Quote:
Well, from your description of the sensor, it seems that you could plug it in to an analog input, and then simply use it as a sort of digital sensor in the following manner (let's pretend the sensor is plugged into analog input 1): PHP Code:
Last edited by prograid : 04-01-2007 at 15:39. |
|
#8
|
|||
|
|||
|
Re: Set Default Digital inputs to Low? How? bad Analog value?
What is sensor you are trying to interface? Can you post a link to or copy of the mfg. spec sheet? The 0.4V output does not sound correct.
|
|
#9
|
||||
|
||||
|
The sensor belongs to OPTEK technologies, OPB742D and OPB606A are the two sensors Im using.
Here are the Sensor Data, http://www.optekinc.com/pdf/OPB740.pdf http://www.optekinc.com/pdf/OPB606a.pdf The voltage picked up from my Multimeter reads DC 0.4V maximum using a 1.5V double A battery source. ---------------------------------------------------------------------------------------------------------------------------------- Also, in hopes of getting rid of the use of Inverters, I've tried instead of setting INPUT; at the end of the IO's, I set them to 0; IO4 = IO5 = IO6 = IO7 = IO8 = IO9 = IO10 = INPUT; <---------Before IO4 = IO5 = IO6 = IO7 = IO8 = IO9 = IO10 = 0; <---------After And I'm still not sure if it works, although the voltage between SIG and BLK is gone, I havnt found a way to trigger it so it goes high. Last edited by Generalx5 : 04-01-2007 at 15:41. Reason: added the section under the dotted line |
|
#10
|
|||
|
|||
|
Re: Set Default Digital inputs to Low? How? bad Analog value?
Check out this application note.
http://www.optekinc.com/pdf/App_Note_213.pdf See figure 1 and figure 3. The collector current of the phototransistor is relatively low. The OPB606 is 500 uA this can pull down 5V thru a 10k resistor. The OPB704 is 50 uA this can pull down 5V thru a 100k resistor. I do not know what the input circuit of your controller looks like, but I would guess that the OPB606 might work with a direct connection as long as pullup is 10k or greater. The OPB704 will very likely need the circuit shown in figure 3. |
|
#11
|
|||||
|
|||||
|
Re: Set Default Digital inputs to Low? How? bad Analog value?
Quote:
(And don't mess with the IO direction settings. What they do is determine whether a given pin is an input or an output. There is always a pullup resistor on the pin.) |
|
#12
|
||||
|
||||
|
Awesome! It works!
Thanks so much for all your help.Problem solved....I'm sure I'll have more problems later on when we start, but yeah! Awesome! |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do the Analog Inputs work? | JBotAlan | Electrical | 3 | 07-01-2005 00:11 |
| OI and analog: Zero value | Astronouth7303 | Programming | 1 | 02-02-2004 16:00 |
| Resistance to Analog Input Value. | Josh Hambright | Electrical | 12 | 15-04-2003 16:12 |
| How to access other Digital inputs on OI? | DougHogg | Electrical | 2 | 12-03-2003 13:57 |
| Analog vs Digital inputs? | f22flyboy | Programming | 8 | 08-11-2002 22:18 |