- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I am making a dark detector sensor on PSoC3. I am new to PSoC programing, so I need a little bit of help.
If you look at my Topdesign (The attached file), I am using a transimpedans amplifier ( To convert current flow from my photo diode ( SFH213) ) and further more I am using a comparator to compare two voltages. I want to make it so that, when it is dark (no or little current flow), the comparator output should be high, then I want to run an interrupts which should sets a pin high. And when it is low, I want to run an interrupts which sets the same pin low.
Info:
When there is light the positive terminal end of comparator is around 2V.
Negative terminal end of the comparator is 1V.
Thank you in advance.
Solved! Go to Solution.
- Labels:
-
PSoC 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
At least one problem is that you enter main(), do the init, then
fall out of main() into never never land. You need to place an
infinite loop after the init in main(), something like
for(;;){ }
or
while( 1 ) { }
Also consider posting project for rest to be looked at -
“File”
“Create Workspace Bundle”
Use firefox or IE, not chrome to post.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So what is exactly your problem, what do you neet help with?
Do you use a development kit? Which one?
When you start coding, try to upload your complete project here using Creator -> File -> Create Workspace Bundle, so we all can have a looki at.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
This is the small code I wrote..
The problem is, that the pin is never set high, which probably means that the interupts routine doesn’t work.
I am using a starter kit PSoC3.
#include <project.h>
CY_ISR(isr_1_Comp_1)
{
CyPins_SetPin(LED_enable_0); // set pin high.
}
void Init()
{
isr_1_StartEx(isr_1_Comp_1);
TIA_2_Start();
Comp_1_Start();
VDAC8_1_Start();
}
int main()
{
Init();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
At least one problem is that you enter main(), do the init, then
fall out of main() into never never land. You need to place an
infinite loop after the init in main(), something like
for(;;){ }
or
while( 1 ) { }
Also consider posting project for rest to be looked at -
“File”
“Create Workspace Bundle”
Use firefox or IE, not chrome to post.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would suggest you to add an analog pin to the output of the TIA and measure the voltage. The TIA is inverting, I'm not quite sure if the polarity is right.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This seems to work. I changed order of components starts to avoid
a spurious ISR. Note once you set LED on with ISR, you have no
code to turn it off.
CY_ISR( isr_1_Comp_1 ) {
CyPins_SetPin( LED_enable_0 ); // set pin high if Compator trips
// LED_enable_Write(1);
}
void Init( void ) {
TIA_2_Start(); // Start TIA and VDAC8 first, before Comparator,
VDAC8_1_Start(); // to avoid spurious interrupt
Comp_1_Start(); // Start Comparator
isr_1_StartEx( isr_1_Comp_1 ); // Start Comparator ISR
}
int main() {
Init(); // Turn on components and enable comparator ISR
CyGlobalIntEnable; // Enable global interrupts
while(1) { } // Loop forever, processing any ISRs
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi thanks for the replies
I am bit confused if this is going to work.
So if anybody else has some idea, how I could make a simple darksensor , it could be great.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Since you have got a PSoC you are not limited at all. The signal conditioning with a TIA and optional a PGA is the first step.
Next you may do a ADC and compare the result to a given treshold.
To make the project more comfortable:
Design a push-button to tell your device "This is the dark treshold" and remember that in EEProm.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The conversion G of the TIA is its fdbk R. http://en.wikipedia.org/wiki/Transimpedance_amplifier
Are you trying to measure abvsolute light level, or just simply turn something on/off
based on a simple sensor like a reverse biased diode ? If the former calibrated
sensors are available from Avago, Rohm, Vishay, and others. If latter just a comparator
and TIA is generally more than enough. In fact you could eliminate TIA easily by using
a R based photocell, like a cadmium type cell controling input level in a divider to
comparator. Set the comparator up with hysterisis in this configuration.
http://en.wikipedia.org/wiki/Photoresistor
Regards, Dana.
Representative example (photo could be cadmium or diode or photo tranistor, shown w/o hysterisis) -
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to implement the whole thing on the PSoC3. It should be pretty precise, but basically the purpose it turn light on/off.
What about sampling with an ADC?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If by precise is you need a known light level at which it trips, the following
could be used -
1) Assumptions, you use an uncalibrated cheap sensor, like diode or CDS photocell or
photo transistor. This means you have to calibrate to the trip level you want the product
to ship. A simple test during production test.
2) To sense all you need is a Comparator. But to do cal two approaches -
a. Use A/D and TIA to develop signal for A/D. Press a button during production test
and using A/D read a calibrated light source, and store that value in EEPROM.
Then future readings with A/D will compare current reading to cal reading to make
determination. You might not need TIA if you use CDS in a simple R divider to
input into A/D.
b. Use sensor + comparator + VDAC8. VDAC8 used to provide offset to comparator.
During production test with calibrated light source slew VDAC8 value until it trips,
store that in EE, and everytime product is powered on it reads the EE value and
and writes this to VDAC8 once to offset the comparator trip point.
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This might be useful as well -
http://www.johnloomis.org/ece445/topics/egginc/tp4.html
http://www.rohm.com/documents/11308/12928/CNA09016_wp.pdf
Regards, Dana.