1/23 操舵 レシーバ
Dependencies: ADXL345_I2C INA226_ver1 mbed
Fork of RS485R_2 by
Diff: main.cpp
- Revision:
- 2:2b98a651b0a1
- Parent:
- 1:563b7d0b896f
- Child:
- 3:2bdb60bbc665
diff -r 563b7d0b896f -r 2b98a651b0a1 main.cpp --- a/main.cpp Sat Dec 05 03:19:30 2015 +0000 +++ b/main.cpp Sat Dec 05 11:21:06 2015 +0000 @@ -18,7 +18,7 @@ void rs485_rx() { - int rec_data = rs485.getc(); + signed char rec_data = rs485.getc(); switch(rec_data) { case 'A': servo_deg1 = rs485.getc(); @@ -26,19 +26,21 @@ break; case 'B': servo_deg2 = rs485.getc(); - pc.printf("counter2:%d\n\r",servo_deg2); + //pc.printf("counter2:%d\n\r",servo_deg2); break; case 'C': Receiver = 1; wait_ms(1); rs485.putc('X'); - rs485.putc(acc[0]); + rs485.putc((signed char)acc[0]); rs485.putc('Y'); - rs485.putc(acc[1]); + rs485.putc((signed char)acc[1]); rs485.putc('Z'); - rs485.putc(acc[2]); + rs485.putc((signed char)acc[2]); +// rs485.printf("X%iY%iZ%i\n\r",(short)acc[0],(short)acc[1],(short)acc[2]); wait_ms(2); Receiver = 0; + //pc.printf("x:%d,y:%d,z:%d\n\r",(signed char)acc[0],(signed char)acc[1],(signed char)acc[2]); break; default: wait_us(5); @@ -70,6 +72,6 @@ accelerometer.getOutput(acc); servo1.pulsewidth(0.00093 + (servo_deg1 / 180.0) * (0.00235 - 0.00077)); servo2.pulsewidth(0.00093 + (servo_deg2 / 180.0) * (0.00235 - 0.00077)); - wait_ms(100); + wait_ms(10); } }