View previous topic :: View next topic |
Author |
Message |
sarkarelias
Joined: 26 May 2014 Posts: 2
|
PIC16F88 |
Posted: Mon May 26, 2014 4:06 pm |
|
|
I want to receive two analogue signal with Sharp distance sensor (GP2D12) and after measuring those voltages I have to control two dc motor in such a way that they work like segway (PID control). A bluetooth (HC-06) communication also need to be set up with any android phone to control the mini robot. Can anyone please help me with sample code??? Thanks _________________ Eli |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon May 26, 2014 4:20 pm |
|
|
How about looking in the Drivers directory of the CCS compiler ?
Quote: | c:\program files\picc\drivers\gp2d12.c |
Also use the forum's search page to find threads on the gp2d12:
http://www.ccsinfo.com/forum/viewtopic.php?t=37242 |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Mon May 26, 2014 4:49 pm |
|
|
Start off by breaking down the project into simpler tasks.
First, get the PIC to flash an LED at 1Hz. This will prove you've wired up the board right and are able to program the PIC.Choose your pin usage wisely so you always have this LED available for future tests.
Next, I'm assuming you'll need some serial communications to a PC. Use 'RS232' and verify this works.Unless you have an onboard LCD module you WILL need to have a PC link to confirm the rest....
Try a pot attached to ONE analog input, cut code to read and send the raw data to the PC.Confirm it works for the full range.Then test the sensors on one channel. After that, code for the 2nd channel, confirm it works as well.
Not sure how you're going to control the motors but I'm assuming PWM. If so, there may be code here in the 'library' for something similar.
Bluetooth would be the next task...
PID is easy and will be last thing to do.
hth
jay |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon May 26, 2014 6:24 pm |
|
|
just wondering.
what pic projects have you done prior to this?
what pics have you worked with before?
do you have a circuit designed for the ambitious external functions
you want to implement?
that you can SHOW us?
can you post the schematic of what you have designed so far?
have you considered powering the system with a
di-lithium crystal reactor ?
http://www.waxingmoondesign.com/WarpSystemTech.html
![Very Happy](images/smiles/icon_biggrin.gif) |
|
![](templates/subSilver/images/spacer.gif) |
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Tue May 27, 2014 12:11 pm |
|
|
Awesome, had not realised my understanding of basic physics was so out of date.
Mike |
|
![](templates/subSilver/images/spacer.gif) |
sarkarelias
Joined: 26 May 2014 Posts: 2
|
|
![](templates/subSilver/images/spacer.gif) |
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Wed May 28, 2014 3:43 pm |
|
|
Hi,
Here is a test program that uses the internal 8.00 MHz oscillator, and blinks an LED connected to an I/O pin. Give it a try and see if your circuit is alive or not!
Code: |
#include <16f88.h>
#fuses INTRC, NOWDT, NOLVP, BROWNOUT //,NOPROTECT
// Tell compiler clock speed is 8.00 MHZ internal Oscillator
#use delay(clock=8000000)
//-----< General Program Defines >-----
#define PWR_LED PIN_B0 // Power LED (High to turn ON)
void main(void)
{
int8 iIndex;
// Here we blip the Power LED at power-up to show that the interface is working
for ( iIndex=0 ; iIndex<4 ; iIndex++ )
{
output_high(PWR_LED);
delay_ms(250);
output_low(PWR_LED);
delay_ms(250);
}
// Here we leave the Power LED ON
output_high(PWR_LED);
while(1); //prevent the code from running off the end.....
}
|
John |
|
![](templates/subSilver/images/spacer.gif) |
|