CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Place Help me, program Array Sensor 256 PIXELES

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gustavo



Joined: 01 Oct 2003
Posts: 4
Location: estudiante

View user's profile Send private message

Place Help me, program Array Sensor 256 PIXELES
PostPosted: Wed Sep 22, 2004 8:44 am     Reply with quote

Helping in this project, this it is my situation.


In the school they asked me that he could capture the values of a sensor formed by an arrangement of 256 pixeles of the hamamatsu, and that the values of each one of the pixeles the capture by means of the convertor A/D of the own PIC via the protocol RS232.

For they facilitated me to it the compiler of PIC in language C of CCS to see 3.11.

The data of the sensor are here; http://usa.hamamatsu.com/hcpdf/parts_S/S8377-128BQ.pdf

I assist this project, use the PIC16F876,por to be one of those but common among the stores of electronic of Barcelona.

The work begins it starting the operation of the arrangement of 256 pixeles, for suy operation it is required of two clock signal, one used as shot or period of integration (SI)y the second as sincronismo (clk) until this moment all road well.

This is the code that generates the pulses of operation of the arrangement.

#include <16f876.h>
#device ADC=10 // A/D Result format
#fuses HS,NOWDT,NOPROTECT,PUT,BROWNOUT,NOLVP,NOCPD,NOWRT

#use delay (CLOCK=10000000)
#use rs232 (BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7)

#use fast_io (b)
#byte porta = 5
#byte portb = 6
#byte portc = 7

main()
{

int i;
set_tris_a(0x00);
set_tris_b(0x00);
portb=0;
porta=0;
Do
{

bit_set(PORTB,7); //CLK High
bit_set (PORTB,6); //SI High

bit_clear(PORTB,6); //SI High
delay_us(1);
bit_clear (PORTB,7); //CLK Low

delay_us(1);
bit_set (PORTB,6); //SI High
delay_us(1);
bit_set(PORTB,7); //CLK High

for(i=0; i<255; i++)
{
bit_clear(PORTB,7); //CLK Low
delay_us(1);
bit_set(PORTB,7); //CLK High
}
delay_ms(50);
}
while(1);
}


With this code you could confirm the good operation of Array.

The inconvenience that is presented and it is part of my current school situation. I am not layers of capturing the 256 pixeles or some series of them (64 0 128 picxels) using the functions of the converter A/D to be able to send it via the protocol RS/232 and to observe the results in the windows (hipertimal).

This is the I finish code and I observe that it doesn't work..

#include <16f876.h>

#fuses HS,NOWDT,NOPROTECT,PUT,BROWNOUT,NOLVP,NOCPD,NOWRT
#device ADC=10

#use delay(CLOCK = 10000000)
#use rs232(BAUD = 9600, XMIT = PIN_C6, RCV = PIN_C7)

#byte porta = 5
#byte portb = 6
#byte portc = 7

unsigned char Data[64];
unsigned long indice=0;

#INT_AD
void rutina_AD()
{
Data[indice]=read_adc(ADC_READ_ONLY);
indice++;
}

