Go to Post you don't need a fancy workshop to build a good robot, just determined people. - pacoliketaco [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Spotlight this post!  
Unread 03-01-2007, 22:14
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: Set Default Digital inputs to Low? How? bad Analog value?

Quote:
Originally Posted by Generalx5 View Post
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!
First up, you're probably going to need an inverter for the sensors, they sell them in a little chips at Radio Shack (hopefully). The digital I/O lines are hardwired to be pulled high unless grounded I believe, can someone else confirm this?

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));
Good luck!

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);
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)

Last edited by Matt Krass : 03-01-2007 at 22:16. Reason: Added something to the usage of Get_Analog_Value()
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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


All times are GMT -5. The time now is 20:40.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi