urgent need!!!!!

Status
Not open for further replies.

engkhlaif

New Member
i need help in writing a code that configure an GP2D12 sensor this sensor reads analog signal and then it must convert it into digital using the
PIC16F877A A/D pins
i need a help as i want to interface this sensor with the mentioned microcontoller
any one can help????
thanx
 
thanx futz
the idea is that iam using MPLAB and every code i found is written in PIC C compiler
please if any has a code or can help me in a code that support MPLAB
 
engkhlaif said:
thanx futz
the idea is that iam using MPLAB and every code i found is written in PIC C compiler
please if any has a code or can help me in a code that support MPLAB
There's asm code in those links. Anyway it's not too hard to do AD conversion with PICs. Just refer to the datasheet and get coding.
 
futz said:
There's asm code in those links. Anyway it's not too hard to do AD conversion with PICs. Just refer to the datasheet and get coding.

Or check my tutorials, which explain it more clearly than the datasheet.
 
need help in writing a code that configure an GP2D12 sensor this sensor reads analog signal and then it must convert it into digital using the
PIC16F877A A/D pins
i need a help as i want to interface this sensor with the mentioned microcontoller
It's really not that big of a deal. Just use the same ground and supply for the GP2D12 as you're using for your PIC (presuming 5V regulated). Connect the third pin of the GP2D12 to the PIC A/D pin of your choice. Set the pin A/D input, read the incoming variables, and write code to suit your application as needed.

Check the datasheet (especially the volts vs. distance graph) for the GP2D12 though while you're experimenting with it. Note that while you're really close to the GP2D12, or when you start to move to the farthest of its range, the readings become erratic and unusable. That's okay, just plan your physical design (e.g. robot wall detection) to work within those limits.

You may also find for detection of a stationary object, the GP2D12 output will fluctuate slightly. That's okay, but the preferred way to compensate seems to be to take an average of several (maybe ten or so) readings, as oppose to using a capacitor to smooth the output.

FYI tip: I had to use one of the Sharp sensors to detect distance changes in an unique situation, where the placement of the sensor required quite a length of wire between it and the mcu it was sending its output signal to. Initially I used a length of telephone cable, but the interference was far too great (resulting in considerable fluctuations in sensor readings). The solution was instead to use a length of USB cable, with the connectors cut off from each end. The extra shielding in the USB cable adequately eliminate the interference, even over a 10' length. Just something to think about if ever you're unable to locate the sensor less than a foot away from your mcu in your design.
 
dear i have read the data sheet of GP2D12 and if wrote a linear equation that describe the distance of the moving object
the idea is how can i display this distance of an LCD not as a string i want to display it as the value is changed continuously
CAN YOU HELP ME WITH A PEICE OF CODE THAT READ THE VALUE FROM THE A/D PIN AND THEN CONVERT IT INTO DISTANCE AND DISPLAY IT ON
LCD 1*16
THANX FOR ATTENTION OF MY NEED
 
dear i have read the data sheet of GP2D12 and if wrote a linear equation that describe the distance of the moving object
If you see the graph on the datasheet, you'll note the relationship between voltage output of the sensor and distance is NOT linear.

I recommend you separate your inquiries into smaller tasks, and study or repost them individually:
- interfacing to LCD (with specific details about what you're using);
- interfacing to the sensor via an A/D pin. I'm not overly familiar with assembly language to be able to do that myself, but I know there are several people on this forum who'd find that easy as anything. You might mention whether or not you're using/looking for assembly code, or if not, what other compiler you're using;
- processing the data from the pin into the LCD usng a program that will satisfy your requirements (again, specific details about your project wouldn't hurt).

Pressuring people by typing in all-caps or being overly insistent that they ought to feel obligated to help you as a top priority will not necessarily endear you to those who might most be able to help you. Yeah, you might have a deadline, but a free forum you can't expect to get much more than what you pay for. Be patient with those helping you, and you might find that patience is returned in kind. If finding a solution was that imperative to you, you would have posted your question a week, or month, or year ago.
 
Last edited:
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…