CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

urgent Problem with ADC

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
xtina



Joined: 14 May 2009
Posts: 7

View user's profile Send private message

urgent Problem with ADC
PostPosted: Thu May 14, 2009 8:12 am     Reply with quote

hi I have a problem with ADC,I have an ultrasonic sensor and this ultrasonic sensor gives analog output between 1.3 volt (when object is very close to the sensor) to 2.0 volt (when is no object detected) so how can I program my PIC16F877A and its configuration using CCS C to control my DC motor as below:

when ultrasonic sensor output voltage is higher than 1.6 volt the DC motor operates.

when ultrasonic sensor output voltage is lower than 1.6 volt the DC motor stops.


plzzzzzzzzzzzzzz help me it's urgent
Guest








PostPosted: Thu May 14, 2009 10:23 am     Reply with quote

Hi,

There are many, many examples on this board about using the A/D converter. This is really a trivial project using CCS C. You should be able to easily read the analog input and determine if the reading is above or below your threshold. You would not even need to convert to volts as long as you figured out what the digital value is that corresponds to your trip point. I'd add some hysteresis to be sure you are not constantly turning the motor Off/On right at the trip point though......

How is your DC motor controlled? Is it a simple 2 wire configuration? If so, you can use a MOSFET transistor to control it. The transistor can be switched by the PIC. If the motor is a stepper, or requires PWM control, it gets more complicated.

Please post your code so that we can comment!

Chad
dyeatman



Joined: 06 Sep 2003
Posts: 1917
Location: Norman, OK

View user's profile Send private message

PostPosted: Thu May 14, 2009 10:54 am     Reply with quote

I think that's the point. There may not be any code yet. This is likely a school project and he wants us to do the work. (may even be due in the next few days!)
Lion
Guest







PostPosted: Sat May 16, 2009 2:55 am     Reply with quote

Hello,

Maybe you can try this way BUT I can not guarantee the result.

First of all, you can use the voltage meter to test the relation between voltage and distance. How close is 1.3 volt. How far is 1.6 volt.

you can put an object in front of you ultrasonic sensor and then you change the distance. you can record the ADC_VALUE each time (resolution 3 centimeter or 5 centimeter). Now you get the some ADC_VALUEs so you can write some code.

if ( ADC_Value > ?)

output_high(PIN_?) // this is the pin which you control the motor

else

do other function.


I hope this will help.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group