Yes, as I have stated, I already checked the suggested threads when I searched. But none of the threads really helped me.these are already dicsussed. you should search the forum before you post new request...
https://www.edaboard.com/threads/214610/
https://www.edaboard.com/threads/155507/
Thank you for the links. I found the 2nd link interesting but the code is written on a different compiler. I only know of that from mikroC. Thanks for the links thoughHere are a few projects which use two or more LDRs to seek a light source:
**broken link removed**
The design requirements are similar to the example below:
Basic Servo Motor Controlling with Microchip PIC Microcontroller - Demos light tracking with two LDRs, PIC16F690 and a servo motor
Hope the info helps,
BigDog
please put the code here and tell where is the problem, we would definetely help you.... we cant provide a code readymade for any hardware... its more of a homework kind of thing....
The project seems simple enough. There could be another alternative...
You could use a single LDR and two stepper motors, during startup the mcu could start scanning the sky for the position of the sun, the position would be indicated by the LDR, once done it could follow the motion. With this method you do not have to save position or align the LDR to the compass points.
In any case which ever project you decide on, start by identifying the components you intend to use such as the type of stepper motor, LDR etc.
Next start developing the interface hardware and basic drivers for these, you should be able to control stepper motor motion, and computer LDR values. This may also involve reading about stepper motors and LDRs
After you finished doing this start developing the algorithm for the main program (for the solar tracker device). By the time you would have done all these I am sure you will have more knowledge than before and be able to diagnose faults as well as improve the original design..
thanks
a
Sir bigdogguru I tried it compiling in mikroC but it made a lot of errors and I didn't modify the code.The example I've provided above utilizes a PWM driven servo along with two LDRs. Compiling the provided code in MikroC should be straight forward. Most servos require a PWM of 50 Hz, which is far too low a frequency to generate using the PICs CCP modules effectively and requires bit banging techniques like those implemented in the example above.
I would recommend you reexamine the source code provided in the example project above and adapt it to your needs.
BigDog
Okay, I'll try to study the code and make my own, this is going to be long it is going to be like a baby just starting to learn how to walk.
//==========================================================================
// Project : Sample code for control single servo motors using delays
// This project is using 16F84A with 4MHz
// Has been try succesfully using GWS S03N STD
//
// Please make sure the hardware is compatible with this code
//
// Project description : This source code is used to control a servo motor.
// Servo motor will continuosly turn from one position to another position
// Lib func __delay_us() and __delay_ms() is use to generate the pulse width.
// The delay timing is independent of crystal but_XTAL_FREQ must be set correctly.
//
//
// Author : BigDogGuru
// Date : April 2011
//==========================================================================
//
// include
//==========================================================================
#include "config.h"
#include "delays.h"
#include <htc.h> // this sample code is using 16F84A !!
// configuration
//==========================================================================
__CONFIG ( 0x3FF2 ); // configuration for the 16F84A
// define
//==========================================================================
#define servo RB5 // servo set RB5
// function (every function must have a function prototype)
//==========================================================================
// none
//
// main function (main fucntion of the program)
//==========================================================================
void main(void)
{
unsigned int i;
//set IO port for servo pin
TRISB = 0b00000000; //servo motor is RB1
PORTB = 0b00000000; //clear port B
//servo will loop infinity
while(1) //from one position to another position
{
//*******************************************************
//
//Delay determine the servo motors position
//Try change the value for different position
//
//Value in __delay_xs() function is unsigned long
//Calculate the timing correctly or servo damage could result!!
//
//******************************************************
for(i=0;i<50;i++) //continues pulse for 50 times
{
servo=1; //set servo pin high
delay_us(900); //delay 0.7ms
servo=0; //set servo pin low
delay_us(19100); //delay 19.3ms
}
// _ _ _
// | | | | | |
// | | | | | | ~~50 times
// | |_________________| |________________| |____________________
// 0.7ms 19ms 0.7ms 19ms 0.7ms 19ms
// | |
// |<-------20ms------>|
for(i=0;i<50;i++) //continues pulse for 50 times
{
servo=1; //set servo pin high
delay_us(1500); //delay 1.8ms
servo=0; //set servo pin low
delay_us(18500); //delay 18.2ms
}
for(i=0;i<50;i++) //continues pulse for 50 times
{
servo=1; //set servo pin high
delay_us(2000); //delay 1.8ms
servo=0; //set servo pin low
delay_us(18000); //delay 18.2ms
}
// ___ ___ ___
// | | | | | |
// | | | | | | ~~50 times
// | |_______________| |_______________| |____________________
// 2ms 18ms 2ms 18ms 2ms 18ms
// | |
// |<-------20ms------>|
}
}
//subroutines
//============================================================================
//
// none
I can't seem to get the right value for this.
Yeah but how do I make the conversion to store the digital values 1 or 0 to a variable? Let's say the if the input is like this value then the digital value should be 1. You know what I mean?
hey ! I am doing the same project.
Can you please share your code .. I have similar problems and am new to coding here . i am too going nuts ..I have been studying about PICs Coding for days now but in vain. I knw you will relate to me so please please share your code. Ill be grateful.THANK YOU !!
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?