void main (void)
{

long data; // Variable para los datos del A/D.
int i;
int j;
int k; // Variable para el inicio del retardo.

//analog data 1
Setup_adc_ports (RA0_RA1_RA3_ANALOG); //RA3 is Ref+ others A/D
Setup_adc (ADC_CLOCK_DIV_32); //Fosc/32 FULL speed

set_tris_a(0x00); // Los puertos a y b se configuran como salida
set_tris_b(0x00); // Si se busca que sean entradas, basta con colocar FF

portb=0; // Inicialisa el puerto "a" a cero
porta=0; // Inicialisa el puerto "b" a cero

//*** Se definen el inicio de la señal (SI) y (CLK) del S8733***//
//**********************************************************************************//

bit_set(PORTB,7); //CLK High
bit_set (PORTB,6); //SI High

bit_clear(PORTB,6); //SI High
delay_us(1);
bit_clear (PORTB,7); //CLK Low

delay_us(1);
bit_set (PORTB,6); //SI High
delay_us(1);
bit_set(PORTB,7); //CLK High

//*** Se iniciA el ciclo de captura del A/D PIC16F876 una vez en alto la señal (SI) ***//
//*****************************************************************************************/


Set_adc_channel(1); //set channel
Delay_us(10); // retardo en 1 us
enable_interrupts(INT_AD);
enable_interrupts(GLOBAL);

for(i=0; i<64; i++)
{
bit_clear(PORTB,7); //CLK Low
read_adc(ADC_START_ONLY); //iniciar conversion
bit_set(PORTB,7); //CLK High
delay_us(1);
}
delay_ms(50);

disable_interrupts(INT_AD);


//*** Se iniciA el ciclo de captura del A/D PIC16F876, e imprime los 64 valores ***//
//*****************************************************************************************/

for(K=0; k<64; k++) // Se coloca la rutina de 64 ciclos para imprimir
{
Printf ("%4LX\r",Data[k]);

}

}


In opinion the my friends' I am changes PIC16F876 for the PIC18F452, now the problem is presented that the compiler doesn't recognize the instruction ADC_READ_ONLY, and no longer you that to make,

please they can help he stops to take out this project..

Any help they will be very grateful for it.



Gustavo A. Mtz.
davidferp



Joined: 26 Sep 2004
Posts: 1
Location: Spain

View user's profile Send private message

respuesta de David (laboratorio)!
PostPosted: Sun Sep 26, 2004 11:06 am     Reply with quote

Hi Gustavo!,

Nice to ear from you again. Possibly you don't recognise my lines at this time... . Well, any way!. At the present I'm working in a PIC project based on a PIC18F452, as well as you. For this, provided you agree, send me some of the related information to my e-mail address (you have it yet) to let me to be able to give you a hand, ok?.

David Fernandez
bertronicom
Guest







Image Sensor CMOS Hamamatsu
PostPosted: Mon Sep 27, 2004 2:01 am     Reply with quote

Hello,

What type of aplication are you developped?

I had worked with the same Image CMOS Sensor but 512 pixels. I didn't recommend to you using internal A/D converters from PIC.

I used fast external A/D from Analog devices up to 1Msps in order to performance and to get stream data each time.

If this configuration is good for you, I can give to you some parts of code.

Alberto Campo
University of Cantabria - SPAIN
Photonic Engineering Group
Guest








Re: Image Sensor CMOS Hamamatsu
PostPosted: Mon Sep 27, 2004 6:53 am     Reply with quote

Alberto Campo.
DPTO. TECNOLOGIA ELECTRONICA E ING. DE SISTEMAS Y AUTOMATICA.
Presente.

Cd.Barcelona, 27 de Septiembre dl 2004.


Reciba usted un cordial saludo, permitame presentarme mi nombre es Gustavo A. Martinez, estudiante de Ingenieria Electronica en la U.PC. en Barcelona, encontre este mesaje el foro de CCS, razon por a cual le estoy muy agradecido por la atención y su ayuda.

Este fue el mensaje que encontre;
***************************************************
Hello,

What type of aplication are you developped?

I had worked with the same Image CMOS Sensor but 512 pixels. I didn't recommend to you using internal A/D converters from PIC.

I used fast external A/D from Analog devices up to 1Msps in order to performance and to get stream data each time.

If this configuration is good for you, I can give to you some parts of code.

Alberto Campo
University of Cantabria - SPAIN
Photonic Engineering Group****************************************************

Si me lo permite en lo referene a mi situación le puedo comentar lo siguiente;


Me encuentro en la necesidad de terminar una practica de electronica, consistente en poder capturar los 256 valores formados por un arreglo de pixeles de la casa Hamamatsu, la idea es el capturar cada uno de
los 256 pixeles del que consta el citado arreglo , ya sea mediante el propio convertidor A/D del propio PIC o cualqier otro esquema propuesto.

Los datos del sensor estan aqui;

http://usa.hamamatsu.com/hcpdf/parts_S/S8377-128BQ.pdf


La idea final de esta practica es la de de enviar
los datos capturados via el protocolo RS232, para
desplegar los datos en la hoja de Excell, utilizando
las opciones del programa de la hiperterminal de
windows. Basicamente el objetivo es el de poder improvisar un rustico espectometro, segun si se incide poco o mucha luz en cada uno de los
pixeles del sensor.


Para ello en la Universidad me facilitaron el compilador de PIC en lenguaje C de CCS ver 3.11.

Para atender este proyecto, utilice el PIC16F876,por
ser uno de los mas comunes entre la tiendas de
electronica de Barcelona.

El trabajo lo inicie poniendo en marcha el
funcionamiento del arreglo de 256 pixeles, para suy
operacion se requiere de dos señales de reloj, una
usada como disparo o periodo de integracion (SI)y la
segunda como sincronismo (clk) hasta este momento todo
camino bien.

Este es el codigo que genera los pulsos de operacion
del arreglo.

#include <16f876.h>
#device ADC=10 // A/D Result format
#fuses
HS,NOWDT,NOPROTECT,PUT,BROWNOUT,NOLVP,NOCPD,NOWRT

#use delay (CLOCK=10000000)
#use rs232 (BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7)

#use fast_io (b)
#byte porta = 5
#byte portb = 6
#byte portc = 7

main()
{

int i;
set_tris_a(0x00);
set_tris_b(0x00);

portb=0;
porta=0;

Do
{

bit_set(PORTB,7); //CLK High
bit_set (PORTB,6); //SI High

bit_clear(PORTB,6); //SI High
delay_us(1);
bit_clear (PORTB,7); //CLK Low

delay_us(1);
bit_set (PORTB,6); //SI High
delay_us(1);
bit_set(PORTB,7); //CLK High

for(i=0; i<255; i++)
{
bit_clear(PORTB,7); //CLK Low
delay_us(1);
bit_set(PORTB,7); //CLK High
}
delay_ms(50);
}
while(1);
}


Con este codigo se pudo confirmar el buen
funcionamiento del arreglo .

El inconveniente que se presenta, es que no soy capas de capturar los 256 pixeles o alguna serie de ellos (64 0 128 picxels) utilizando las funciones del convertidor A/D del propio Pic. para posteriorment poder enviarlo via el protocolo RS/232 y
observar los resultados en la hipertimal de windows.
Para despues con la hoja de Excell poder ver su
dibujo.

En el archivo adjunto esta el esquema electronico que
se esta utilizando para poder resolverlo esta
situación.

Me comentan mis compañeros que el pic no es el
adedcuado, que tiene poca memoria que es muy lento,
etc, etc, lo que creo es que el pic es muy lento a comparación de como funciona el convertidor.

Mis amigos me han comentado que el uso de las interupciones es fundamental, situacion que
en lo particular no soy muy habil programandolas y
creo que menos las del convertidor A/D con el lenguaje
C.

Este es lo ultimo que puedo hacer en lo referente al
codigo, y observo que no funciona..

#include <16f876.h>

#fuses
HS,NOWDT,NOPROTECT,PUT,BROWNOUT,NOLVP,NOCPD,NOWRT
#device ADC=10

#use delay(CLOCK = 10000000)
#use rs232(BAUD = 9600, XMIT = PIN_C6, RCV = PIN_C7)

#byte porta = 5
#byte portb = 6
#byte portc = 7

unsigned char Data[64];
unsigned long indice=0;

#INT_AD
void rutina_AD()
{
Data[indice]=read_adc(ADC_READ_ONLY);
indice++;
}


