Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
nclude <mega8.h>#include <delay.h>// Standard Input/Output functions#include <stdio.h> void writepan(void);void readpan(void);// Declare your global variables here unsigned char aval,address; signed char rddata; signed long int accu;void main(void){// Declare your local variables hereunsigned char i;// Input/Output Ports initialization// Port B initialization// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out // State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 State1=0 State0=0 PORTB=0x00;DDRB=0x3F;// Port C initialization// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State6=T State5=T State4=T State3=T State2=T State1=P State0=T PORTC=0x02;DDRC=0x2C;// Port D initialization// Func7=Out Func6=Out Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=1 State6=1 State5=T State4=T State3=T State2=T State1=T State0=T PORTD=0xC0;DDRD=0xC0;// Timer/Counter 0 initialization// Clock source: System Clock// Clock value: Timer 0 StoppedTCCR0=0x00;TCNT0=0x00;// Timer/Counter 1 initialization// Clock source: System Clock// Clock value: Timer 1 Stopped// Mode: Normal top=FFFFh// OC1A output: Discon.// OC1B output: Discon.// Noise Canceler: Off// Input Capture on Falling Edge// Timer 1 Overflow Interrupt: Off// Input Capture Interrupt: Off// Compare A Match Interrupt: Off// Compare B Match Interrupt: OffTCCR1A=0x00;TCCR1B=0x00;TCNT1H=0x00;TCNT1L=0x00;ICR1H=0x00;ICR1L=0x00;OCR1AH=0x00;OCR1AL=0x00;OCR1BH=0x00;OCR1BL=0x00;// Timer/Counter 2 initialization// Clock source: System Clock// Clock value: Timer 2 Stopped// Mode: Normal top=FFh// OC2 output: DisconnectedASSR=0x00;TCCR2=0x00;TCNT2=0x00;OCR2=0x00;// External Interrupt(s) initialization// INT0: Off// INT1: OffMCUCR=0x00;// Timer(s)/Counter(s) Interrupt(s) initializationTIMSK=0x00;// USART initialization// Communication Parameters: 8 Data, 1 Stop, No Parity// USART Receiver: On// USART Transmitter: On// USART Mode: Asynchronous// USART Baud rate: 9600UCSRA=0x00;UCSRB=0x18;UCSRC=0x86;UBRRH=0x00;UBRRL=0x33;// Analog Comparator initialization// Analog Comparator: Off// Analog Comparator Input Capture by Timer/Counter 1: OffACSR=0x80;SFIOR=0x00;rddata=0x10;accu=0xAAAAAAAA;checkagain:if (PINC.1 == 1) goto checkagain;delay_ms(4000);aval=0b00001101;address=0x1A;writepan();while (1) { // Place your code here address=0x41; //010xxxxx readpan(); delay_ms(1000); address=0x16; // motion readpan(); delay_ms(1000); address=0x01; //000xxxxx readpan(); delay_ms(1000); address=0x44; // quality readpan(); delay_ms(1000); PORTC.5=~PORTC.5; //toggle led to check program flow };}void writepan(void){ #asm RJMP writepandelay5:NOPPUSH R16CLZLDI R16,9back:DEC R16BRNE backPOP R16retdelay4:NOPPUSH R16CLZLDI R16,7back1:DEC R16BRNE back1POP R16retwritepan:CBI 0x12,7SBI 0x12,6RCALL delay5SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R4,6RJMP clearout11SBI 0x12,6RJMP cont11clearout11:CBI 0x12,6cont11:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R4,5RJMP clearout21SBI 0x12,6RJMP cont21clearout21:CBI 0x12,6cont21:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R4,4RJMP clearout31SBI 0x12,6RJMP cont31clearout31:CBI 0x12,6cont31:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R4,3RJMP clearout41SBI 0x12,6RJMP cont41clearout41:CBI 0x12,6cont41:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R4,2RJMP clearout51SBI 0x12,6RJMP cont51clearout51:CBI 0x12,6cont51:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R4,1RJMP clearout61SBI 0x12,6RJMP cont61clearout61:CBI 0x12,6cont61:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R4,0RJMP clearout71SBI 0x12,6RJMP cont71clearout71:CBI 0x12,6cont71:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R5,7RJMP clearout81SBI 0x12,6RJMP cont81clearout81:CBI 0x12,6cont81:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R5,6RJMP clearout91SBI 0x12,6RJMP cont91clearout91:CBI 0x12,6cont91:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R5,5RJMP clearout101SBI 0x12,6RJMP cont101clearout101:CBI 0x12,6cont101:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R5,4RJMP clearout111SBI 0x12,6RJMP cont111clearout111:CBI 0x12,6cont111:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R5,3RJMP clearout121SBI 0x12,6RJMP cont121clearout121:CBI 0x12,6cont121:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R5,2RJMP clearout131SBI 0x12,6RJMP cont131clearout131:CBI 0x12,6cont131:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R5,1RJMP clearout141SBI 0x12,6RJMP cont141clearout141:CBI 0x12,6cont141:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R5,0RJMP clearout151SBI 0x12,6RJMP cont151clearout151:CBI 0x12,6cont151:RCALL delay4SBI 0x12,7RCALL delay5#endasm}void readpan(void){#asmreadpan:CBI 0x12,7CBI 0x12,6RCALL delay5SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R4,6RJMP clearout1SBI 0x12,6RJMP cont1clearout1:CBI 0x12,6cont1:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R4,5RJMP clearout2SBI 0x12,6RJMP cont2clearout2:CBI 0x12,6cont2:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R4,4RJMP clearout3SBI 0x12,6RJMP cont3clearout3:CBI 0x12,6cont3:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R4,3RJMP clearout4SBI 0x12,6RJMP cont4clearout4:CBI 0x12,6cont4:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R4,2RJMP clearout5SBI 0x12,6RJMP cont5clearout5:CBI 0x12,6cont5:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R4,1RJMP clearout6SBI 0x12,6RJMP cont6clearout6:CBI 0x12,6cont6:RCALL delay4SBI 0x12,7RCALL delay5CBI 0x12,7SBRS R4,0RJMP clearout7SBI 0x12,6RJMP cont7clearout7:CBI 0x12,6cont7:RCALL delay4SBI 0x12,7RCALL delay4CBI 0x11,6SBI 0x12,6NOPNOPNOPNOPCBI 0x12,7RCALL delay5SBI 0x12,7SBIS 0x10,6RJMP clearb7SBI 0x15,3RJMP con7clearb7:CBI 0x15,3con7:RCALL delay4CBI 0x12,7RCALL delay5SBI 0x12,7SBIS 0x10,6RJMP clearb6SBI 0x15,2RJMP con6clearb6:CBI 0x15,2con6:RCALL delay4CBI 0x12,7RCALL delay5SBI 0x12,7SBIS 0x10,6RJMP clearb5SBI 0x18,5RJMP con5clearb5:CBI 0x18,5con5:RCALL delay4CBI 0x12,7RCALL delay5SBI 0x12,7SBIS 0x10,6RJMP clearb4SBI 0x18,4RJMP con4clearb4:CBI 0x18,4con4:RCALL delay4CBI 0x12,7RCALL delay5SBI 0x12,7SBIS 0x10,6RJMP clearb3SBI 0x18,3RJMP con3clearb3:CBI 0x18,3con3:RCALL delay4CBI 0x12,7RCALL delay5SBI 0x12,7SBIS 0x10,6RJMP clearb2SBI 0x18,2RJMP con2clearb2:CBI 0x18,2con2:RCALL delay4CBI 0x12,7RCALL delay5SBI 0x12,7SBIS 0x10,6RJMP clearb1SBI 0x18,1RJMP con1clearb1:CBI 0x18,1con1:RCALL delay4CBI 0x12,7RCALL delay5SBI 0x12,7SBIS 0x10,6RJMP clearb0SBI 0x18,0RJMP con0clearb0:CBI 0x18,0con0:RCALL delay4CBI 0x12,7RCALL delay5SBI 0x12,7SBI 0x11,6 SBIS 0x15,3RJMP clearr77SETRJMP contin7clearr77:CLTcontin7:BLD R7,7 SBIS 0x15,2RJMP clearr76SETRJMP contin6clearr76:CLTcontin6:BLD R7,6SBIS 0x18,5RJMP clearr75SETRJMP contin5clearr75:CLTcontin5:BLD R7,5SBIS 0x18,4RJMP clearr74SETRJMP contin4clearr74:CLTcontin4:BLD R7,4 SBIS 0x18,3RJMP clearr73SETRJMP contin3clearr73:CLTcontin3:BLD R7,3SBIS 0x18,2RJMP clearr72SETRJMP contin2clearr72:CLTcontin2:BLD R7,2SBIS 0x18,1RJMP clearr71SETRJMP contin1clearr71:CLTcontin1:BLD R7,1SBIS 0x18,0RJMP clearr70SETRJMP contin0clearr70:CLTcontin0:BLD R7,0#endasm}
How long did it take to write that sucker?
info about lenses are pretty much plenty but im lookin for the optical conditions to meet to make this sensor have good quality image
also read the NASA tech review paper which is referred in this link.http://home.roadrunner.com/~maccody/robotics/croms-1/croms-1.html
can somebody tell which optical mouse model of which company is build using these sensors ? so that i can use it for my hack.
so does that imply that I have to generate a clock signal from my microcontroller of frequency 2MHz ?
can the Serial Port Clock Frequency be less than that ?
generating a 2MHz clock using timer as well as writing or reading the SDIO pin during one half cycle (ie we complete writing to SDIO during the time clock is low) would be a tricky part with ATMega8L that I use because ATMega8L can run max at 8MHz ?
magnification=lenght of 2 pixels/max displacement of robot in 1 frame.
now aperture value is needed to make sure that correct amount of light intensity is avaliable for sensor and also the aperture value changes the depth field .According to the links and NASA paper I would go with a lens of aperture 10mm and us different aperture stop during testing.
to know how the code works you have to have the pan3101 datasheet /check serial communication protocol.i did implement this protocol in assembly ,,the main program that calls the functions is in cfeel free to ask any questions