View previous topic :: View next topic |
Author |
Message |
xtina
Joined: 14 May 2009 Posts: 7
|
urgent Problem with ADC |
Posted: Thu May 14, 2009 8:12 am |
|
|
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
|
|
Posted: Thu May 14, 2009 10:23 am |
|
|
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: 1934 Location: Norman, OK
|
|
Posted: Thu May 14, 2009 10:54 am |
|
|
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
|
|
Posted: Sat May 16, 2009 2:55 am |
|
|
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. |
|
|
|