void main (void)
{

long data; // Variable para los datos del A/D.
int i;
int j;
int k; // Variable para el inicio del retardo.

//analog data 1
Setup_adc_ports (RA0_RA1_RA3_ANALOG); //RA3 is Ref+
others A/D
Setup_adc (ADC_CLOCK_DIV_32); //Fosc/32 FULL speed

set_tris_a(0x00); // Los puertos a y b se configuran
como salida
set_tris_b(0x00); // Si se busca que sean entradas,
basta con colocar FF

portb=0; // Inicialisa el puerto "a" a cero
porta=0; // Inicialisa el puerto "b" a cero

//*** Se definen el inicio de la señal (SI) y (CLK)
del S8733***//
//**********************************************************************************//


bit_set(PORTB,7); //CLK High
bit_set (PORTB,6); //SI High

bit_clear(PORTB,6); //SI High
delay_us(1);
bit_clear (PORTB,7); //CLK Low

delay_us(1);
bit_set (PORTB,6); //SI High
delay_us(1);
bit_set(PORTB,7); //CLK High

//*** Se iniciA el ciclo de captura del A/D PIC16F876
una vez en alto la señal (SI) ***//
//*****************************************************************************************/



Set_adc_channel(1); //set channel
Delay_us(10); // retardo en 1 us
enable_interrupts(INT_AD);
enable_interrupts(GLOBAL);

for(i=0; i<64; i++)
{
bit_clear(PORTB,7); //CLK Low
read_adc(ADC_START_ONLY); //iniciar conversion
bit_set(PORTB,7); //CLK High
delay_us(1);
}
delay_ms(50);

disable_interrupts(INT_AD);


//*** Se iniciA el ciclo de captura del A/D PIC16F876,
e imprime los 64 valores ***//
//*****************************************************************************************/


for(K=0; k<64; k++) // Se coloca la rutina de 64
ciclos para imprimir
{
Printf ("%4LX\r",Data[k]);

}

}

Si me pudiera hacer el favor de ayudarme en este proyecto, yo estare muy agradecido por ello.

En lo referente a la recomendación de utilizar algun tipo de convertidor externo, yo me ecuentro en la mejor disposición de poder buscarlo en las tiendas de Barcelona, y buscar por algun modo el poner en operación esta practica, si por favor me pudiera orientar como se podria resolver este proyecto yo estoy en la mejor disposición de tabajar para consegirlo, ya que mi experiencia es muy corta en lo referente al empleo de Pic con algun otro tipo de circuito.

Finalente le estoy muy agradecido por escribir en el
foro de ccs, yo me despido, sin antes desearle
todo lo mejor y que todos sus proyectos se
hagan realidad.

Respetuosamente.

Gustavo Mtz.




bertronicom wrote:
Hello,

What type of aplication are you developped?

I had worked with the same Image CMOS Sensor but 512 pixels. I didn't recommend to you using internal A/D converters from PIC.

I used fast external A/D from Analog devices up to 1Msps in order to performance and to get stream data each time.

If this configuration is good for you, I can give to you some parts of code.

Alberto Campo
University of Cantabria - SPAIN
Photonic Engineering Group
Guest








Re: Image Sensor CMOS Hamamatsu
PostPosted: Mon Sep 27, 2004 6:54 am     Reply with quote

Alberto Campo.
DPTO. TECNOLOGIA ELECTRONICA E ING. DE SISTEMAS Y AUTOMATICA.
Presente.

Cd.Barcelona, 27 de Septiembre dl 2004.


Reciba usted un cordial saludo, permitame presentarme mi nombre es Gustavo A. Martinez, estudiante de Ingenieria Electronica en la U.PC. en Barcelona, encontre este mesaje el foro de CCS, razon por a cual le estoy muy agradecido por la atención y su ayuda.

Este fue el mensaje que encontre;
***************************************************
Hello,

What type of aplication are you developped?

I had worked with the same Image CMOS Sensor but 512 pixels. I didn't recommend to you using internal A/D converters from PIC.

I used fast external A/D from Analog devices up to 1Msps in order to performance and to get stream data each time.

If this configuration is good for you, I can give to you some parts of code.

Alberto Campo
University of Cantabria - SPAIN
Photonic Engineering Group****************************************************

Si me lo permite en lo referene a mi situación le puedo comentar lo siguiente;


Me encuentro en la necesidad de terminar una practica de electronica, consistente en poder capturar los 256 valores formados por un arreglo de pixeles de la casa Hamamatsu, la idea es el capturar cada uno de
los 256 pixeles del que consta el citado arreglo , ya sea mediante el propio convertidor A/D del propio PIC o cualqier otro esquema propuesto.

Los datos del sensor estan aqui;

http://usa.hamamatsu.com/hcpdf/parts_S/S8377-128BQ.pdf


La idea final de esta practica es la de de enviar
los datos capturados via el protocolo RS232, para
desplegar los datos en la hoja de Excell, utilizando
las opciones del programa de la hiperterminal de
windows. Basicamente el objetivo es el de poder improvisar un rustico espectometro, segun si se incide poco o mucha luz en cada uno de los
pixeles del sensor.


Para ello en la Universidad me facilitaron el compilador de PIC en lenguaje C de CCS ver 3.11.

Para atender este proyecto, utilice el PIC16F876,por
ser uno de los mas comunes entre la tiendas de
electronica de Barcelona.

El trabajo lo inicie poniendo en marcha el
funcionamiento del arreglo de 256 pixeles, para suy
operacion se requiere de dos señales de reloj, una
usada como disparo o periodo de integracion (SI)y la
segunda como sincronismo (clk) hasta este momento todo
camino bien.

Este es el codigo que genera los pulsos de operacion
del arreglo.

#include <16f876.h>
#device ADC=10 // A/D Result format
#fuses
HS,NOWDT,NOPROTECT,PUT,BROWNOUT,NOLVP,NOCPD,NOWRT

#use delay (CLOCK=10000000)
#use rs232 (BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7)

#use fast_io (b)
#byte porta = 5
#byte portb = 6
#byte portc = 7

main()
{

int i;
set_tris_a(0x00);
set_tris_b(0x00);

portb=0;
porta=0;

Do
{

bit_set(PORTB,7); //CLK High
bit_set (PORTB,6); //SI High

bit_clear(PORTB,6); //SI High
delay_us(1);
bit_clear (PORTB,7); //CLK Low

delay_us(1);
bit_set (PORTB,6); //SI High
delay_us(1);
bit_set(PORTB,7); //CLK High

for(i=0; i<255; i++)
{
bit_clear(PORTB,7); //CLK Low
delay_us(1);
bit_set(PORTB,7); //CLK High
}
delay_ms(50);
}
while(1);
}


Con este codigo se pudo confirmar el buen
funcionamiento del arreglo .

El inconveniente que se presenta, es que no soy capas de capturar los 256 pixeles o alguna serie de ellos (64 0 128 picxels) utilizando las funciones del convertidor A/D del propio Pic. para posteriorment poder enviarlo via el protocolo RS/232 y
observar los resultados en la hipertimal de windows.
Para despues con la hoja de Excell poder ver su
dibujo.

En el archivo adjunto esta el esquema electronico que
se esta utilizando para poder resolverlo esta
situación.

Me comentan mis compañeros que el pic no es el
adedcuado, que tiene poca memoria que es muy lento,
etc, etc, lo que creo es que el pic es muy lento a comparación de como funciona el convertidor.

Mis amigos me han comentado que el uso de las interupciones es fundamental, situacion que
en lo particular no soy muy habil programandolas y
creo que menos las del convertidor A/D con el lenguaje
C.

Este es lo ultimo que puedo hacer en lo referente al
codigo, y observo que no funciona..

#include <16f876.h>

#fuses
HS,NOWDT,NOPROTECT,PUT,BROWNOUT,NOLVP,NOCPD,NOWRT
#device ADC=10

#use delay(CLOCK = 10000000)
#use rs232(BAUD = 9600, XMIT = PIN_C6, RCV = PIN_C7)

#byte porta = 5
#byte portb = 6
#byte portc = 7

unsigned char Data[64];
unsigned long indice=0;

#INT_AD
void rutina_AD()
{
Data[indice]=read_adc(ADC_READ_ONLY);
indice++;
}


void main (void)
{

long data; // Variable para los datos del A/D.
int i;
int j;
int k; // Variable para el inicio del retardo.

//analog data 1
Setup_adc_ports (RA0_RA1_RA3_ANALOG); //RA3 is Ref+
others A/D
Setup_adc (ADC_CLOCK_DIV_32); //Fosc/32 FULL speed

set_tris_a(0x00); // Los puertos a y b se configuran
como salida
set_tris_b(0x00); // Si se busca que sean entradas,
basta con colocar FF

portb=0; // Inicialisa el puerto "a" a cero
porta=0; // Inicialisa el puerto "b" a cero

//*** Se definen el inicio de la señal (SI) y (CLK)
del S8733***//
//**********************************************************************************//


bit_set(PORTB,7); //CLK High
bit_set (PORTB,6); //SI High

bit_clear(PORTB,6); //SI High
delay_us(1);
bit_clear (PORTB,7); //CLK Low

delay_us(1);
bit_set (PORTB,6); //SI High
delay_us(1);
bit_set(PORTB,7); //CLK High

//*** Se iniciA el ciclo de captura del A/D PIC16F876
una vez en alto la señal (SI) ***//
//*****************************************************************************************/



Set_adc_channel(1); //set channel
Delay_us(10); // retardo en 1 us
enable_interrupts(INT_AD);
enable_interrupts(GLOBAL);

for(i=0; i<64; i++)
{
bit_clear(PORTB,7); //CLK Low
read_adc(ADC_START_ONLY); //iniciar conversion
bit_set(PORTB,7); //CLK High
delay_us(1);
}
delay_ms(50);

disable_interrupts(INT_AD);


//*** Se iniciA el ciclo de captura del A/D PIC16F876,
e imprime los 64 valores ***//
//*****************************************************************************************/


for(K=0; k<64; k++) // Se coloca la rutina de 64
ciclos para imprimir
{
Printf ("%4LX\r",Data[k]);

}

}

Si me pudiera hacer el favor de ayudarme en este proyecto, yo estare muy agradecido por ello.

En lo referente a la recomendación de utilizar algun tipo de convertidor externo, yo me ecuentro en la mejor disposición de poder buscarlo en las tiendas de Barcelona, y buscar por algun modo el poner en operación esta practica, si por favor me pudiera orientar como se podria resolver este proyecto yo estoy en la mejor disposición de tabajar para consegirlo, ya que mi experiencia es muy corta en lo referente al empleo de Pic con algun otro tipo de circuito.

Finalente le estoy muy agradecido por escribir en el
foro de ccs, yo me despido, sin antes desearle
todo lo mejor y que todos sus proyectos se
hagan realidad.

Respetuosamente.

Gustavo Mtz.

bertronicom wrote:
Hello,

What type of aplication are you developped?

I had worked with the same Image CMOS Sensor but 512 pixels. I didn't recommend to you using internal A/D converters from PIC.

I used fast external A/D from Analog devices up to 1Msps in order to performance and to get stream data each time.

If this configuration is good for you, I can give to you some parts of code.

Alberto Campo
University of Cantabria - SPAIN
Photonic Engineering Group
Guest








Re: Image Sensor CMOS Hamamatsu
PostPosted: Mon Sep 27, 2004 6:56 am     Reply with quote

Alberto Campo.
DPTO. TECNOLOGIA ELECTRONICA E ING. DE SISTEMAS Y AUTOMATICA.
Presente.

Cd.Barcelona, 27 de Septiembre dl 2004.


Reciba usted un cordial saludo, permitame presentarme mi nombre es Gustavo A. Martinez, estudiante de Ingenieria Electronica en la U.PC. en Barcelona, encontre este mesaje el foro de CCS, razon por a cual le estoy muy agradecido por la atención y su ayuda.

Este fue el mensaje que encontre;
***************************************************
Hello,

What type of aplication are you developped?

I had worked with the same Image CMOS Sensor but 512 pixels. I didn't recommend to you using internal A/D converters from PIC.

I used fast external A/D from Analog devices up to 1Msps in order to performance and to get stream data each time.

If this configuration is good for you, I can give to you some parts of code.

Alberto Campo
University of Cantabria - SPAIN
Photonic Engineering Group****************************************************

Si me lo permite en lo referene a mi situación le puedo comentar lo siguiente;


Me encuentro en la necesidad de terminar una practica de electronica, consistente en poder capturar los 256 valores formados por un arreglo de pixeles de la casa Hamamatsu, la idea es el capturar cada uno de
los 256 pixeles del que consta el citado arreglo , ya sea mediante el propio convertidor A/D del propio PIC o cualqier otro esquema propuesto.

Los datos del sensor estan aqui;

http://usa.hamamatsu.com/hcpdf/parts_S/S8377-128BQ.pdf


La idea final de esta practica es la de de enviar
los datos capturados via el protocolo RS232, para
desplegar los datos en la hoja de Excell, utilizando
las opciones del programa de la hiperterminal de
windows. Basicamente el objetivo es el de poder improvisar un rustico espectometro, segun si se incide poco o mucha luz en cada uno de los
pixeles del sensor.


Para ello en la Universidad me facilitaron el compilador de PIC en lenguaje C de CCS ver 3.11.

Para atender este proyecto, utilice el PIC16F876,por
ser uno de los mas comunes entre la tiendas de
electronica de Barcelona.

El trabajo lo inicie poniendo en marcha el
funcionamiento del arreglo de 256 pixeles, para suy
operacion se requiere de dos señales de reloj, una
usada como disparo o periodo de integracion (SI)y la
segunda como sincronismo (clk) hasta este momento todo
camino bien.

Este es el codigo que genera los pulsos de operacion
del arreglo.

#include <16f876.h>
#device ADC=10 // A/D Result format
#fuses
HS,NOWDT,NOPROTECT,PUT,BROWNOUT,NOLVP,NOCPD,NOWRT

#use delay (CLOCK=10000000)
#use rs232 (BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7)

#use fast_io (b)
#byte porta = 5
#byte portb = 6
#byte portc = 7

main()
{

int i;
set_tris_a(0x00);
set_tris_b(0x00);

portb=0;
porta=0;

Do
{

bit_set(PORTB,7); //CLK High
bit_set (PORTB,6); //SI High

bit_clear(PORTB,6); //SI High
delay_us(1);
bit_clear (PORTB,7); //CLK Low

delay_us(1);
bit_set (PORTB,6); //SI High
delay_us(1);
bit_set(PORTB,7); //CLK High

for(i=0; i<255; i++)
{
bit_clear(PORTB,7); //CLK Low
delay_us(1);
bit_set(PORTB,7); //CLK High
}
delay_ms(50);
}
while(1);
}


Con este codigo se pudo confirmar el buen
funcionamiento del arreglo .

El inconveniente que se presenta, es que no soy capas de capturar los 256 pixeles o alguna serie de ellos (64 0 128 picxels) utilizando las funciones del convertidor A/D del propio Pic. para posteriorment poder enviarlo via el protocolo RS/232 y
observar los resultados en la hipertimal de windows.
Para despues con la hoja de Excell poder ver su
dibujo.

En el archivo adjunto esta el esquema electronico que
se esta utilizando para poder resolverlo esta
situación.

Me comentan mis compañeros que el pic no es el
adedcuado, que tiene poca memoria que es muy lento,
etc, etc, lo que creo es que el pic es muy lento a comparación de como funciona el convertidor.

Mis amigos me han comentado que el uso de las interupciones es fundamental, situacion que
en lo particular no soy muy habil programandolas y
creo que menos las del convertidor A/D con el lenguaje
C.

Este es lo ultimo que puedo hacer en lo referente al
codigo, y observo que no funciona..

#include <16f876.h>

#fuses
HS,NOWDT,NOPROTECT,PUT,BROWNOUT,NOLVP,NOCPD,NOWRT
#device ADC=10

#use delay(CLOCK = 10000000)
#use rs232(BAUD = 9600, XMIT = PIN_C6, RCV = PIN_C7)

#byte porta = 5
#byte portb = 6
#byte portc = 7

unsigned char Data[64];
unsigned long indice=0;

#INT_AD
void rutina_AD()
{
Data[indice]=read_adc(ADC_READ_ONLY);
indice++;
}


void main (void)
{

long data; // Variable para los datos del A/D.
int i;
int j;
int k; // Variable para el inicio del retardo.

//analog data 1
Setup_adc_ports (RA0_RA1_RA3_ANALOG); //RA3 is Ref+
others A/D
Setup_adc (ADC_CLOCK_DIV_32); //Fosc/32 FULL speed

set_tris_a(0x00); // Los puertos a y b se configuran
como salida
set_tris_b(0x00); // Si se busca que sean entradas,
basta con colocar FF

portb=0; // Inicialisa el puerto "a" a cero
porta=0; // Inicialisa el puerto "b" a cero

//*** Se definen el inicio de la señal (SI) y (CLK)
del S8733***//
//**********************************************************************************//


bit_set(PORTB,7); //CLK High
bit_set (PORTB,6); //SI High

bit_clear(PORTB,6); //SI High
delay_us(1);
bit_clear (PORTB,7); //CLK Low

delay_us(1);
bit_set (PORTB,6); //SI High
delay_us(1);
bit_set(PORTB,7); //CLK High

//*** Se iniciA el ciclo de captura del A/D PIC16F876
una vez en alto la señal (SI) ***//
//*****************************************************************************************/



Set_adc_channel(1); //set channel
Delay_us(10); // retardo en 1 us
enable_interrupts(INT_AD);
enable_interrupts(GLOBAL);

for(i=0; i<64; i++)
{
bit_clear(PORTB,7); //CLK Low
read_adc(ADC_START_ONLY); //iniciar conversion
bit_set(PORTB,7); //CLK High
delay_us(1);
}
delay_ms(50);

disable_interrupts(INT_AD);


//*** Se iniciA el ciclo de captura del A/D PIC16F876,
e imprime los 64 valores ***//
//*****************************************************************************************/


for(K=0; k<64; k++) // Se coloca la rutina de 64
ciclos para imprimir
{
Printf ("%4LX\r",Data[k]);

}

}

Si me pudiera hacer el favor de ayudarme en este proyecto, yo estare muy agradecido por ello.

En lo referente a la recomendación de utilizar algun tipo de convertidor externo, yo me ecuentro en la mejor disposición de poder buscarlo en las tiendas de Barcelona, y buscar por algun modo el poner en operación esta practica, si por favor me pudiera orientar como se podria resolver este proyecto yo estoy en la mejor disposición de tabajar para consegirlo, ya que mi experiencia es muy corta en lo referente al empleo de Pic con algun otro tipo de circuito.

Finalente le estoy muy agradecido por escribir en el
foro de ccs, yo me despido, sin antes desearle
todo lo mejor y que todos sus proyectos se
hagan realidad.

Respetuosamente.

Gustavo Mtz.
gamartinezch@yahoo.com




bertronicom wrote:
Hello,

What type of aplication are you developped?

I had worked with the same Image CMOS Sensor but 512 pixels. I didn't recommend to you using internal A/D converters from PIC.

I used fast external A/D from Analog devices up to 1Msps in order to performance and to get stream data each time.

If this configuration is good for you, I can give to you some parts of code.

Alberto Campo
University of Cantabria - SPAIN
Photonic Engineering Group
bertronicom
Guest







Image sensor
PostPosted: Mon Sep 27, 2004 8:18 am     Reply with quote

I'll recomend to you reading carefully the datasheet. Extremely care with gnd analog and digital because sensor had connected internally.

Therefore you musn't join both gnd's in any point from your board.

Probably now you're not reading anything for that.

This sensor is quite fast to hadle with your PIC at 10Mhz. I'll recommend to you use a PIC18 part and using internal x4 Pll to come to 40Mhz.

I'll recommend to you use external A/D's because can able to run faster than internal A/D PIC's
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group