sir project is intensity based solar tracking according to dat project wen intensity is low my panel rotates so i following code for comparator design and stepper motor
As you mention that you have no experience with C code, my advice would be start with some simple project, understand PSoC and C and then build your project.
Start with a project that has only the Comparator. Route the comparator output to a port pin through DigBuf and check if the output of the comparator behaves as you expect it to behave. You can connect an LED or a multimeter to the ouput pin, vary the input voltage and check if the output is correct.
Then in firmware you can add code to check the output of the comparator by checking the CMP_CR0 register. This register has bits that get set whenever a comparator bus goes high. For example, if you have placed the comparator in AnalogColumn0, the code will look something like this:
if(CMP_CR0 & 0x10)
// Do something here
For stepper motor, I dont think the code you have given will work. As you are starting with PSoC, my advice would be not to go for complicated stepper motor code that has half step control. Just use four GPIO pins and set and clear them in the proper sequence to generate full step control and move the stepper motor. You can control the GPIO pins using the PRTxDR register. Read the below articles to understand how to control GPIO.
PSoC GPIO Demystified - Part1
PSoC GPIO Demystified - Part2
Create a simple project, start with setting and clearing GPIO pins, then add code that turns on and off the GPIO in sequence to control the stepper.
Spend a few days learning the basics. That will help you to complete the project successfully.
Good luck with your project!!
The PSoC Hacker
sir i want to do some modification in my project instead of using solar panel output to change d control ,i am using two ldr for my project...i think dis ll make things better.if light falls on d both d ldr the panel is not rotated.and ldr is kept on d front and back end of d panel. in dis approach i ll keep two threshold voltage to the two comparators wat i am using(for ex 3v).suppose light intensity fall on ldr becomes less dan thresold value the panel ll rotate clockwise and anticlockwise
so d algorithm is
if(ldr1=1&ldr2=0) //dis statement means dat ldr1 voltage is below threshold and ldr2 is above threshold
for other conditon panel dont rotate
sir i just want to knw entire c code how psoc read frm input port which is connected to ldr den delay prgrm etc initialization etc
cn i give if(comp1==0&&comp2==1)
The output current of the reverse biased Photo diode can be connected to a Trans Impedance Amplifier (TIA) and then passed through a non-inverting PGA.
This amplified output voltage can be fed to an ADC in order to measure the digital values and then take decision, or can be connected to a comparator. The Hysteresis of the Comparator will ensure that the panel will not oscillate at equilibrium.
You can use a DC motor to rotate the Panel. Geared low speed (high torque) DC motor might be sufficient for this application depending upon the dimension of your panel.
Motor driver (such as L293D or L298) can be used whose input is driven by PSoC.
The speed of such a driver IC can also be controlled by feeding a PWM signal from PSoC to its Enable pin.
sir i did my prjct using single ldr and adc concept it wrks fine.....now i want use two ldr and compare logic, sir cn u briefly explain y it is necessary for two ldr