|
1 | | -# firmware |
| 1 | +# Dynamics Lab Firmware |
| 2 | + |
| 3 | +Please Note: This firmware relies on a MODIFIED version of the uStepperS32 library, please uninstall any version installed from the Arduino library manager and install [this](https://github.com/ImogenWren/uStepperS32) version available at [https://github.com/ImogenWren/uStepperS32](https://github.com/ImogenWren/uStepperS32) |
| 4 | + |
| 5 | +## Current Version |
| 6 | +-> [dynamics-lab-firmware-V1.0.0](https://github.com/practable/dynamics-lab/tree/fw-dev/fw/dynamics_lab_firmware_V1_x_x) |
| 7 | + |
| 8 | +## Calibration Procedure: Setting home position (V1.0.0 - Beta Firmware) |
| 9 | +#### Setting Secret |
| 10 | +_Secret must be set before calibration data can be entered. Once set, a finite number (20) of calibrations are permitted. To calibrate after this point, secret must be reset using `Resetting Secret` procedure_ |
| 11 | +- Enter new 8-character secret using command `{"set":"secret","to":"XXXXXXXX"}` |
| 12 | +- Once set this is persistant and will require re-programming firmware to reset |
| 13 | +<br><br> |
| 14 | + |
| 15 | +_All following steps should be carried out during runtime without powering off in between. If steps are missed and status is unknown, or system has run out of calibration memory, please see section `Resetting Secret`_ |
| 16 | + |
| 17 | +#### Finding Home Position & Calibration Offset figure |
| 18 | +- `{"set":"cal","to":"0"} ` to remove any existing offset |
| 19 | +- Use `{"set":goto","to":"X"}` (int -> goto angle) and `{"set":"move","to":"X"}` (float -> move angle) to position weighted blade in the 12 o'clock or 0 degree position |
| 20 | +- Note down `"pos(raw)"` value from Serial JSON stream. Retain this value as it will be required later. |
| 21 | +- `{"set":"cal","to":"{pos(raw)}"} ` to apply offset. |
| 22 | +<br> |
| 23 | + |
| 24 | +#### Testing Calibration |
| 25 | +- Use `{"set":goto","to":"180"}` to position weighted blade away from home position. |
| 26 | +- Test homing function with `{"set":"home"}`. Weighted blade should return to the home position |
| 27 | +- If nessissary run complete experiment to check for any deviation from nominal data set. |
| 28 | +- Repeat untill happy with system calibration |
| 29 | +- When happy with calibration, move on to `Saving Calibration Data to Persistant Memory` |
| 30 | +- <br> |
| 31 | + |
| 32 | +#### Saving Calibration Data to Persistant Memory |
| 33 | +- use command ` {"set":"setcal","to":"0 - 32k", "auth":"XXXXXXXX"}` using the integer value previously noted down, and the secret entered into persistant memory in the first step. This will error if authorisation secret is incorrect, or the system has run out of available calibrations |
| 34 | +- Use command ` {"set":"getcal"} ` to check contents of persistant memory |
| 35 | +<br> |
| 36 | + |
| 37 | +##### Possible Errors |
| 38 | +- If error `signature did not match` secret may not have been entered |
| 39 | +<br> |
| 40 | + |
| 41 | +#### Resetting Secret |
| 42 | +- To reset secret firmware file must be modified. |
| 43 | +- In file `secretObject.h` find line `#define PROGRAM_SIGNATURE 0xXXXXXXXX` |
| 44 | +- This value is arbitary and simply validates the data stored in persistant memory with the currently installed firmware. |
| 45 | +- Change this value and re-Upload firmware. |
| 46 | +- On boot-up, system will not recognise previous signature and will allow entry of a new secret (though calibration data may still be visible having been recalled from persistant memory -> this will be overwritten when new secret is added) |
| 47 | +<br><br> |
| 48 | + |
| 49 | +_Verbose Command Structure_ |
| 50 | +``` |
| 51 | + {"set":"hz","to": -20 to 20} -> Set Motor Speed in Hz |
| 52 | + {"set":"rpm","to": -200 to 200} -> Set Motor Speed in RPM |
| 53 | + {"set":"home"} -> Move Motor to home pos |
| 54 | + {"set":"cal","to":0-32768} -> Set the home position offset calibration |
| 55 | + {"set":"free"} -> Set freewheel brake mode |
| 56 | + {"set":"brake"} -> Set coolbrake brake mode |
| 57 | + {"set":"goto","to": -360 to 360} -> Goto Angle (int val) |
| 58 | + {"set":"move","to": -360 to 360} -> Move Angle (float val) |
| 59 | + {"set":"sample","to": 1 to 200} -> Set Samplerate in Hz (dflt: 200) |
| 60 | + {"set":"print","to": 1 to 50} -> Set Print Rate in Hz (dflt: 50) |
| 61 | + {"set":"stream"} -> Start Data Streaming |
| 62 | + {"set":"endst"} -> End Data Streaming |
| 63 | + {"set":"snap"} -> Take Data Snapshot |
| 64 | + {"set":"time","to": 1 to 250000 } -> Set Time for Data Snapshot (mS) |
| 65 | + {"set":"ping"} -> Ping Servo |
| 66 | + {"set":"offset","to":-32k to 32k} -> DEPRECIATED |
| 67 | + {"set":"secret","to":"XXXXXXXX"} -> Set 8 character secret |
| 68 | + {"set":"setcal","to":"0 - 32k", "auth":"XXXXXXXX"} -> Set calibration offset to memory |
| 69 | + {"set":"getcal"} -> Load calibration from memory |
| 70 | + {"set":"demo"} -> Run Demo Mode (interrupted by any other command) |
| 71 | + {"set":"help"} -> Print Commands to Serial Monitor |
| 72 | +
|
| 73 | +
|
| 74 | +``` |
| 75 | + |
| 76 | + |
| 77 | +_Succinct Command Structure_ |
| 78 | +``` |
| 79 | + {"hz": -20 to 20} -> Set Motor Speed in Hz |
| 80 | + {"rpm": -200 to 200} -> Set Motor Speed in RPM |
| 81 | + {"home":0}* -> Move Motor to home pos |
| 82 | + {"cal":0-32768} -> Set the home position offset calibration |
| 83 | + {"free":0}* -> Set freewheel brake mode |
| 84 | + {"brake":0}* -> Set coolbrake brake mode |
| 85 | + {"goto": -360 to 360} -> Goto Angle (int val) |
| 86 | + {"move", -360 to 360} -> Move Angle (float val) |
| 87 | + {"sample": 1 to 200} -> Set Samplerate in Hz (dflt: 200) |
| 88 | + {"print": 1 to 50} -> Set Print Rate in Hz (dflt: 50) |
| 89 | + {"stream":0}* -> Start Data Streaming |
| 90 | + {"endst":0}* -> End Data Streaming |
| 91 | + {"snap":0}* -> Take Data Snapshot |
| 92 | + {"time": 1 - 250000 } -> Set Time for Data Snapshot (mS) |
| 93 | + {"ping":0}* -> Ping Servo |
| 94 | + {"offset":-32k to 32k} -> DEPRECIATED |
| 95 | + {"secret":"XXXXXXXX"} -> Set 8 character secret |
| 96 | + {"setcal":"0 - 32k", "auth":"XXXXXXXX"} -> Set calibration offset to memory |
| 97 | + {"getcal":0}* -> Load calibration from memory |
| 98 | + {"demo":0}* -> Run Demo Mode (interrupted by any other command) |
| 99 | + {"help":0}* -> Print Commands to Serial Monitor |
| 100 | +
|
| 101 | +* For single commands data value is ignored but required for valid JSON string |
| 102 | +``` |
| 103 | + |
0 commit comments