T1CONbits.TMR1ON = 1 // bit 0 enables timer T1CONbits.TMR1CS = 0 // bit 1 Timer1 Clock Source Select bit.0 = Internal clock (FOSC/4) T1CONbits.T1SYNC = 1 // bit 2 Timer1 External Clock Input Synchronization Control bit.1 = Do not synchronize external clock input T1CONbits.T1OSCEN = 1 // bit 3 Timer1 Oscillator Enable Control bit 1 = on T1CONbits.T1CKPS1 = 0 // bits 5-4 Prescaler Rate Select bits RCSTAbits.ADDEN = 0 //Testing this out might not help with overflow Servo0Max = 65000 //Max value allowed PAN 65000 TRISC = 0b10110000 //RC4 and RC5 inputs for switches PIR1bits.TMR2IF = 0 //Turn off Int Flag TMR0H = timer0/256 //Extract HIGH byte always do Hbyte first INTCONbits.TMR0IF = 0 //Turn off Int Flag #pragma code /* return to the default code section */ variables used to disect the comma delimited stringĬhar CVdata //do we have a command and value? Unsigned int timer1, servo1Min, servo1Max Ĭhar array //input rs-232 buffer Unsigned int timer0, servo0Min, servo0Max Unsigned char hertz = 75 //value to generate 5-=60 hertz wave default value 75 Void limitServo0() //limit movement via predetermined min/max Data is stored in a ring buffer as it is received and processed as soon as possible. Currently it is fed x and y positions via serial communications from my C# application. Thinking outside the box I think I could hide and center the mouse on the screen, record how much the mouse moved on mousemoved events, process that data, then recenter the mouse on the screen to give me unlimited movement in each axis.Įnclosed below is my PIC18F2420 code. So my question is what options are available to me for tracking mouse movement up to 10,000 steps/resolution in the X and Y axis? This worked fine and dandy till I needed to move a greater amount of steps than my monitor has resolution. In the past I had created a box or image that was the resolution(number of steps) my servos were capable of, clipped the mouse to that box or image, and processed where the cursor was in that box and sent data to my servos to move to that position. I'm using a C# application to record keyboard and mouse movement, processing that movement and sending serial data out to a micro-controller that interpreters that data and moves a set of servos.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |