Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of SunflowerMach1 by
Revision 12:cb92c0183ec9, committed 2014-05-26
- Comitter:
- cvitas
- Date:
- Mon May 26 12:45:54 2014 +0000
- Parent:
- 11:f243d8ed556d
- Commit message:
- Verzija suncokret (Milan)
Changed in this revision
PinDetect.lib | Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f243d8ed556d -r cb92c0183ec9 PinDetect.lib --- a/PinDetect.lib Wed Dec 11 14:54:25 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/AjK/code/PinDetect/#cb3afc45028b
diff -r f243d8ed556d -r cb92c0183ec9 main.cpp --- a/main.cpp Wed Dec 11 14:54:25 2013 +0000 +++ b/main.cpp Mon May 26 12:45:54 2014 +0000 @@ -1,7 +1,6 @@ #include "mbed.h" #include "Motor.h" #include "TextLCD.h" -#include "PinDetect.h" #define sensorStartTreshold 0.08 #define sensorStopTreshold 0.02 @@ -12,14 +11,12 @@ #define calibrateFactorSenzD 0.9 #define lcdOutputEnable true -#define serialOutputEnable true -#define serialOutputBaudrate 9600 +#define serialOutputEnable false +#define serialOutputBaudrate 115200 Serial pc(USBTX, USBRX); TextLCD lcd(p13, p14, p5, p6, p7, p8); // rs, e, d4-d7 -Ticker Prikaz; - DigitalOut ledBoot(LED1); DigitalOut ledAz(LED3); DigitalOut ledEl(LED4); @@ -29,38 +26,10 @@ AnalogIn ainSensC(p18); AnalogIn ainSensD(p19); -PinDetect pb_azimut(p11); -PinDetect pb_elevacija(p12); - float valAzimut = 0; float valElevacija = 0; -int volatile count_azimut=0; -int volatile count_elevacija=0; - - float SensA, SensB, SensC, SensD; - -// Callback routine is interrupt activated by a debounced pb hit -void pb_azimut_hit_callback (void) { - count_azimut++; -} - -void pb_elevacija_hit_callback (void) { - count_elevacija++; -} - -char GetKeyInput(void) { - char c = pc.getc(); // get keyboard data (note numerical ascii range) - pc.printf("%c",c); // print ascii value to host PC terminal - return (c&0x0F); // return value as non-ascii (bitmask c with value 0x0f -} - -void od_prikaza(){ - lcd.cls(); - lcd.printf(" %d %d ", count_azimut , count_elevacija); -} - void readValuesForAveraging() { SensA = 0; @@ -89,10 +58,10 @@ if(serialOutputEnable) { - pc.printf("az:%6.3f el:%6.3f :: A:%.3f B:%.3f C:%.3f D:%.3f \n\r", - valAzimut, valElevacija, SensA, SensB, SensC, SensD); +// pc.printf("az:%6.3f el:%6.3f :: A:%.3f B:%.3f C:%.3f D:%.3f \n", +// valAzimut, valElevacija, SensA, SensB, SensC, SensD); - // pc.printf("az:%6.3f el:%6.3f \n", valAzimut, valElevacija); + // pc.printf("az:%6.3f el:%6.3f \n", valAzimut, valElevacija); } if(lcdOutputEnable) { @@ -103,20 +72,10 @@ } -char data1, data2; // variable declarations int main() { ledBoot = 1; - Prikaz.attach(&od_prikaza, 0.1); - - // Setup Interrupt callback function for a pb hit - pb_elevacija.attach_deasserted(&pb_elevacija_hit_callback); - pb_azimut.attach_deasserted(&pb_azimut_hit_callback); - // Start sampling pb input using interrupts - pb_elevacija.setSampleFrequency(); - pb_azimut.setSampleFrequency(); pc.baud(serialOutputBaudrate); - Motor *motorAz = new Motor(p28, p27, p26); // relej, relej, pwm Motor *motorEl = new Motor(p24, p23, p25); if(lcdOutputEnable) { @@ -128,32 +87,7 @@ ledBoot = 0; while(1) { - - data2 = GetKeyInput(); // call function to get 1st key press - switch (data2) { - case 0: - (*motorAz).stop(); - (*motorEl).stop(); - break; - case 1: - (*motorAz).movePositive(); - break; - case 2: - (*motorAz).moveNegative(); - break; - case 3: - (*motorEl).movePositive(); - break; - case 4: - (*motorEl).moveNegative(); - break; - default: - (*motorAz).stop(); - (*motorEl).stop(); - break; - } - - /* + // ---- citanje senzora ------------ readValuesForAveraging(); @@ -187,12 +121,10 @@ (*motorEl).stop(); ledEl = 0; } - */ + // ----- pauza ------ - - //wait_ms(200); - + wait_ms(100); } }