diff --git a/README.md b/README.md index 32b7fdc..3476ef2 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Table of Contents * [Example Variants ](#example-variants) * [Flashing](#flashing) * [3D Visualization Demo](#3d-visualization-demo) +* [Wiring iBUS Receiver](#wiring-ibus-receiver) * [Contributions](#contributions) --- @@ -49,8 +50,9 @@ For more details see the [MPU-6050 datasheet](/docs/1_MPU-6000-Datasheet.pdf) an ## Example Variants This firmware offers currently these variants (selectable in [platformio.ini](/platformio.ini) or [config.h](/Inc/config.h)): -- **VARIANT_DEBUG**: In this variant the user can interact with sideboard by sending commands via a Serial Monitor to observe and check the capabilities of the sideboard. -- **VARIANT_HOVERBOARD**: In this variant the sideboard is communicating with the mainboard of a hoverboard using the [FOC firmware repository](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC). +- **VARIANT_DEBUG**: In this variant the user can interact with sideboard by sending commands via a Serial Monitor to observe and check the capabilities of the sideboard +- **VARIANT_HOVERCAR**: This variant can be used for Hovercar build. An RC receiver with iBUS protocol can be connected to the AUX serial Rx pin (see [schematic](#wiring-ibus-receiver)) +- **VARIANT_HOVERBOARD**: In this variant the sideboard is communicating with the mainboard of a hoverboard using the [FOC firmware repository](https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC) Of course the firmware can be further customized for other needs or projects. @@ -103,6 +105,14 @@ By [converting Quaternions to Euler angles](https://en.wikipedia.org/wiki/Conver ![sketch_pic](/docs/pictures/sketch_processing_pic.png) +--- +## Wiring iBUS Receiver + +An RC transmitter (Flysky [FS-i6S](https://www.banggood.com/custlink/3KvdPnfDPc) or [FS-i6X](https://www.banggood.com/custlink/KmDy5swKPD)) can be connected to the sideboard using an [FS-iA6B](https://www.banggood.com/custlink/KD3RFswKcT) receiver as shown in the following schematic: + +![wiring_iBUS_pic](/docs/pictures/wiring_ibus_rc.png) + + --- ## Contributions diff --git a/Src/mpu6050.c b/Src/mpu6050.c index f018ebd..c77d663 100644 --- a/Src/mpu6050.c +++ b/Src/mpu6050.c @@ -3720,19 +3720,19 @@ void mpu_print_to_console(void) { #ifdef SERIAL_DEBUG if (hal.report & PRINT_ACCEL) { - log_i( "Accel[XYZ]: %d %d %d\r\n", mpu.accel.x, mpu.accel.y, mpu.accel.z); + log_i( "accX:%d accY:%d accZ:%d\r\n", mpu.accel.x, mpu.accel.y, mpu.accel.z); } if (hal.report & PRINT_GYRO) { - log_i( "Gyro[XYZ]: %d %d %d\r\n", mpu.gyro.x, mpu.gyro.y, mpu.gyro.z); + log_i( "gyrX:%d gyrY:%d gyrZ:%d\r\n", mpu.gyro.x, mpu.gyro.y, mpu.gyro.z); } if (hal.report & PRINT_QUAT) { - log_i( "Quat[WXYZ]: %ld %ld %ld %ld\r\n", (long)mpu.quat.w, (long)mpu.quat.x, (long)mpu.quat.y, (long)mpu.quat.z); + log_i( "qW:%ld qX:%ld qY:%ld qZ:%ld\r\n", (long)mpu.quat.w, (long)mpu.quat.x, (long)mpu.quat.y, (long)mpu.quat.z); } if (hal.report & PRINT_EULER) { - log_i( "Euler[RPY]: %d %d %d\r\n", mpu.euler.roll, mpu.euler.pitch, mpu.euler.yaw); + log_i( "Roll:%d Pitch:%d Yaw:%d\r\n", mpu.euler.roll, mpu.euler.pitch, mpu.euler.yaw); } if (hal.report & PRINT_TEMP) { - log_i( "Temp: %d\r\n", mpu.temp); + log_i( "Temp:%d\r\n", mpu.temp); } if (hal.report & PRINT_PEDO) { unsigned long timestamp; diff --git a/Src/util.c b/Src/util.c index dafc64a..87c1b13 100644 --- a/Src/util.c +++ b/Src/util.c @@ -110,6 +110,7 @@ volatile int8_t i2c_aux_nRABytes; #endif + /* =========================== General Functions =========================== */ void consoleLog(char *message) @@ -182,10 +183,10 @@ void intro_demo_led(uint32_t tDelay) uint8_t switch_check(uint16_t ch, uint8_t type) { - if (type) { // 3 position switch - if (ch > 850) return 2; // switch in position 2 - else if (ch > 250) return 1; // switch in position 1 - else return 0; // switch in position 0 + if (type) { // 3 positions switch + if (ch < 250) return 0; // switch in position 0 + else if (ch < 850) return 1; // switch in position 1 + else return 2; // switch in position 2 } else { // 2 positions switch return (ch > 850); } @@ -376,7 +377,7 @@ void handle_usart(void) { /* * Handle of the sideboard LEDs */ -void handle_leds(void){ +void handle_leds(void) { #ifdef SERIAL_FEEDBACK if (!timeoutFlagSerial1) { if (Feedback.cmdLed & LED1_SET) { gpio_bit_set(LED1_GPIO_Port, LED1_Pin); } else { gpio_bit_reset(LED1_GPIO_Port, LED1_Pin); } @@ -463,7 +464,7 @@ void usart_process_debug(uint8_t *userCommand, uint32_t len) */ #ifdef SERIAL_FEEDBACK void usart_process_data(SerialFeedback *Feedback_in, SerialFeedback *Feedback_out) -{ +{ uint16_t checksum; if (Feedback_in->start == SERIAL_START_FRAME) { checksum = (uint16_t)(Feedback_in->start ^ Feedback_in->cmd1 ^ Feedback_in->cmd2 ^ Feedback_in->speedR_meas ^ Feedback_in->speedL_meas diff --git a/build/VARIANT_DEBUG/firmware.bin b/build/VARIANT_DEBUG/firmware.bin deleted file mode 100644 index 4b409a5..0000000 Binary files a/build/VARIANT_DEBUG/firmware.bin and /dev/null differ diff --git a/build/VARIANT_DEBUG/firmware.elf b/build/VARIANT_DEBUG/firmware.elf deleted file mode 100644 index c42d0e6..0000000 Binary files a/build/VARIANT_DEBUG/firmware.elf and /dev/null differ diff --git a/build/VARIANT_HOVERBOARD/firmware.bin b/build/VARIANT_HOVERBOARD/firmware.bin deleted file mode 100644 index 4a940a2..0000000 Binary files a/build/VARIANT_HOVERBOARD/firmware.bin and /dev/null differ diff --git a/build/VARIANT_HOVERBOARD/firmware.elf b/build/VARIANT_HOVERBOARD/firmware.elf deleted file mode 100644 index 1adac2a..0000000 Binary files a/build/VARIANT_HOVERBOARD/firmware.elf and /dev/null differ diff --git a/docs/pictures/GD_pics.pptx b/docs/pictures/GD_pics.pptx index 22a44d4..6352ca0 100644 Binary files a/docs/pictures/GD_pics.pptx and b/docs/pictures/GD_pics.pptx differ diff --git a/docs/pictures/wiring_ibus_rc.png b/docs/pictures/wiring_ibus_rc.png new file mode 100644 index 0000000..af848c2 Binary files /dev/null and b/docs/pictures/wiring_ibus_rc.png differ