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.
Dependencies: mbed WattBob_TextLCD MCP23017 globals
Revision 1:7cb0ee7f57b6, committed 2011-12-01
- Comitter:
- Nurbol
- Date:
- Thu Dec 01 08:40:29 2011 +0000
- Parent:
- 0:485df37a69ec
- Commit message:
Changed in this revision
--- a/cmd_io.cpp Thu Dec 01 04:16:04 2011 +0000 +++ b/cmd_io.cpp Thu Dec 01 08:40:29 2011 +0000 @@ -146,11 +146,13 @@ sprintf(buffer, "%u\n", (int)command->result_data[0]); } if (command->nos_data == 2) { - sprintf(buffer, "%u %u\n", (int)command->result_data[0], (int)command->result_data[1]); + sprintf(buffer, "%u\n", (int)command->result_data[1]); } - if (command->nos_data == 7) { - sprintf(buffer, "%u %u %u %u %u %u %u\n", (int)command->result_data[0], (int)command->result_data[1], (int)command->result_data[2], (int)command->result_data[3], - (int)command->result_data[4], (int)command->result_data[5], (int)command->result_data[6]); + if (command->nos_data == 3) { + sprintf(buffer, "%u\n", (int)command->result_data[2]); + } + if (command->nos_data == 4) { + sprintf(buffer, "%u\n", (int)command->result_data[3]); } // // send string
--- a/cmd_io.lib Thu Dec 01 04:16:04 2011 +0000 +++ b/cmd_io.lib Thu Dec 01 08:40:29 2011 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/Nurbol/code/cmd_io/#d841cc27ebf9 +http://mbed.org/users/Nurbol/code/cmd_io/#30c4e3e11cb5
--- a/main.cpp Thu Dec 01 04:16:04 2011 +0000 +++ b/main.cpp Thu Dec 01 08:40:29 2011 +0000 @@ -123,6 +123,7 @@ valueLED2=0; clk=0; + Motor = 0; return; } // end init_sys @@ -171,43 +172,30 @@ case 0 : servo_0.pulsewidth_us(pulse_width); break; case 4 : servo_4.pulsewidth_us(pulse_width); break; case 5 : servo_5.pulsewidth_us(pulse_width); break; - } last_servo = command->param[0]; break; // -// return last servo number +// return data of the value of sensor 1p and sensor 2p // case READ_CMD : - - if((bSort_Mode == 0)&&(bMaint_Mode == 1)){ - command->nos_data = 2;// no data to be returned + if((bSort_Mode == 0)&&(bMaint_Mode == 1)){ // when we are on sort mode + command->nos_data = 2; command->result_data[0] = valueLED1; command->result_data[1] = valueLED2; } - else if((bSort_Mode == 1)&&(bMaint_Mode == 0)){ - command->nos_data = 7;// no data to be returned - command->result_data[0] = valueLED1; - command->result_data[1] = valueLED2; - command->result_data[2] = counter1p; - command->result_data[3] = counter2p; - command->result_data[4] = Position1_1p; - command->result_data[5] = Position1_2p; - command->result_data[2] = Motor; - //send_data(&ext_cmd); - } break; // // Mode value // - case MAINT_MODE : + case MAINT_MODE : // Maintenance mode bSort_Mode = 0; bMaint_Mode = 1; Reset = 1; - servo_4.pulsewidth_us(0); - servo_0.pulsewidth_us(0); - servo_5.pulsewidth_us(0); + servo_4.pulsewidth_us(0); // Motor stop + servo_0.pulsewidth_us(0); // Servo 1p stop + servo_5.pulsewidth_us(0); // Servo 2p stop lcd->cls(); lcd->locate(0,7); lcd->printf("W3C"); @@ -216,7 +204,7 @@ break; - case SORT_MODE : + case SORT_MODE : // sort mode bSort_Mode = 1; bMaint_Mode = 0; Reset = 0; @@ -232,14 +220,14 @@ // // Urgency mode // - case URGENCY : + case URGENCY : Reset = 1; bSort_Mode = 0; bMaint_Mode = 0; state = 0; - servo_4.pulsewidth_us(0); - servo_0.pulsewidth_us(0); - servo_5.pulsewidth_us(0); + servo_4.pulsewidth_us(0); // Motor stop + servo_0.pulsewidth_us(0); // Servo 1p stop + servo_5.pulsewidth_us(0); // Servo 2p stop lcd->cls(); lcd->locate(0,7); lcd->printf("W3C"); @@ -254,13 +242,56 @@ bSort_Mode = 0; bMaint_Mode = 0; state = 0; - servo_4.pulsewidth_us(0); - servo_0.pulsewidth_us(0); - servo_5.pulsewidth_us(0); + servo_4.pulsewidth_us(0); // Motor stop + servo_0.pulsewidth_us(0); // sensor 1p stop + servo_5.pulsewidth_us(0); // sensor 2p stop lcd->cls(); lcd->locate(0,7); lcd->printf("W3C"); - break; + break; + +// Send data of the value led 2p + case VALUE_LED1 : + command->nos_data = 1; + command->result_data[0] = valueLED1; + break; + +// Send data of the value led 1p + case VALUE_LED2 : + command->nos_data = 2; + command->result_data[1] = valueLED2; + break; + +// Send data of the value counter 1p + case COUNTER1P : + command->nos_data = 3; + command->result_data[2] = counter1p; + break; + +// Send data of the value counter 2p + case COUNTER2P : + command->nos_data = 4; + command->result_data[3] = counter2p; + break; + +// Send data of the value position1 1p + case POSITION1_1P : + command->nos_data = 1; + command->result_data[0] = Position1_1p; + break; + +// Send data of the value position1 2p + case POSITION1_2P : + command->nos_data = 2; + command->result_data[1] = Position1_2p; + break; + +// Send data of the motor + case MOTOR : + command->nos_data = 3; + command->result_data[2] = Motor; + break; + // // catch any problems // @@ -390,8 +421,9 @@ } } - +// //************************************************************************ +// Main Program // int main() { @@ -405,7 +437,7 @@ counter1p.read(); counter2p.read(); - timerstatemachine.attach(&state_machine, 0.1); + timerstatemachine.attach(&state_machine, 0.1); // function state machine is readinf all the 100 ms clk = !clk; wait(0.001); @@ -435,10 +467,6 @@ // process_cmd(&ext_cmd); reply_to_cmd(&ext_cmd); - - - - } }