Merge pull request #72 from pyr0ball/develop
Add I2C input + addtl features
This commit is contained in:
commit
4239641fc1
35 changed files with 1746 additions and 779 deletions
|
|
@ -1268,4 +1268,193 @@ Changelog updated 2020-01-16_11-24-38
|
||||||
- changed error LED behavor to instead indicate a trigger event [view commit](http://github.com/pyr0ball/pyr0piezo/commit/a1267204d5403a3fcd20f680be75cc6753366ca9)
|
- changed error LED behavor to instead indicate a trigger event [view commit](http://github.com/pyr0ball/pyr0piezo/commit/a1267204d5403a3fcd20f680be75cc6753366ca9)
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
### v2.2.1 to v2.3.0
|
||||||
|
|
||||||
|
Changelog updated 2020-05-10_15-07-19
|
||||||
|
|
||||||
|
*Added Features*
|
||||||
|
|
||||||
|
- Added FFC-X-Mot board for v2.1.2 [view commit](http://github.com/pyr0ball/pyr0piezo/commit/9db036fc1ee13d3b5176fb5bf5b92bc0b1705af0)
|
||||||
|
|
||||||
|
- Added eagle source files for SingleDisk PCB adapters [view commit](http://github.com/pyr0ball/pyr0piezo/commit/6b6d13e08fdaa915b19635e5706014ff1557589d)
|
||||||
|
|
||||||
|
- added configs for new features logic level and pzdet [view commit](http://github.com/pyr0ball/pyr0piezo/commit/a4a9cb90813fc5e266a67536046f3ae7843fea3a)
|
||||||
|
|
||||||
|
- updated eagle parts library to latest [view commit](http://github.com/pyr0ball/pyr0piezo/commit/83e43f34ae264cc559ccf97175229d012f8606b7)
|
||||||
|
|
||||||
|
- Added support for either 5v or 3.3v operation [view commit](http://github.com/pyr0ball/pyr0piezo/commit/b1830500647f918d589c5a2789fab86cfa5f2167)
|
||||||
|
|
||||||
|
- updated parts library with new logo and TH parts [view commit](http://github.com/pyr0ball/pyr0piezo/commit/b4ea4d7b3e801fa4bebc78481b3216e79aae7109)
|
||||||
|
|
||||||
|
- Built pyr0-piezo v2 circuit on a business card [view commit](http://github.com/pyr0ball/pyr0piezo/commit/d41e24f2eadb59d8c6f5cf00d4713b647d4d98bf)
|
||||||
|
|
||||||
|
- added compiled firmware used on MPDM [view commit](http://github.com/pyr0ball/pyr0piezo/commit/8838301821af1c50062aa33850ca78bdb6a1e888)
|
||||||
|
|
||||||
|
- Added code for switching between 3.3v and 5v signal output [view commit](http://github.com/pyr0ball/pyr0piezo/commit/12f86c971b6423e21b550d0ae3377014a091d48b)
|
||||||
|
|
||||||
|
- Serial commands are now case-insensitive [view commit](http://github.com/pyr0ball/pyr0piezo/commit/2f4e42d34a00b0e58e4ca3b12aa95ce10a417e57)
|
||||||
|
|
||||||
|
- Added user-friendty VCC readings adjustment Minor fixes to i2c #bugfix [view commit](http://github.com/pyr0ball/pyr0piezo/commit/65dbe60c877d7df285dea69503dcf04b4e33f95f)
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
*Bugfixes*
|
||||||
|
|
||||||
|
- updated v2.2.0 eagle files with latest library parts [view commit](http://github.com/pyr0ball/pyr0piezo/commit/2e8d5cba4c94b07c971bc0f6fb4b212f942b47e4)
|
||||||
|
|
||||||
|
- gave singledisk pcb a bit more flex for better sensitivity [view commit](http://github.com/pyr0ball/pyr0piezo/commit/0de1676e642282700ff34fe56c29fd853e1f06e2)
|
||||||
|
|
||||||
|
- updated piezoPCB singledisk for better actuation [view commit](http://github.com/pyr0ball/pyr0piezo/commit/effa5c7d7faf5e5383f9e7b8dcab6c5f0658d752)
|
||||||
|
|
||||||
|
- trying to eliminate those pesky lbr temp files again [view commit](http://github.com/pyr0ball/pyr0piezo/commit/db0e457450fa9ba14a52c7b514dc4d7800f73a21)
|
||||||
|
|
||||||
|
- Added user-friendty VCC readings adjustment #featureadd Minor fixes to i2c [view commit](http://github.com/pyr0ball/pyr0piezo/commit/65dbe60c877d7df285dea69503dcf04b4e33f95f)
|
||||||
|
|
||||||
|
- fixed string concatentate issue on version_git.py [view commit](http://github.com/pyr0ball/pyr0piezo/commit/74eabff95006689712e1e82c747ca5aed931c24f)
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
*Documentation Updates*
|
||||||
|
|
||||||
|
- updated internal version with latest commit [view commit](http://github.com/pyr0ball/pyr0piezo/commit/3f5af8ced7dc1dfc5b8074e8f6127acd8a35957a)
|
||||||
|
|
||||||
|
- updated circuit explanation docs [view commit](http://github.com/pyr0ball/pyr0piezo/commit/91b72b71a10293e891dcd5d7f01b6684f2775397)
|
||||||
|
|
||||||
|
- Added installation tutorial for MPDM [view commit](http://github.com/pyr0ball/pyr0piezo/commit/067c4c0df390b468aa43b1285c58c6f5e602a4ed)
|
||||||
|
|
||||||
|
- fixed typo and missing image asset on install page [view commit](http://github.com/pyr0ball/pyr0piezo/commit/529485f75a239028bec144c34d826c6e769c535d)
|
||||||
|
|
||||||
|
- added a little more info about gettin support to installation page [view commit](http://github.com/pyr0ball/pyr0piezo/commit/e625f5fcaf89aa806cfd58b865e57ec195017f2a)
|
||||||
|
|
||||||
|
- Fixed links to images in a couple of pages [view commit](http://github.com/pyr0ball/pyr0piezo/commit/3955912fb1bd1ec780ddd105a04e84ff1cf5a2d8)
|
||||||
|
|
||||||
|
- Added paypal.me donation link to docs site [view commit](http://github.com/pyr0ball/pyr0piezo/commit/83997a2fab4375cddff9256202e29f0b1f4d4e3f)
|
||||||
|
|
||||||
|
- formatting fix for markdown in pt100 page [view commit](http://github.com/pyr0ball/pyr0piezo/commit/3b46a42023dd5dc6e368d0758cb93247772f33ad)
|
||||||
|
|
||||||
|
- Code comments/formatting [view commit](http://github.com/pyr0ball/pyr0piezo/commit/7086002db535978ebb8bbd9deb0b0a25816f8a55)
|
||||||
|
|
||||||
|
- fixed incorrect annotation on one config [view commit](http://github.com/pyr0ball/pyr0piezo/commit/a44ed2556f393929b5706f03524492a56760e9a8)
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
*Full Changelog*
|
||||||
|
|
||||||
|
- updated readme [view commit](http://github.com/pyr0ball/pyr0piezo/commit/4300c905516beb5e0963778b450ec2463ccec9f0)
|
||||||
|
|
||||||
|
- #feature Autogenerating version number [view commit](http://github.com/pyr0ball/pyr0piezo/commit/5cf9c4e94a3b14414befba0423b0cb3273846a4c)
|
||||||
|
|
||||||
|
- updated internal version with latest commit [view commit](http://github.com/pyr0ball/pyr0piezo/commit/3f5af8ced7dc1dfc5b8074e8f6127acd8a35957a)
|
||||||
|
|
||||||
|
- Merge branch 'develop' into master [view commit](http://github.com/pyr0ball/pyr0piezo/commit/052023eb7947be76b7c6ac7a7e4dcd39207122b4)
|
||||||
|
|
||||||
|
- Merge pull request #64 from loredan/master [view commit](http://github.com/pyr0ball/pyr0piezo/commit/ca0669d7dffa44ea5e437aef12aec28bc39d7829)
|
||||||
|
|
||||||
|
- Added FFC-X-Mot board for v2.1.2 [view commit](http://github.com/pyr0ball/pyr0piezo/commit/9db036fc1ee13d3b5176fb5bf5b92bc0b1705af0)
|
||||||
|
|
||||||
|
- Added eagle source files for SingleDisk PCB adapters [view commit](http://github.com/pyr0ball/pyr0piezo/commit/6b6d13e08fdaa915b19635e5706014ff1557589d)
|
||||||
|
|
||||||
|
- added configs for new features logic level and pzdet [view commit](http://github.com/pyr0ball/pyr0piezo/commit/a4a9cb90813fc5e266a67536046f3ae7843fea3a)
|
||||||
|
|
||||||
|
- updated v2.2.0 eagle files with latest library parts [view commit](http://github.com/pyr0ball/pyr0piezo/commit/2e8d5cba4c94b07c971bc0f6fb4b212f942b47e4)
|
||||||
|
|
||||||
|
- updated eagle parts library to latest [view commit](http://github.com/pyr0ball/pyr0piezo/commit/83e43f34ae264cc559ccf97175229d012f8606b7)
|
||||||
|
|
||||||
|
- updated eagle project file with latest library urn [view commit](http://github.com/pyr0ball/pyr0piezo/commit/62c459e0dc21a6f95cb10052ce2009102c441938)
|
||||||
|
|
||||||
|
- gave singledisk pcb a bit more flex for better sensitivity [view commit](http://github.com/pyr0ball/pyr0piezo/commit/0de1676e642282700ff34fe56c29fd853e1f06e2)
|
||||||
|
|
||||||
|
- Merge branch 'master' of https://github.com/pyr0ball/pyr0piezo into develop [view commit](http://github.com/pyr0ball/pyr0piezo/commit/61995934eb96a093d42fb98284abd59c655b2741)
|
||||||
|
|
||||||
|
- Merge branch 'develop' of https://github.com/pyr0ball/pyr0piezo into develop [view commit](http://github.com/pyr0ball/pyr0piezo/commit/76fb8c36310b9d08ca59388e83678511cce2491d)
|
||||||
|
|
||||||
|
- Merge pull request #65 from pyr0ball/develop [view commit](http://github.com/pyr0ball/pyr0piezo/commit/65f941cd0680d61e33342ae1d4a51e85a2202633)
|
||||||
|
|
||||||
|
- added eagle library backup files to gitignore [view commit](http://github.com/pyr0ball/pyr0piezo/commit/d203ce5e9617a2120a04a04697e361f0435a15da)
|
||||||
|
|
||||||
|
- updated gitignore with eagle library temp files [view commit](http://github.com/pyr0ball/pyr0piezo/commit/4c6e21e67ab8cc35e0c6a46edd24b5490e4426cf)
|
||||||
|
|
||||||
|
- updated eagle library with latest parts [view commit](http://github.com/pyr0ball/pyr0piezo/commit/43e04a3e90131085a976a528813d200e5ed1e2d6)
|
||||||
|
|
||||||
|
- Update to README [view commit](http://github.com/pyr0ball/pyr0piezo/commit/82dd63f11111d0ddbd11bed4a46ad8f5200f0623)
|
||||||
|
|
||||||
|
- updated piezoPCB singledisk for better actuation [view commit](http://github.com/pyr0ball/pyr0piezo/commit/effa5c7d7faf5e5383f9e7b8dcab6c5f0658d752)
|
||||||
|
|
||||||
|
- trying to eliminate those pesky lbr temp files again [view commit](http://github.com/pyr0ball/pyr0piezo/commit/db0e457450fa9ba14a52c7b514dc4d7800f73a21)
|
||||||
|
|
||||||
|
- updated circuit explanation docs [view commit](http://github.com/pyr0ball/pyr0piezo/commit/91b72b71a10293e891dcd5d7f01b6684f2775397)
|
||||||
|
|
||||||
|
- Merge branch 'master' of https://github.com/pyr0ball/pyr0piezo [view commit](http://github.com/pyr0ball/pyr0piezo/commit/fd7fa2b3bdc8c2474bbcb2d7e7d2e5c7559e1859)
|
||||||
|
|
||||||
|
- Added separate cmd file [view commit](http://github.com/pyr0ball/pyr0piezo/commit/30afcdd8b7be6f0fd13ab5e50c1eb692173c7a66)
|
||||||
|
|
||||||
|
- Attempt at fixing compile error [view commit](http://github.com/pyr0ball/pyr0piezo/commit/36b6402b2e1bf0a174e935cc42dd0559d939d87c)
|
||||||
|
|
||||||
|
- Separating declaration and definition - volatile [view commit](http://github.com/pyr0ball/pyr0piezo/commit/bf800e99409aa2a77a68f65a6380e21cf10abf8a)
|
||||||
|
|
||||||
|
- More separation of declaration and definition [view commit](http://github.com/pyr0ball/pyr0piezo/commit/60a26ad3f713238cdc536b0302aa6de5a44fa6f2)
|
||||||
|
|
||||||
|
- Added installation tutorial for MPDM [view commit](http://github.com/pyr0ball/pyr0piezo/commit/067c4c0df390b468aa43b1285c58c6f5e602a4ed)
|
||||||
|
|
||||||
|
- fixed typo and missing image asset on install page [view commit](http://github.com/pyr0ball/pyr0piezo/commit/529485f75a239028bec144c34d826c6e769c535d)
|
||||||
|
|
||||||
|
- added a little more info about gettin support to installation page [view commit](http://github.com/pyr0ball/pyr0piezo/commit/e625f5fcaf89aa806cfd58b865e57ec195017f2a)
|
||||||
|
|
||||||
|
- updated gitignore for CAM outputs under Eagle_Files [view commit](http://github.com/pyr0ball/pyr0piezo/commit/1efaf53379f11a3136bee61716f45fb0534af48b)
|
||||||
|
|
||||||
|
- Added support for either 5v or 3.3v operation [view commit](http://github.com/pyr0ball/pyr0piezo/commit/b1830500647f918d589c5a2789fab86cfa5f2167)
|
||||||
|
|
||||||
|
- updated parts library with new logo and TH parts [view commit](http://github.com/pyr0ball/pyr0piezo/commit/b4ea4d7b3e801fa4bebc78481b3216e79aae7109)
|
||||||
|
|
||||||
|
- Built pyr0-piezo v2 circuit on a business card [view commit](http://github.com/pyr0ball/pyr0piezo/commit/d41e24f2eadb59d8c6f5cf00d4713b647d4d98bf)
|
||||||
|
|
||||||
|
- added compiled firmware used on MPDM [view commit](http://github.com/pyr0ball/pyr0piezo/commit/8838301821af1c50062aa33850ca78bdb6a1e888)
|
||||||
|
|
||||||
|
- Pull latest changes from master into develop [view commit](http://github.com/pyr0ball/pyr0piezo/commit/c4fc40fa818a78b452a2bdc85cb7c610f2daf903)
|
||||||
|
|
||||||
|
- Merge pull request #68 from loredan/master [view commit](http://github.com/pyr0ball/pyr0piezo/commit/c521adccd33b6d8597e7da8c751769d26fd7cbe2)
|
||||||
|
|
||||||
|
- Added code for switching between 3.3v and 5v signal output [view commit](http://github.com/pyr0ball/pyr0piezo/commit/12f86c971b6423e21b550d0ae3377014a091d48b)
|
||||||
|
|
||||||
|
- Finished business card design [view commit](http://github.com/pyr0ball/pyr0piezo/commit/8d2174d549d7c7d12a626af161ca07902a616246)
|
||||||
|
|
||||||
|
- Formatting [view commit](http://github.com/pyr0ball/pyr0piezo/commit/f2c3843668c0c5cf79aa38b490d3b087d26d91ec)
|
||||||
|
|
||||||
|
- i2c support, not tested #feature [view commit](http://github.com/pyr0ball/pyr0piezo/commit/02d734b177014aa8d2fc55b756e8568df9544931)
|
||||||
|
|
||||||
|
- Added i2c bridge sketch [view commit](http://github.com/pyr0ball/pyr0piezo/commit/57d11c5b97227ff954a04ad26cda8fe61bfe7241)
|
||||||
|
|
||||||
|
- Correct I2C port now used, fixed config and state reply [view commit](http://github.com/pyr0ball/pyr0piezo/commit/46fc068619dfae9bec039a5e430702ed039f5fff)
|
||||||
|
|
||||||
|
- Merge branch 'develop' of https://github.com/pyr0ball/pyr0piezo [view commit](http://github.com/pyr0ball/pyr0piezo/commit/b3cc47daad9a0a4e9e4517dcdfe4aa05ce0ae3bc)
|
||||||
|
|
||||||
|
- Added VCC switch to I2C [view commit](http://github.com/pyr0ball/pyr0piezo/commit/21f7ee25fed4163b46f0cfd30ddc90b16c9d8a50)
|
||||||
|
|
||||||
|
- Fixed links to images in a couple of pages [view commit](http://github.com/pyr0ball/pyr0piezo/commit/3955912fb1bd1ec780ddd105a04e84ff1cf5a2d8)
|
||||||
|
|
||||||
|
- Added paypal.me donation link to docs site [view commit](http://github.com/pyr0ball/pyr0piezo/commit/83997a2fab4375cddff9256202e29f0b1f4d4e3f)
|
||||||
|
|
||||||
|
- fixed syntax error in pt100 page [view commit](http://github.com/pyr0ball/pyr0piezo/commit/acb2e7cee714cae4cdbaaf007af572315ee8e1ef)
|
||||||
|
|
||||||
|
- Merge pull request #70 from loredan/master [view commit](http://github.com/pyr0ball/pyr0piezo/commit/ce91ff63ddbf9a93051e909930894cf10b6faba5)
|
||||||
|
|
||||||
|
- Merge branch 'master' of https://github.com/pyr0ball/pyr0piezo into develop [view commit](http://github.com/pyr0ball/pyr0piezo/commit/b45315f3b53e765771f010d0f22c3864423477c9)
|
||||||
|
|
||||||
|
- Serial commands are now case-insensitive [view commit](http://github.com/pyr0ball/pyr0piezo/commit/2f4e42d34a00b0e58e4ca3b12aa95ce10a417e57)
|
||||||
|
|
||||||
|
- Added user-friendty VCC readings adjustment Minor fixes to i2c [view commit](http://github.com/pyr0ball/pyr0piezo/commit/65dbe60c877d7df285dea69503dcf04b4e33f95f)
|
||||||
|
|
||||||
|
- Merge pull request #71 from loredan/master [view commit](http://github.com/pyr0ball/pyr0piezo/commit/1ea927ecd9c4be146695a829b980e3383231ba26)
|
||||||
|
|
||||||
|
- formatting fix for markdown in pt100 page [view commit](http://github.com/pyr0ball/pyr0piezo/commit/3b46a42023dd5dc6e368d0758cb93247772f33ad)
|
||||||
|
|
||||||
|
- Code comments/formatting [view commit](http://github.com/pyr0ball/pyr0piezo/commit/7086002db535978ebb8bbd9deb0b0a25816f8a55)
|
||||||
|
|
||||||
|
- fixed incorrect annotation on one config [view commit](http://github.com/pyr0ball/pyr0piezo/commit/a44ed2556f393929b5706f03524492a56760e9a8)
|
||||||
|
|
||||||
|
- fixed string concatentate issue on version_git.py [view commit](http://github.com/pyr0ball/pyr0piezo/commit/74eabff95006689712e1e82c747ca5aed931c24f)
|
||||||
|
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
|
||||||
183
docs/changelogs/changelog_2020-05-10_v2.2.1_v2.3.0.md
Normal file
183
docs/changelogs/changelog_2020-05-10_v2.2.1_v2.3.0.md
Normal file
|
|
@ -0,0 +1,183 @@
|
||||||
|
###Pyr0-Piezo Changelog v2.2.1 to v2.3.0
|
||||||
|
|
||||||
|
#### Added Features
|
||||||
|
|
||||||
|
- Added FFC-X-Mot board for v2.1.2 [view commit](http://github.com/pyr0ball/pyr0piezo/commit/9db036fc1ee13d3b5176fb5bf5b92bc0b1705af0)
|
||||||
|
|
||||||
|
- Added eagle source files for SingleDisk PCB adapters [view commit](http://github.com/pyr0ball/pyr0piezo/commit/6b6d13e08fdaa915b19635e5706014ff1557589d)
|
||||||
|
|
||||||
|
- added configs for new features logic level and pzdet [view commit](http://github.com/pyr0ball/pyr0piezo/commit/a4a9cb90813fc5e266a67536046f3ae7843fea3a)
|
||||||
|
|
||||||
|
- updated eagle parts library to latest [view commit](http://github.com/pyr0ball/pyr0piezo/commit/83e43f34ae264cc559ccf97175229d012f8606b7)
|
||||||
|
|
||||||
|
- Added support for either 5v or 3.3v operation [view commit](http://github.com/pyr0ball/pyr0piezo/commit/b1830500647f918d589c5a2789fab86cfa5f2167)
|
||||||
|
|
||||||
|
- updated parts library with new logo and TH parts [view commit](http://github.com/pyr0ball/pyr0piezo/commit/b4ea4d7b3e801fa4bebc78481b3216e79aae7109)
|
||||||
|
|
||||||
|
- Built pyr0-piezo v2 circuit on a business card [view commit](http://github.com/pyr0ball/pyr0piezo/commit/d41e24f2eadb59d8c6f5cf00d4713b647d4d98bf)
|
||||||
|
|
||||||
|
- added compiled firmware used on MPDM [view commit](http://github.com/pyr0ball/pyr0piezo/commit/8838301821af1c50062aa33850ca78bdb6a1e888)
|
||||||
|
|
||||||
|
- Added code for switching between 3.3v and 5v signal output [view commit](http://github.com/pyr0ball/pyr0piezo/commit/12f86c971b6423e21b550d0ae3377014a091d48b)
|
||||||
|
|
||||||
|
- Serial commands are now case-insensitive [view commit](http://github.com/pyr0ball/pyr0piezo/commit/2f4e42d34a00b0e58e4ca3b12aa95ce10a417e57)
|
||||||
|
|
||||||
|
- Added user-friendty VCC readings adjustment Minor fixes to i2c #bugfix [view commit](http://github.com/pyr0ball/pyr0piezo/commit/65dbe60c877d7df285dea69503dcf04b4e33f95f)
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
#### Bugfixes
|
||||||
|
|
||||||
|
- updated v2.2.0 eagle files with latest library parts [view commit](http://github.com/pyr0ball/pyr0piezo/commit/2e8d5cba4c94b07c971bc0f6fb4b212f942b47e4)
|
||||||
|
|
||||||
|
- gave singledisk pcb a bit more flex for better sensitivity [view commit](http://github.com/pyr0ball/pyr0piezo/commit/0de1676e642282700ff34fe56c29fd853e1f06e2)
|
||||||
|
|
||||||
|
- updated piezoPCB singledisk for better actuation [view commit](http://github.com/pyr0ball/pyr0piezo/commit/effa5c7d7faf5e5383f9e7b8dcab6c5f0658d752)
|
||||||
|
|
||||||
|
- trying to eliminate those pesky lbr temp files again [view commit](http://github.com/pyr0ball/pyr0piezo/commit/db0e457450fa9ba14a52c7b514dc4d7800f73a21)
|
||||||
|
|
||||||
|
- Added user-friendty VCC readings adjustment #featureadd Minor fixes to i2c [view commit](http://github.com/pyr0ball/pyr0piezo/commit/65dbe60c877d7df285dea69503dcf04b4e33f95f)
|
||||||
|
|
||||||
|
- fixed string concatentate issue on version_git.py [view commit](http://github.com/pyr0ball/pyr0piezo/commit/74eabff95006689712e1e82c747ca5aed931c24f)
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
#### Documentation Updates
|
||||||
|
|
||||||
|
- updated internal version with latest commit [view commit](http://github.com/pyr0ball/pyr0piezo/commit/3f5af8ced7dc1dfc5b8074e8f6127acd8a35957a)
|
||||||
|
|
||||||
|
- updated circuit explanation docs [view commit](http://github.com/pyr0ball/pyr0piezo/commit/91b72b71a10293e891dcd5d7f01b6684f2775397)
|
||||||
|
|
||||||
|
- Added installation tutorial for MPDM [view commit](http://github.com/pyr0ball/pyr0piezo/commit/067c4c0df390b468aa43b1285c58c6f5e602a4ed)
|
||||||
|
|
||||||
|
- fixed typo and missing image asset on install page [view commit](http://github.com/pyr0ball/pyr0piezo/commit/529485f75a239028bec144c34d826c6e769c535d)
|
||||||
|
|
||||||
|
- added a little more info about gettin support to installation page [view commit](http://github.com/pyr0ball/pyr0piezo/commit/e625f5fcaf89aa806cfd58b865e57ec195017f2a)
|
||||||
|
|
||||||
|
- Fixed links to images in a couple of pages [view commit](http://github.com/pyr0ball/pyr0piezo/commit/3955912fb1bd1ec780ddd105a04e84ff1cf5a2d8)
|
||||||
|
|
||||||
|
- Added paypal.me donation link to docs site [view commit](http://github.com/pyr0ball/pyr0piezo/commit/83997a2fab4375cddff9256202e29f0b1f4d4e3f)
|
||||||
|
|
||||||
|
- formatting fix for markdown in pt100 page [view commit](http://github.com/pyr0ball/pyr0piezo/commit/3b46a42023dd5dc6e368d0758cb93247772f33ad)
|
||||||
|
|
||||||
|
- Code comments/formatting [view commit](http://github.com/pyr0ball/pyr0piezo/commit/7086002db535978ebb8bbd9deb0b0a25816f8a55)
|
||||||
|
|
||||||
|
- fixed incorrect annotation on one config [view commit](http://github.com/pyr0ball/pyr0piezo/commit/a44ed2556f393929b5706f03524492a56760e9a8)
|
||||||
|
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
#### Full Changelog
|
||||||
|
|
||||||
|
- updated readme [view commit](http://github.com/pyr0ball/pyr0piezo/commit/4300c905516beb5e0963778b450ec2463ccec9f0)
|
||||||
|
|
||||||
|
- #feature Autogenerating version number [view commit](http://github.com/pyr0ball/pyr0piezo/commit/5cf9c4e94a3b14414befba0423b0cb3273846a4c)
|
||||||
|
|
||||||
|
- updated internal version with latest commit [view commit](http://github.com/pyr0ball/pyr0piezo/commit/3f5af8ced7dc1dfc5b8074e8f6127acd8a35957a)
|
||||||
|
|
||||||
|
- Merge branch 'develop' into master [view commit](http://github.com/pyr0ball/pyr0piezo/commit/052023eb7947be76b7c6ac7a7e4dcd39207122b4)
|
||||||
|
|
||||||
|
- Merge pull request #64 from loredan/master [view commit](http://github.com/pyr0ball/pyr0piezo/commit/ca0669d7dffa44ea5e437aef12aec28bc39d7829)
|
||||||
|
|
||||||
|
- Added FFC-X-Mot board for v2.1.2 [view commit](http://github.com/pyr0ball/pyr0piezo/commit/9db036fc1ee13d3b5176fb5bf5b92bc0b1705af0)
|
||||||
|
|
||||||
|
- Added eagle source files for SingleDisk PCB adapters [view commit](http://github.com/pyr0ball/pyr0piezo/commit/6b6d13e08fdaa915b19635e5706014ff1557589d)
|
||||||
|
|
||||||
|
- added configs for new features logic level and pzdet [view commit](http://github.com/pyr0ball/pyr0piezo/commit/a4a9cb90813fc5e266a67536046f3ae7843fea3a)
|
||||||
|
|
||||||
|
- updated v2.2.0 eagle files with latest library parts [view commit](http://github.com/pyr0ball/pyr0piezo/commit/2e8d5cba4c94b07c971bc0f6fb4b212f942b47e4)
|
||||||
|
|
||||||
|
- updated eagle parts library to latest [view commit](http://github.com/pyr0ball/pyr0piezo/commit/83e43f34ae264cc559ccf97175229d012f8606b7)
|
||||||
|
|
||||||
|
- updated eagle project file with latest library urn [view commit](http://github.com/pyr0ball/pyr0piezo/commit/62c459e0dc21a6f95cb10052ce2009102c441938)
|
||||||
|
|
||||||
|
- gave singledisk pcb a bit more flex for better sensitivity [view commit](http://github.com/pyr0ball/pyr0piezo/commit/0de1676e642282700ff34fe56c29fd853e1f06e2)
|
||||||
|
|
||||||
|
- Merge branch 'master' of https://github.com/pyr0ball/pyr0piezo into develop [view commit](http://github.com/pyr0ball/pyr0piezo/commit/61995934eb96a093d42fb98284abd59c655b2741)
|
||||||
|
|
||||||
|
- Merge branch 'develop' of https://github.com/pyr0ball/pyr0piezo into develop [view commit](http://github.com/pyr0ball/pyr0piezo/commit/76fb8c36310b9d08ca59388e83678511cce2491d)
|
||||||
|
|
||||||
|
- Merge pull request #65 from pyr0ball/develop [view commit](http://github.com/pyr0ball/pyr0piezo/commit/65f941cd0680d61e33342ae1d4a51e85a2202633)
|
||||||
|
|
||||||
|
- added eagle library backup files to gitignore [view commit](http://github.com/pyr0ball/pyr0piezo/commit/d203ce5e9617a2120a04a04697e361f0435a15da)
|
||||||
|
|
||||||
|
- updated gitignore with eagle library temp files [view commit](http://github.com/pyr0ball/pyr0piezo/commit/4c6e21e67ab8cc35e0c6a46edd24b5490e4426cf)
|
||||||
|
|
||||||
|
- updated eagle library with latest parts [view commit](http://github.com/pyr0ball/pyr0piezo/commit/43e04a3e90131085a976a528813d200e5ed1e2d6)
|
||||||
|
|
||||||
|
- Update to README [view commit](http://github.com/pyr0ball/pyr0piezo/commit/82dd63f11111d0ddbd11bed4a46ad8f5200f0623)
|
||||||
|
|
||||||
|
- updated piezoPCB singledisk for better actuation [view commit](http://github.com/pyr0ball/pyr0piezo/commit/effa5c7d7faf5e5383f9e7b8dcab6c5f0658d752)
|
||||||
|
|
||||||
|
- trying to eliminate those pesky lbr temp files again [view commit](http://github.com/pyr0ball/pyr0piezo/commit/db0e457450fa9ba14a52c7b514dc4d7800f73a21)
|
||||||
|
|
||||||
|
- updated circuit explanation docs [view commit](http://github.com/pyr0ball/pyr0piezo/commit/91b72b71a10293e891dcd5d7f01b6684f2775397)
|
||||||
|
|
||||||
|
- Merge branch 'master' of https://github.com/pyr0ball/pyr0piezo [view commit](http://github.com/pyr0ball/pyr0piezo/commit/fd7fa2b3bdc8c2474bbcb2d7e7d2e5c7559e1859)
|
||||||
|
|
||||||
|
- Added separate cmd file [view commit](http://github.com/pyr0ball/pyr0piezo/commit/30afcdd8b7be6f0fd13ab5e50c1eb692173c7a66)
|
||||||
|
|
||||||
|
- Attempt at fixing compile error [view commit](http://github.com/pyr0ball/pyr0piezo/commit/36b6402b2e1bf0a174e935cc42dd0559d939d87c)
|
||||||
|
|
||||||
|
- Separating declaration and definition - volatile [view commit](http://github.com/pyr0ball/pyr0piezo/commit/bf800e99409aa2a77a68f65a6380e21cf10abf8a)
|
||||||
|
|
||||||
|
- More separation of declaration and definition [view commit](http://github.com/pyr0ball/pyr0piezo/commit/60a26ad3f713238cdc536b0302aa6de5a44fa6f2)
|
||||||
|
|
||||||
|
- Added installation tutorial for MPDM [view commit](http://github.com/pyr0ball/pyr0piezo/commit/067c4c0df390b468aa43b1285c58c6f5e602a4ed)
|
||||||
|
|
||||||
|
- fixed typo and missing image asset on install page [view commit](http://github.com/pyr0ball/pyr0piezo/commit/529485f75a239028bec144c34d826c6e769c535d)
|
||||||
|
|
||||||
|
- added a little more info about gettin support to installation page [view commit](http://github.com/pyr0ball/pyr0piezo/commit/e625f5fcaf89aa806cfd58b865e57ec195017f2a)
|
||||||
|
|
||||||
|
- updated gitignore for CAM outputs under Eagle_Files [view commit](http://github.com/pyr0ball/pyr0piezo/commit/1efaf53379f11a3136bee61716f45fb0534af48b)
|
||||||
|
|
||||||
|
- Added support for either 5v or 3.3v operation [view commit](http://github.com/pyr0ball/pyr0piezo/commit/b1830500647f918d589c5a2789fab86cfa5f2167)
|
||||||
|
|
||||||
|
- updated parts library with new logo and TH parts [view commit](http://github.com/pyr0ball/pyr0piezo/commit/b4ea4d7b3e801fa4bebc78481b3216e79aae7109)
|
||||||
|
|
||||||
|
- Built pyr0-piezo v2 circuit on a business card [view commit](http://github.com/pyr0ball/pyr0piezo/commit/d41e24f2eadb59d8c6f5cf00d4713b647d4d98bf)
|
||||||
|
|
||||||
|
- added compiled firmware used on MPDM [view commit](http://github.com/pyr0ball/pyr0piezo/commit/8838301821af1c50062aa33850ca78bdb6a1e888)
|
||||||
|
|
||||||
|
- Pull latest changes from master into develop [view commit](http://github.com/pyr0ball/pyr0piezo/commit/c4fc40fa818a78b452a2bdc85cb7c610f2daf903)
|
||||||
|
|
||||||
|
- Merge pull request #68 from loredan/master [view commit](http://github.com/pyr0ball/pyr0piezo/commit/c521adccd33b6d8597e7da8c751769d26fd7cbe2)
|
||||||
|
|
||||||
|
- Added code for switching between 3.3v and 5v signal output [view commit](http://github.com/pyr0ball/pyr0piezo/commit/12f86c971b6423e21b550d0ae3377014a091d48b)
|
||||||
|
|
||||||
|
- Finished business card design [view commit](http://github.com/pyr0ball/pyr0piezo/commit/8d2174d549d7c7d12a626af161ca07902a616246)
|
||||||
|
|
||||||
|
- Formatting [view commit](http://github.com/pyr0ball/pyr0piezo/commit/f2c3843668c0c5cf79aa38b490d3b087d26d91ec)
|
||||||
|
|
||||||
|
- i2c support, not tested #feature [view commit](http://github.com/pyr0ball/pyr0piezo/commit/02d734b177014aa8d2fc55b756e8568df9544931)
|
||||||
|
|
||||||
|
- Added i2c bridge sketch [view commit](http://github.com/pyr0ball/pyr0piezo/commit/57d11c5b97227ff954a04ad26cda8fe61bfe7241)
|
||||||
|
|
||||||
|
- Correct I2C port now used, fixed config and state reply [view commit](http://github.com/pyr0ball/pyr0piezo/commit/46fc068619dfae9bec039a5e430702ed039f5fff)
|
||||||
|
|
||||||
|
- Merge branch 'develop' of https://github.com/pyr0ball/pyr0piezo [view commit](http://github.com/pyr0ball/pyr0piezo/commit/b3cc47daad9a0a4e9e4517dcdfe4aa05ce0ae3bc)
|
||||||
|
|
||||||
|
- Added VCC switch to I2C [view commit](http://github.com/pyr0ball/pyr0piezo/commit/21f7ee25fed4163b46f0cfd30ddc90b16c9d8a50)
|
||||||
|
|
||||||
|
- Fixed links to images in a couple of pages [view commit](http://github.com/pyr0ball/pyr0piezo/commit/3955912fb1bd1ec780ddd105a04e84ff1cf5a2d8)
|
||||||
|
|
||||||
|
- Added paypal.me donation link to docs site [view commit](http://github.com/pyr0ball/pyr0piezo/commit/83997a2fab4375cddff9256202e29f0b1f4d4e3f)
|
||||||
|
|
||||||
|
- fixed syntax error in pt100 page [view commit](http://github.com/pyr0ball/pyr0piezo/commit/acb2e7cee714cae4cdbaaf007af572315ee8e1ef)
|
||||||
|
|
||||||
|
- Merge pull request #70 from loredan/master [view commit](http://github.com/pyr0ball/pyr0piezo/commit/ce91ff63ddbf9a93051e909930894cf10b6faba5)
|
||||||
|
|
||||||
|
- Merge branch 'master' of https://github.com/pyr0ball/pyr0piezo into develop [view commit](http://github.com/pyr0ball/pyr0piezo/commit/b45315f3b53e765771f010d0f22c3864423477c9)
|
||||||
|
|
||||||
|
- Serial commands are now case-insensitive [view commit](http://github.com/pyr0ball/pyr0piezo/commit/2f4e42d34a00b0e58e4ca3b12aa95ce10a417e57)
|
||||||
|
|
||||||
|
- Added user-friendty VCC readings adjustment Minor fixes to i2c [view commit](http://github.com/pyr0ball/pyr0piezo/commit/65dbe60c877d7df285dea69503dcf04b4e33f95f)
|
||||||
|
|
||||||
|
- Merge pull request #71 from loredan/master [view commit](http://github.com/pyr0ball/pyr0piezo/commit/1ea927ecd9c4be146695a829b980e3383231ba26)
|
||||||
|
|
||||||
|
- formatting fix for markdown in pt100 page [view commit](http://github.com/pyr0ball/pyr0piezo/commit/3b46a42023dd5dc6e368d0758cb93247772f33ad)
|
||||||
|
|
||||||
|
- Code comments/formatting [view commit](http://github.com/pyr0ball/pyr0piezo/commit/7086002db535978ebb8bbd9deb0b0a25816f8a55)
|
||||||
|
|
||||||
|
- fixed incorrect annotation on one config [view commit](http://github.com/pyr0ball/pyr0piezo/commit/a44ed2556f393929b5706f03524492a56760e9a8)
|
||||||
|
|
||||||
|
- fixed string concatentate issue on version_git.py [view commit](http://github.com/pyr0ball/pyr0piezo/commit/74eabff95006689712e1e82c747ca5aed931c24f)
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
### PT100 RTD Thermal Sensor Integration
|
# PT100 RTD Thermal Sensor Integration
|
||||||
|
|
||||||
The EasyPiezi (Rev 1.1.x and Rev 2.x.x) utilize an extra amp channel to allow the use of a PT100 RTD Thermal sensor with minimal additional components. The circuit is based on E3D's daughterboard designed for PT100 sensors.
|
The EasyPiezi (Rev 1.1.x and Rev 2.x.x) utilize an extra amp channel to allow the use of a PT100 RTD Thermal sensor with minimal additional components. The circuit is based on E3D's daughterboard designed for PT100 sensors.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
ColumnLimit: 200
|
||||||
|
AllowShortFunctionsOnASingleLine: false
|
||||||
|
|
@ -32,15 +32,15 @@
|
||||||
#endif
|
#endif
|
||||||
#include "LightChrono.h"
|
#include "LightChrono.h"
|
||||||
|
|
||||||
LightChrono::LightChrono()
|
LightChrono::LightChrono() {
|
||||||
{
|
|
||||||
restart();
|
restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightChrono::start() { restart(); }
|
void LightChrono::start() {
|
||||||
|
restart();
|
||||||
|
}
|
||||||
|
|
||||||
void LightChrono::restart()
|
void LightChrono::restart() {
|
||||||
{
|
|
||||||
_startTime = millis();
|
_startTime = millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,8 +48,7 @@ LightChrono::chrono_t LightChrono::elapsed() const {
|
||||||
return (millis() - _startTime);
|
return (millis() - _startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LightChrono::hasPassed(LightChrono::chrono_t timeout) const
|
bool LightChrono::hasPassed(LightChrono::chrono_t timeout) const {
|
||||||
{
|
|
||||||
return (elapsed() >= timeout);
|
return (elapsed() >= timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,10 +57,7 @@ bool LightChrono::hasPassed(LightChrono::chrono_t timeout, bool restartIfPassed)
|
||||||
if (restartIfPassed)
|
if (restartIfPassed)
|
||||||
restart();
|
restart();
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,7 @@
|
||||||
* // do something
|
* // do something
|
||||||
* // ...
|
* // ...
|
||||||
*/
|
*/
|
||||||
class LightChrono
|
class LightChrono {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
#if defined(ARDUINO_ARC32_TOOLS)
|
#if defined(ARDUINO_ARC32_TOOLS)
|
||||||
typedef uint64_t chrono_t;
|
typedef uint64_t chrono_t;
|
||||||
|
|
@ -68,5 +67,3 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,11 @@
|
||||||
* PC0 ADC0 (Voltage Reference Check 'A0')
|
* PC0 ADC0 (Voltage Reference Check 'A0')
|
||||||
* PC1 ADC1 (Sensitivity Adjustment Check 'A1')
|
* PC1 ADC1 (Sensitivity Adjustment Check 'A1')
|
||||||
* PD4 PCINT20 (Error feedback LED 'D4')
|
* PD4 PCINT20 (Error feedback LED 'D4')
|
||||||
* PB6 PCINT6 (Voltage Adjustment Resistor 0 'D20')
|
* PB6 PCINT6 (Gain Adjustment Resistor 0 'D20')
|
||||||
* PB7 PCINT7 (Voltage Adjustment Resistor 1 'D21')
|
* PB7 PCINT7 (Gain Adjustment Resistor 1 'D21')
|
||||||
* PD5 T1 (Voltage Adjustment Resistor 2 'D5')
|
* PD5 T1 (Gain Adjustment Resistor 2 'D5')
|
||||||
* PD6 PCINT22 (Voltage Adjustment Resistor 3 'D6')
|
* PD6 PCINT22 (Gain Adjustment Resistor 3 'D6')
|
||||||
|
* PB0 PCINT0 (VCC Adjustment Resistors 'D8')
|
||||||
* PB1 OC1A (Comparator VRef PWM Out 'D9')
|
* PB1 OC1A (Comparator VRef PWM Out 'D9')
|
||||||
* PD3 OC2B (Voltage Follower VRef PWM Out 'D3')
|
* PD3 OC2B (Voltage Follower VRef PWM Out 'D3')
|
||||||
|
|
||||||
|
|
@ -36,6 +37,7 @@ To change trigger active duration: TRG_D [integer for milliseconds]
|
||||||
To change gain factor: GAIN_F [integer for gain state - see note*]
|
To change gain factor: GAIN_F [integer for gain state - see note*]
|
||||||
To change the output logic: LOGIC [0|1] (0 for active low, 1 for active high)
|
To change the output logic: LOGIC [0|1] (0 for active low, 1 for active high)
|
||||||
To enable piezo plugged detection: PZDET [0|1] (0 for disabled, 1 for enabled)
|
To enable piezo plugged detection: PZDET [0|1] (0 for disabled, 1 for enabled)
|
||||||
|
To set the sensor's output voltage: VCCSW [0|1] (0 for 3.3v, 1 for 5v)
|
||||||
To change ADC hysteresis value: HYST [integer in millivolts]
|
To change ADC hysteresis value: HYST [integer in millivolts]
|
||||||
To change sensor input pullup vRef low threshold: VFOL [integer in millivolts]
|
To change sensor input pullup vRef low threshold: VFOL [integer in millivolts]
|
||||||
To change comparator trigger high threshold: VCOMP [integer in millivolts]
|
To change comparator trigger high threshold: VCOMP [integer in millivolts]
|
||||||
|
|
@ -84,30 +86,26 @@ update the voltMeterConstant variable in pP_config.h with the correct value
|
||||||
|
|
||||||
------------------------------------------------------------*/
|
------------------------------------------------------------*/
|
||||||
|
|
||||||
/* Debug output verbose mode will continuously output sensor readings
|
|
||||||
rather than waiting for user input */
|
|
||||||
#define VERBOSE true
|
|
||||||
|
|
||||||
// Headers, variables, and functions
|
|
||||||
#include <Arduino.h>
|
|
||||||
#include <EEPROM.h>
|
|
||||||
#include "LightChrono.h"
|
|
||||||
#include "pP_pins.h"
|
|
||||||
#include "pP_config.h"
|
|
||||||
#include "pP_volatile.h"
|
|
||||||
#include "pP_function.h"
|
|
||||||
#include "pP_serial.h"
|
|
||||||
|
|
||||||
// i2c input toggle. Uncomment to enable
|
// i2c input toggle. Uncomment to enable
|
||||||
#define I2C_INPUT
|
#define I2C_INPUT
|
||||||
|
|
||||||
|
// Headers, variables, and functions
|
||||||
|
#include "LightChrono.h"
|
||||||
|
#include "pP_pins.h"
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <EEPROM.h>
|
||||||
|
#include "pP_function.h"
|
||||||
|
#include "pP_i2c.hpp"
|
||||||
|
#include "pP_serial.h"
|
||||||
|
#include "pP_volatile.h"
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
//Setup PWM on voltage follower (PD3)
|
// Setup PWM on voltage follower (PD3)
|
||||||
TCCR2A = (1 << COM2B1) | (0 << COM2B0) | (0 << WGM21) | (1 << WGM20);
|
TCCR2A = (1 << COM2B1) | (0 << COM2B0) | (0 << WGM21) | (1 << WGM20);
|
||||||
TCCR2B = (0 << WGM22) | (0 << CS22) | (0 << CS21) | (1 << CS20);
|
TCCR2B = (0 << WGM22) | (0 << CS22) | (0 << CS21) | (1 << CS20);
|
||||||
DDRD |= (1 << DDD3);
|
DDRD |= (1 << DDD3);
|
||||||
|
|
||||||
//Setup PWM on comparator (PB1)
|
// Setup PWM on comparator (PB1)
|
||||||
TCCR1A = (1 << COM1A1) | (0 << COM1A0) | (1 << WGM11) | (1 << WGM10);
|
TCCR1A = (1 << COM1A1) | (0 << COM1A0) | (1 << WGM11) | (1 << WGM10);
|
||||||
TCCR1B = (0 << WGM13) | (0 << WGM12) | (0 << CS12) | (0 << CS11) | (1 << CS10);
|
TCCR1B = (0 << WGM13) | (0 << WGM12) | (0 << CS12) | (0 << CS11) | (1 << CS10);
|
||||||
DDRB |= (1 << DDB1);
|
DDRB |= (1 << DDB1);
|
||||||
|
|
@ -128,10 +126,14 @@ void setup() {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
Serial.println("Initializing Pyr0-Piezo Sensor...");
|
Serial.println("Initializing Pyr0-Piezo Sensor...");
|
||||||
|
|
||||||
|
i2cInit();
|
||||||
|
|
||||||
restoreConfig();
|
restoreConfig();
|
||||||
|
|
||||||
adjustGain();
|
adjustGain();
|
||||||
|
|
||||||
|
adjustVcc();
|
||||||
|
|
||||||
digitalWriteFast(TRG_OUT, !LOGIC);
|
digitalWriteFast(TRG_OUT, !LOGIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,7 +146,7 @@ void loop() {
|
||||||
if (BlinkCount > 0) {
|
if (BlinkCount > 0) {
|
||||||
BlinkState = !BlinkState;
|
BlinkState = !BlinkState;
|
||||||
digitalWriteFast(ERR_LED, BlinkState);
|
digitalWriteFast(ERR_LED, BlinkState);
|
||||||
//digitalWriteFast(TRG_OUT, BlinkState);
|
// digitalWriteFast(TRG_OUT, BlinkState);
|
||||||
--BlinkCount;
|
--BlinkCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -159,6 +161,9 @@ void loop() {
|
||||||
// Set the amplification gain factor
|
// Set the amplification gain factor
|
||||||
adjustGain();
|
adjustGain();
|
||||||
|
|
||||||
|
// Set the VCC input switch
|
||||||
|
adjustVcc();
|
||||||
|
|
||||||
// Check voltage of first and second stages and compare against thresholds
|
// Check voltage of first and second stages and compare against thresholds
|
||||||
readVin();
|
readVin();
|
||||||
VComp = analogReadFast(VCOMP_SENSE_PIN);
|
VComp = analogReadFast(VCOMP_SENSE_PIN);
|
||||||
|
|
@ -183,11 +188,11 @@ void loop() {
|
||||||
if (BlinkCount > 0) {
|
if (BlinkCount > 0) {
|
||||||
BlinkState = !BlinkState;
|
BlinkState = !BlinkState;
|
||||||
digitalWriteFast(ERR_LED, BlinkState);
|
digitalWriteFast(ERR_LED, BlinkState);
|
||||||
// digitalWriteFast(TRG_OUT, BlinkState);
|
// digitalWriteFast(TRG_OUT, BlinkState);
|
||||||
--BlinkCount;
|
--BlinkCount;
|
||||||
// } else {
|
// } else {
|
||||||
// Check for error state
|
// Check for error state
|
||||||
// checkError();
|
// checkError();
|
||||||
} else {
|
} else {
|
||||||
digitalWriteFast(ERR_LED, 0);
|
digitalWriteFast(ERR_LED, 0);
|
||||||
}
|
}
|
||||||
|
|
@ -197,7 +202,7 @@ void loop() {
|
||||||
serialPrintState();
|
serialPrintState();
|
||||||
}
|
}
|
||||||
// Sets trigger output state to false after completing loop
|
// Sets trigger output state to false after completing loop
|
||||||
//digitalWriteFast(TRG_OUT, HIGH);
|
// digitalWriteFast(TRG_OUT, HIGH);
|
||||||
sensorHReading = 0;
|
sensorHReading = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
117
firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_cmd.cpp
Normal file
117
firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_cmd.cpp
Normal file
|
|
@ -0,0 +1,117 @@
|
||||||
|
#include "EEPROM.h"
|
||||||
|
#include "pP_config.h"
|
||||||
|
#include "pP_function.h"
|
||||||
|
#include "pP_volatile.h"
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void updateGainFactor(int value) {
|
||||||
|
if (value >= 0) {
|
||||||
|
GAIN_FACTOR = value;
|
||||||
|
adjustGain();
|
||||||
|
EEPROM.put(GAIN_FACTOR_ADDRESS, GAIN_FACTOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void updateVFol(int value) {
|
||||||
|
if (value >= 0) {
|
||||||
|
followerThrs = value;
|
||||||
|
adjustFollow();
|
||||||
|
EEPROM.put(FOLLOWER_THRESHOLD_ADDRESS, followerThrs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void updateVComp(int value) {
|
||||||
|
if (value >= 0) {
|
||||||
|
compThrs = value;
|
||||||
|
adjustComp();
|
||||||
|
EEPROM.put(COMP_THRESHOLD_ADDRESS, compThrs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void updateLoopDuration(int value) {
|
||||||
|
if (value >= 0) {
|
||||||
|
LOOP_DUR = value;
|
||||||
|
EEPROM.put(LOOP_DUR_ADDRESS, LOOP_DUR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void updateTrigDuration(int value) {
|
||||||
|
if (value >= 0) {
|
||||||
|
TRG_DUR = value;
|
||||||
|
EEPROM.put(TRG_DUR_ADDRESS, TRG_DUR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void updateHysteresis(int value) {
|
||||||
|
if (value >= 0) {
|
||||||
|
Hyst = value;
|
||||||
|
EEPROM.put(HYST_ADDRESS, Hyst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void updateLogic(int value) {
|
||||||
|
if (value >= 0) {
|
||||||
|
LOGIC = value;
|
||||||
|
EEPROM.put(LOGIC_ADDRESS, LOGIC);
|
||||||
|
pulse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void updatePzDet(int value) {
|
||||||
|
if (value >= 0) {
|
||||||
|
PZDET = value;
|
||||||
|
EEPROM.put(PZDET_ADDRESS, PZDET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void updateVccSwitch(int value) {
|
||||||
|
if (value >= 0) {
|
||||||
|
VCCSW = value;
|
||||||
|
EEPROM.put(VCCSW_ADDRESS, VCCSW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void updateConstant(long value) {
|
||||||
|
if (value >= 0) {
|
||||||
|
voltMeterConstant = value;
|
||||||
|
EEPROM.put(VM_CONST_ADDRESS, voltMeterConstant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void adjustConstant(int value) {
|
||||||
|
if (value > 0 && Vin > 0) {
|
||||||
|
voltMeterConstant = (long)(1.1 * value / Vin * 1023 * 1000);
|
||||||
|
EEPROM.put(VM_CONST_ADDRESS, voltMeterConstant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void updateDebug(int value) {
|
||||||
|
if (value > 0) {
|
||||||
|
Debug = 1;
|
||||||
|
} else if (value == 0) {
|
||||||
|
Debug = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
17
firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_cmd.h
Normal file
17
firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_cmd.h
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef PP_CMD_H
|
||||||
|
#define PP_CMD_H
|
||||||
|
|
||||||
|
void updateGainFactor(int value);
|
||||||
|
void updateVFol(int value);
|
||||||
|
void updateVComp(int value);
|
||||||
|
void updateLoopDuration(int value);
|
||||||
|
void updateTrigDuration(int value);
|
||||||
|
void updateHysteresis(int value);
|
||||||
|
void updateLogic(int value);
|
||||||
|
void updatePzDet(int value);
|
||||||
|
void updateVccSwitch(int value);
|
||||||
|
void updateConstant(long value);
|
||||||
|
void adjustConstant(int value);
|
||||||
|
void updateDebug(int value);
|
||||||
|
|
||||||
|
#endif // PP_CMD_H
|
||||||
|
|
@ -1,14 +1,138 @@
|
||||||
#include "pP_config.h"
|
#include "pP_config.h"
|
||||||
|
#include "pP_function.h"
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
|
|
||||||
int GAIN_FACTOR = GAIN_FACTOR_DEFAULT; // Gain adjustment factor. 0=3x, 1=3.5x, 2=4.33x, 3=6x, 4=11x
|
int GAIN_FACTOR = GAIN_FACTOR_DEFAULT;
|
||||||
int followerThrs = FOLLOWER_THRESHOLD_DEFAULT;
|
int followerThrs = FOLLOWER_THRESHOLD_DEFAULT;
|
||||||
int compThrs = COMP_THRESHOLD_DEFAULT;
|
int compThrs = COMP_THRESHOLD_DEFAULT;
|
||||||
int LOOP_DUR = LOOP_DUR_DEFAULT; // duration of time between ADC checks and other loop functions
|
int LOOP_DUR = LOOP_DUR_DEFAULT;
|
||||||
int TRG_DUR = TRG_DUR_DEFAULT; // duration of the Z-axis pulse sent, in ms
|
int TRG_DUR = TRG_DUR_DEFAULT;
|
||||||
int Hyst = HYST_DEFAULT; // Hysteresis value for ADC measurements
|
int Hyst = HYST_DEFAULT;
|
||||||
int LOGIC = LOGIC_DEFAULT; // Trigger output logic (active low or active high)
|
int LOGIC = LOGIC_DEFAULT;
|
||||||
int PZDET = PZDET_DEFAULT; // Enable/disable piezo connection detection
|
int PZDET = PZDET_DEFAULT;
|
||||||
|
int VCCSW = VCCSW_DEFAULT;
|
||||||
int Debug = 0;
|
int Debug = 0;
|
||||||
long voltMeterConstant = VM_CONST_DEFAULT;
|
long voltMeterConstant = VM_CONST_DEFAULT;
|
||||||
uint8_t pP_i2c_address = 0xa0;
|
uint8_t pP_i2c_address = 0x10;
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void eraseEEPROM() {
|
||||||
|
|
||||||
|
setDefaultConfig();
|
||||||
|
|
||||||
|
EEPROM.put(GAIN_FACTOR_ADDRESS, GAIN_FACTOR);
|
||||||
|
EEPROM.put(FOLLOWER_THRESHOLD_ADDRESS, followerThrs);
|
||||||
|
EEPROM.put(COMP_THRESHOLD_ADDRESS, compThrs);
|
||||||
|
EEPROM.put(LOOP_DUR_ADDRESS, LOOP_DUR);
|
||||||
|
EEPROM.put(TRG_DUR_ADDRESS, TRG_DUR);
|
||||||
|
EEPROM.put(HYST_ADDRESS, Hyst);
|
||||||
|
EEPROM.put(PZDET_ADDRESS, PZDET);
|
||||||
|
EEPROM.put(LOGIC_ADDRESS, LOGIC);
|
||||||
|
EEPROM.put(VCCSW_ADDRESS, VCCSW);
|
||||||
|
EEPROM.put(VM_CONST_ADDRESS, voltMeterConstant);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
// Restore config from EEPROM, otherwise erase config and write to EEPROM
|
||||||
|
void restoreConfig() {
|
||||||
|
int temp;
|
||||||
|
|
||||||
|
bool erase = false;
|
||||||
|
|
||||||
|
EEPROM.get(GAIN_FACTOR_ADDRESS, temp);
|
||||||
|
if (temp < 0 || temp > 4) {
|
||||||
|
erase = true;
|
||||||
|
} else {
|
||||||
|
GAIN_FACTOR = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
EEPROM.get(FOLLOWER_THRESHOLD_ADDRESS, temp);
|
||||||
|
if (temp < 0 || temp > 5000) {
|
||||||
|
erase = true;
|
||||||
|
} else {
|
||||||
|
followerThrs = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
EEPROM.get(COMP_THRESHOLD_ADDRESS, temp);
|
||||||
|
if (temp < 0 || temp > 5000) {
|
||||||
|
erase = true;
|
||||||
|
} else {
|
||||||
|
compThrs = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
EEPROM.get(LOOP_DUR_ADDRESS, temp);
|
||||||
|
if (temp < 0 && temp > 1000) {
|
||||||
|
erase = true;
|
||||||
|
} else {
|
||||||
|
LOOP_DUR = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
EEPROM.get(TRG_DUR_ADDRESS, temp);
|
||||||
|
if (temp < 0 || temp > 1000) {
|
||||||
|
erase = true;
|
||||||
|
} else {
|
||||||
|
TRG_DUR = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
EEPROM.get(HYST_ADDRESS, temp);
|
||||||
|
if (temp < 0 || temp > 1000) {
|
||||||
|
erase = true;
|
||||||
|
} else {
|
||||||
|
Hyst = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
EEPROM.get(PZDET_ADDRESS, temp);
|
||||||
|
if (temp < 0 || temp > 1) {
|
||||||
|
erase = true;
|
||||||
|
} else {
|
||||||
|
PZDET = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
EEPROM.get(LOGIC_ADDRESS, temp);
|
||||||
|
if (temp < 0 || temp > 1) {
|
||||||
|
erase = true;
|
||||||
|
} else {
|
||||||
|
LOGIC = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
EEPROM.get(VCCSW_ADDRESS, temp);
|
||||||
|
if (temp < 0 || temp > 1) {
|
||||||
|
erase = true;
|
||||||
|
} else {
|
||||||
|
VCCSW = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
long longTemp;
|
||||||
|
EEPROM.get(VM_CONST_ADDRESS, longTemp);
|
||||||
|
if (longTemp < 1000000L || longTemp > 1200000L) {
|
||||||
|
erase = true;
|
||||||
|
} else {
|
||||||
|
voltMeterConstant = longTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (erase) {
|
||||||
|
eraseEEPROM();
|
||||||
|
}
|
||||||
|
|
||||||
|
adjustFollow();
|
||||||
|
adjustComp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void setDefaultConfig() {
|
||||||
|
GAIN_FACTOR = GAIN_FACTOR_DEFAULT;
|
||||||
|
followerThrs = FOLLOWER_THRESHOLD_DEFAULT;
|
||||||
|
compThrs = COMP_THRESHOLD_DEFAULT;
|
||||||
|
LOOP_DUR = LOOP_DUR_DEFAULT;
|
||||||
|
TRG_DUR = TRG_DUR_DEFAULT;
|
||||||
|
Hyst = HYST_DEFAULT;
|
||||||
|
PZDET = PZDET_DEFAULT;
|
||||||
|
LOGIC = LOGIC_DEFAULT;
|
||||||
|
VCCSW = VCCSW_DEFAULT;
|
||||||
|
voltMeterConstant = VM_CONST_DEFAULT;
|
||||||
|
adjustFollow();
|
||||||
|
adjustComp();
|
||||||
|
}
|
||||||
|
|
@ -1,76 +1,58 @@
|
||||||
#ifndef PP_CONFIG_H
|
#ifndef PP_CONFIG_H
|
||||||
#define PP_CONFIG_H
|
#define PP_CONFIG_H
|
||||||
|
|
||||||
|
#include "stdint.h"
|
||||||
|
|
||||||
// Configurable settings:
|
// Configurable settings:
|
||||||
|
|
||||||
#define GAIN_FACTOR_DEFAULT 2 // Gain adjustment factor. 0=3x, 1=3.5x, 2=4.33x, 3=6x, 4=11x
|
#define GAIN_FACTOR_DEFAULT 2 // Gain adjustment factor. 0=3x, 1=3.5x, 2=4.33x, 3=6x, 4=11x
|
||||||
#define GAIN_FACTOR_ADDRESS 0
|
#define GAIN_FACTOR_ADDRESS 0
|
||||||
#if !(defined(GAIN_FACTOR))
|
extern int GAIN_FACTOR;
|
||||||
extern int GAIN_FACTOR;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define FOLLOWER_THRESHOLD_DEFAULT 1450 // Voltage follower default voltage in mV
|
#define FOLLOWER_THRESHOLD_DEFAULT 1450 // Voltage follower default voltage in mV
|
||||||
#define FOLLOWER_THRESHOLD_ADDRESS 4
|
#define FOLLOWER_THRESHOLD_ADDRESS 4
|
||||||
#if !(defined(followerThrs))
|
extern int followerThrs;
|
||||||
extern int followerThrs;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define COMP_THRESHOLD_DEFAULT 2850 // Comparatore Vref default voltage in mV
|
#define COMP_THRESHOLD_DEFAULT 2850 // Comparatore Vref default voltage in mV
|
||||||
#define COMP_THRESHOLD_ADDRESS 8
|
#define COMP_THRESHOLD_ADDRESS 8
|
||||||
#if !(defined(compThrs))
|
extern int compThrs;
|
||||||
extern int compThrs;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef InitCount
|
#ifndef InitCount
|
||||||
#define InitCount 6 // Number of times to blink the LED on start
|
#define InitCount 6 // Number of times to blink the LED on start
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LOOP_DUR_DEFAULT 50 // duration of time between ADC checks and other loop functions
|
#define LOOP_DUR_DEFAULT 50 // duration of time between ADC checks and other loop functions
|
||||||
#define LOOP_DUR_ADDRESS 12
|
#define LOOP_DUR_ADDRESS 12
|
||||||
#if !(defined(LOOP_DUR))
|
extern int LOOP_DUR;
|
||||||
extern int LOOP_DUR;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TRG_DUR_DEFAULT 20 // duration of the Z-axis pulse sent, in ms
|
#define TRG_DUR_DEFAULT 20 // duration of the Z-axis pulse sent, in ms
|
||||||
#define TRG_DUR_ADDRESS 16
|
#define TRG_DUR_ADDRESS 16
|
||||||
#if !(defined(TRG_DUR))
|
extern int TRG_DUR;
|
||||||
extern int TRG_DUR;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define HYST_DEFAULT 20
|
#define HYST_DEFAULT 20
|
||||||
#define HYST_ADDRESS 20
|
#define HYST_ADDRESS 20
|
||||||
#if !(defined(Hyst))
|
extern int Hyst; // Hysteresis value for ADC measurements
|
||||||
extern int Hyst; // Hysteresis value for ADC measurements
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LOGIC_DEFAULT 1
|
#define LOGIC_DEFAULT 1
|
||||||
#define LOGIC_ADDRESS 32
|
#define LOGIC_ADDRESS 32
|
||||||
#if !(defined(LOGIC))
|
extern int LOGIC; // Trigger logic scheme, Active LOW is default
|
||||||
extern int LOGIC; // Trigger logic scheme, Active LOW is default
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PZDET_DEFAULT 0
|
#define PZDET_DEFAULT 0
|
||||||
#define PZDET_ADDRESS 26
|
#define PZDET_ADDRESS 26
|
||||||
#if !(defined(PZDET))
|
extern int PZDET; // Enable or disable piezo connection detection, default is off
|
||||||
extern int PZDET; // Enable or disable piezo connection detection, default is off
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !(defined(Debug))
|
#define VCCSW_DEFAULT 0
|
||||||
extern int Debug;
|
#define VCCSW_ADDRESS 28
|
||||||
#endif
|
extern int VCCSW; // Set the signal output to 3.3v [0] or 5v logic [1]
|
||||||
|
|
||||||
#define VM_CONST_ADDRESS 28
|
extern int Debug;
|
||||||
|
|
||||||
|
#define VM_CONST_ADDRESS 30
|
||||||
#define VM_CONST_DEFAULT 1125300L
|
#define VM_CONST_DEFAULT 1125300L
|
||||||
#if !(defined(voltMeterConstant))
|
extern long voltMeterConstant; // For fine tuning input voltage sense
|
||||||
extern long voltMeterConstant; // For fine tuning input voltage sense
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef I2C_INPUT
|
#define I2C_SLAVE_ADDRESS 24
|
||||||
#define I2C_SLAVE_ADDRESS 24
|
extern uint8_t pP_i2c_address;
|
||||||
#if !(defined(pP_i2c_address))
|
|
||||||
extern uint8_t pP_i2c_address; // I2C Bus Address
|
|
||||||
#endif
|
|
||||||
#endif // I2C_INPUT
|
|
||||||
|
|
||||||
void eraseEEPROM();
|
void eraseEEPROM();
|
||||||
void setDefaultConfig();
|
void setDefaultConfig();
|
||||||
|
|
|
||||||
201
firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.cpp
Normal file
201
firmware/AVR-Source/Pyr0_Piezo_Sensor_v2.x.x/src/pP_function.cpp
Normal file
|
|
@ -0,0 +1,201 @@
|
||||||
|
/*
|
||||||
|
pyr0-piezo functions library
|
||||||
|
Created by Alan "pyr0ball" Weinstock 6/26/2019
|
||||||
|
*/
|
||||||
|
|
||||||
|
//#pragma once
|
||||||
|
//#include "pP_function.h"
|
||||||
|
|
||||||
|
#include "pP_function.h"
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "pP_config.h"
|
||||||
|
#include "pP_pins.h"
|
||||||
|
#include "pP_volatile.h"
|
||||||
|
#include "stdint.h"
|
||||||
|
|
||||||
|
void digitalWriteFast(uint8_t pin, uint8_t x) {
|
||||||
|
if (pin / 8) { // pin >= 8
|
||||||
|
PORTB ^= (-x ^ PORTB) & (1 << (pin % 8));
|
||||||
|
} else {
|
||||||
|
PORTD ^= (-x ^ PORTD) & (1 << (pin % 8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int analogReadFast(uint8_t ADCpin) {
|
||||||
|
byte ADCSRAoriginal = ADCSRA;
|
||||||
|
ADCSRA = (ADCSRA & B11111000) | 4;
|
||||||
|
int adc = analogRead(ADCpin);
|
||||||
|
ADCSRA = ADCSRAoriginal;
|
||||||
|
return adc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void doubleFlash() {
|
||||||
|
BlinkCount = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void pulse() {
|
||||||
|
digitalWriteFast(TRG_OUT, LOGIC);
|
||||||
|
sensorHReading = 1;
|
||||||
|
delay(TRG_DUR);
|
||||||
|
digitalWriteFast(TRG_OUT, !LOGIC);
|
||||||
|
Serial.println("Trig'd!");
|
||||||
|
doubleFlash();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
long readVcc() {
|
||||||
|
// Read 1.1V reference against AVcc
|
||||||
|
|
||||||
|
// Atmega's Secret Voltmeter setup:
|
||||||
|
// set the reference to Vcc and the measurement to the internal 1.1V reference
|
||||||
|
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||||
|
ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
|
||||||
|
#elif defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
|
||||||
|
ADMUX = _BV(MUX5) | _BV(MUX0);
|
||||||
|
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
|
||||||
|
ADMUX = _BV(MUX3) | _BV(MUX2);
|
||||||
|
#else
|
||||||
|
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
delay(2); // Wait for vref to settle
|
||||||
|
|
||||||
|
ADCSRA |= _BV(ADSC); // Start conversion
|
||||||
|
while (bit_is_set(ADCSRA, ADSC))
|
||||||
|
; // measuring
|
||||||
|
|
||||||
|
uint8_t low = ADCL; // must read ADCL first - it then locks ADCH
|
||||||
|
uint8_t high = ADCH; // unlocks both
|
||||||
|
|
||||||
|
long result = (high << 8) | low;
|
||||||
|
|
||||||
|
result = voltMeterConstant / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
|
||||||
|
return result; // Vcc in millivolts
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------
|
||||||
|
The above function assumes an "ideal" multiplier constant.
|
||||||
|
Each Atmega chip is slightly different, so it won't be completely accurate
|
||||||
|
without tuning. Most of the time this won't be necessary, so don't mess
|
||||||
|
with this if you don't know what you're doing!
|
||||||
|
The reading can be fine-tuned by using a multimeter, and this equation:
|
||||||
|
|
||||||
|
scale_constant = internal1.1Ref * 1023 * 1000
|
||||||
|
|
||||||
|
where
|
||||||
|
|
||||||
|
internal1.1Ref = 1.1 * Vcc1 (per voltmeter) / Vcc2 (per readVcc() function)
|
||||||
|
|
||||||
|
If the scale_constant calculated is different from the default 1125300,
|
||||||
|
update the voltMeterConstant variable in pP_config.h with the correct value
|
||||||
|
--------------------------------------------------*/
|
||||||
|
|
||||||
|
void readVin() {
|
||||||
|
VOld = Vin;
|
||||||
|
Vin = readVcc();
|
||||||
|
followerLong = followerThrs * 1023L;
|
||||||
|
compLong = compThrs * 1023L;
|
||||||
|
followerInt = (long long)followerLong / Vin;
|
||||||
|
compInt = (long long)compLong / Vin;
|
||||||
|
followerInt = (int)followerInt;
|
||||||
|
compInt = (int)compInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void adjustFollow() {
|
||||||
|
/* Compares diffs of threshold vs read value
|
||||||
|
if positive, adjusts the follower to within
|
||||||
|
the range set above*/
|
||||||
|
followerLong = followerThrs * 1023L;
|
||||||
|
followerInt = (long long)followerLong / Vin;
|
||||||
|
followerInt = (int)followerInt;
|
||||||
|
ADJ_FOLLOW = (followerInt / 4);
|
||||||
|
|
||||||
|
// Analog output (PWM) of duty cycle
|
||||||
|
OCR2B = ADJ_FOLLOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void adjustComp() {
|
||||||
|
compLong = compThrs * 1023L;
|
||||||
|
compInt = (long long)compLong / Vin;
|
||||||
|
compInt = (int)compInt;
|
||||||
|
OCR1A = compInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void calibrateAlert() {
|
||||||
|
VLast = VOld - Vin;
|
||||||
|
if (VLast > Hyst || VLast < -Hyst) {
|
||||||
|
ERR_STATE = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void adjustGain() {
|
||||||
|
switch (GAIN_FACTOR) {
|
||||||
|
case 4:
|
||||||
|
pinMode(GADJ_R0, OUTPUT);
|
||||||
|
digitalWriteFast(GADJ_R0, LOW);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
pinMode(GADJ_R1, OUTPUT);
|
||||||
|
digitalWriteFast(GADJ_R1, LOW);
|
||||||
|
pinMode(GADJ_R0, INPUT);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
pinMode(GADJ_R2, OUTPUT);
|
||||||
|
digitalWriteFast(GADJ_R2, LOW);
|
||||||
|
pinMode(GADJ_R1, INPUT);
|
||||||
|
pinMode(GADJ_R0, INPUT);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
pinMode(GADJ_R3, OUTPUT);
|
||||||
|
digitalWriteFast(GADJ_R3, LOW);
|
||||||
|
pinMode(GADJ_R2, INPUT);
|
||||||
|
pinMode(GADJ_R1, INPUT);
|
||||||
|
pinMode(GADJ_R0, INPUT);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
pinMode(GADJ_R3, INPUT);
|
||||||
|
pinMode(GADJ_R2, INPUT);
|
||||||
|
pinMode(GADJ_R1, INPUT);
|
||||||
|
pinMode(GADJ_R0, INPUT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void adjustVcc() {
|
||||||
|
switch (VCCSW) {
|
||||||
|
case 0:
|
||||||
|
pinMode(VCCSW_PIN, OUTPUT);
|
||||||
|
digitalWriteFast(VCCSW_PIN, LOW);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
default:
|
||||||
|
pinMode(VCCSW_PIN, INPUT);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void pzConCheck() {
|
||||||
|
PZ_STATE = digitalRead(PZDET_PIN);
|
||||||
|
if (PZ_STATE == PZDET) {
|
||||||
|
// digitalWriteFast(TRG_OUT, LOGIC);
|
||||||
|
ERR_STATE = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,296 +6,22 @@
|
||||||
//#pragma once
|
//#pragma once
|
||||||
//#include "pP_function.h"
|
//#include "pP_function.h"
|
||||||
|
|
||||||
void digitalWriteFast(uint8_t pin, uint8_t x) {
|
#ifndef PP_FUNCTION_H
|
||||||
if (pin / 8) { // pin >= 8
|
#define PP_FUNCTION_H
|
||||||
PORTB ^= (-x ^ PORTB) & (1 << (pin % 8));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
PORTD ^= (-x ^ PORTD) & (1 << (pin % 8));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int inline analogReadFast(byte ADCpin)
|
#include "stdint.h"
|
||||||
{ byte ADCSRAoriginal = ADCSRA;
|
|
||||||
ADCSRA = (ADCSRA & B11111000) | 4;
|
|
||||||
int adc = analogRead(ADCpin);
|
|
||||||
ADCSRA = ADCSRAoriginal;
|
|
||||||
return adc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
void digitalWriteFast(uint8_t pin, uint8_t x);
|
||||||
|
int analogReadFast(uint8_t ADCpin);
|
||||||
|
void doubleFlash();
|
||||||
|
void pulse();
|
||||||
|
long readVcc();
|
||||||
|
void readVin();
|
||||||
|
void adjustFollow();
|
||||||
|
void adjustComp();
|
||||||
|
void adjustVcc();
|
||||||
|
void calibrateAlert();
|
||||||
|
void adjustGain();
|
||||||
|
void pzConCheck();
|
||||||
|
|
||||||
void doubleFlash() {
|
#endif // PP_FUNCTION_H
|
||||||
BlinkCount = 4 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void pulse() {
|
|
||||||
digitalWriteFast(TRG_OUT, LOGIC);
|
|
||||||
sensorHReading = 1;
|
|
||||||
delay(TRG_DUR);
|
|
||||||
digitalWriteFast(TRG_OUT, !LOGIC);
|
|
||||||
Serial.println("Trig'd!");
|
|
||||||
doubleFlash();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
long readVcc() {
|
|
||||||
// Read 1.1V reference against AVcc
|
|
||||||
|
|
||||||
// Atmega's Secret Voltmeter setup:
|
|
||||||
// set the reference to Vcc and the measurement to the internal 1.1V reference
|
|
||||||
#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
|
||||||
ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
|
|
||||||
#elif defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__)
|
|
||||||
ADMUX = _BV(MUX5) | _BV(MUX0);
|
|
||||||
#elif defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
|
|
||||||
ADMUX = _BV(MUX3) | _BV(MUX2);
|
|
||||||
#else
|
|
||||||
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
delay(2); // Wait for vref to settle
|
|
||||||
|
|
||||||
ADCSRA |= _BV(ADSC); // Start conversion
|
|
||||||
while (bit_is_set(ADCSRA,ADSC)); // measuring
|
|
||||||
|
|
||||||
uint8_t low = ADCL; // must read ADCL first - it then locks ADCH
|
|
||||||
uint8_t high = ADCH; // unlocks both
|
|
||||||
|
|
||||||
long result = (high<<8) | low;
|
|
||||||
|
|
||||||
result = voltMeterConstant / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
|
|
||||||
return result; // Vcc in millivolts
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
|
||||||
The above function assumes an "ideal" multiplier constant.
|
|
||||||
Each Atmega chip is slightly different, so it won't be completely accurate
|
|
||||||
without tuning. Most of the time this won't be necessary, so don't mess
|
|
||||||
with this if you don't know what you're doing!
|
|
||||||
The reading can be fine-tuned by using a multimeter, and this equation:
|
|
||||||
|
|
||||||
scale_constant = internal1.1Ref * 1023 * 1000
|
|
||||||
|
|
||||||
where
|
|
||||||
|
|
||||||
internal1.1Ref = 1.1 * Vcc1 (per voltmeter) / Vcc2 (per readVcc() function)
|
|
||||||
|
|
||||||
If the scale_constant calculated is different from the default 1125300,
|
|
||||||
update the voltMeterConstant variable in pP_config.h with the correct value
|
|
||||||
--------------------------------------------------*/
|
|
||||||
|
|
||||||
void readVin() {
|
|
||||||
VOld = Vin;
|
|
||||||
Vin = readVcc();
|
|
||||||
followerLong = followerThrs * 1023L;
|
|
||||||
compLong = compThrs * 1023L;
|
|
||||||
followerInt = (long long) followerLong / Vin;
|
|
||||||
compInt = (long long) compLong / Vin;
|
|
||||||
followerInt = (int) followerInt;
|
|
||||||
compInt = (int) compInt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void adjustFollow() {
|
|
||||||
/* Compares diffs of threshold vs read value
|
|
||||||
if positive, adjusts the follower to within
|
|
||||||
the range set above*/
|
|
||||||
followerLong = followerThrs * 1023L;
|
|
||||||
followerInt = (long long) followerLong / Vin;
|
|
||||||
followerInt = (int) followerInt;
|
|
||||||
ADJ_FOLLOW = (followerInt / 4);
|
|
||||||
|
|
||||||
// Analog output (PWM) of duty cycle
|
|
||||||
OCR2B = ADJ_FOLLOW;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void adjustComp() {
|
|
||||||
compLong = compThrs * 1023L;
|
|
||||||
compInt = (long long) compLong / Vin;
|
|
||||||
compInt = (int) compInt;
|
|
||||||
OCR1A = compInt;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void calibrateAlert() {
|
|
||||||
VLast = VOld - Vin;
|
|
||||||
if (VLast > Hyst || VLast < -Hyst ) {
|
|
||||||
ERR_STATE = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void adjustGain() {
|
|
||||||
switch (GAIN_FACTOR)
|
|
||||||
{
|
|
||||||
case 4:
|
|
||||||
pinMode(GADJ_R0, OUTPUT);
|
|
||||||
digitalWriteFast(GADJ_R0, LOW);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
pinMode(GADJ_R1, OUTPUT);
|
|
||||||
digitalWriteFast(GADJ_R1, LOW);
|
|
||||||
pinMode(GADJ_R0, INPUT);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
pinMode(GADJ_R2, OUTPUT);
|
|
||||||
digitalWriteFast(GADJ_R2, LOW);
|
|
||||||
pinMode(GADJ_R1, INPUT);
|
|
||||||
pinMode(GADJ_R0, INPUT);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
pinMode(GADJ_R3, OUTPUT);
|
|
||||||
digitalWriteFast(GADJ_R3, LOW);
|
|
||||||
pinMode(GADJ_R2, INPUT);
|
|
||||||
pinMode(GADJ_R1, INPUT);
|
|
||||||
pinMode(GADJ_R0, INPUT);
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
default:
|
|
||||||
pinMode(GADJ_R3, INPUT);
|
|
||||||
pinMode(GADJ_R2, INPUT);
|
|
||||||
pinMode(GADJ_R1, INPUT);
|
|
||||||
pinMode(GADJ_R0, INPUT);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
//void checkError () {
|
|
||||||
// if (ERR_STATE == 1) {
|
|
||||||
// digitalWriteFast(ERR_LED, BlinkState);
|
|
||||||
// BlinkState = !BlinkState;
|
|
||||||
// }
|
|
||||||
// else if (ERR_STATE == 0) {
|
|
||||||
// BlinkState = LOW;
|
|
||||||
// digitalWriteFast(ERR_LED, BlinkState);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void pzConCheck () {
|
|
||||||
PZ_STATE = digitalRead(PZDET_PIN);
|
|
||||||
if (PZ_STATE == PZDET) {
|
|
||||||
//digitalWriteFast(TRG_OUT, LOGIC);
|
|
||||||
ERR_STATE = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
void eraseEEPROM() {
|
|
||||||
|
|
||||||
setDefaultConfig();
|
|
||||||
|
|
||||||
EEPROM.put(GAIN_FACTOR_ADDRESS, GAIN_FACTOR);
|
|
||||||
EEPROM.put(FOLLOWER_THRESHOLD_ADDRESS, followerThrs);
|
|
||||||
EEPROM.put(COMP_THRESHOLD_ADDRESS, compThrs);
|
|
||||||
EEPROM.put(LOOP_DUR_ADDRESS, LOOP_DUR);
|
|
||||||
EEPROM.put(TRG_DUR_ADDRESS, TRG_DUR);
|
|
||||||
EEPROM.put(HYST_ADDRESS, Hyst);
|
|
||||||
EEPROM.put(PZDET_ADDRESS, PZDET);
|
|
||||||
EEPROM.put(LOGIC_ADDRESS, LOGIC);
|
|
||||||
EEPROM.put(VM_CONST_ADDRESS, voltMeterConstant);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore config from EEPROM, otherwise erase config and write to EEPROM
|
|
||||||
void restoreConfig() {
|
|
||||||
int temp;
|
|
||||||
|
|
||||||
bool erase = false;
|
|
||||||
|
|
||||||
EEPROM.get(GAIN_FACTOR_ADDRESS, temp);
|
|
||||||
if (temp < 0 || temp > 4) {
|
|
||||||
erase = true;
|
|
||||||
} else {
|
|
||||||
GAIN_FACTOR = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
EEPROM.get(FOLLOWER_THRESHOLD_ADDRESS, temp);
|
|
||||||
if (temp < 0 || temp > 5000) {
|
|
||||||
erase = true;
|
|
||||||
} else {
|
|
||||||
followerThrs = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
EEPROM.get(COMP_THRESHOLD_ADDRESS, temp);
|
|
||||||
if (temp < 0 || temp > 5000) {
|
|
||||||
erase = true;
|
|
||||||
} else {
|
|
||||||
compThrs = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
EEPROM.get(LOOP_DUR_ADDRESS, temp);
|
|
||||||
if (temp < 0 && temp > 1000) {
|
|
||||||
erase = true;
|
|
||||||
} else {
|
|
||||||
LOOP_DUR = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
EEPROM.get(TRG_DUR_ADDRESS, temp);
|
|
||||||
if (temp < 0 || temp > 1000) {
|
|
||||||
erase = true;
|
|
||||||
} else {
|
|
||||||
TRG_DUR = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
EEPROM.get(HYST_ADDRESS, temp);
|
|
||||||
if (temp < 0 || temp > 1000) {
|
|
||||||
erase = true;
|
|
||||||
} else {
|
|
||||||
Hyst = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
EEPROM.get(PZDET_ADDRESS, temp);
|
|
||||||
if (temp < 0 || temp > 1) {
|
|
||||||
erase = true;
|
|
||||||
} else {
|
|
||||||
PZDET = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
EEPROM.get(LOGIC_ADDRESS, temp);
|
|
||||||
if (temp < 0 || temp > 1) {
|
|
||||||
erase = true;
|
|
||||||
} else {
|
|
||||||
LOGIC = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
long longTemp;
|
|
||||||
EEPROM.get(VM_CONST_ADDRESS, longTemp);
|
|
||||||
if (longTemp < 1000000L || longTemp > 1200000L) {
|
|
||||||
erase = true;
|
|
||||||
} else {
|
|
||||||
voltMeterConstant = longTemp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (erase) {
|
|
||||||
eraseEEPROM();
|
|
||||||
}
|
|
||||||
|
|
||||||
adjustFollow();
|
|
||||||
adjustComp();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDefaultConfig() {
|
|
||||||
GAIN_FACTOR = GAIN_FACTOR_DEFAULT;
|
|
||||||
followerThrs = FOLLOWER_THRESHOLD_DEFAULT;
|
|
||||||
compThrs = COMP_THRESHOLD_DEFAULT;
|
|
||||||
LOOP_DUR = LOOP_DUR_DEFAULT;
|
|
||||||
TRG_DUR = TRG_DUR_DEFAULT;
|
|
||||||
Hyst = HYST_DEFAULT;
|
|
||||||
PZDET = PZDET_DEFAULT;
|
|
||||||
LOGIC = LOGIC_DEFAULT;
|
|
||||||
voltMeterConstant = VM_CONST_DEFAULT;
|
|
||||||
adjustFollow();
|
|
||||||
adjustComp();
|
|
||||||
}
|
|
||||||
|
|
@ -1,131 +1,130 @@
|
||||||
#ifdef I2C_INPUT
|
#include "pP_i2c.hpp"
|
||||||
|
#include "pP_cmd.h"
|
||||||
|
#include "pP_i2c_config.h"
|
||||||
|
#include "pP_volatile.h"
|
||||||
|
#include <Wire1.h>
|
||||||
|
|
||||||
#include <Arduino.h>
|
uint8_t command;
|
||||||
#include "pP_config.h"
|
uint32_t value;
|
||||||
#include "pP_i2c.h"
|
|
||||||
#include <Wire.h>
|
|
||||||
|
|
||||||
byte registerMap[regMapSize];
|
|
||||||
byte registerMapTemp[regMapSize - 1];
|
|
||||||
byte receivedCommands[maxBytes];
|
|
||||||
|
|
||||||
pP_i2c::pP_i2c(){
|
|
||||||
|
|
||||||
|
void i2cWrite(uint8_t *buffer, int offset, int data) {
|
||||||
|
buffer[offset] = (uint8_t)(data >> 8);
|
||||||
|
buffer[offset + 1] = (uint8_t)data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pP_i2c::init() {
|
void i2cWrite(uint8_t *buffer, int offset, long data) {
|
||||||
Wire.begin(pP_i2c_address);
|
buffer[offset] = (uint8_t)(data >> 24);
|
||||||
Wire.onRequest(i2cReply);
|
buffer[offset + 1] = (uint8_t)(data >> 16);
|
||||||
Wire.onReceive(i2cInput);
|
buffer[offset + 2] = (uint8_t)(data >> 8);
|
||||||
|
buffer[offset + 3] = (uint8_t)data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pP_i2c::i2cReportStatus() {
|
void i2cReportConfig() {
|
||||||
_i2cResponse = "{"
|
uint8_t length = 20 + sizeof(PP_VERSION) - 1;
|
||||||
|
if (length > 32) {
|
||||||
|
length = 32;
|
||||||
|
}
|
||||||
|
uint8_t buffer[length];
|
||||||
|
i2cWrite(buffer, 0, GAIN_FACTOR);
|
||||||
|
i2cWrite(buffer, 2, followerThrs);
|
||||||
|
i2cWrite(buffer, 4, compThrs);
|
||||||
|
i2cWrite(buffer, 6, LOOP_DUR);
|
||||||
|
i2cWrite(buffer, 8, TRG_DUR);
|
||||||
|
i2cWrite(buffer, 10, Hyst);
|
||||||
|
i2cWrite(buffer, 12, LOGIC);
|
||||||
|
i2cWrite(buffer, 14, PZDET);
|
||||||
|
i2cWrite(buffer, 16, VCCSW);
|
||||||
|
i2cWrite(buffer, 18, voltMeterConstant);
|
||||||
|
memcpy(buffer + 22, PP_VERSION, length - 22);
|
||||||
|
Wire1.write(buffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pP_i2c::i2cReportVersion() {
|
void i2cReportState() {
|
||||||
|
uint8_t length = 10;
|
||||||
|
uint8_t buffer[length];
|
||||||
|
i2cWrite(buffer, 0, Vin);
|
||||||
|
i2cWrite(buffer, 2, (int)((long)VComp * Vin / 1023));
|
||||||
|
i2cWrite(buffer, 4, (int)((long)VFol * Vin / 1023));
|
||||||
|
i2cWrite(buffer, 6, ERR_STATE);
|
||||||
|
i2cWrite(buffer, 8, PZ_STATE);
|
||||||
|
Wire1.write(buffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pP_i2c::i2cReportConfig() {
|
void i2cReply() {
|
||||||
|
switch (command) {
|
||||||
|
case CMD_CONFIG:
|
||||||
|
case CMD_ERASE:
|
||||||
|
i2cReportConfig();
|
||||||
|
break;
|
||||||
|
case CMD_STATE:
|
||||||
|
i2cReportState();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void pP_i2c::i2cReportIdentity() {
|
void i2cInput(int bytesReceived) {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void pP_i2c::i2cRequestInput() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void pP_i2c::i2cReply() {
|
|
||||||
Wire.send()
|
|
||||||
}
|
|
||||||
|
|
||||||
void pP_i2c::i2cInput(int bytesReceived) {
|
|
||||||
for (int a = 0; a < bytesReceived; a++) {
|
for (int a = 0; a < bytesReceived; a++) {
|
||||||
// Check length of message, drops anything longer than [longBytes]
|
// Check length of message, drops anything longer than [longBytes]
|
||||||
if (a <= maxBytes) {
|
if (a == 0) {
|
||||||
cmdRcvd[a] = Wire.receive();
|
command = Wire1.read();
|
||||||
|
} else if (a == 1) {
|
||||||
|
value = Wire1.read();
|
||||||
|
} else {
|
||||||
|
value = value << 8 | Wire1.read();
|
||||||
}
|
}
|
||||||
elif (a <= longBytes) {
|
|
||||||
longRcvd[a] = Wire.receive();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Wire.receive(); //
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check input command corresponds with register map, set 0x00 if not
|
|
||||||
if (bytesReceived == 1 && (cmdRcvd[0] < regMapSize)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (bytesReceived == 1 && (cmdRcvd[0] >= regMapSize)) {
|
|
||||||
cmdRcvd[0] = 0x00;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse commands and apply changes or actions
|
// Parse commands and apply changes or actions
|
||||||
switch (cmdRcvd[0]) {
|
switch (command) {
|
||||||
case 0x00:
|
case CMD_GAIN_F:
|
||||||
i2cReportStatus();
|
updateGainFactor(value);
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case CMD_VFOL:
|
||||||
followerInt = (int) cmdRcvd[1];
|
updateVFol(value);
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
case CMD_VCOMP:
|
||||||
compInt = (int) cmdRcvd[1];
|
updateVComp(value);
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
case 0x03:
|
case CMD_LOOP_D:
|
||||||
GAIN_FACTOR = (int) cmdRcvd[1];
|
updateLoopDuration(value);
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
case 0x04:
|
case CMD_TRG_D:
|
||||||
Hyst = (int) cmdRcvd[1];
|
updateTrigDuration(value);
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
case 0x05:
|
case CMD_HYST:
|
||||||
LOOP_DUR = (int) cmdRcvd[1];
|
updateHysteresis(value);
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
case 0x06:
|
case CMD_LOGIC:
|
||||||
LOGIC = (int) cmdRcvd[1];
|
updateLogic(value);
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
case 0x07:
|
case CMD_PZDET:
|
||||||
PZDET = (int) cmdRcvd[1];
|
updatePzDet(value);
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
case 0x08:
|
case CMD_CONST:
|
||||||
TRG_DUR = (int) cmdRcvd[1];
|
updateConstant(value);
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
case 0x09:
|
case CMD_CONFIG:
|
||||||
DEBUG = (int) cmdRcvd[1];
|
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
case 0x0a:
|
case CMD_ERASE:
|
||||||
voltMeterConstant = longRcvd[0]*65536+longRcvd[1]*256+longRcvd[2];
|
eraseEEPROM();
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
case 0x0b:
|
case CMD_STATE:
|
||||||
reportVersion();
|
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
case 0x0c:
|
case CMD_VCCSW:
|
||||||
reportConfig();
|
updateVccSwitch(value);
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
case 0x0d:
|
case CMD_VCCADJUST:
|
||||||
reportIdentity();
|
adjustConstant(value);
|
||||||
return;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
void i2cInit() {
|
||||||
|
Wire1.begin(pP_i2c_address);
|
||||||
|
Wire1.onRequest(i2cReply);
|
||||||
|
Wire1.onReceive(i2cInput);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
#ifndef _pP_i2c_h_
|
|
||||||
#define _pP_i2c_h_
|
|
||||||
#ifdef I2C_INPUT
|
|
||||||
|
|
||||||
#define status_Offset 0x00 // Status register
|
|
||||||
#define senseInt_Offset 0x01 // Integer of sense threshold in millivolts
|
|
||||||
#define compInt_Offset 0x02 // Integer of comparator threshold in millivolts
|
|
||||||
#define gainFactor_Offset 0x03 // Gain adjustment factor. 0=3x, 1=3.5x, 2=4.33x, 3=6x, 4=11x
|
|
||||||
#define hysteresis_Offset 0x04 // Hysteresis value for ADC measurements
|
|
||||||
#define loopDuration_Offset 0x05 // duration of time between ADC checks and other loop functions
|
|
||||||
#define logicLevel_Offset 0x06
|
|
||||||
#define piezoDetect_Offset 0x07
|
|
||||||
#define triggerDuration_Offset 0x08 // duration of the Z-axis pulse sent, in ms
|
|
||||||
#define debugEnable_Offset 0x09
|
|
||||||
#define voltMeterLong_Offset 0x0a // For fine-tuning the input volt master
|
|
||||||
#define versionRegister_Offset 0x0b
|
|
||||||
#define configRegister_Offset 0x0c
|
|
||||||
#define identRegister_Offset 0x0d
|
|
||||||
|
|
||||||
/*-------------------------Variables------------------------*/
|
|
||||||
#define regMapSize 14
|
|
||||||
#define maxBytes 2
|
|
||||||
#define longBytes 4
|
|
||||||
byte regMap[regMapSize];
|
|
||||||
byte regMapTemp[regMapSize];
|
|
||||||
byte cmdRcvd[maxBytes];
|
|
||||||
byte longRcvd[longBytes];
|
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
class pP_i2c {
|
|
||||||
public:
|
|
||||||
pP_i2c(uint8_t address=pP_i2c_address);
|
|
||||||
void init();
|
|
||||||
void i2cInput(int bytesReceived);
|
|
||||||
private:
|
|
||||||
char _i2cResponse;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // I2C_INPUT
|
|
||||||
#endif // _pP_i2c_h_
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef _pP_i2c_h_
|
||||||
|
#define _pP_i2c_h_
|
||||||
|
|
||||||
|
#include "pP_config.h"
|
||||||
|
#include "stdint.h"
|
||||||
|
|
||||||
|
void i2cInit();
|
||||||
|
|
||||||
|
#endif // _pP_i2c_h_
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
#define CMD_GAIN_F 0x00
|
||||||
|
#define CMD_VFOL 0x01
|
||||||
|
#define CMD_VCOMP 0x02
|
||||||
|
#define CMD_LOOP_D 0x03
|
||||||
|
#define CMD_TRG_D 0x04
|
||||||
|
#define CMD_HYST 0x05
|
||||||
|
#define CMD_LOGIC 0x06
|
||||||
|
#define CMD_PZDET 0x07
|
||||||
|
#define CMD_CONST 0x08
|
||||||
|
#define CMD_CONFIG 0x09
|
||||||
|
#define CMD_ERASE 0x0a
|
||||||
|
#define CMD_STATE 0x0b
|
||||||
|
#define CMD_VCCSW 0x0c
|
||||||
|
#define CMD_VCCADJUST 0x0d
|
||||||
|
|
@ -31,3 +31,4 @@ Default pins (based on Rev.2.x.xPCB layout)
|
||||||
#define V_FOL_PWM 3 // PWM analog output pin for voltage follower adjustment
|
#define V_FOL_PWM 3 // PWM analog output pin for voltage follower adjustment
|
||||||
#define VCOMP_PWM 9 // PWM analog output pin for comparator adjustment
|
#define VCOMP_PWM 9 // PWM analog output pin for comparator adjustment
|
||||||
#define PZDET_PIN 16 // Digital input pin for detecting piezo connection
|
#define PZDET_PIN 16 // Digital input pin for detecting piezo connection
|
||||||
|
#define VCCSW_PIN 8 // VCC variable regulator switch pin
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
#include "pP_cmd.h"
|
||||||
|
#include "pP_volatile.h"
|
||||||
|
#include "string.h"
|
||||||
|
|
||||||
void parseData() {
|
void parseData() {
|
||||||
|
|
||||||
// split the data into its parts
|
// split the data into its parts
|
||||||
|
|
@ -9,16 +13,12 @@ void parseData() {
|
||||||
|
|
||||||
strtokIndx = strtok(NULL, " "); // this continues where the previous call left off
|
strtokIndx = strtok(NULL, " "); // this continues where the previous call left off
|
||||||
serialLong = atol(strtokIndx); // convert this part to an integer
|
serialLong = atol(strtokIndx); // convert this part to an integer
|
||||||
|
|
||||||
}
|
}
|
||||||
/*------------------------------------------------*/
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
void identifyMarkers() {
|
void identifyMarkers() {
|
||||||
|
|
||||||
char x = Serial.read();
|
char x = Serial.read();
|
||||||
#ifdef I2C_INPUT
|
|
||||||
char y = Wire.read();
|
|
||||||
#endif // I2C_INPUT
|
|
||||||
|
|
||||||
if (x == '\n' || x == '\r') {
|
if (x == '\n' || x == '\r') {
|
||||||
serialIncoming = true;
|
serialIncoming = true;
|
||||||
|
|
@ -32,111 +32,6 @@ void identifyMarkers() {
|
||||||
bytesRecvd = buffSize - 1;
|
bytesRecvd = buffSize - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef I2C_INPUT
|
|
||||||
if (y == '\n' || y == '\r') {
|
|
||||||
serialIncoming = true;
|
|
||||||
inputBuffer[bytesRecvd] = 0;
|
|
||||||
parseData();
|
|
||||||
bytesRecvd = 0;
|
|
||||||
} else {
|
|
||||||
inputBuffer[bytesRecvd] = y;
|
|
||||||
bytesRecvd++;
|
|
||||||
if (bytesRecvd == buffSize) {
|
|
||||||
bytesRecvd = buffSize - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void updateGainFactor()
|
|
||||||
{
|
|
||||||
if (serialLong >= 0) {
|
|
||||||
GAIN_FACTOR = serialLong;
|
|
||||||
adjustGain();
|
|
||||||
EEPROM.put(GAIN_FACTOR_ADDRESS, GAIN_FACTOR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void updateVFol() {
|
|
||||||
if (serialLong >= 0) {
|
|
||||||
followerThrs = serialLong;
|
|
||||||
adjustFollow();
|
|
||||||
EEPROM.put(FOLLOWER_THRESHOLD_ADDRESS, followerThrs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void updateVComp() {
|
|
||||||
if (serialLong >= 0) {
|
|
||||||
compThrs = serialLong;
|
|
||||||
adjustComp();
|
|
||||||
EEPROM.put(COMP_THRESHOLD_ADDRESS, compThrs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void updateLoopDuration() {
|
|
||||||
if (serialLong >= 0) {
|
|
||||||
LOOP_DUR = serialLong;
|
|
||||||
EEPROM.put(LOOP_DUR_ADDRESS, LOOP_DUR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void updateTrigDuration() {
|
|
||||||
if (serialLong >= 0) {
|
|
||||||
TRG_DUR = serialLong;
|
|
||||||
EEPROM.put(TRG_DUR_ADDRESS, TRG_DUR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void updateHysteresis() {
|
|
||||||
if (serialLong >= 0) {
|
|
||||||
Hyst = serialLong;
|
|
||||||
EEPROM.put(HYST_ADDRESS, Hyst);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void updateLogic() {
|
|
||||||
if (serialLong >= 0) {
|
|
||||||
LOGIC = serialLong;
|
|
||||||
EEPROM.put(LOGIC_ADDRESS, LOGIC);
|
|
||||||
pulse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void updatePzDet() {
|
|
||||||
if (serialLong >= 0) {
|
|
||||||
PZDET = serialLong;
|
|
||||||
EEPROM.put(PZDET_ADDRESS, PZDET);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void updateConstant() {
|
|
||||||
if (serialLong >= 0) {
|
|
||||||
voltMeterConstant = (long) serialLong;
|
|
||||||
EEPROM.put(VM_CONST_ADDRESS, voltMeterConstant);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
|
||||||
|
|
||||||
void updateDebug() {
|
|
||||||
if (serialLong > 0) {
|
|
||||||
Debug = 1;
|
|
||||||
} else if (serialLong == 0) {
|
|
||||||
Debug = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------*/
|
/*------------------------------------------------*/
|
||||||
|
|
@ -186,6 +81,20 @@ void serialPrintConfig() {
|
||||||
Serial.print("PZDET ");
|
Serial.print("PZDET ");
|
||||||
Serial.println(PZDET);
|
Serial.println(PZDET);
|
||||||
|
|
||||||
|
Serial.print("VCCSW ");
|
||||||
|
Serial.print(VCCSW);
|
||||||
|
switch (VCCSW) {
|
||||||
|
case 0:
|
||||||
|
Serial.println(" 3.3v");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
Serial.println(" 5v");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Serial.println(" INVALID");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Serial.print("VM_CONST ");
|
Serial.print("VM_CONST ");
|
||||||
Serial.println(voltMeterConstant);
|
Serial.println(voltMeterConstant);
|
||||||
|
|
||||||
|
|
@ -201,11 +110,11 @@ void serialPrintState() {
|
||||||
Serial.print(",");
|
Serial.print(",");
|
||||||
|
|
||||||
Serial.print("\"VComp\":");
|
Serial.print("\"VComp\":");
|
||||||
Serial.print((long) VComp * Vin / 1023);
|
Serial.print((long)VComp * Vin / 1023);
|
||||||
Serial.print(",");
|
Serial.print(",");
|
||||||
|
|
||||||
Serial.print("\"VFol\":");
|
Serial.print("\"VFol\":");
|
||||||
Serial.print((long) VFol * Vin / 1023);
|
Serial.print((long)VFol * Vin / 1023);
|
||||||
Serial.print(",");
|
Serial.print(",");
|
||||||
|
|
||||||
Serial.print("\"Err\":");
|
Serial.print("\"Err\":");
|
||||||
|
|
@ -214,59 +123,46 @@ void serialPrintState() {
|
||||||
|
|
||||||
Serial.print("\"PzCon\":");
|
Serial.print("\"PzCon\":");
|
||||||
Serial.print(PZ_STATE);
|
Serial.print(PZ_STATE);
|
||||||
Serial.print(",");
|
|
||||||
|
|
||||||
Serial.print("\"Firm_Ver\":");
|
|
||||||
Serial.print(PP_VERSION);
|
|
||||||
Serial.print(",");
|
|
||||||
|
|
||||||
Serial.println("}");
|
Serial.println("}");
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateParams() {
|
void updateParams() {
|
||||||
serialIncoming = false;
|
serialIncoming = false;
|
||||||
|
strupr(serialMessageIn);
|
||||||
if (strcmp(serialMessageIn, "GAIN_F") == 0) {
|
if (strcmp(serialMessageIn, "GAIN_F") == 0) {
|
||||||
updateGainFactor();
|
updateGainFactor(serialLong);
|
||||||
}
|
} else if (strcmp(serialMessageIn, "VFOL") == 0) {
|
||||||
else if (strcmp(serialMessageIn, "VFOL") == 0) {
|
updateVFol(serialLong);
|
||||||
updateVFol();
|
} else if (strcmp(serialMessageIn, "VCOMP") == 0) {
|
||||||
}
|
updateVComp(serialLong);
|
||||||
else if (strcmp(serialMessageIn, "VCOMP") == 0) {
|
} else if (strcmp(serialMessageIn, "LOOP_D") == 0) {
|
||||||
updateVComp();
|
updateLoopDuration(serialLong);
|
||||||
}
|
} else if (strcmp(serialMessageIn, "TRG_D") == 0) {
|
||||||
else if (strcmp(serialMessageIn, "LOOP_D") == 0) {
|
updateTrigDuration(serialLong);
|
||||||
updateLoopDuration();
|
} else if (strcmp(serialMessageIn, "HYST") == 0) {
|
||||||
}
|
updateHysteresis(serialLong);
|
||||||
else if (strcmp(serialMessageIn, "TRG_D") == 0) {
|
} else if (strcmp(serialMessageIn, "LOGIC") == 0) {
|
||||||
updateTrigDuration();
|
updateLogic(serialLong);
|
||||||
}
|
} else if (strcmp(serialMessageIn, "PZDET") == 0) {
|
||||||
else if (strcmp(serialMessageIn, "HYST") == 0) {
|
updatePzDet(serialLong);
|
||||||
updateHysteresis();
|
} else if (strcmp(serialMessageIn, "VCCSW") == 0) {
|
||||||
}
|
updateVccSwitch(serialLong);
|
||||||
else if (strcmp(serialMessageIn, "LOGIC") == 0) {
|
} else if (strcmp(serialMessageIn, "CONST") == 0) {
|
||||||
updateLogic();
|
updateConstant(serialLong);
|
||||||
}
|
} else if (strcmp(serialMessageIn, "VCCADJUST") == 0) {
|
||||||
else if (strcmp(serialMessageIn, "PZDET") == 0) {
|
adjustConstant(serialLong);
|
||||||
updatePzDet();
|
} else if (strcmp(serialMessageIn, "DEBUG") == 0) {
|
||||||
}
|
updateDebug(serialLong);
|
||||||
else if (strcmp(serialMessageIn, "CONST") == 0) {
|
} else if (strcmp(serialMessageIn, "CONFIG") == 0) {
|
||||||
updateConstant();
|
|
||||||
}
|
|
||||||
else if (strcmp(serialMessageIn, "DEBUG") == 0) {
|
|
||||||
updateDebug();
|
|
||||||
}
|
|
||||||
else if (strcmp(serialMessageIn, "CONFIG") == 0) {
|
|
||||||
serialPrintConfig();
|
serialPrintConfig();
|
||||||
}
|
} else if (strcmp(serialMessageIn, "ERASE") == 0) {
|
||||||
else if (strcmp(serialMessageIn, "ERASE") == 0) {
|
|
||||||
eraseEEPROM();
|
eraseEEPROM();
|
||||||
serialPrintConfig();
|
serialPrintConfig();
|
||||||
}
|
} else if (strcmp(serialMessageIn, "STATE") == 0) {
|
||||||
else if (strcmp(serialMessageIn, "STATE") == 0) {
|
|
||||||
serialPrintState();
|
serialPrintState();
|
||||||
}
|
} else if (strcmp(serialMessageIn, "HELP") == 0) {
|
||||||
else if (strcmp(serialMessageIn, "HELP") == 0) {
|
#if defined(ARDUINO_AVR_ATmega328PB)
|
||||||
#if defined(ARDUINO_AVR_ATmega328PB)
|
|
||||||
Serial.println("To change gain factor: GAIN_F [integer for gain state - see note*]");
|
Serial.println("To change gain factor: GAIN_F [integer for gain state - see note*]");
|
||||||
Serial.println("To change voltage follower voltage (low threshold): VFOL [float value]");
|
Serial.println("To change voltage follower voltage (low threshold): VFOL [float value]");
|
||||||
Serial.println("To change comparator voltage (high threshold): VCOMP [float value]");
|
Serial.println("To change comparator voltage (high threshold): VCOMP [float value]");
|
||||||
|
|
@ -276,7 +172,10 @@ void updateParams() {
|
||||||
Serial.println(" (0 for active low, 1 for active high)");
|
Serial.println(" (0 for active low, 1 for active high)");
|
||||||
Serial.println("To enable piezo plugged detection: PZDET [0|1]");
|
Serial.println("To enable piezo plugged detection: PZDET [0|1]");
|
||||||
Serial.println(" (0 for disabled, 1 for enabled)");
|
Serial.println(" (0 for disabled, 1 for enabled)");
|
||||||
|
Serial.println("To change the main voltage of the circuit: VCCSW [0|1]");
|
||||||
|
Serial.println(" (0 for 3.3v, 1 for 5v)");
|
||||||
Serial.println("To change ADC hysteresis value: HYST [integer in millivolts]");
|
Serial.println("To change ADC hysteresis value: HYST [integer in millivolts]");
|
||||||
|
Serial.println("To adjust VCC voltage readings: VCCADJUST [integer in millivolts, use value from multimeter]");
|
||||||
Serial.println("To enable or disable debug output: DEBUG [0|1]");
|
Serial.println("To enable or disable debug output: DEBUG [0|1]");
|
||||||
Serial.println("To print current config: CONFIG");
|
Serial.println("To print current config: CONFIG");
|
||||||
Serial.println("To set config to defaults: ERASE");
|
Serial.println("To set config to defaults: ERASE");
|
||||||
|
|
@ -289,14 +188,13 @@ void updateParams() {
|
||||||
Serial.println("Examples:");
|
Serial.println("Examples:");
|
||||||
Serial.println("GAIN_F 3 <~ set gain factor to index 3 (6x)");
|
Serial.println("GAIN_F 3 <~ set gain factor to index 3 (6x)");
|
||||||
Serial.println("VFOL 2350 <~ set the vref floor to 2.35V");
|
Serial.println("VFOL 2350 <~ set the vref floor to 2.35V");
|
||||||
#else
|
#else
|
||||||
Serial.println("Check docs.pyroballpcbs.com/config");
|
Serial.println("Check docs.pyroballpcbs.com/config");
|
||||||
#endif // defined(ARDUINO_AVR_ATmega328PB)
|
#endif // defined(ARDUINO_AVR_ATmega328PB)
|
||||||
}
|
}
|
||||||
parseData();
|
parseData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void serialInput() {
|
void serialInput() {
|
||||||
// receive data from Serial and save it into inputBuffer
|
// receive data from Serial and save it into inputBuffer
|
||||||
if (Serial.available() > 0) {
|
if (Serial.available() > 0) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
#include "pP_volatile.h"
|
||||||
|
#include "pP_config.h"
|
||||||
|
#include "stdint.h"
|
||||||
|
|
||||||
|
// these variables will change on their own. Do not edit ANYTHING below this line
|
||||||
|
volatile int sensorHReading = 0; // variable to store the value read from the sensor pin
|
||||||
|
volatile int ADJ_FOLLOW = 0; // Variable for Follower adjustment
|
||||||
|
volatile int ADJ_COMP = 0; // Variable for Comparator adjustment
|
||||||
|
volatile int ERR_STATE = 0;
|
||||||
|
volatile int PZ_STATE = 0;
|
||||||
|
|
||||||
|
int Vin = 5000; // input reference voltage in millivolts (multiply V by 1000)
|
||||||
|
int VOld = 5000; // Variable to store previous cycle's Vin
|
||||||
|
int VLast = 0;
|
||||||
|
|
||||||
|
// Convert threshold values based on the input voltage
|
||||||
|
|
||||||
|
long followerLong = followerThrs * 1023L;
|
||||||
|
long compLong = compThrs * 1023L;
|
||||||
|
long followerInt = 0;
|
||||||
|
long compInt = 0;
|
||||||
|
|
||||||
|
// Voltage Comparator Adjustment parameters
|
||||||
|
int VComp = 0;
|
||||||
|
|
||||||
|
// Voltage Follower Adjustment parameters
|
||||||
|
int VFol = 0;
|
||||||
|
|
||||||
|
// Error blink parameters
|
||||||
|
|
||||||
|
int BlinkState = 0;
|
||||||
|
int BlinkCount = (InitCount * 2) + 1; // Multiply Blink count by 2 to handle toggle state, add one extra to make sure light is on after
|
||||||
|
|
||||||
|
// Serial Input Parsing Variables
|
||||||
|
char inputBuffer[buffSize];
|
||||||
|
uint8_t bytesRecvd = 0;
|
||||||
|
bool serialIncoming = false;
|
||||||
|
char serialMessageIn[buffSize] = {0};
|
||||||
|
long serialLong = 0;
|
||||||
|
|
||||||
|
LightChrono mainLoop;
|
||||||
|
|
@ -1,43 +1,51 @@
|
||||||
// these variables will change on their own. Do not edit ANYTHING below this line
|
#ifndef PP_VOLATILE_H
|
||||||
volatile int sensorHReading = 0; // variable to store the value read from the sensor pin
|
#define PP_VOLATILE_H
|
||||||
volatile int ADJ_FOLLOW = 0; // Variable for Follower adjustment
|
|
||||||
volatile int ADJ_COMP = 0; // Variable for Comparator adjustment
|
|
||||||
volatile int ERR_STATE = 0;
|
|
||||||
volatile int PZ_STATE = 0;
|
|
||||||
|
|
||||||
int Vin = 5000; // input reference voltage in millivolts (multiply V by 1000)
|
#include "LightChrono.h"
|
||||||
int VOld = 5000; // Variable to store previous cycle's Vin
|
#include "stdint.h"
|
||||||
int VLast = 0;
|
|
||||||
|
// these variables will change on their own. Do not edit ANYTHING below this line
|
||||||
|
extern volatile int sensorHReading; // variable to store the value read from the sensor pin
|
||||||
|
extern volatile int ADJ_FOLLOW; // Variable for Follower adjustment
|
||||||
|
extern volatile int ADJ_COMP; // Variable for Comparator adjustment
|
||||||
|
extern volatile int ERR_STATE;
|
||||||
|
extern volatile int PZ_STATE;
|
||||||
|
|
||||||
|
extern int Vin; // input reference voltage in millivolts (multiply V by 1000)
|
||||||
|
extern int VOld; // Variable to store previous cycle's Vin
|
||||||
|
extern int VLast;
|
||||||
|
|
||||||
// Convert threshold values based on the input voltage
|
// Convert threshold values based on the input voltage
|
||||||
|
|
||||||
long followerLong = followerThrs * 1023L;
|
extern long followerLong;
|
||||||
long compLong = compThrs * 1023L;
|
extern long compLong;
|
||||||
long followerInt;
|
extern long followerInt;
|
||||||
long compInt;
|
extern long compInt;
|
||||||
|
|
||||||
// Voltage Comparator Adjustment parameters
|
// Voltage Comparator Adjustment parameters
|
||||||
int VComp = 0;
|
extern int VComp;
|
||||||
|
|
||||||
// Voltage Follower Adjustment parameters
|
// Voltage Follower Adjustment parameters
|
||||||
int VFol = 0;
|
extern int VFol;
|
||||||
|
|
||||||
// Error blink parameters
|
// Error blink parameters
|
||||||
|
|
||||||
int BlinkState = 0;
|
extern int BlinkState;
|
||||||
int BlinkCount = (InitCount * 2) + 1; // Multiply Blink count by 2 to handle toggle state, add one extra to make sure light is on after
|
extern int BlinkCount; // Multiply Blink count by 2 to handle toggle state, add one extra to make sure light is on after
|
||||||
|
|
||||||
// Serial Input Parsing Variables
|
// Serial Input Parsing Variables
|
||||||
#define buffSize 40
|
#define buffSize 40
|
||||||
char inputBuffer[buffSize];
|
extern char inputBuffer[buffSize];
|
||||||
#define endMarker '\n'
|
#define endMarker '\n'
|
||||||
byte bytesRecvd = 0;
|
extern uint8_t bytesRecvd;
|
||||||
bool serialIncoming = false;
|
extern bool serialIncoming;
|
||||||
char serialMessageIn[buffSize] = {0};
|
extern char serialMessageIn[buffSize];
|
||||||
long serialLong = 0;
|
extern long serialLong;
|
||||||
|
|
||||||
//#define LOW 0
|
//#define LOW 0
|
||||||
//#define HIGH 1
|
//#define HIGH 1
|
||||||
|
|
||||||
// Task scheduler instances
|
// Task scheduler instances
|
||||||
LightChrono mainLoop;
|
extern LightChrono mainLoop;
|
||||||
|
|
||||||
|
#endif // PP_VOLATILE_H
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
major_version = "2.2.1"
|
major_version = "2.3.0"
|
||||||
print("-DPP_VERSION=\\\"" + major_version + "_" + subprocess.check_output(["git", "rev-parse", "HEAD"])[0:6] + "\\\"")
|
|
||||||
|
git_head = str(subprocess.check_output(["git", "rev-parse", "HEAD"])[0:6])
|
||||||
|
|
||||||
|
print("-DPP_VERSION=\\\"" + major_version + "_" + git_head + "\\\"")
|
||||||
3
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/.clang-format
Normal file
3
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/.clang-format
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
ColumnLimit: 200
|
||||||
|
AllowShortFunctionsOnASingleLine: false
|
||||||
7
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/.gitignore
vendored
Normal file
7
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
.pio
|
||||||
|
.vscode/.browse.c_cpp.db*
|
||||||
|
.vscode/c_cpp_properties.json
|
||||||
|
.vscode/launch.json
|
||||||
|
.vscode/ipch
|
||||||
|
.vscode/settings.json
|
||||||
|
.travis.yml
|
||||||
7
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/.vscode/extensions.json
vendored
Normal file
7
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/.vscode/extensions.json
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||||
|
// for the documentation about the extensions.json format
|
||||||
|
"recommendations": [
|
||||||
|
"platformio.platformio-ide"
|
||||||
|
]
|
||||||
|
}
|
||||||
39
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/include/README
Normal file
39
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/include/README
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
|
||||||
|
This directory is intended for project header files.
|
||||||
|
|
||||||
|
A header file is a file containing C declarations and macro definitions
|
||||||
|
to be shared between several project source files. You request the use of a
|
||||||
|
header file in your project source file (C, C++, etc) located in `src` folder
|
||||||
|
by including it, with the C preprocessing directive `#include'.
|
||||||
|
|
||||||
|
```src/main.c
|
||||||
|
|
||||||
|
#include "header.h"
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Including a header file produces the same results as copying the header file
|
||||||
|
into each source file that needs it. Such copying would be time-consuming
|
||||||
|
and error-prone. With a header file, the related declarations appear
|
||||||
|
in only one place. If they need to be changed, they can be changed in one
|
||||||
|
place, and programs that include the header file will automatically use the
|
||||||
|
new version when next recompiled. The header file eliminates the labor of
|
||||||
|
finding and changing all the copies as well as the risk that a failure to
|
||||||
|
find one copy will result in inconsistencies within a program.
|
||||||
|
|
||||||
|
In C, the usual convention is to give header files names that end with `.h'.
|
||||||
|
It is most portable to use only letters, digits, dashes, and underscores in
|
||||||
|
header file names, and at most one dot.
|
||||||
|
|
||||||
|
Read more about using header files in official GCC documentation:
|
||||||
|
|
||||||
|
* Include Syntax
|
||||||
|
* Include Operation
|
||||||
|
* Once-Only Headers
|
||||||
|
* Computed Includes
|
||||||
|
|
||||||
|
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||||
46
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/lib/README
Normal file
46
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/lib/README
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
|
||||||
|
This directory is intended for project specific (private) libraries.
|
||||||
|
PlatformIO will compile them to static libraries and link into executable file.
|
||||||
|
|
||||||
|
The source code of each library should be placed in a an own separate directory
|
||||||
|
("lib/your_library_name/[here are source files]").
|
||||||
|
|
||||||
|
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||||
|
|
||||||
|
|--lib
|
||||||
|
| |
|
||||||
|
| |--Bar
|
||||||
|
| | |--docs
|
||||||
|
| | |--examples
|
||||||
|
| | |--src
|
||||||
|
| | |- Bar.c
|
||||||
|
| | |- Bar.h
|
||||||
|
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||||
|
| |
|
||||||
|
| |--Foo
|
||||||
|
| | |- Foo.c
|
||||||
|
| | |- Foo.h
|
||||||
|
| |
|
||||||
|
| |- README --> THIS FILE
|
||||||
|
|
|
||||||
|
|- platformio.ini
|
||||||
|
|--src
|
||||||
|
|- main.c
|
||||||
|
|
||||||
|
and a contents of `src/main.c`:
|
||||||
|
```
|
||||||
|
#include <Foo.h>
|
||||||
|
#include <Bar.h>
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
PlatformIO Library Dependency Finder will find automatically dependent
|
||||||
|
libraries scanning project source files.
|
||||||
|
|
||||||
|
More information about PlatformIO Library Dependency Finder
|
||||||
|
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||||
14
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/platformio.ini
Normal file
14
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/platformio.ini
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
; PlatformIO Project Configuration File
|
||||||
|
;
|
||||||
|
; Build options: build flags, source filter
|
||||||
|
; Upload options: custom upload port, speed and extra flags
|
||||||
|
; Library options: dependencies, extra library storages
|
||||||
|
; Advanced options: extra scripting
|
||||||
|
;
|
||||||
|
; Please visit documentation for the other options and examples
|
||||||
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
|
[env:uno]
|
||||||
|
platform = atmelavr
|
||||||
|
board = uno
|
||||||
|
framework = arduino
|
||||||
81
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/src/i2c.cpp
Normal file
81
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/src/i2c.cpp
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
#include "i2c.h"
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "Wire.h"
|
||||||
|
|
||||||
|
uint16_t read16() {
|
||||||
|
uint8_t value = Wire.read();
|
||||||
|
uint8_t value1 = Wire.read();
|
||||||
|
return ((uint16_t)value) << 8 | value1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t read32() {
|
||||||
|
uint8_t value = Wire.read();
|
||||||
|
uint8_t value1 = Wire.read();
|
||||||
|
uint8_t value2 = Wire.read();
|
||||||
|
uint8_t value3 = Wire.read();
|
||||||
|
return ((uint32_t)value) << 24 | ((uint32_t)value1) << 16 | ((uint16_t)value2) << 8 | value3;
|
||||||
|
}
|
||||||
|
|
||||||
|
void write(uint8_t cmd) {
|
||||||
|
Wire.beginTransmission(ADDRESS);
|
||||||
|
Wire.write(cmd);
|
||||||
|
Wire.endTransmission();
|
||||||
|
}
|
||||||
|
|
||||||
|
void write(uint8_t cmd, uint16_t value) {
|
||||||
|
Wire.beginTransmission(ADDRESS);
|
||||||
|
Wire.write(cmd);
|
||||||
|
Wire.write(value >> 8);
|
||||||
|
Wire.write(value);
|
||||||
|
Wire.endTransmission();
|
||||||
|
}
|
||||||
|
|
||||||
|
void write(uint8_t cmd, uint32_t value) {
|
||||||
|
Wire.beginTransmission(ADDRESS);
|
||||||
|
Wire.write(cmd);
|
||||||
|
Wire.write(value >> 24);
|
||||||
|
Wire.write(value >> 16);
|
||||||
|
Wire.write(value >> 8);
|
||||||
|
Wire.write(value);
|
||||||
|
Wire.endTransmission();
|
||||||
|
}
|
||||||
|
|
||||||
|
config_t requestConfig() {
|
||||||
|
Wire.beginTransmission(ADDRESS);
|
||||||
|
Wire.write(CMD_CONFIG);
|
||||||
|
Wire.endTransmission();
|
||||||
|
|
||||||
|
uint8_t bytes = Wire.requestFrom(ADDRESS, 255);
|
||||||
|
|
||||||
|
config_t config;
|
||||||
|
config.GAIN_FACTOR = read16();
|
||||||
|
config.followerThrs = read16();
|
||||||
|
config.compThrs = read16();
|
||||||
|
config.LOOP_DUR = read16();
|
||||||
|
config.TRG_DUR = read16();
|
||||||
|
config.Hyst = read16();
|
||||||
|
config.LOGIC = read16();
|
||||||
|
config.PZDET = read16();
|
||||||
|
config.VCCSW = read16();
|
||||||
|
config.voltMeterConstant = read32();
|
||||||
|
config.version = Wire.readString();
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
state_t requestState() {
|
||||||
|
Wire.beginTransmission(ADDRESS);
|
||||||
|
Wire.write(CMD_STATE);
|
||||||
|
Wire.endTransmission();
|
||||||
|
|
||||||
|
uint8_t bytes = Wire.requestFrom(ADDRESS, 10);
|
||||||
|
|
||||||
|
state_t state;
|
||||||
|
state.Vin = read16();
|
||||||
|
state.VComp = read16();
|
||||||
|
state.VFol = read16();
|
||||||
|
state.ERR_STATE = read16();
|
||||||
|
state.PZ_STATE = read16();
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
52
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/src/i2c.h
Normal file
52
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/src/i2c.h
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
#ifndef I2C
|
||||||
|
#define I2C
|
||||||
|
|
||||||
|
#define ADDRESS 0x10
|
||||||
|
|
||||||
|
#define CMD_GAIN_F 0x00
|
||||||
|
#define CMD_VFOL 0x01
|
||||||
|
#define CMD_VCOMP 0x02
|
||||||
|
#define CMD_LOOP_D 0x03
|
||||||
|
#define CMD_TRG_D 0x04
|
||||||
|
#define CMD_HYST 0x05
|
||||||
|
#define CMD_LOGIC 0x06
|
||||||
|
#define CMD_PZDET 0x07
|
||||||
|
#define CMD_CONST 0x08
|
||||||
|
#define CMD_CONFIG 0x09
|
||||||
|
#define CMD_ERASE 0x0a
|
||||||
|
#define CMD_STATE 0x0b
|
||||||
|
#define CMD_VCCSW 0x0c
|
||||||
|
#define CMD_VCCADJUST 0x0d
|
||||||
|
|
||||||
|
#include "WString.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t GAIN_FACTOR;
|
||||||
|
uint16_t followerThrs;
|
||||||
|
uint16_t compThrs;
|
||||||
|
uint16_t LOOP_DUR;
|
||||||
|
uint16_t TRG_DUR;
|
||||||
|
uint16_t Hyst;
|
||||||
|
uint16_t LOGIC;
|
||||||
|
uint16_t PZDET;
|
||||||
|
uint16_t VCCSW;
|
||||||
|
uint32_t voltMeterConstant;
|
||||||
|
String version;
|
||||||
|
} config_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t Vin;
|
||||||
|
uint16_t VComp;
|
||||||
|
uint16_t VFol;
|
||||||
|
uint16_t ERR_STATE;
|
||||||
|
uint16_t PZ_STATE;
|
||||||
|
} state_t;
|
||||||
|
|
||||||
|
void write(uint8_t cmd);
|
||||||
|
void write(uint8_t cmd, uint16_t value);
|
||||||
|
void write(uint8_t cmd, uint32_t value);
|
||||||
|
|
||||||
|
config_t requestConfig();
|
||||||
|
state_t requestState();
|
||||||
|
|
||||||
|
#endif
|
||||||
21
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/src/main.cpp
Normal file
21
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/src/main.cpp
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
#define ARDUINO_AVR_ATmega328PB
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
|
#include "pP_serial.h"
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(9600);
|
||||||
|
Serial.println("Initializing Pyr0-Piezo i2c Bridge...");
|
||||||
|
|
||||||
|
Wire.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
serialInput();
|
||||||
|
|
||||||
|
if (serialIncoming) {
|
||||||
|
updateParams();
|
||||||
|
}
|
||||||
|
}
|
||||||
214
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/src/pP_serial.h
Normal file
214
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/src/pP_serial.h
Normal file
|
|
@ -0,0 +1,214 @@
|
||||||
|
#include "i2c.h"
|
||||||
|
#include "stdint.h"
|
||||||
|
#include "string.h"
|
||||||
|
|
||||||
|
#define buffSize 40
|
||||||
|
bool serialIncoming = false;
|
||||||
|
uint8_t bytesRecvd = 0;
|
||||||
|
char inputBuffer[buffSize];
|
||||||
|
char serialMessageIn[buffSize] = {0};
|
||||||
|
uint32_t serialLong = 0;
|
||||||
|
|
||||||
|
void parseData() {
|
||||||
|
|
||||||
|
// split the data into its parts
|
||||||
|
|
||||||
|
char *strtokIndx; // this is used by strtok() as an index
|
||||||
|
|
||||||
|
strtokIndx = strtok(inputBuffer, " "); // get the first part - the string
|
||||||
|
strcpy(serialMessageIn, strtokIndx); // copy it to serialMessageIn
|
||||||
|
|
||||||
|
strtokIndx = strtok(NULL, " "); // this continues where the previous call left off
|
||||||
|
serialLong = atol(strtokIndx); // convert this part to an integer
|
||||||
|
}
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void identifyMarkers() {
|
||||||
|
|
||||||
|
char x = Serial.read();
|
||||||
|
|
||||||
|
if (x == '\n' || x == '\r') {
|
||||||
|
serialIncoming = true;
|
||||||
|
inputBuffer[bytesRecvd] = 0;
|
||||||
|
parseData();
|
||||||
|
bytesRecvd = 0;
|
||||||
|
} else {
|
||||||
|
inputBuffer[bytesRecvd] = x;
|
||||||
|
bytesRecvd++;
|
||||||
|
if (bytesRecvd == buffSize) {
|
||||||
|
bytesRecvd = buffSize - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------*/
|
||||||
|
|
||||||
|
void serialPrintConfig() {
|
||||||
|
config_t config = requestConfig();
|
||||||
|
|
||||||
|
Serial.print("GAIN_F ");
|
||||||
|
Serial.print(config.GAIN_FACTOR);
|
||||||
|
switch (config.GAIN_FACTOR) {
|
||||||
|
case 0:
|
||||||
|
Serial.println(" 3x");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
Serial.println(" 3.5x");
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
Serial.println(" 4.33x");
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
Serial.println(" 6x");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
Serial.println(" 11x");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Serial.println(" INVALID");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.print("VFOL ");
|
||||||
|
Serial.println(config.followerThrs);
|
||||||
|
|
||||||
|
Serial.print("VCOMP ");
|
||||||
|
Serial.println(config.compThrs);
|
||||||
|
|
||||||
|
Serial.print("LOOP_D ");
|
||||||
|
Serial.println(config.LOOP_DUR);
|
||||||
|
|
||||||
|
Serial.print("TRG_D ");
|
||||||
|
Serial.println(config.TRG_DUR);
|
||||||
|
|
||||||
|
Serial.print("HYST ");
|
||||||
|
Serial.println(config.Hyst);
|
||||||
|
|
||||||
|
Serial.print("LOGIC ");
|
||||||
|
Serial.println(config.LOGIC);
|
||||||
|
|
||||||
|
Serial.print("PZDET ");
|
||||||
|
Serial.println(config.PZDET);
|
||||||
|
|
||||||
|
Serial.print("VCCSW ");
|
||||||
|
Serial.print(config.VCCSW);
|
||||||
|
switch (config.VCCSW) {
|
||||||
|
case 0:
|
||||||
|
Serial.println(" 3.3v");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
Serial.println(" 5v");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Serial.println(" INVALID");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.print("VM_CONST ");
|
||||||
|
Serial.println(config.voltMeterConstant);
|
||||||
|
|
||||||
|
Serial.print("Firmware Version ");
|
||||||
|
Serial.println(config.version);
|
||||||
|
}
|
||||||
|
|
||||||
|
void serialPrintState() {
|
||||||
|
state_t state = requestState();
|
||||||
|
|
||||||
|
Serial.print("{");
|
||||||
|
|
||||||
|
Serial.print("\"Vcc\":");
|
||||||
|
Serial.print(state.Vin);
|
||||||
|
Serial.print(",");
|
||||||
|
|
||||||
|
Serial.print("\"VComp\":");
|
||||||
|
Serial.print(state.VComp);
|
||||||
|
Serial.print(",");
|
||||||
|
|
||||||
|
Serial.print("\"VFol\":");
|
||||||
|
Serial.print(state.VFol);
|
||||||
|
Serial.print(",");
|
||||||
|
|
||||||
|
Serial.print("\"Err\":");
|
||||||
|
Serial.print(state.ERR_STATE);
|
||||||
|
Serial.print(",");
|
||||||
|
|
||||||
|
Serial.print("\"PzCon\":");
|
||||||
|
Serial.print(state.PZ_STATE);
|
||||||
|
|
||||||
|
Serial.println("}");
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateParams() {
|
||||||
|
serialIncoming = false;
|
||||||
|
strupr(serialMessageIn);
|
||||||
|
if (strcmp(serialMessageIn, "GAIN_F") == 0) {
|
||||||
|
write(CMD_GAIN_F, (uint16_t)serialLong);
|
||||||
|
} else if (strcmp(serialMessageIn, "VFOL") == 0) {
|
||||||
|
write(CMD_VFOL, (uint16_t)serialLong);
|
||||||
|
} else if (strcmp(serialMessageIn, "VCOMP") == 0) {
|
||||||
|
write(CMD_VCOMP, (uint16_t)serialLong);
|
||||||
|
} else if (strcmp(serialMessageIn, "LOOP_D") == 0) {
|
||||||
|
write(CMD_LOOP_D, (uint16_t)serialLong);
|
||||||
|
} else if (strcmp(serialMessageIn, "TRG_D") == 0) {
|
||||||
|
write(CMD_TRG_D, (uint16_t)serialLong);
|
||||||
|
} else if (strcmp(serialMessageIn, "HYST") == 0) {
|
||||||
|
write(CMD_HYST, (uint16_t)serialLong);
|
||||||
|
} else if (strcmp(serialMessageIn, "LOGIC") == 0) {
|
||||||
|
write(CMD_LOGIC, (uint16_t)serialLong);
|
||||||
|
} else if (strcmp(serialMessageIn, "PZDET") == 0) {
|
||||||
|
write(CMD_PZDET, (uint16_t)serialLong);
|
||||||
|
} else if (strcmp(serialMessageIn, "VCCSW") == 0) {
|
||||||
|
write(CMD_VCCSW, (uint16_t)serialLong);
|
||||||
|
} else if (strcmp(serialMessageIn, "CONST") == 0) {
|
||||||
|
write(CMD_CONST, serialLong);
|
||||||
|
} else if (strcmp(serialMessageIn, "VCCADJUST") == 0) {
|
||||||
|
write(CMD_VCCADJUST, (uint16_t)serialLong);
|
||||||
|
} else if (strcmp(serialMessageIn, "CONFIG") == 0) {
|
||||||
|
serialPrintConfig();
|
||||||
|
} else if (strcmp(serialMessageIn, "ERASE") == 0) {
|
||||||
|
write(CMD_ERASE);
|
||||||
|
serialPrintConfig();
|
||||||
|
} else if (strcmp(serialMessageIn, "STATE") == 0) {
|
||||||
|
serialPrintState();
|
||||||
|
} else if (strcmp(serialMessageIn, "HELP") == 0) {
|
||||||
|
#if defined(ARDUINO_AVR_ATmega328PB)
|
||||||
|
Serial.println("To change gain factor: GAIN_F [integer for gain state - see note*]");
|
||||||
|
Serial.println("To change voltage follower voltage (low threshold): VFOL [float value]");
|
||||||
|
Serial.println("To change comparator voltage (high threshold): VCOMP [float value]");
|
||||||
|
Serial.println("To change main loop period: LOOP_D [integer for milliseconds]");
|
||||||
|
Serial.println("To change trigger active duration: TRG_D [integer for milliseconds]");
|
||||||
|
Serial.println("To change the output logic: LOGIC [0|1]");
|
||||||
|
Serial.println(" (0 for active low, 1 for active high)");
|
||||||
|
Serial.println("To enable piezo plugged detection: PZDET [0|1]");
|
||||||
|
Serial.println(" (0 for disabled, 1 for enabled)");
|
||||||
|
Serial.println("To change the main voltage of the circuit: VCCSW [0|1]");
|
||||||
|
Serial.println(" (0 for 3.3v, 1 for 5v)");
|
||||||
|
Serial.println("To change ADC hysteresis value: HYST [integer in millivolts]");
|
||||||
|
Serial.println("To adjust VCC voltage readings: VCCADJUST [integer in millivolts, use value from multimeter]");
|
||||||
|
Serial.println("To enable or disable debug output: DEBUG [0|1]");
|
||||||
|
Serial.println("To print current config: CONFIG");
|
||||||
|
Serial.println("To set config to defaults: ERASE");
|
||||||
|
Serial.println("To print current state: STATE");
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println("Commands are entered in this format:");
|
||||||
|
Serial.println("CMD VAL");
|
||||||
|
Serial.println("Commands are confirmed with Enter key");
|
||||||
|
Serial.println("");
|
||||||
|
Serial.println("Examples:");
|
||||||
|
Serial.println("GAIN_F 3 <~ set gain factor to index 3 (6x)");
|
||||||
|
Serial.println("VFOL 2350 <~ set the vref floor to 2.35V");
|
||||||
|
#else
|
||||||
|
Serial.println("Check docs.pyroballpcbs.com/config");
|
||||||
|
#endif // defined(ARDUINO_AVR_ATmega328PB)
|
||||||
|
}
|
||||||
|
parseData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void serialInput() {
|
||||||
|
// receive data from Serial and save it into inputBuffer
|
||||||
|
if (Serial.available() > 0) {
|
||||||
|
|
||||||
|
// the order of these IF clauses is significant
|
||||||
|
identifyMarkers();
|
||||||
|
}
|
||||||
|
}
|
||||||
11
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/test/README
Normal file
11
firmware/AVR-Source/Pyr0_Piezo_i2c_Bridge/test/README
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
This directory is intended for PIO Unit Testing and project tests.
|
||||||
|
|
||||||
|
Unit Testing is a software testing method by which individual units of
|
||||||
|
source code, sets of one or more MCU program modules together with associated
|
||||||
|
control data, usage procedures, and operating procedures, are tested to
|
||||||
|
determine whether they are fit for use. Unit testing finds problems early
|
||||||
|
in the development cycle.
|
||||||
|
|
||||||
|
More information about PIO Unit Testing:
|
||||||
|
- https://docs.platformio.org/page/plus/unit-testing.html
|
||||||
|
|
@ -90,6 +90,7 @@ nav:
|
||||||
- Changelog:
|
- Changelog:
|
||||||
- Version List: 'changelog.md'
|
- Version List: 'changelog.md'
|
||||||
- Logs:
|
- Logs:
|
||||||
|
- 'v2.2.1-v2.3.0': 'changelogs/changelog_2020-05-10_v2.2.1_v2.3.0.md'
|
||||||
- 'v2.2.0-v2.2.1': 'changelogs/changelog_2020-01-16_v2.2.0_v2.2.1.md'
|
- 'v2.2.0-v2.2.1': 'changelogs/changelog_2020-01-16_v2.2.0_v2.2.1.md'
|
||||||
- 'v2.1.5-v2.1.6': 'changelogs/changelog_2019-12-28_v2.1.5_v2.1.6.md'
|
- 'v2.1.5-v2.1.6': 'changelogs/changelog_2019-12-28_v2.1.5_v2.1.6.md'
|
||||||
- 'v2.1.4-v2.1.5': 'changelogs/changelog_2019-10-30_v2.1.4_v2.1.5.md'
|
- 'v2.1.4-v2.1.5': 'changelogs/changelog_2019-10-30_v2.1.4_v2.1.5.md'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue