polarsnake
Newbie level 4

Hi everybody! I'm doing a project now that uses EOG signals (signals picked up by electrodes on the eyes) to control mouse cursor. So basically what it does is that the user will use his/her eyes to move the cursor and navigate the PC. I'm using PIC18F4553 and it is to be interfaced with a PC via USB.
I know there are 3 main things that I would have to tackle in this project:
1) Analog to Digital Conversion (eye signals into microcontroller)
2) USB interfacing
3) Translating the signals into mouse movement
-----------------------------------------------------------------------------------------------------------------------
I have been told to use the USB framework that has been provided in the Microchip website to aid me in interfacing the USB, however after downloading it I have no freaking clue how to use it. Can someone please help me in this?
And I have already started on the analog to digital conversion part and have already written a pseudo-code for it. Can anybody tell me if I'm on the right track here?:
#include <pic18f4553.h>
#include <delays.h>
#include <adc.h>
#include <stdlib.h>
int result;
dec convert(void);
void main()
{
ADCON0=0x01; //select channel AN0
ADCON1=0x0E; //RA0 is configured as analog input
ADCON2=0x84; //Right justification and manual acquisition
TRISA=0xFF; //RA0 is configured as input, the rest of the pins are unused
TRISB=0xFF; //Port B all unused
TRISC=OxFF; //Port C all unused
TRISD=0xFF; //Port D all unused
TRISE=0xFF; //Port E all unused
while(1)
{
result = convert();
if(result>=xxx && result<=xxx) //xxx to be replaced with values later
{
//insert code here to make cursor click
}
else if(result>=xxx && result<=xxx) //xxx to be replaced with values later
{
//insert code here to make cursor move up
}
else if(result>=xxx && result<=xxx) //xxx to be replaced with values later
{
//insert code here to make cursor move down
}
else if(result>=xxx && result<=xxx) //xxx to be replaced with values later
{
//insert code here to make cursor move left
}
else if(result>=xxx && result<=xxx) //xxx to be replaced with values later
{
//insert code here to make cursor move right
}
} //end of while(1) loop
} //end of main
dec convert()
{
Delay10TCYx(3); // Wait for required acquisition time (6us)
ConvertADC(); //start A/D conversion
while(BusyADC()); //wait for completion
result = ReadADC(); //read result
CloseADC();
return(result);
}
I know there are 3 main things that I would have to tackle in this project:
1) Analog to Digital Conversion (eye signals into microcontroller)
2) USB interfacing
3) Translating the signals into mouse movement
-----------------------------------------------------------------------------------------------------------------------
I have been told to use the USB framework that has been provided in the Microchip website to aid me in interfacing the USB, however after downloading it I have no freaking clue how to use it. Can someone please help me in this?
And I have already started on the analog to digital conversion part and have already written a pseudo-code for it. Can anybody tell me if I'm on the right track here?:
#include <pic18f4553.h>
#include <delays.h>
#include <adc.h>
#include <stdlib.h>
int result;
dec convert(void);
void main()
{
ADCON0=0x01; //select channel AN0
ADCON1=0x0E; //RA0 is configured as analog input
ADCON2=0x84; //Right justification and manual acquisition
TRISA=0xFF; //RA0 is configured as input, the rest of the pins are unused
TRISB=0xFF; //Port B all unused
TRISC=OxFF; //Port C all unused
TRISD=0xFF; //Port D all unused
TRISE=0xFF; //Port E all unused
while(1)
{
result = convert();
if(result>=xxx && result<=xxx) //xxx to be replaced with values later
{
//insert code here to make cursor click
}
else if(result>=xxx && result<=xxx) //xxx to be replaced with values later
{
//insert code here to make cursor move up
}
else if(result>=xxx && result<=xxx) //xxx to be replaced with values later
{
//insert code here to make cursor move down
}
else if(result>=xxx && result<=xxx) //xxx to be replaced with values later
{
//insert code here to make cursor move left
}
else if(result>=xxx && result<=xxx) //xxx to be replaced with values later
{
//insert code here to make cursor move right
}
} //end of while(1) loop
} //end of main
dec convert()
{
Delay10TCYx(3); // Wait for required acquisition time (6us)
ConvertADC(); //start A/D conversion
while(BusyADC()); //wait for completion
result = ReadADC(); //read result
CloseADC();
return(result);
}