Re: help to develop psoc based solar tracker

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 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

   
        
   
    comparator c code   
   
    #include <m8c.h>        // part specific constants and macros   
   
    #include "PSoCAPI.h"    // PSoC API definitions for all User Modules   
   
        
   
        
   
    void main(void)   
   
    {    
   
    // start the Low Threshold comparator with HIGH Power   
   
    lt_Start(3);   
   
     // start the High Threshold comparator with HIGH Power   
   
     ht_Start(3);   
   
     //Start the DigBuf   
   
     DigBuf_Start();   
   
          
   
           
   
          
   
       while(1) {   
   
          
   
       }      
   
    stepper motor c code   
   
        
   
    #include <m8c.h>        // part specific constants and macros   
   
    #include "PSoCAPI.h"    // PSoC API definitions for all User Modules   
   
        
   
        
   
        
   
    #define HALFSTEP   
   
        
   
    void main()   
   
    {   
   
    Half-Step Initialization  */      
   
       PRS8_1_WriteSeed(0x83);   
   
       PRS8_2_WriteSeed(0x38);   
   
       PRS8_3_WriteSeed(0x0e);   
   
       PRS8_4_WriteSeed(0xe0);   
   
        
   
    //  Start shift register   
   
       PRS8_1_WritePolynomial(0x80);   
   
       PRS8_2_WritePolynomial(0x80);   
   
       PRS8_3_WritePolynomial(0x80);   
   
       PRS8_4_WritePolynomial(0x80);   
   
       PRS8_1_Start();   
   
       PRS8_2_Start();   
   
       PRS8_3_Start();   
   
       PRS8_4_Start();   
   
         
   
    //  Start internal 360 degree pulse (96 step in half step mode)   
   
    //  If user need an external input the common prs clock should connect ta an external pin   
   
       Counter8_1_Start();   
   
       Counter8_2_Start();   
   
          
   
       while(1) {   
   
          
   
       }      
   
        
   
    accordingly i hve these two codes .sir in my project comparator senses d panel voltage wen it reaches d threshold comparator goes high and stepper motor program is initiated ,sir i need certain steps as i am not aware of c program ,sir i need c code dat wen comparator goes high stepper motor is initiated and rotated one step and after dis control gvn to comparator prgrm and it den senses d panel voltage   
0 Likes
8 Replies
MR_41
Employee
Employee
First like received

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!!

Best Regards,
Ganesh
The PSoC Hacker

0 Likes
Anonymous
Not applicable

 sir which psoc evaluation kit cn i use for this project

0 Likes
Anonymous
Not applicable

 sir which psoc evaluation kit cn i use for this project

0 Likes
MR_41
Employee
Employee
First like received

CY3210 PSoC Eval1 board should be fine for your project.  You will have to assemble external circuits for the solar panel voltage sensing and stepper motor drive.

   

 

   

Best Regards,

   

Ganesh

   

The PSoC Hacker

0 Likes
Anonymous
Not applicable

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

   

rotate clockwise 

   

if(ldr1=1&ldr2=1)

   

rotate anticlockwise

   

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)  

0 Likes
Anonymous
Not applicable

Hello,

   
        
  • It is possible to implement this design using LDR. However a better way of implementing the same is to use Photodiodes, you can use two photodiodes. Reverse Current through photodiodes vary according to the incident light. This current can be converted to voltage using a series resistor. Approriate resistor needs to be slected to generate sensible voltage.
  •     
  • Connect the output of photodiodes to ADC. Take the ADC digital values and compare them, rotate the panel in such a way that these values match(ideally you can not make them equal, hence defince a small band). Rotate the panel in opposite direction if the difference increases.
  •     
  • You can DC motors to drive the panel orientation. PSoC1 can easily do this !! 
  •    
0 Likes
Anonymous
Not applicable

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.

0 Likes
Anonymous
Not applicable

 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

0 Likes