Jogpad for the Mach3 CNC control software with Maple Mini board (STM32F103CBT6).

Dependencies:   mbed mbed-MapleMini USBDevice_STM32F103

Mach3 Jogpad

Jogpad for the Mach3 CNC control software with Maple Mini board (STM32F103CBT6). Have a look also at the MapleMini USBSerial. Communication with the PC and power supply is over a USB cable. Since the Jogpad is a USB HID (Human Interface Device) no USB driver has to be installed to the PC (as such is available on each MS Windows PC by default).

If you'd like to build a USBJoystick Device have a look at Wim's wonderful page.

Schematic

https://os.mbed.com/media/uploads/hudakz/jogpad_schematic_01.png

Board design

https://os.mbed.com/media/uploads/hudakz/jogpad_board_01.png

Because zip files cannot be uploaded to mbed wiki pages anymore, in order to download the zipped eagle project files right-click on the link and select Save link as.... Once saved to your local drive, change the extension from png to zip and then unzip.

Board assembled

https://os.mbed.com/media/uploads/hudakz/jogpad_device_01.jpg

Files at this revision

API Documentation at this revision

Comitter:
hudakz
Date:
Mon Mar 16 15:05:47 2020 +0000
Commit message:
Jogpad for Mach3 CNC software with STM32F103 (Maple Mini board).

Changed in this revision

USBDevice_STM32F103.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-MapleMini.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice_STM32F103.lib	Mon Mar 16 15:05:47 2020 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/hudakz/code/USBDevice_STM32F103/#a6dcac43ceaf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Mar 16 15:05:47 2020 +0000
@@ -0,0 +1,70 @@
+#include "MapleMini.h"
+#include "mbed.h"
+#include "USBKeyboard.h"
+
+#define POS_MIN 20000
+#define POS_MAX 50000
+
+DigitalOut      led(PB_1);                  // LED
+DigitalOut      usbEn(PB_9);                // Used for connecting/disconnecting the 1k5 resistor to/from the USB DP pin
+AnalogIn        vRx(PB_0);                  // Joystick Rx pin
+AnalogIn        vRy(PA_7);                  // Joystick Ry pin
+DigitalIn       btnCtrl(PB_12, PullDown);   // Ctrl key
+DigitalIn       btnShift(PB_14 , PullDown); // Shift key
+DigitalIn       btnUp(PA_10, PullDown);     // PageUp key (Z-up)
+DigitalIn       btnDown(PA_1, PullDown);    // PageDown key (Z-down)
+uint8_t         modifier = 0;
+USBKeyboard*    keyboard;
+
+/**
+ * @brief
+ * @note
+ * @param
+ * @retval
+ */
+int main()
+{
+    confSysClock(); //Configure system clock (72MHz HSE clock, 48MHz USB clock)
+    led = 1;
+    keyboard = new USBKeyboard();
+    usbEn = 0;      //Keep the on-board 1k5 resistor connected to USB DP pin
+    while (1) {
+        if (btnShift == 1) {
+            modifier = KEY_SHIFT;
+        }
+        else
+        if (btnCtrl == 1) {
+            modifier = KEY_CTRL;
+        }
+        else {
+            modifier = 0;
+        }
+
+        if (vRy.read_u16() < POS_MIN) {
+            keyboard->keyCode(LEFT_ARROW, modifier, false);
+        }
+        else
+        if (vRy.read_u16() > POS_MAX) {
+            keyboard->keyCode(RIGHT_ARROW, modifier, false);
+        }
+        else
+        if (vRx.read_u16() < POS_MIN) {
+            keyboard->keyCode(DOWN_ARROW, modifier, false);
+        }
+        else
+        if (vRx.read_u16() > POS_MAX) {
+            keyboard->keyCode(UP_ARROW, modifier, false);
+        }
+        else
+        if (btnUp == 1) {
+            keyboard->keyCode(KEY_PAGE_UP, modifier, false);
+        }
+        else
+        if (btnDown == 1) {
+            keyboard->keyCode(KEY_PAGE_DOWN, modifier, false);
+        }
+        else {
+            keyboard->keyCode(0, 0);    // Release the key(s)
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-MapleMini.lib	Mon Mar 16 15:05:47 2020 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/hudakz/code/mbed-MapleMini/#f0b2ddbf8ba6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Mar 16 15:05:47 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file