/**************************************** Propeller replace mindstorm brick codename: myrOBOT Author : Reinhard Mayer Date : 2011 - DEC - 03 Version : 0.0.1 Compiler: propgcc ._____ _____. | \__/ | Button1| 1 40 |TXD Button2| 2 39 |RXD Sound.out| 3 38 |SDA Analog.out| 4 37 |SCL MotorB dir| 5 36 |ADC_FAST.SCLK MotorA dir| 6 35 |ADC_FAST.nCS MotorB Power| 7 34 |ADC_FAST.DIN MotorA Power| 8 33 |ADC_FAST.DOUT Vss| 9 32 |VDD nBOE| 10 31 |XO nRES| 11 30 |XI Vdd| 12 29 |Vss SigmaDelta.in| 13 28 |LCD.DB7 SigmaDelta.fb| 14 27 |LCD.DB6 spare| 15 26 |LCD.DB5 spare| 16 25 |LCD.DB4 spare| 17 24 |LCD.DB3 LCD.RS| 18 23 |LCD.DB2 LCD.RW| 19 22 |LCD.DB1 LCD.EN| 20 21 |LCD.DB0 |______________| *****************************************/ #include #include #include "kernel.h" #include "motor.h" #include "analog_out.h" #include "max147.h" #include "lcd.h" #include "sound.h" // this is the mailbox for Sigma Delta ADC // it is important to place declaration here ! unsigned int value; // sound note_t song[] = { {_C6,1}, // note = C6, duration = 100ms {_D6,1}, {_E6,1}, {_F6,1}, {_G6,2}, // note = G6, duration = 200ms {END,0} }; #define Teststub ////////////////////////////////////////////////////////// void main () { int percent; unsigned short adc_fast; kernel_init(); #ifdef Teststub DIRA |= 1 << 16; // Sigma Delta Limit Indicator LED // lcd putchar lcd_putchar(':'); lcd_putchar('-'); lcd_putchar(')'); while(1) { for(percent = 0; percent <= 100;percent++) { //motor pwm and direction, for this test of course no common motor - axis ;-) setMotorA(percent,fwd); setMotorB(100 - percent,rev); //analog out (normaly lowpass filtered with RC) setAnalogOut(percent); // delay before next pwm delta msleep(100); //Sigma Delta ADC if(value > 300) { //pulse LED if sigma delta value exceeds a limit OUTA |= 1 << 16; msleep(500); OUTA &= ~(1 << 16); } //buttons and lcd puts if( CLOSE == getButtonState(1) ) { swapMotorADirection (); lcd_puts("Button 1 close"); playSound(song); } else lcd_puts("Button 1 open "); if( CLOSE == getButtonState(2) ) swapMotorBDirection (); //adc_fast, for more info read max147 datasheet adc_fast = readMAX147(0xFF); } percent = 0; msleep(500); } #endif }