Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 1 > Re: help to develop psoc based solar tracker

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



Re: help to develop psoc based solar tracker
Moderator:
ARVI

Post Reply
Follow this topic



Re: help to develop psoc based solar tracker

gauti posted on 24 Apr 2011 7:46 AM PST
Senior Member
11 Forum Posts

 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



Re: Re: help to develop psoc based solar tracker

graa posted on 24 Apr 2011 06:41 PM PST
Cypress Employee
275 Forum Posts

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



Re: Re: help to develop psoc based solar tracker

gauti posted on 27 Apr 2011 07:33 AM PST
Senior Member
11 Forum Posts

 sir which psoc evaluation kit cn i use for this project



Re: Re: help to develop psoc based solar tracker

gauti posted on 27 Apr 2011 07:33 AM PST
Senior Member
11 Forum Posts

 sir which psoc evaluation kit cn i use for this project



Re: Re: help to develop psoc based solar tracker

graa posted on 27 Apr 2011 09:17 AM PST
Cypress Employee
275 Forum Posts

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



Re: Re: help to develop psoc based solar tracker

gauti posted on 04 May 2011 08:55 AM PST
Senior Member
11 Forum Posts

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)  

 



Re: Re: help to develop psoc based solar tracker

U2 posted on 09 May 2011 02:21 AM PST
Cypress Employee
589 Forum Posts

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


Re: Re: help to develop psoc based solar tracker

Gautam Das posted on 18 May 2011 11:09 AM PST
Cypress Employee
742 Forum Posts

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.



Re: Re: help to develop psoc based solar tracker

gauti posted on 20 May 2011 04:36 AM PST
Senior Member
11 Forum Posts

 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






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20