Compare commits

...

143 Commits

Author SHA1 Message Date
YiChin c94c382dae error fix 2019-10-29 12:28:07 +08:00
weiting2 0a19abd0e8 first attempt to pointer of pointer 2019-10-24 12:10:08 +08:00
YiChin 284cfe6d05 double pointer attempt 2019-10-24 11:52:34 +08:00
weiting2 3298b6226b first attempt to pointer of pointer 2019-10-24 11:48:19 +08:00
YiChin dfcaf2d908 double pointer attempt 2019-10-24 11:45:00 +08:00
weiting2 d517318a67 first attempt to pointer of pointer 2019-10-24 11:36:59 +08:00
weiting2 d0aa520329 Merge branch 'Elite_master' of https://gitlab.com/bioproscientific/bioprocc2650 into Elite_master 2019-10-24 11:02:41 +08:00
weiting2 9a875b8459 first attempt to pointer of pointer 2019-10-24 10:59:19 +08:00
YiChin 73ac2f5c90 should be a stable version 2019-10-24 10:17:24 +08:00
YiChin efcb1132de auto gain seems done
need more test
2019-10-23 18:42:17 +08:00
YiChin 7492ed161d auto gain prob 2019-10-23 17:05:25 +08:00
YiChin ae7ec2e5ce auto gain prob 2019-10-23 16:42:28 +08:00
weiting2 63fde4bdbc TODO: IV CV add Imax 2019-10-23 14:04:35 +08:00
YiChin 32ccb8838f add water star data 2019-10-23 11:14:00 +08:00
YiChin 5b6fd53830 CV underflow done? 2019-10-23 10:42:53 +08:00
YiChin 86eef98b13 CV still underflow, implement auto gain on IV CV IT RT 2019-10-22 18:15:35 +08:00
YiChin 3fdbfcf39f CV still underflow 2019-10-22 15:25:41 +08:00
weiting2 847ea9f3c0 IV underflow 2019-10-22 14:56:01 +08:00
weiting2 25bd5b5ebe auto gain 2019-10-22 14:27:27 +08:00
YiChin 335fe6a9a4 IV CV still underflow 2019-10-22 12:28:48 +08:00
YiChin 6a0480613c fix CC mode feedback bug 2019-10-22 11:55:16 +08:00
YiChin 300fb9a44c fix IV CV underflow if Vfinal = -5V 2019-10-22 11:41:38 +08:00
weiting2 4fac2aa380 update board 21 2019-10-22 10:11:44 +08:00
YiChin d2ab4c1fe8 RT done, UI should X1e5 for every resister value 2019-10-21 19:01:24 +08:00
YiChin 6048e10ab7 RT done, UI should X1e5 for every resister value 2019-10-21 18:28:00 +08:00
weiting2 6bd94e3f73 gain switch in RT mode 2019-10-21 17:52:22 +08:00
YiChin fc302d4c75 should modify DAC usercode 2019-10-21 16:53:49 +08:00
weiting2 26a35a1446 gain switch in RT mode 2019-10-21 14:45:53 +08:00
YiChin 8f2eda7281 The least gain can not witch to max gain in one step 2019-10-21 12:20:44 +08:00
weiting2 e26a97a32f Merge remote-tracking branch 'origin/Elite_ZTcurve' into Elite_ZTcurve 2019-10-21 11:38:49 +08:00
weiting2 5bdb0b04da gain switch in one cycle, debug 2019-10-21 11:38:31 +08:00
YiChin 8f8407601e error fix 2019-10-21 11:31:47 +08:00
YiChin 4c6dbcf98d error fix 2019-10-21 11:26:40 +08:00
weiting2 20ccd5de56 gain switch in one cycle 2019-10-21 11:24:59 +08:00
weiting2 3c3ad8ccc7 Merge remote-tracking branch 'origin/Elite_ZTcurve' into Elite_ZTcurve
# Conflicts:
#	simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteITCurve.h
2019-10-21 11:21:42 +08:00
weiting2 1030d6625b TODO: gain switch in one cycle 2019-10-21 11:20:46 +08:00
weiting2 326f3eb6b6 LED shows ADC gain state 2019-10-21 10:57:26 +08:00
YiChin 9dd7228eb5 clean warning 2019-10-21 10:51:13 +08:00
weiting2 59ac6b9909 add ReadCurrent() 2019-10-21 10:37:33 +08:00
YiChin e24ce8e5d5 auto gain done 2019-10-21 10:26:52 +08:00
weiting2 8720300bfc small-mid range gain switch test 2019-10-21 10:11:10 +08:00
weiting2 23fc75a236 small-mid range gain switch test 2019-10-18 18:06:13 +08:00
weiting2 80c25267cb all range auto scale 2019-10-18 17:49:31 +08:00
YiChin 81d1aff615 maybe auto gain should read data after circuit stable 2019-10-18 16:27:00 +08:00
weiting2 3221fe6492 largest and mid gain switch, considering negative current 2019-10-18 16:07:22 +08:00
weiting2 4ca7d5b681 try easy auto-scale ADC gain 2019-10-18 15:55:23 +08:00
weiting2 49677aa5b1 try easy auto-scale ADC gain 2019-10-18 15:30:46 +08:00
YiChin bbfef99a65 maybe auto gain should read data after circuit stable 2019-10-18 15:12:20 +08:00
weiting2 05f11fd147 try easy auto-scale ADC gain 2019-10-18 14:26:40 +08:00
YiChin f0aedf786d CC mode done 2019-10-17 18:15:37 +08:00
weiting2 a12146a479 CC mode bug fix 2019-10-17 16:26:55 +08:00
weiting2 410bef2e23 CC mode bug fix 2019-10-17 16:03:15 +08:00
YiChin 17c6a506cb error fix 2019-10-17 15:42:38 +08:00
weiting2 0b9c945aee change IUC and CC mode BT instruction 2019-10-17 15:08:31 +08:00
YiChin 53ef219d6e [CC] battery test perfect, should add +- current in UI 2019-10-17 11:38:53 +08:00
YiChin a14b2480db [CC] battery test perfect, should add +- current in UI 2019-10-17 11:11:25 +08:00
YiChin 89368d5352 CC mode mA done 2019-10-16 17:36:48 +08:00
YiChin f7903a0a31 CC mode earth 2019-10-16 17:03:24 +08:00
YiChin 56f42d21c5 CC mode earth 2019-10-16 17:01:15 +08:00
YiChin 52a8baad08 CC mode mA 2019-10-16 15:01:05 +08:00
YiChin 7acdbf6e78 [CC] seems done 2019-10-16 14:10:10 +08:00
YiChin 393394be6f [CC] seems done 2019-10-16 12:25:30 +08:00
YiChin b7f305e378 [CC] discharge fine, charge doesn't work 2019-10-16 11:50:26 +08:00
weiting2 cad8a78164 check IUC-Measure difference 2019-10-16 10:48:27 +08:00
YiChin 0c4ebcac79 [CC] discharge fine, charge doesn't work 2019-10-16 10:41:17 +08:00
YiChin e700657d5d [CC] discharge fine, charge doesn't work 2019-10-15 18:16:17 +08:00
YiChin ea9fb92d53 [CC] discharge fine, charge doesn't work 2019-10-15 18:12:18 +08:00
YiChin ba215c7ca9 pointer->value compare error 2019-10-15 16:54:48 +08:00
YiChin 564dc6e266 test cc mode notify 2019-10-15 15:43:13 +08:00
weiting2 86a2e54694 trans IUC current update 2019-10-15 14:21:57 +08:00
YiChin 358950bec0 CC mode read, done 2019-10-15 12:17:53 +08:00
weiting2 de2cb269b7 check measure current 2019-10-14 18:42:24 +08:00
YiChin 151e829973 test IUC 2019-10-14 17:50:35 +08:00
YiChin 19121b55a7 test IUC 2019-10-14 17:34:25 +08:00
alan 31f03582a3 check notify 2019-10-14 17:27:10 +08:00
alan 0859f6da6d check notify 2019-10-14 17:12:27 +08:00
YiChin 120b7086e5 USA demo version 2019-10-14 10:05:43 +08:00
YiChin d393872d8c [CV] done 2019-10-10 17:28:29 +08:00
YiChin 3ab9afdcd3 Merge remote-tracking branch 'origin/Elite_ZTcurve' into Elite_ZTcurve 2019-10-10 17:27:25 +08:00
YiChin 8812b4c103 [CV] done 2019-10-10 17:27:00 +08:00
Benny Liu 4cccced7ac calibration data for European 2019-10-09 18:40:09 +08:00
alan 7b3d342be6 [CV] Test turn back measure current 2019-10-09 16:50:26 +08:00
alan 97409c88c3 [IV][IT][VT][RT][Vout] work fine
[CV] turn direction has an offset bug
2019-10-08 19:01:03 +08:00
Benny Liu 1d675d9d78 calibration data 2019-10-08 18:57:00 +08:00
Benny Liu 1774a255d8 Merge branch 'Elite_ZTcurve' of https://gitlab.com/bioproscientific/bioprocc2650 into Elite_ZTcurve 2019-10-08 18:48:34 +08:00
Benny Liu 1863016b63 calibration data of various boards 2019-10-08 18:48:24 +08:00
YiChin 1e89a540a1 macro CAPS 2019-10-08 18:00:57 +08:00
alan 5daa67e054 Merge remote-tracking branch 'origin/Elite_ZTcurve' into Elite_ZTcurve 2019-10-08 17:56:23 +08:00
alan 05ce7f7f44 [IV][CV] get sample after wait 0.1 sec 2019-10-08 17:56:08 +08:00
YiChin 9391c700a1 macro CAPS 2019-10-08 16:38:27 +08:00
YiChin 16c4ecf9f2 Merge remote-tracking branch 'origin/Elite_ZTcurve' into Elite_ZTcurve 2019-10-08 16:34:58 +08:00
alan 7280f76fae [Test] CC mode Vout = Iconstant 2019-10-08 16:33:52 +08:00
YiChin 3a5d40a5d9 kelly macro CAPS 2019-10-08 11:56:22 +08:00
alan 40dd596fef CV mode debug 2019-10-08 10:15:59 +08:00
YiChin 56b240b101 CC mode can read current and set IUC correctly 2019-10-07 18:21:42 +08:00
alan bf36103499 test CCmode output Volt 2019-10-07 16:39:20 +08:00
YiChin 477144dc24 delete gain switch LED 2019-10-05 14:31:26 +08:00
alan 0aa45cfedc Merge remote-tracking branch 'origin/Elite_ZTcurve' into Elite_ZTcurve 2019-10-05 14:12:41 +08:00
alan 4691345831 test CCmode output Volt 2019-10-05 14:12:22 +08:00
Benny Liu 8445f8c263 board BAY_BAY calibration data 2019-10-05 12:09:52 +08:00
Benny Liu 7176f91a3f fix error 2019-10-05 11:32:58 +08:00
Benny Liu e37065ce91 board Kelly calibration data 2019-10-05 11:29:46 +08:00
YiChin 2537b76256 error fix 2019-10-05 10:47:47 +08:00
alan 59e275c997 test switch ADC gain 2019-10-05 10:07:56 +08:00
105042004 bfe61896e8 BAYBAY Kwlly Iin callibration 2019-10-04 19:13:43 +08:00
alan 0ad8b13db2 Merge remote-tracking branch 'origin/Elite_ZTcurve' into Elite_ZTcurve 2019-10-04 16:42:26 +08:00
alan 3c8abc04a8 ADC test WITHOUT avg 2019-10-04 16:42:08 +08:00
Benny Liu a48cf75c90 Merge branch 'Elite_ZTcurve' of https://gitlab.com/bioproscientific/bioprocc2650 into Elite_ZTcurve 2019-10-04 15:22:34 +08:00
alan 4f7017d5b2 Merge remote-tracking branch 'origin/Elite_ZTcurve' into Elite_ZTcurve 2019-10-04 15:16:58 +08:00
alan 79f0d57161 ADC test with avg 2019-10-04 15:16:42 +08:00
Benny Liu d76e8e6f3f Merge branch 'Elite_ZTcurve' of https://gitlab.com/bioproscientific/bioprocc2650 into Elite_ZTcurve 2019-10-04 15:08:43 +08:00
Benny Liu b6147c1fe5 fish_vet calibration data 2019-10-04 15:08:32 +08:00
YiChin 4bbd92127a Merge remote-tracking branch 'origin/Elite_ZTcurve' into Elite_ZTcurve 2019-10-04 15:03:31 +08:00
YiChin 337c2aef8d add CV curve 2019-10-04 15:03:11 +08:00
alan e943d22a5f Merge remote-tracking branch 'origin/Elite_ZTcurve' into Elite_ZTcurve 2019-10-04 14:47:27 +08:00
alan bceb8b9134 ADC test with avg 2019-10-04 14:47:09 +08:00
YiChin 14adc8a768 10/4 demo version 2019-10-04 14:00:21 +08:00
YiChin 7c44ad2272 10/6 demo version 2019-10-04 11:22:07 +08:00
alan c8272dd455 Merge remote-tracking branch 'origin/Elite_ZTcurve' into Elite_ZTcurve 2019-10-04 09:51:34 +08:00
YiChin cb2aa2126b 10/6 demo version 2019-10-03 18:35:55 +08:00
YiChin f74a412611 10/6 demo version 2019-10-03 18:18:23 +08:00
YiChin f0b92f8578 ADD 517 CORRECTION DATA 2019-10-03 18:14:15 +08:00
YiChin e7cae7dc21 10/6 demo version 2019-10-03 16:49:57 +08:00
YiChin 1c41bd7a45 Merge remote-tracking branch 'origin/Elite_ZTcurve' into Elite_ZTcurve 2019-10-03 12:58:31 +08:00
YiChin a671a4916d 10/6 demo version 2019-10-03 12:57:18 +08:00
alan 15ea1488c9 Merge remote-tracking branch 'origin/Elite_ZTcurve' into Elite_ZTcurve 2019-10-02 18:27:06 +08:00
Benny Liu f92dd743ef triceratops calibration data 2019-10-02 18:03:19 +08:00
alan eddbe3980a 10/6 demo version 2019-10-02 17:49:06 +08:00
Benny Liu b27df1489b Merge branch 'Elite_ZTcurve' of https://gitlab.com/bioproscientific/bioprocc2650 into Elite_ZTcurve 2019-10-02 17:46:35 +08:00
YiChin dc3f2ee046 10/6 demo version 2019-10-02 16:47:43 +08:00
YiChin ba7f03daeb 10/6 demo version 2019-10-02 16:19:14 +08:00
YiChin 079500faff 10/6 demo version 2019-10-02 16:13:21 +08:00
YiChin ce0defe5e9 RT mode demo prepare 2019-10-02 15:40:53 +08:00
alan 7b1bcd5147 Elite 1.4-re CCmode test read current 2019-10-02 14:01:34 +08:00
alan 787eb5dce1 Elite 1.4-re CCmode test read current 2019-10-02 12:04:45 +08:00
YiChin 9d73fab37e CC MDOE error fix 2019-10-02 11:31:39 +08:00
alan 6a833aabee Elite 1.4-re CCmode test read current 2019-10-01 18:42:42 +08:00
alan e40d0896b8 Elite 1.4-re CCmode test read current 2019-10-01 17:56:47 +08:00
alan c265eb0118 Elite 1.4-re CCmode test read current 2019-10-01 17:41:38 +08:00
alan cead3b0b5c Merge remote-tracking branch 'origin/Elite_ZTcurve' into Elite_ZTcurve
# Conflicts:
#	simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/EliteCCMode.h
2019-10-01 17:22:56 +08:00
alan 238c09befd Elite 1.4-re CCmode test read current 2019-10-01 17:22:18 +08:00
YiChin de1867d523 CC MDOE error fix 2019-10-01 17:19:06 +08:00
YiChin 906e02e265 CC MDOE error fix 2019-10-01 16:47:14 +08:00
23 changed files with 947 additions and 442 deletions
@@ -16,7 +16,7 @@
# sources were generated) is:
# C:\ti\simplelink\ble_sdk_2_02_02_25\examples\cc2650em\simple_peripheral\ccs\config\src
#
GEN_SRC_DIR ?= ../../config/src
GEN_SRC_DIR ?= ../../../../../ti/simplelink/ble_sdk_2_02_02_25/examples/cc2650em/simple_peripheral/ccs/config/src
ifeq (,$(wildcard $(GEN_SRC_DIR)))
$(error "ERROR: GEN_SRC_DIR must be set to the directory containing the generated sources")
@@ -1,12 +1,12 @@
XOPTS = -I"C:/ti/xdctools_3_32_02_25_core/packages/" -Dxdc_target_types__=C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/targets/arm/elf/std.h -Dxdc_target_name__=M3
XOPTS = -I"C:/ti/xdctools_3_32_00_06_core/packages/" -Dxdc_target_types__=C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/targets/arm/elf/std.h -Dxdc_target_name__=M3
vpath % C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/sysbios/
vpath %.c C:/ti/xdctools_3_32_02_25_core/packages/
vpath %.c C:/ti/xdctools_3_32_00_06_core/packages/
CCOPTS = --endian=little -mv7M3 --abi=eabi -q -ms --opt_for_speed=0 --program_level_compile -o3 -g --optimize_with_debug -Dti_sysbios_knl_Task_minimizeLatency__D=FALSE -Dti_sysbios_family_arm_cc26xx_Boot_driverlibVersion=2 -Dti_sysbios_knl_Clock_stopCheckNext__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_enableException__D=TRUE -Dti_sysbios_family_arm_m3_Hwi_disablePriority__D=32U -Dti_sysbios_family_arm_m3_Hwi_numSparseInterrupts__D=0U
XDC_ROOT = C:/ti/xdctools_3_32_02_25_core/packages/
XDC_ROOT = C:/ti/xdctools_3_32_00_06_core/packages/
BIOS_ROOT = C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/ti/sysbios/
@@ -16,14 +16,14 @@ BIOS_INC = -I"C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/pa
TARGET_INC = -I"C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/"
INCS = $(BIOS_INC) $(TARGET_INC) --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/icall/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/dev_info" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/heapmgr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/controller/cc26xx/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/target" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/osal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/sdata" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/saddr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/icall/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/rom" --include_path="C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/cc26xxware_2_24_03_17272" -IC:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/
INCS = $(BIOS_INC) $(TARGET_INC) --include_path="C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/include" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/icall/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/roles" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/dev_info" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/heapmgr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/controller/cc26xx/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/target" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/target/_common/cc26xx" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/hal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/osal/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/sdata" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/services/src/saddr" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/components/icall/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/inc" --include_path="C:/ti/simplelink/ble_sdk_2_02_02_25/src/rom" --include_path="C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/cc26xxware_2_24_03_17272" -IC:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/bios_6_46_01_38/packages/
CC = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include
ASM = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include
AR = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armar rq
CC = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/include
ASM = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/bin/armcl -c $(CCOPTS) -I C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/include
AR = C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.4.LTS/bin/armar rq
DEL = C:/ti/xdctools_3_32_02_25_core/packages/../bin/rm -f
CP = C:/ti/xdctools_3_32_02_25_core/packages/../bin/cp -f
DEL = C:/ti/xdctools_3_32_00_06_core/packages/../bin/rm -f
CP = C:/ti/xdctools_3_32_00_06_core/packages/../bin/cp -f
define RM
$(if $(wildcard $1),$(DEL) $1,:)
@@ -76,6 +76,11 @@ static void ADCGainControl(uint8_t ADCLevel){
PIN_setOutputValue(pin_handle, Turnon10K, 0);
PIN_setOutputValue(pin_handle, Turnon100R, 1);
}
else if(ADCLevel == 3){
// ADC gain level = 0, auto gain (using 200R resister)
PIN_setOutputValue(pin_handle, Turnon10K, 0);
PIN_setOutputValue(pin_handle, Turnon100R, 0);
}
else{
// default using 200R resister
PIN_setOutputValue(pin_handle, Turnon10K, 0);
@@ -121,4 +126,103 @@ static void ADCChannelSelect(uint8_t ADCChannel){
}
}
static void ReadVolt(uint8_t *buf){
// Read data twice since the first data we get is previous data
ADCChannelSelect(ADC_CH_VOLT);
CPUdelay(10);
ADC_read(buf);
ADCChannelSelect(ADC_CH_VOLT);
CPUdelay(10);
ADC_read(buf);
}
static void ReadCurrent(uint8_t *buf){
// Read data twice since the first data we get is previous data
ADCGainControl(INSTRUCTION.ADCGainLevel);
ADCChannelSelect(ADC_CH_CURRENT);
CPUdelay(10);
ADC_read(buf);
ADCChannelSelect(ADC_CH_CURRENT);
CPUdelay(10);
ADC_read(buf);
}
// theoretical boundary <20, 10~500, >100 (uA)
#define GAIN_SMALL_BOUNDARY 40000 // 40 uA = 40,000,000 pA
#define GAIN_MID_BOUNDARY1 20000 // 20 uA = 20,000,000 pA
#define GAIN_MID_BOUNDARY2 400000 // 400 uA = 400,000,000 pA
#define GAIN_LARGE_BOUNDARY 200000 // 200 uA = 200,000 nA
static int32_t AutoGainReadCurrent(uint8_t *buf){
int32_t Real_Current = 0;
if(INSTRUCTION.ADCGainLevel == GAIN_AUTO){
INSTRUCTION.ADCGainLevel = GAIN_200R;
}
if(INSTRUCTION.ADCGainLevel == GAIN_200R){
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
// switch to mid range current
if(Real_Current < GAIN_LARGE_BOUNDARY && Real_Current > -1*GAIN_LARGE_BOUNDARY){
// LED_color(DARKLED, 0x00, 0x0F, 0xFF);
INSTRUCTION.ADCGainLevel = GAIN_10K;
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
// switch to small range current
if (Real_Current < GAIN_MID_BOUNDARY1 && Real_Current > -1*GAIN_MID_BOUNDARY1){
// LED_color(DARKLED, 0x00, 0x00, 0xFF);
INSTRUCTION.ADCGainLevel = GAIN_200K;
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
}
}
else if(INSTRUCTION.ADCGainLevel == GAIN_10K){
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
// switch to large range current
if(Real_Current > GAIN_MID_BOUNDARY2 || Real_Current < -1*GAIN_MID_BOUNDARY2){
// LED_color(DARKLED, 0xFF, 0x0F, 0x0F);
INSTRUCTION.ADCGainLevel = GAIN_200R;
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
// switch to small range current
else if (Real_Current < GAIN_MID_BOUNDARY1 && Real_Current > -1*GAIN_MID_BOUNDARY1){
// LED_color(DARKLED, 0x00, 0x00, 0xFF);
INSTRUCTION.ADCGainLevel = GAIN_200K;
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
}
else if(INSTRUCTION.ADCGainLevel == GAIN_200K){
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
// switch to mid range current
if(Real_Current > GAIN_SMALL_BOUNDARY || Real_Current < -1*GAIN_SMALL_BOUNDARY){
// LED_color(DARKLED, 0x00, 0x0F, 0xFF);
INSTRUCTION.ADCGainLevel = GAIN_10K;
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
// switch to large range current
// if(Real_Current > GAIN_MID_BOUNDARY2 || Real_Current < -1*GAIN_MID_BOUNDARY2){
// LED_color(DARKLED, 0xFF, 0x0F, 0x0F);
// INSTRUCTION.ADCGainLevel = GAIN_200R;
// ReadCurrent(spi_ADC_rxbuf);
// Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
// }
}
}
return Real_Current;
}
#endif
@@ -2,41 +2,47 @@
#ifndef ELITECCMODE
#define ELITECCMODE
#define CURRENT_LV_FOUR 4
#define CURRENT_LV_THREE 3
#define CURRENT_LV_TWO 2
#define CC_ZERO_POINT 1500000
#define MAX_DAC_UC 50000
#define MIN_DAC_UC 0
#define CURRENT_LV_ONE 1
#define CURRENT_LV_ZERO 0
static void CCModeDACControl(int32_t IUC_Measure_Difference);
/*********************************************************************
* @struct Constant Current Code
*
* @brief A struct to handle CC mode command
*/
typedef struct _CURRENT_USER_CODE {
/** current level range: 0-4 **/
// current level = 0 => 0-499 nA => ADCGainLevel = 200K
// current level = 1 => 500-999 nA => ADCGainLevel = 10K
// current level = 2 => 0-499 uA => ADCGainLevel = 10K
// current level = 3 => 500-999 uA => ADCGainLevel = 200R
// current level = 4 => 0-499 mA => ADCGainLevel = 200R
uint8_t lv;
/** current value **/
// current value divide current level into 50000 pieces
uint16_t value;
// current value divide current level into 3,000,001 pieces
// 1,500,000 is zero point
int32_t value;
/** ADC level range: 0-2 **/
// constant current value will decide ADC gain level
// if |1500000 - value| > 10000 (+-100 uA) => lv = GAIN_200R
// else if |1500000 - valule| > 1000 (+-10 uA) => lv = GAIN_10K
// else lv = GAIN_200K
uint8_t lv;
/* Vmax and Vmin */
// Vmax protect battery charge
// Vmin protect battery discharge
// uint = mV
uint16_t Vmax;
uint16_t Vmin;
/** transform a current user code (IUC) to real current in nA **/
int32_t (*_Transform2RealnA)(struct _CURRENT_USER_CODE *);
/** Measure Current **/
int32_t _MeasureCurrent;
/** transform a current user code (IUC) to real current in pA **/
// handle current lv 0~2
int32_t (*_Transform2RealpA)(struct _CURRENT_USER_CODE *);
/** transform an IUC to real current in nA **/
// handle current lv 3~4
int32_t (*_Transform2RealnA)(struct _CURRENT_USER_CODE *);
/** MeasureCurrent operation **/
void (*SetMeasureCurrent)(struct _CURRENT_USER_CODE *, int32_t);
@@ -45,174 +51,109 @@ typedef struct _CURRENT_USER_CODE {
//static CURRENT_USER_CODE CurrentUserCode;
static int32_t CCModeReadCurrent(CURRENT_USER_CODE *CurrentUserCode){
int32_t Real_Current = 0;
CCModeReset = 0; // This flag will control DAC working
static int32_t CCModeReadCurrent(void *WorkModeData){
int32_t Real_Current = 0;
CURRENT_USER_CODE *CurrentUserCode = WorkModeData;
// CurrentUserCode = WorkModeData;
CCModeDACEnable = 1; // This flag will control DAC working
// set current value and ADC gain level
CCCurrent2IUC(CurrentUserCode);
// if(CurrentUserCode->lv == CURRENT_LV_FOUR){
// Real_Current = CurrentUserCode->_Transform2RealnA(CurrentUserCode);
// }
// else{
// Real_Current = CurrentUserCode->_Transform2RealpA(CurrentUserCode);
// }
// set ADC gain according to constant current value
SetCCModeGain(CurrentUserCode);
INSTRUCTION.ADCGainLevel = CurrentUserCode->lv;
// read ADC current
ADCGainControl(INSTRUCTION.ADCGainLevel);
ADCChannelSelect(ADC_CH_CURRENT);
CPUdelay(10);
ADC_read(spi_ADC_rxbuf);
ReadCurrent(spi_ADC_rxbuf);
// decode ADC value and put it into notify buffer
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
Real_Current = 8787877;
CurrentUserCode->SetMeasureCurrent(CurrentUserCode, Real_Current);
return Real_Current;
}
static int32_t CCModeVoltOut(CURRENT_USER_CODE *CurrentUserCode){
int32_t MeasureCurrent = 0;
static int32_t CCModeVoltOut(void *WorkModeData){
int32_t MeasureCurrent = 0, IUCCurrent = 0;
CURRENT_USER_CODE *CurrentUserCode = WorkModeData;
if(CCModeReset){
if(!CCModeDACEnable){
// DAC should not work now
return 0;
}
// MeasureCurrent = CurrentUserCode->GetMeasureCurrent(CurrentUserCode);
IUCCurrent = CurrentUserCode->_Transform2RealnA(CurrentUserCode);
if(CurrentUserCode->lv == GAIN_200K || CurrentUserCode->lv == GAIN_10K ){
MeasureCurrent = CurrentUserCode->GetMeasureCurrent(CurrentUserCode);
CCModeDACControl(IUCCurrent - MeasureCurrent);
}
else{
MeasureCurrent = CurrentUserCode->GetMeasureCurrent(CurrentUserCode);
CCModeDACControl(IUCCurrent - MeasureCurrent);
}
// NotifyCurrent[0] = (uint8_t) (IUCCurrent >> 24);
// NotifyCurrent[1] = (uint8_t) ((IUCCurrent & 0x00FF0000) >> 16);
// NotifyCurrent[2] = (uint8_t) ((IUCCurrent & 0x0000FF00) >> 8);
// NotifyCurrent[3] = (uint8_t) (IUCCurrent & 0x000000FF);
//
// NotifyVolt[0] = (uint8_t) (MeasureCurrent >> 24);
// NotifyVolt[1] = (uint8_t) ((MeasureCurrent & 0x00FF0000) >> 16);
// NotifyVolt[2] = (uint8_t) ((MeasureCurrent & 0x0000FF00) >> 8);
// NotifyVolt[3] = (uint8_t) (MeasureCurrent & 0x000000FF);
NotifyCurrent[0] = (uint8_t) (MeasureCurrent >> 24);
NotifyCurrent[1] = (uint8_t) ((MeasureCurrent & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t) ((MeasureCurrent & 0x0000FF00) >> 8);
NotifyCurrent[3] = (uint8_t) (MeasureCurrent & 0x000000FF);
NotifyVolt[0] = (uint8_t) (MeasureCurrent >> 24);
NotifyVolt[1] = (uint8_t) ((MeasureCurrent & 0x00FF0000) >> 16);
NotifyVolt[2] = (uint8_t) ((MeasureCurrent & 0x0000FF00) >> 8);
NotifyVolt[3] = (uint8_t) (MeasureCurrent & 0x000000FF);
// INSTRUCTION.VoltConstant = 24999 + 500;
// DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
DACCode2Real2Notify(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
CCModeDACEnable = 0;
return MeasureCurrent;
}
static void SetCCModeGain(CURRENT_USER_CODE *CurrentUserCode){
switch(CurrentUserCode->lv){
case CURRENT_LV_FOUR:{
INSTRUCTION.ADCGainLevel = GAIN_200R;
break;
}
case CURRENT_LV_THREE:{
INSTRUCTION.ADCGainLevel = GAIN_200R;
break;
}
case CURRENT_LV_TWO:{
INSTRUCTION.ADCGainLevel = GAIN_10K;
break;
}
case CURRENT_LV_ONE:{
INSTRUCTION.ADCGainLevel = GAIN_200K;
break;
}
case CURRENT_LV_ZERO:{
INSTRUCTION.ADCGainLevel = GAIN_200K;
break;
}
default :{
INSTRUCTION.ADCGainLevel = GAIN_200R;
break;
}
static void CCModeDACControl(int32_t IUC_Measure_Difference){
if(IUC_Measure_Difference > 100000 || IUC_Measure_Difference < -100000){
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant + IUC_Measure_Difference/1e4;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
}
else if(IUC_Measure_Difference > 1000 || IUC_Measure_Difference < -1000){
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant + IUC_Measure_Difference/1e3;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
}
else if(IUC_Measure_Difference > 0){
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant + 1;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
}
else if(IUC_Measure_Difference < 0){
INSTRUCTION.VoltConstant = INSTRUCTION.VoltConstant - 1;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
}
}
/* Transform setting CC into IUC
*
* User code in CC mode : 0 ~ 3000000
* Real current value : -15.00000 ~ 15.00000 mA
* => user code = 1500000 mapping to 0.00000 mA
*/
static void CCCurrent2IUC(CURRENT_USER_CODE *CurrentUserCode){
if (INSTRUCTION.CurrentLV == CURRENT_LV_MA){
// largest current ( 0~500 mA)
CurrentUserCode->lv = CURRENT_LV_FOUR;
CurrentUserCode->value = (uint16_t) (INSTRUCTION.ConstantCurrent);
int32_t CurrentValue = 0;
CurrentUserCode->value = INSTRUCTION.ConstantCurrent;
CurrentValue = CurrentUserCode->value - CC_ZERO_POINT;
/* set ADC level */
// largest current
if (CurrentValue > 10000 || CurrentValue < -10000){
CurrentUserCode->lv = GAIN_200R;
}
else if (INSTRUCTION.CurrentLV == CURRENT_LV_UA){
if(INSTRUCTION.ConstantCurrent >= 50000){
// mid range current ( 500 uA ~ 999 uA)
CurrentUserCode->lv = CURRENT_LV_THREE;
CurrentUserCode->value = (uint16_t) (INSTRUCTION.ConstantCurrent - 50000);
}
else{
// mid range current ( 0 uA ~ 499 uA)
CurrentUserCode->lv = CURRENT_LV_TWO;
CurrentUserCode->value = (uint16_t) (INSTRUCTION.ConstantCurrent);
}
// mid range current
else if (CurrentValue > 1000 || CurrentValue < -1000){
CurrentUserCode->lv = GAIN_10K;
}
// least range current
else{
if(INSTRUCTION.ConstantCurrent >= 50000){
// mid range current ( 500 nA ~ 999 nA)
CurrentUserCode->lv = CURRENT_LV_ONE;
CurrentUserCode->value = (uint16_t) (INSTRUCTION.ConstantCurrent - 50000);
}
else{
// mid range current ( 0 nA ~ 499 nA)
CurrentUserCode->lv = CURRENT_LV_ZERO;
CurrentUserCode->value = (uint16_t) (INSTRUCTION.ConstantCurrent);
}
CurrentUserCode->lv = GAIN_200K;
}
}
//static int32_t IUC2RealnA(){
//
//}
//
//static int32_t IUC2RealpA{
//
//}
/*********************************************************************
* @fn Transform2RealpA
*
* @brief transform an IUC into real current value in pA.
*
* @param self, which is an IUC
*
* @return an int32_t current value in pA
*/
static int32_t _Transform2RealpA(CURRENT_USER_CODE *self){
int32_t IUCReal;
/** current level range: 0-4 **/
// current level = 0 => 0-499 nA => ADCGainLevel = 200K
// current level = 1 => 500-999 nA => ADCGainLevel = 10K
// current level = 2 => 0-499 uA => ADCGainLevel = 10K
// current level = 3 => 500-999 uA => ADCGainLevel = 200R
// current level = 4 => 0-499 mA => ADCGainLevel = 200R
// Saturate if current > 500 uA
if (self->lv == CURRENT_LV_FOUR){
return 0xFFFFFFFF;
}
if (self->lv == CURRENT_LV_THREE){
return 0xFFFFFFFF;
}
// 0-499 nA
if (self->lv == CURRENT_LV_ZERO){
IUCReal = (int32_t) (self->value) * 1e3;
}
// 500-999 nA
else if (self->lv == CURRENT_LV_ONE){
IUCReal = ((int32_t) (self->value) * 1e3);
IUCReal = IUCReal + 500e3;
}
// 0-499 uA
else if (self->lv == CURRENT_LV_TWO){
IUCReal = (int32_t) (self->value) * 1e6;
}
return IUCReal;
}
/*********************************************************************
* @fn Transform2RealnA
*
@@ -225,86 +166,30 @@ static int32_t _Transform2RealpA(CURRENT_USER_CODE *self){
static int32_t _Transform2RealnA(CURRENT_USER_CODE *self){
int32_t IUCReal;
// Saturate if current < 500 uA
if (self->lv == CURRENT_LV_ZERO | self->lv == CURRENT_LV_ONE | self->lv == CURRENT_LV_TWO){
return 0;
}
// 500-999 uA
if (self->lv == CURRENT_LV_THREE){
IUCReal = (int32_t) (self->value) * 1e3;
IUCReal = IUCReal + 500e3;
}
// 0-499 mA
else if (self->lv == 4){
IUCReal = (int32_t) (self->value) * 1e6;
}
// self->value : 0 ~ 3000000 (which is -1500000 ~ 1500000 (10nA) )
IUCReal = (self->value - CC_ZERO_POINT) * 10;
return IUCReal;
}
/*********************************************************************
* @fn CompareCurrent
*
* @brief compare an int32 current with CURRENT_USER_CODE (IUC) type current.
*
* @param unit is current unit (0 = pA, 1 = nA)
* value is current value
*
* @return 0 if equal
* 1 if IUC is larger
* 2 if int32 current is larger.
*/
static uint8_t CompareCurrent(CURRENT_USER_CODE *self, uint8_t unit, int32_t value){
int32_t ErrorRangeIUCReal;
// unit = pA
if (unit == 0){
if (self->_Transform2RealpA(self) > value){
return 1;
}
else if (self->_Transform2RealpA(self) < value){
return 2;
}
else{
return 0;
}
}
// unit = nA
else if (unit == 1){
if (self->_Transform2RealnA(self) > value){
return 1;
}
else if (self->_Transform2RealnA(self) < value){
return 2;
}
else{
return 0;
}
}
}
static void SetMeasureCurrent(CURRENT_USER_CODE *self, int32_t current){
self->_MeasureCurrent = current;
}
static int32_t GetMeasureCurrent(CURRENT_USER_CODE *self){
LED_color(DARKLED, 0x0F, 0x00, 0xFF);
return self->_MeasureCurrent;
}
static CURRENT_USER_CODE *InitCurrentUserCode(){
CURRENT_USER_CODE *CurrentUserCode = malloc(sizeof(CURRENT_USER_CODE));
CurrentUserCode->lv = 0;
CurrentUserCode->value = 0;
CurrentUserCode->_MeasureCurrent = 0;
CurrentUserCode->value = CC_ZERO_POINT;
CurrentUserCode->lv = GAIN_AUTO;
CurrentUserCode->Vmax = MAX_DAC_UC; // max DAC UserCode
CurrentUserCode->Vmin = MIN_DAC_UC; // min DAC UserCode
CurrentUserCode-> _MeasureCurrent = 0;
CurrentUserCode->_Transform2RealnA = &_Transform2RealnA;
CurrentUserCode->_Transform2RealpA = &_Transform2RealpA;
CurrentUserCode->SetMeasureCurrent = &SetMeasureCurrent;
CurrentUserCode->GetMeasureCurrent = &GetMeasureCurrent;
return CurrentUserCode;
}
#endif
@@ -133,15 +133,13 @@ static uint16_t DPVCurve() {
}
static uint16_t CVCurve() {
static uint8_t ramp0;
static uint8_t ramp1;
static uint16_t outputV;
static bool direction_up;
static bool current_direction_up;
static uint16_t DACOutCode;
static bool direction_up; // direction_up = true, if Vfinal > Vorigin
static bool current_direction_up; // current_direction_up = true, Vstep => positive. vice versa
// reset origin volt at the begin
if (DACReset) {
outputV = INSTRUCTION.VoltOrigin;
DACUserCode = INSTRUCTION.VoltOrigin;
if (INSTRUCTION.VoltFinal > INSTRUCTION.VoltOrigin) {
direction_up = true;
current_direction_up = true;
@@ -149,51 +147,99 @@ static uint16_t CVCurve() {
direction_up = false;
current_direction_up = false;
}
ramp0 = (uint8_t)(INSTRUCTION.VoltOrigin & 0x00FF); // right byte
ramp1 = (uint8_t)((INSTRUCTION.VoltOrigin >> 8) & 0x00FF); // left byte
DACReset = false;
DACOutCode = Usercode_Correction_to_DAC(DACUserCode);
DAC_outputV(DACOutCode); // output VOLT_ORIGIN
DACReset = false;
return DACOutCode;
}
// output a certain volt
DAC_outputV(outputV);
if (StepTimeCounter == INSTRUCTION.StepTime) {
if (direction_up) {
if (outputV >= INSTRUCTION.VoltFinal) {
current_direction_up = false; // problem occurs when origin == 0000 final == ffff!!!!!!
} else if (outputV <= INSTRUCTION.VoltOrigin) {
current_direction_up = true;
if (INSTRUCTION.CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
// Decide next direction
if (direction_up) {
if (DACUserCode >= INSTRUCTION.VoltFinal) {
current_direction_up = false; // problem occurs when origin == 0000 final == ffff!!!!!!
} else if (DACUserCode <= INSTRUCTION.VoltOrigin) {
current_direction_up = true;
if (INSTRUCTION.CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
}
INSTRUCTION.CycleNumber--;
}
INSTRUCTION.CycleNumber--;
}
} else {
if (outputV <= INSTRUCTION.VoltFinal) {
current_direction_up = true; // problem occurs when origin == 0000 final == ffff!!!!!!
} else if (outputV >= INSTRUCTION.VoltOrigin) {
current_direction_up = false;
if (INSTRUCTION.CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
} else {
if (DACUserCode <= INSTRUCTION.VoltFinal) {
current_direction_up = true; // problem occurs when origin == 0000 final == ffff!!!!!!
} else if (DACUserCode >= INSTRUCTION.VoltOrigin) {
current_direction_up = false;
if (INSTRUCTION.CycleNumber == 0) {
PeriodicEvent = false; // periodic event end
DACReset = true;
}
INSTRUCTION.CycleNumber--;
}
INSTRUCTION.CycleNumber--;
}
}
if (current_direction_up) {
if (outputV + INSTRUCTION.Step < outputV)
outputV = 0xffff;
else
outputV = outputV + INSTRUCTION.Step;
} else {
if (outputV - INSTRUCTION.Step > outputV)
outputV = 0x0000;
else
outputV = outputV - INSTRUCTION.Step;
}
// Next output voltage
if (direction_up) {
if (current_direction_up) {
// DACUserCode overflow ?
if (DACUserCode + INSTRUCTION.Step < DACUserCode) {
DACUserCode = INSTRUCTION.VoltFinal;
}
else if (DACUserCode + INSTRUCTION.Step > INSTRUCTION.VoltFinal) {
DACUserCode = INSTRUCTION.VoltFinal;
}
else {
DACUserCode = DACUserCode + INSTRUCTION.Step;
}
}
else {
// DACUserCode underflow ?
if (DACUserCode - INSTRUCTION.Step > DACUserCode || DACUserCode > 60000) {
DACUserCode = INSTRUCTION.VoltOrigin;
}
return outputV;
// reach Vorigin ?
else if (DACUserCode - INSTRUCTION.Step < INSTRUCTION.VoltOrigin) {
DACUserCode = INSTRUCTION.VoltOrigin;
}
else {
DACUserCode = DACUserCode - INSTRUCTION.Step;
}
}
}
else {
if (current_direction_up) {
if (DACUserCode + INSTRUCTION.Step < DACUserCode) {
DACUserCode = INSTRUCTION.VoltOrigin;
}
else if (DACUserCode + INSTRUCTION.Step > INSTRUCTION.VoltOrigin) {
DACUserCode = INSTRUCTION.VoltOrigin;
}
else {
DACUserCode = DACUserCode + INSTRUCTION.Step;
}
}
else {
if (DACUserCode - INSTRUCTION.Step > DACUserCode || DACUserCode > 60000) {
DACUserCode = INSTRUCTION.VoltFinal;
}
else if (DACUserCode - INSTRUCTION.Step < INSTRUCTION.VoltFinal) {
DACUserCode = INSTRUCTION.VoltFinal;
}
else {
DACUserCode = DACUserCode - INSTRUCTION.Step;
}
}
}
DACOutCode = Usercode_Correction_to_DAC(DACUserCode);
DAC_outputV(DACOutCode);
}
return DACOutCode;
}
#endif
@@ -57,4 +57,9 @@ static uint16_t DAC_outputV(uint16_t voltLV) {
#endif
static int32_t User2Real(uint16_t UserCode){
/* transfer usercode to real voltage value (mV) */
return (int32_t) ((UserCode - 25000)*2)/10;
}
#endif
@@ -29,7 +29,7 @@
*/
#define BOARD_BAY_BAY
#define BOARD_MERCURY
typedef struct _formula{
@@ -66,8 +66,8 @@ struct _correction{
.DAC2RealV.coeff = (-18959656),
.DAC2RealV.offset = 565743281498,
.Usercode2DAC.coeff = (-10548714),
.Usercode2DAC.offset = 562100522714,
.Usercode2DAC.coeff = (-10517325),
.Usercode2DAC.offset = 561574831511,
.Gain0Boundary[0] = 0x5F75,
.Gain0Boundary[1] = 0x5FB2,
@@ -82,11 +82,11 @@ struct _correction{
.ADC_volt.coeff = (-6259045),
.ADC_volt.offset = 150606390230,
.ADC_current[0].coeff = 27661202,
.ADC_current[0].offset = (-664225386769),
.ADC_current[0].coeff = 30675739,
.ADC_current[0].offset = (-736666253953),
.ADC_current[1].coeff = 663176124,
.ADC_current[1].offset = (-15925056526152),
.ADC_current[1].coeff = 749057318,
.ADC_current[1].offset = (-17984432358007),
.ADC_current[2].coeff = 31242587,
.ADC_current[2].offset = (-750184492407),
@@ -144,8 +144,8 @@ struct _correction{
.ADC_current[1].coeff = 658398533,
.ADC_current[1].offset = -16001498741131,
.ADC_current[2].coeff = 30908351,
.ADC_current[2].offset = -746548614824,
.ADC_current[2].coeff = 30908351000,
.ADC_current[2].offset = -746548614824000,
.DAC2RealV.coeff = (-19007867),
.DAC2RealV.offset = 646316924837,
@@ -199,13 +199,13 @@ struct _correction{
#endif
#ifdef BOARD_BAY_BAY
#ifdef BOARD_GENIUS
{
.ADC_volt.coeff = (-6236652),
.ADC_volt.offset = 101533279052,
.ADC_current[0].coeff = 309083900,
.ADC_current[0].offset = (-7414775955140),
.ADC_current[0].coeff = 31094976,
.ADC_current[0].offset = (-507114075439),
.ADC_current[1].coeff = 31218018,
.ADC_current[1].offset = (-508593562044),
@@ -283,6 +283,341 @@ struct _correction{
};
#endif
#ifdef BOARD_LITTLE_STAR
{
.ADC_volt.coeff = (-6224192),
.ADC_volt.offset = 101472884698,
.ADC_current[0].coeff = 31293602,
.ADC_current[0].offset = (-510187416959),
.ADC_current[1].coeff = 655130048,
.ADC_current[1].offset = (-10680093830418),
.ADC_current[2].coeff = 31450484,
.ADC_current[2].offset = (-512697942950),
.DAC2RealV.coeff = (-18690126),
.DAC2RealV.offset = 564319610294 ,
.Usercode2DAC.coeff = (-10524846),
.Usercode2DAC.offset = 561713962333,
.Gain0Boundary[0] = 0x5E2F,
.Gain0Boundary[1] = 0x5E96,
.Gain1Boundary[0] = 0x5878,
.Gain1Boundary[1] = 0x645A
};
#endif
#ifdef BOARD_517
{
.ADC_volt.coeff = (-6244769),
.ADC_volt.offset = 101714685687,
.ADC_current[0].coeff = 30919726,
.ADC_current[0].offset = (-503489101786),
.ADC_current[1].coeff = 654824495,
.ADC_current[1].offset = (-10660542778914),
.ADC_current[2].coeff = 31376265,
.ADC_current[2].offset = (-510797752348),
.DAC2RealV.coeff = (-18690126),
.DAC2RealV.offset = 564319610294 ,
.Usercode2DAC.coeff = (-10500774),
.Usercode2DAC.offset = 560779455904,
.Gain0Boundary[0] = 0x5E2F,
.Gain0Boundary[1] = 0x5E96,
.Gain1Boundary[0] = 0x5878,
.Gain1Boundary[1] = 0x645A
};
#endif
#ifdef BOARD_FISH_VET
{
.ADC_volt.coeff = (-6243954),
.ADC_volt.offset = 101956814341,
.ADC_current[0].coeff = 6208753,
.ADC_current[0].offset = (-101076436901),
.ADC_current[1].coeff = 68760643,
.ADC_current[1].offset = (-1123221851971),
.ADC_current[2].coeff = 61882330,
.ADC_current[2].offset = (-1010385966159),
.DAC2RealV.coeff = (-18690126),
.DAC2RealV.offset = 564319610294,
.Usercode2DAC.coeff = (-10517326),
.Usercode2DAC.offset = 561574831512,
.Gain0Boundary[0] = 0x5E2F,
.Gain0Boundary[1] = 0x5E96,
.Gain1Boundary[0] = 0x5878,
.Gain1Boundary[1] = 0x645A
};
#endif
#ifdef BOARD_KELLY
{
.ADC_volt.coeff = (-6238112),
.ADC_volt.offset = 101628014509,
.ADC_current[0].coeff = 6087943,
.ADC_current[0].offset = (-99768174580),
.ADC_current[1].coeff = 68915156,
.ADC_current[1].offset = (-1121470119188),
.ADC_current[2].coeff = 61800515,
.ADC_current[2].offset = (-1006755993534),
.DAC2RealV.coeff = (-18690126),
.DAC2RealV.offset = 564319610294,
.Usercode2DAC.coeff = (-10528309),
.Usercode2DAC.offset = 561035476688,
.Gain0Boundary[0] = 0x5E2F,
.Gain0Boundary[1] = 0x5E96,
.Gain1Boundary[0] = 0x5878,
.Gain1Boundary[1] = 0x645A
};
#endif
#ifdef BOARD_BAY_BAY
{
.ADC_volt.coeff = (-6223734),
.ADC_volt.offset = 101647006833,
.ADC_current[0].coeff = 31039179,
.ADC_current[0].offset = (-506383432096),
.ADC_current[1].coeff = 647940355,
.ADC_current[1].offset = (-10611041889224),
.ADC_current[2].coeff = 31094976,
.ADC_current[2].offset = (-507114075439),
.DAC2RealV.coeff = (-18690126),
.DAC2RealV.offset = 564319610294,
.Usercode2DAC.coeff = (-10541677),
.Usercode2DAC.offset = 562208801371,
.Gain0Boundary[0] = 0x5E2F,
.Gain0Boundary[1] = 0x5E96,
.Gain1Boundary[0] = 0x5878,
.Gain1Boundary[1] = 0x645A
};
#endif
#ifdef BOARD_MEOWMI
{
.ADC_volt.coeff = (-6265015),
.ADC_volt.offset = 101843650153,
.ADC_current[0].coeff = 62522034,
.ADC_current[0].offset = (-1016702373525),
.ADC_current[1].coeff = 31613132,
.ADC_current[1].offset = (-514033175600),
.ADC_current[2].coeff = 565897139,
.ADC_current[2].offset = (-9201204539440),
.DAC2RealV.coeff = (-18990774),
.DAC2RealV.offset = 570886531263,
.Usercode2DAC.coeff = (-10541427),
.Usercode2DAC.offset = 562159124753,
.Gain0Boundary[0] = 0x5D96,
.Gain0Boundary[1] = 0x5DD9,
.Gain1Boundary[0] = 0x57CD,
.Gain1Boundary[1] = 0x639F
};
#endif
#ifdef BOARD_EUROPEAN
{
.ADC_volt.coeff = (-6264190),
.ADC_volt.offset = 101683809669,
.ADC_current[0].coeff = 31301451,
.ADC_current[0].offset = (-508301866021),
.ADC_current[1].coeff = 656423459,
.ADC_current[1].offset = (-10660544072862),
.ADC_current[2].coeff = 31414514,
.ADC_current[2].offset = (-510185549182),
.DAC2RealV.coeff = (-18990774),
.DAC2RealV.offset = 570886531263,
.Usercode2DAC.coeff = (-10513774),
.Usercode2DAC.offset = 559795292677,
.Gain0Boundary[0] = 0x5D96,
.Gain0Boundary[1] = 0x5DD9,
.Gain1Boundary[0] = 0x57CD,
.Gain1Boundary[1] = 0x639F
};
#endif
#ifdef BOARD_EARTH
{
.ADC_volt.coeff = (-6256660),
.ADC_volt.offset = 101658275678,
.ADC_current[0].coeff = 31271240,
.ADC_current[0].offset = (-508496329863),
.ADC_current[1].coeff = 659931818,
.ADC_current[1].offset = (-10729666444387),
.ADC_current[2].coeff = 31485559000,
.ADC_current[2].offset = (-511907957163000),
.DAC2RealV.coeff = (-19047143),
.DAC2RealV.offset = 565935714286,
.Usercode2DAC.coeff = (-10500262),
.Usercode2DAC.offset = 559630236100,
.Gain0Boundary[0] = 0x5D96,
.Gain0Boundary[1] = 0x5DD9,
.Gain1Boundary[0] = 0x57CD,
.Gain1Boundary[1] = 0x639F
};
#endif
#ifdef BOARD_WATER_STAR
{
.ADC_volt.coeff = (-6259808),
.ADC_volt.offset = 102009860128,
.ADC_current[0].coeff = 31335917,
.ADC_current[0].offset = (-511426612252),
.ADC_current[1].coeff = 658172815,
.ADC_current[1].offset = (-10738251896209),
.ADC_current[2].coeff = 31482687000,
.ADC_current[2].offset = (-513650531545000),
.DAC2RealV.coeff = (-10548297),
.DAC2RealV.offset = 562611756757,
.Usercode2DAC.coeff = (-10500262),
.Usercode2DAC.offset = 559630236100,
.Gain0Boundary[0] = 0x5D96,
.Gain0Boundary[1] = 0x5DD9,
.Gain1Boundary[0] = 0x57CD,
.Gain1Boundary[1] = 0x639F
};
#endif
#ifdef BOARD_MARS
{
.ADC_volt.coeff = (-6270623),
.ADC_volt.offset = 102383421553,
.ADC_current[0].coeff = 31187022,
.ADC_current[0].offset = (-509159321195),
.ADC_current[1].coeff = 655981611,
.ADC_current[1].offset = (-10709717111320),
.ADC_current[2].coeff = 31256968,
.ADC_current[2].offset = (-510275213115),
.DAC2RealV.coeff = (-18937347),
.DAC2RealV.offset = 568558163265,
.Usercode2DAC.coeff = (-10561141),
.Usercode2DAC.offset = 564249134291,
.Gain0Boundary[0] = 0x5D96,
.Gain0Boundary[1] = 0x5DD9,
.Gain1Boundary[0] = 0x57CD,
.Gain1Boundary[1] = 0x639F
};
#endif
#ifdef BOARD_VENUS
{
.ADC_volt.coeff = (-6268996),
.ADC_volt.offset = 102204055818,
.ADC_current[0].coeff = 31131930,
.ADC_current[0].offset = (-507382432547),
.ADC_current[1].coeff = 654620883,
.ADC_current[1].offset = (-10668953588943),
.ADC_current[2].coeff = 31245260000,
.ADC_current[2].offset = (-509181085054000),
.DAC2RealV.coeff = (-19009388),
.DAC2RealV.offset = 567032653061,
.Usercode2DAC.coeff = (-10521117),
.Usercode2DAC.offset = 561308254899,
.Gain0Boundary[0] = 0x5D96,
.Gain0Boundary[1] = 0x5DD9,
.Gain1Boundary[0] = 0x57CD,
.Gain1Boundary[1] = 0x639F
};
#endif
#ifdef BOARD_MERCURY
{
.ADC_volt.coeff = (-6259808),
.ADC_volt.offset = 102009860128,
.ADC_current[0].coeff = 31335917,
.ADC_current[0].offset = (-511426612252),
.ADC_current[1].coeff = 658172815,
.ADC_current[1].offset = (-10738251896209),
.ADC_current[2].coeff = 31482687000,
.ADC_current[2].offset = (-513650531545000),
.DAC2RealV.coeff = (-19009388),
.DAC2RealV.offset = 567032653061,
.Usercode2DAC.coeff = (-10548297),
.Usercode2DAC.offset = 562611756757,
.Gain0Boundary[0] = 0x5D96,
.Gain0Boundary[1] = 0x5DD9,
.Gain1Boundary[0] = 0x57CD,
.Gain1Boundary[1] = 0x639F
};
#endif
// this function turn ADC measure value (0xXXXX) into real voltage
// unit should be mV
@@ -308,34 +643,35 @@ static int32_t DecodeADCCurrent(uint8_t ADCGain, uint16_t ADC_measure){
}
static int32_t DecodeResister(uint8_t ADCGainLevel, uint16_t CurrentMeasure, uint16_t VoltMeasure){
long long ADCRealResister = 0, ADCRealCurrent=0, ADCRealVolt=0;
int32_t current_32, volt_32, resister_32;
long long ADCRealCurrent=0, ADCRealVolt=0;
int32_t resister_32;
// get measure current
ADCRealCurrent = (Correction.ADC_current[ADCGainLevel].coeff * CurrentMeasure + Correction.ADC_current[ADCGainLevel].offset)/1e7;
current_32 = (int32_t) (ADCRealCurrent);
// get measure volt
// This step is necessary, if the measure resister !>> 10 ohm
ADCRealVolt = (Correction.ADC_volt.coeff * VoltMeasure + Correction.ADC_volt.offset);
ADCRealVolt = ADCRealVolt / 1e4;
volt_32 = (int32_t) (ADCRealVolt);
if (INSTRUCTION.ADCGainLevel == GAIN_200R){
resister_32 = (int32_t) ((ADCRealVolt) / (ADCRealCurrent/1e3)); // nV / uA = mV
}
else{
resister_32 = (int32_t) ((ADCRealVolt) / (ADCRealCurrent/1e6)); // nV / uA = mV
}
// NotifyVolt[0] = (uint8_t) (volt_32 >> 24);
// NotifyVolt[1] = (uint8_t) ((volt_32 & 0x00FF0000) >> 16);
// NotifyVolt[2] = (uint8_t) ((volt_32 & 0x0000FF00) >> 8);
// NotifyVolt[3] = (uint8_t) (volt_32 & 0x000000FF);
//
// NotifyCurrent[0] = (uint8_t) (current_32 >> 24);
// NotifyCurrent[1] = (uint8_t) ((current_32 & 0x00FF0000) >> 16);
// NotifyCurrent[2] = (uint8_t) ((current_32 & 0x0000FF00) >> 8);
// NotifyCurrent[3] = (uint8_t) (current_32 & 0x000000FF);
// if (INSTRUCTION.ADCGainLevel == GAIN_200R){
resister_32 = (int32_t) ((ADCRealVolt) / (ADCRealCurrent/1e3)); // nV / uA = mV
// }
// else{
// resister_32 = (int32_t) ((ADCRealVolt) / (ADCRealCurrent/1e6)); // nV / uA = mV
// }
int32_t volt_32 = (int32_t) (ADCRealVolt);
int32_t current_32 = (int32_t) (ADCRealCurrent);
NotifyVolt[0] = (uint8_t) (volt_32 >> 24);
NotifyVolt[1] = (uint8_t) ((volt_32 & 0x00FF0000) >> 16);
NotifyVolt[2] = (uint8_t) ((volt_32 & 0x0000FF00) >> 8);
NotifyVolt[3] = (uint8_t) (volt_32 & 0x000000FF);
NotifyCurrent[0] = (uint8_t) (current_32 >> 24);
NotifyCurrent[1] = (uint8_t) ((current_32 & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t) ((current_32 & 0x0000FF00) >> 8);
NotifyCurrent[3] = (uint8_t) (current_32 & 0x000000FF);
NotifyImpedance[0] = (uint8_t) (resister_32 >> 24);
NotifyImpedance[1] = (uint8_t) ((resister_32 & 0x00FF0000) >> 16);
@@ -349,7 +685,7 @@ static int32_t DecodeResister(uint8_t ADCGainLevel, uint16_t CurrentMeasure, uin
static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_raw){
uint16_t ADC_measure = (uint16_t) (ADC_raw[0] << 8) | (uint16_t) (ADC_raw[1]);
int32_t ADCRealVolt = 0, ret = 0, ADCRealCurrent = 0, ADCRealResister = 0;
int32_t ADCRealVolt = 0, ret = 0, ADCRealCurrent = 0;
// return real volt to controller
if(ADCChannel == ADC_CH_VOLT){
@@ -364,12 +700,20 @@ static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_
// return real current to controller
else if(ADCChannel == ADC_CH_CURRENT){
if (INSTRUCTION.eliteFxn == IV_CURVE) {
if ( (INSTRUCTION.eliteFxn == IV_CURVE) || (INSTRUCTION.eliteFxn == CV_CURVE)) {
// wait 0.1 sec until circuit stable => discard first data means wait 0.1 sec
if(DiscardIVFirstData){
DiscardIVFirstData = 0;
return 0;
}
ADCRealCurrent_long += DecodeADCCurrent(ADCGain, ADC_measure);
avg_number++;
// return a real time current (used for deciding auto gain)
ret = DecodeADCCurrent(ADCGain, ADC_measure);
ADCRealCurrent_long = ADCRealCurrent_long + ret;
avg_number ++;
if (StepTimeCounter == INSTRUCTION.StepTime) {
if (StepTimeCounter == INSTRUCTION.StepTime - 1) {
DiscardIVFirstData = 1;
ADCRealCurrent_long = ADCRealCurrent_long / avg_number;
NotifyCurrent[0] = (uint8_t) (ADCRealCurrent_long >> 24);
NotifyCurrent[1] = (uint8_t) ((ADCRealCurrent_long & 0x00FF0000) >> 16);
@@ -379,6 +723,8 @@ static int32_t DecodeADCValue(uint8_t ADCGain, uint8_t ADCChannel, uint8_t *ADC_
ADCRealCurrent_long = 0;
}
}
// IT curve
else {
ADCRealCurrent = DecodeADCCurrent(ADCGain, ADC_measure);
NotifyCurrent[0] = (uint8_t) (ADCRealCurrent >> 24);
@@ -2,20 +2,35 @@
#ifndef ELITEIT
#define ELITEIT
static int32_t IT_Plot() {
//static int32_t IT_Plot() {
// // read ADC current
// int32_t Real_Current = 0;
// ADCGainControl(INSTRUCTION.ADCGainLevel);
// ADCChannelSelect(ADC_CH_CURRENT);
// CPUdelay(10);
// ADC_read(spi_ADC_rxbuf);
//
// // check if ADC over/under flow
// // let the output saturate if over/under flow
//// ADC_overflow(INSTRUCTION.ADCGainLevel, spi_ADC_rxbuf);
//
// // decode ADC value and put it into notify buffer
// Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
//
// return Real_Current;
//}
static int32_t IT_Plot() {
// read ADC current
int32_t Real_Current = 0;
ADCGainControl(INSTRUCTION.ADCGainLevel);
ADCChannelSelect(ADC_CH_CURRENT);
CPUdelay(10);
ADC_read(spi_ADC_rxbuf);
// check if ADC over/under flow
// let the output saturate if over/under flow
// ADC_overflow(INSTRUCTION.ADCGainLevel, spi_ADC_rxbuf);
// decode ADC value and put it into notify buffer
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
if(INSTRUCTION.AutoGainEnable){
Real_Current = AutoGainReadCurrent(spi_ADC_rxbuf);
}
else{
ReadCurrent(spi_ADC_rxbuf);
Real_Current = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
return Real_Current;
}
@@ -13,7 +13,7 @@ static uint16_t VoltScan() {
Voltage = SWVCurve();
} else if (INSTRUCTION.eliteFxn == DIFFERENTIAL_PULSE_VOLTAMMETRY) {
Voltage = DPVCurve();
} else if (INSTRUCTION.eliteFxn == CYCLIC_VOLTAMMETRY) {
} else if (INSTRUCTION.eliteFxn == CV_CURVE) {
Voltage = CVCurve();
}
@@ -52,8 +52,22 @@ static uint16_t OneWayVoltScan() {
DACReset = true;
}
} else {
// output the next output volt
DACUserCode = DACUserCode - INSTRUCTION.Step;
// check if DACUserCode underflow
if(DACUserCode >= 60000){
// LED_color(DARKLED, 0xFF, 0x00, 0x00);
DACUserCode = INSTRUCTION.VoltFinal;
}
// int32_t DACUC = DACUserCode;
// NotifyImpedance[0] = (uint8_t) (DACUC >> 24);
// NotifyImpedance[1] = (uint8_t) ((DACUC & 0x00FF0000) >> 16);
// NotifyImpedance[2] = (uint8_t) ((DACUC & 0x0000FF00) >> 8);
// NotifyImpedance[3] = (uint8_t) (DACUC & 0x000000FF);
// output the next output volt
DACOutCode = Usercode_Correction_to_DAC(DACUserCode);
DAC_outputV(DACOutCode);
@@ -30,23 +30,24 @@ struct HEADSTAGE_INSTRUCTION {
/** Sample rate **/
// SampleRate = SampleRateTable[SampleRateIndex]
uint8_t SampleRateIndex;
uint16_t SampleRate;
uint32_t SampleRate;
/** DAC parameter **/
// volt san parameter
uint16_t VoltOrigin;
uint16_t VoltFinal;
uint16_t Step;
uint8_t StepTime;
uint16_t StepTime;
// constant volt
uint16_t VoltConstant;
/** ADC parameter **/
uint8_t ADCGainLevel;
uint8_t AutoGainEnable;
/** Constant Current Parameter **/
uint8_t CurrentLV; // nA? uA? mA?
uint32_t ConstantCurrent;
int32_t ConstantCurrent;
/** Resister Measure **/
uint8_t ResisterMeter;
@@ -75,10 +76,10 @@ static void InitEliteInstruction(){
INSTRUCTION.VoltFinal = DAC_POS_MAX;
INSTRUCTION.Step = 0x0005; // 0x0005 = 1mV
INSTRUCTION.StepTime = STEPTIME_HALF_SEC; // about 0.5 sec
INSTRUCTION.VoltConstant = 24999; // is about 0V
INSTRUCTION.ADCGainLevel = GAIN_200R;
INSTRUCTION.ResisterMeter = RESISTER_METER_SMALL;
INSTRUCTION.CurrentLV = 0x00;
INSTRUCTION.VoltConstant = 25000; // is about 0V
INSTRUCTION.ADCGainLevel = GAIN_AUTO;
INSTRUCTION.AutoGainEnable = 1;
INSTRUCTION.ResisterMeter = RESISTER_METER_LARGE;
INSTRUCTION.ConstantCurrent = 0x00000000;
INSTRUCTION.eliteFxn = 0; // default is a null event
INSTRUCTION.CycleNumber = 0;
@@ -97,7 +98,7 @@ static void GetInstructionParameter(uint8 *ins){
// CurrentLV=0 => unit is nA
// CurrentLV=1 => unit is uA
// CurrentLV=2 => unit is mA
INSTRUCTION.CurrentLV = (*ins);
// INSTRUCTION.CurrentLV = (*ins);
// ConstantCurrentRange=0 => current value is 0~499
// ConstantCurrentRange=1 => current value is 500~999
@@ -29,7 +29,7 @@ static void WorkModeLED() {
WORKLED();
break;
}
case CYCLIC_VOLTAMMETRY: {
case CV_CURVE: {
WORKLED();
break;
}
@@ -50,14 +50,17 @@ static void WorkModeLED() {
break;
}
case VT_CURVE: {
// WORKLED();
WORKLED();
break;
}
case IT_CURVE: {
WORKLED();
break;
}
case CONSTANT_CURRENT:{
WORKLED();
break;
}
case VIS_RST: {
LEDPowerON();
break;
@@ -82,7 +85,7 @@ static void KeyWorkModeLED() {
LED_color(LIGHTLED, 0xF0, 0xF0, 0x00);
break;
}
case CYCLIC_VOLTAMMETRY:{
case CV_CURVE:{
LED_color(LIGHTLED, 0xF0, 0xF0, 0x00);
break;
}
@@ -5,12 +5,16 @@
static void reset() {
PeriodicEvent = false;
DACReset = true;
CCModeReset = 1;
CCModeDACEnable = 0;
InitEliteInstruction();
SampleRate_counter = 1;
StepTimeCounter = 1;
DiscardIVFirstData = 1;
avg_number = 0;
ADCRealCurrent_long = 0;
ADCGainControl(INSTRUCTION.ADCGainLevel);
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
if (INSTRUCTION.eliteFxn == CONSTANT_CURRENT){
INSTRUCTION.eliteFxn = 0;
@@ -48,12 +52,15 @@ static void reset() {
static void Eliteinterrupt() {
PeriodicEvent = false;
DACReset = true;
CCModeReset = 1;
CCModeDACEnable = 0;
InitEliteInstruction();
StepTimeCounter = 1;
SampleRate_counter = 1;
DiscardIVFirstData = 1;
avg_number = 0;
ADCRealCurrent_long = 0;
ADCGainControl(INSTRUCTION.ADCGainLevel);
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
LEDPowerON();
for (int i = 0; i < BLE_INS_BUFF_SIZE; i++) {
@@ -87,10 +94,11 @@ static void Eliteinterrupt() {
static void CleanBuffer() {
PeriodicEvent = false;
DACReset = true;
CCModeReset = 1;
CCModeDACEnable = 0;
// InitEliteInstruction();
SampleRate_counter = 1;
StepTimeCounter = 1;
DiscardIVFirstData = 1;
avg_number = 0;
ADCRealCurrent_long = 0;
@@ -7,9 +7,7 @@ static void VT_Plot() {
uint8_t ADCGain = 0;
// read ADC volt
ADCChannelSelect(ADC_CH_VOLT);
CPUdelay(10);
ADC_read(spi_ADC_rxbuf);
ReadVolt(spi_ADC_rxbuf);
// decode ADC value and put it into notify buffer
DecodeADCValue(ADCGain, ADC_CH_VOLT, spi_ADC_rxbuf);
@@ -10,61 +10,97 @@ static void ZT_notify(int32_t impedance);
// change the output voltage step
// => get a R-T curve (with resolution = 1 sample/volt step )
static void ZT_Plot() {
int32_t Real_Resister = 0;
// int32_t Real_Resister = 0;
static uint16_t CurrentMeasure=0, VoltMeasure=0;
uint8_t SPICurrent[SPI_ADC_SIZE]={0}, SPIVolt[SPI_ADC_SIZE]={0};
static uint8_t VoltCurrentSwitch = 0;
// set ADC GAIN
if(INSTRUCTION.ResisterMeter == RESISTER_METER_SMALL){
INSTRUCTION.ADCGainLevel = GAIN_200R;
}
else if(INSTRUCTION.ResisterMeter == RESISTER_METER_MIDDLE1){
INSTRUCTION.ADCGainLevel = GAIN_200R;
}
else if(INSTRUCTION.ResisterMeter == RESISTER_METER_MIDDLE2){
INSTRUCTION.ADCGainLevel = GAIN_10K;
}
else{
INSTRUCTION.ADCGainLevel = GAIN_200K;
}
ADCGainControl(INSTRUCTION.ADCGainLevel);
int32_t volt_32 = 0;
int32_t current_32 = 0;
int32_t resister_32 = 0;
if(VoltCurrentSwitch < 9){
ADCChannelSelect(ADC_CH_CURRENT);
CPUdelay(10);
ADC_read(SPICurrent);
VoltCurrentSwitch ++;
}
else if(VoltCurrentSwitch == 9){
// read current
ADCChannelSelect(ADC_CH_CURRENT);
CPUdelay(10);
ADC_read(SPICurrent);
CurrentMeasure = (uint16_t) (SPICurrent[0] << 8) | (uint16_t) (SPICurrent[1]);
VoltCurrentSwitch ++;
}
else if(VoltCurrentSwitch <18){
// read volt
ADCChannelSelect(ADC_CH_VOLT);
CPUdelay(10);
ADC_read(SPIVolt);
VoltCurrentSwitch++;
}
else if(VoltCurrentSwitch == 18){
// read volt
ADCChannelSelect(ADC_CH_VOLT);
CPUdelay(10);
ADC_read(SPIVolt);
VoltMeasure = (uint16_t) (SPIVolt[0] << 8) | (uint16_t) (SPIVolt[1]);
VoltCurrentSwitch++;
if(INSTRUCTION.AutoGainEnable){
current_32 = AutoGainReadCurrent(SPICurrent);
}
else{
VoltCurrentSwitch = 0;
ReadCurrent(spi_ADC_rxbuf);
current_32 = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
volt_32 = User2Real(INSTRUCTION.VoltConstant)*1e4;
// ReadVolt(SPIVolt);
// VoltMeasure = (uint16_t) (SPIVolt[0] << 8) | (uint16_t) (SPIVolt[1]);
// volt_32 = DecodeADCVolt(VoltMeasure)*1e4;
resister_32 = volt_32 / current_32;
NotifyVolt[0] = (uint8_t) (volt_32 >> 24);
NotifyVolt[1] = (uint8_t) ((volt_32 & 0x00FF0000) >> 16);
NotifyVolt[2] = (uint8_t) ((volt_32 & 0x0000FF00) >> 8);
NotifyVolt[3] = (uint8_t) (volt_32 & 0x000000FF);
NotifyCurrent[0] = (uint8_t) (current_32 >> 24);
NotifyCurrent[1] = (uint8_t) ((current_32 & 0x00FF0000) >> 16);
NotifyCurrent[2] = (uint8_t) ((current_32 & 0x0000FF00) >> 8);
NotifyCurrent[3] = (uint8_t) (current_32 & 0x000000FF);
NotifyImpedance[0] = (uint8_t) (resister_32 >> 24);
NotifyImpedance[1] = (uint8_t) ((resister_32 & 0x00FF0000) >> 16);
NotifyImpedance[2] = (uint8_t) ((resister_32 & 0x0000FF00) >> 8);
NotifyImpedance[3] = (uint8_t) (resister_32 & 0x000000FF);
// set ADC GAIN
// if(INSTRUCTION.ResisterMeter == RESISTER_METER_LARGE){
// INSTRUCTION.ADCGainLevel = GAIN_200R;
// }
// else if(INSTRUCTION.ResisterMeter == RESISTER_METER_MIDDLE2){
// INSTRUCTION.ADCGainLevel = GAIN_200R;
// }
// else if(INSTRUCTION.ResisterMeter == RESISTER_METER_MIDDLE1){
// INSTRUCTION.ADCGainLevel = GAIN_10K;
// }
// else{
// INSTRUCTION.ADCGainLevel = GAIN_200K;
// }
// ADCGainControl(INSTRUCTION.ADCGainLevel);
// Use 9-th measure value as real-measure value
// because some value in the begin are garbage
// if(VoltCurrentSwitch < 9){
// ADCChannelSelect(ADC_CH_CURRENT);
// CPUdelay(10);
// ADC_read(SPICurrent);
// VoltCurrentSwitch ++;
// }
// else if(VoltCurrentSwitch == 9){
// // read current
// ADCChannelSelect(ADC_CH_CURRENT);
// CPUdelay(10);
// ADC_read(SPICurrent);
// CurrentMeasure = (uint16_t) (SPICurrent[0] << 8) | (uint16_t) (SPICurrent[1]);
// VoltCurrentSwitch ++;
// }
// else if(VoltCurrentSwitch <18){
// // read volt
// ADCChannelSelect(ADC_CH_VOLT);
// CPUdelay(10);
// ADC_read(SPIVolt);
// VoltCurrentSwitch++;
// }
// else if(VoltCurrentSwitch == 18){
// // read volt
// ADCChannelSelect(ADC_CH_VOLT);
// CPUdelay(10);
// ADC_read(SPIVolt);
// VoltMeasure = (uint16_t) (SPIVolt[0] << 8) | (uint16_t) (SPIVolt[1]);
// VoltCurrentSwitch++;
// }
// else{
// VoltCurrentSwitch = 0;
// }
// decode ADC value and put it into notify buffer
DecodeResister(INSTRUCTION.ADCGainLevel, CurrentMeasure, VoltMeasure);
// DecodeResister(INSTRUCTION.ADCGainLevel, CurrentMeasure, VoltMeasure);
// Real_Resister = DecodeADCValue(INSTRUCTION.ADCGainLevel, ADC_CH_CURRENT, spi_ADC_rxbuf);
}
@@ -190,14 +190,14 @@ MUX
PGA
programmable gain amplifier configuration
(Full Scale Range = FSR)
000 = FSR is 6.144 V
001 = FSR is 4.096 V
010 = FSR is 2.048 V (default)
011 = FSR is 1.024 V
100 = FSR is 0.512 V
101 = FSR is 0.256 V
110 = FSR is 0.256 V
111 = FSR is 0.256 V
000 = FSR is 6.144 V
001 = FSR is 4.096 V
010 = FSR is 2.048 V (default)
011 = FSR is 1.024 V
100 = FSR is 0.512 V
101 = FSR is 0.256 V
110 = FSR is 0.256 V
111 = FSR is 0.256 V
M
ADC operating mode
@@ -579,7 +579,7 @@ static void set_update_instruction_callback(update_instruction_callback_type cal
// real instruction
#define IV_CURVE 0b00010000
#define CYCLIC_VOLTAMMETRY 0b00100000
#define CV_CURVE 0b00100000
#define VOLT_OUTPUT 0b00110000
#define ZT_CURVE 0b01000000
#define VT_CURVE 0b01010000
@@ -607,11 +607,12 @@ static int32_t DAC_to_realV(uint16_t DACcode);
#define DAC_NEG_MAX 0xFFFF
static uint16_t DACUserCode = 0x0000;
static uint32_t SampleRateTable[6] = {10, 100, 1000, 5000, 10000, 100000}; // 1 =>100 Hz, 10000=>0.01 Hz
static uint16_t SampleRate_counter = 1;
static uint32_t SampleRateTable[6] = {100, 1000, 10000, 50000, 100000, 1000000}; // 1 =>100 Hz, 10000=>0.01 Hz
static uint32_t SampleRate_counter = 1;
// record value for IV curve to calculate average current
static int16_t avg_number = 0;
static uint8_t DiscardIVFirstData = 1;
static uint16_t avg_number = 0;
static long long ADCRealCurrent_long = 0;
// Step time macro
@@ -620,7 +621,7 @@ static long long ADCRealCurrent_long = 0;
#define STEPTIME_TWO_SEC 20000
// Constant Current Mode function
static uint8_t CCModeReset = 1;
static uint8_t CCModeDACEnable = 0;
static int32_t CCModeReadCurrent();
static int32_t CCModeVoltOut();
static void SetCCModeGain();
@@ -635,8 +636,7 @@ static uint16_t PulseWidth_16;
static uint8_t PulsePeriod;
static uint16_t PulsePeriod_16;
static uint16_t StepTime_16 = 0;
static uint8_t StepTimeCounter = 1;
static uint16_t StepTimeCounter = 1;
// real instruction fxn
static uint16_t VoltScan(); // used in I-V and cyclic
@@ -700,7 +700,7 @@ static void update_ZM_instruction(uint8 *ins) {
INSTRUCTION.chip_id = chip_ID;
uint8_t oper = ins[1] & 0xF0; // this is don't care in RIS
uint8_t data_length = ins[1] & 0x0F;
// uint8_t data_length = ins[1] & 0x0F;
if (!If10Von) {
// TurnOn10V();
@@ -711,10 +711,10 @@ static void update_ZM_instruction(uint8 *ins) {
case INS_TYPE_RIS: {
switch (ins[2]) {
case IV_CURVE: {
CleanBuffer();
// CleanBuffer();
INSTRUCTION.eliteFxn = IV_CURVE;
DACReset = true;
INSTRUCTION.SampleRate = 10;
INSTRUCTION.SampleRate = 1000;
if (ins[3] | ins[4]) {
INSTRUCTION.VoltOrigin = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
@@ -802,18 +802,19 @@ static void update_ZM_instruction(uint8 *ins) {
break;
}
case CYCLIC_VOLTAMMETRY: {
CleanBuffer();
INSTRUCTION.eliteFxn = CYCLIC_VOLTAMMETRY;
case CV_CURVE: {
// CleanBuffer();
INSTRUCTION.eliteFxn = CV_CURVE;
DACReset = true;
INSTRUCTION.SampleRate = 1000;
if (ins[3] | ins[4]) {
INSTRUCTION.VoltOrigin = ((uint16_t)(ins[3]) << 8) | (uint16_t)(ins[4]);
INSTRUCTION.VoltOrigin = Usercode_Correction_to_DAC(INSTRUCTION.VoltOrigin);
// INSTRUCTION.VoltOrigin = Usercode_Correction_to_DAC(INSTRUCTION.VoltOrigin);
}
if (ins[5] | ins[6]) {
INSTRUCTION.VoltFinal = ((uint16_t)(ins[5]) << 8) | (uint16_t)(ins[6]);
INSTRUCTION.VoltFinal = Usercode_Correction_to_DAC(INSTRUCTION.VoltFinal);
// INSTRUCTION.VoltFinal = Usercode_Correction_to_DAC(INSTRUCTION.VoltFinal);
}
if (ins[7] | ins[8]) {
@@ -831,6 +832,7 @@ static void update_ZM_instruction(uint8 *ins) {
break;
}
case VOLT_OUTPUT: {
INSTRUCTION.eliteFxn = VOLT_OUTPUT;
INSTRUCTION.VoltConstant = ( ((uint16_t)(ins[3])) << 8) | (uint16_t)(ins[4]);
@@ -841,14 +843,14 @@ static void update_ZM_instruction(uint8 *ins) {
// impedance test
case ZT_CURVE: {
CleanBuffer();
// CleanBuffer();
INSTRUCTION.eliteFxn = ZT_CURVE;
// INSTRUCTION.VoltConstant = ( ((uint16_t)(ins[3])) << 8) | (uint16_t)(ins[4]);
break;
}
case VT_CURVE: {
CleanBuffer();
// CleanBuffer();
INSTRUCTION.eliteFxn = VT_CURVE;
// SimpleProfile_SetParameter(BLE_DAT_BUFF_CHAR, BLE_DAT_BUFF_SIZE, not_buf);
// VT_Plot(); // enable 10v = 0
@@ -856,7 +858,7 @@ static void update_ZM_instruction(uint8 *ins) {
}
case IT_CURVE: {
CleanBuffer();
// CleanBuffer();
INSTRUCTION.eliteFxn = IT_CURVE;
// IT_Plot(); // enable 10v = 1
break;
@@ -881,8 +883,8 @@ static void update_ZM_instruction(uint8 *ins) {
case CONSTANT_CURRENT:{
INSTRUCTION.eliteFxn = CONSTANT_CURRENT;
INSTRUCTION.CurrentLV = ins[3];
INSTRUCTION.ConstantCurrent = ( (uint32_t) (ins[4])<<24 | (uint32_t) (ins[5])<<16 | (uint32_t) (ins[6])<<8 | (uint32_t) (ins[7]) );
INSTRUCTION.SampleRate = 2;
INSTRUCTION.ConstantCurrent = ( (uint32_t) (ins[3])<<24 | (uint32_t) (ins[4])<<16 | (uint32_t) (ins[5])<<8 | (uint32_t) (ins[6]) );
// GetInstructionParameter(ins+2);
// CCCurrent2IUC();
break;
@@ -890,6 +892,21 @@ static void update_ZM_instruction(uint8 *ins) {
case SET_ADC_GAIN: {
INSTRUCTION.ADCGainLevel = ins[3];
if(INSTRUCTION.ADCGainLevel != GAIN_AUTO){
INSTRUCTION.AutoGainEnable = 0;
}
else{
INSTRUCTION.AutoGainEnable = 1;
}
// if(INSTRUCTION.ADCGainLevel == GAIN_200R){
// LED_color(DARKLED, 0x0F, 0x00, 0x00);
// }
// else if(INSTRUCTION.ADCGainLevel == GAIN_10K){
// LED_color(DARKLED, 0x0F, 0x00, 0x0F);
// }
// else if(INSTRUCTION.ADCGainLevel == GAIN_200K){
// LED_color(DARKLED, 0x0F, 0x02, 0xFF);
// }
break;
}
@@ -903,15 +920,27 @@ static void update_ZM_instruction(uint8 *ins) {
int32_t ADCRealValue = 0;
uint8_t CIS_buf[9] = {0};
ADCGainControl(ins[3]);
ADCChannelSelect(ins[4]);
CPUdelay(1600);
ADC_read(spi_ADC_rxbuf);
// for(int i=0 ; i<10 ; i++){
ADCGainControl(ins[3]);
ADCChannelSelect(ins[4]);
CPUdelay(10);
ADC_read(spi_ADC_rxbuf);
// CPUdelay(10);
//
// ADCValueTemp = ( uint16_t) (spi_ADC_rxbuf[0]) << 8 | (uint16_t) (spi_ADC_rxbuf[1]);
// ADCValueAVG = ADCValueAVG + ADCValueTemp;
// }
// ADCValueAVG = ADCValueAVG / 10;
// ADCValueTemp = (uint16_t) (ADCValueAVG);
CIS_buf[0] = chip_ID;
for (int i = 0; i < 4; i++) {
CIS_buf[i + 1] = spi_ADC_rxbuf[i];
for(int i=0; i<4 ; i++){
CIS_buf[i+1] = spi_ADC_rxbuf[i];
}
// CIS_buf[1] = (uint8_t) ((ADCValueTemp & 0xFF00) >> 8);
// CIS_buf[2] = (uint8_t) (ADCValueTemp & 0x00FF);
// CIS_buf[3] = spi_ADC_rxbuf[2];
// CIS_buf[4] = spi_ADC_rxbuf[3];
// decode ADC measure value
ADCRealValue = DecodeADCValue(ins[3], ins[4], spi_ADC_rxbuf);
@@ -1,7 +1,7 @@
/*
* impedance_meter.h
*
* Created on: 2019~115
* Created on: 2019/01/15
* Author: benny
*/
#ifndef HEADSTAGE_H
@@ -20,7 +20,7 @@
#include <ti/drivers/PIN.h>
#include "board.h"
static void SimpleBLEPeripheral_performPeriodicTask(CURRENT_USER_CODE *CurrentUserCode);
static void SimpleBLEPeripheral_performPeriodicTask(void *WorkModeData);
static void SimpleBLEPeripheral_clockHandler(UArg arg) {
// Store the event.
@@ -51,6 +51,7 @@ static void ZM_init() {
PIN_setOutputValue(pin_handle, DAC_CS, 1); // DAC_CS HIGH
InitEliteInstruction();
ADCGainControl(GAIN_AUTO);
elite_gptimer_open();
// PIN_registerIntCb(pin_handle, switch_on_callback);
@@ -72,6 +73,7 @@ static void DACCode2Real2Notify(uint16_t DACcode) {
#define IsPeriodicMode() ( \
(INSTRUCTION.eliteFxn == IV_CURVE) || \
(INSTRUCTION.eliteFxn == CV_CURVE) || \
(INSTRUCTION.eliteFxn == IT_CURVE) || \
(INSTRUCTION.eliteFxn == VT_CURVE) || \
(INSTRUCTION.eliteFxn == ZT_CURVE) || \
@@ -87,10 +89,9 @@ static void DACCode2Real2Notify(uint16_t DACcode) {
*
* @return None.
*/
static void SimpleBLEPeripheral_performPeriodicTask(CURRENT_USER_CODE *CurrentUserCode) {
static void SimpleBLEPeripheral_performPeriodicTask(void *WorkModeData) {
if ( IsPeriodicMode() ){
// XXX Using nwe clock => StepTime/SampleRate should change
if (StepTimeCounter == INSTRUCTION.StepTime){
StepTimeCounter = 1;
}
@@ -112,36 +113,45 @@ static void SimpleBLEPeripheral_performPeriodicTask(CURRENT_USER_CODE *CurrentUs
// In IV, CV, and func-gen mode, DAC will output voltage
// else DAC do nothing.
EliteDACControl();
EliteDACControl(WorkModeData);
// Control ADC to sample rate
EliteADCControl(CurrentUserCode);
EliteADCControl(WorkModeData);
// Notify control, check if we need to send notify
EliteNotifyControl();
}
}
static void EliteDACControl(CURRENT_USER_CODE *CurrentUserCode) {
if (INSTRUCTION.eliteFxn == IV_CURVE) {
static void EliteDACControl(void *WorkModeData) {
if ((INSTRUCTION.eliteFxn == IV_CURVE) || (INSTRUCTION.eliteFxn == CV_CURVE)) {
// output a certain voltage and put it into NotifyVolt
DACCode2Real2Notify(VoltScan());
}
else if (INSTRUCTION.eliteFxn == ZT_CURVE){
if(INSTRUCTION.ResisterMeter == RESISTER_METER_SMALL){
// output 5mV
INSTRUCTION.VoltConstant = 24999 + 50;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
// output 1V
if (DACReset) {
INSTRUCTION.VoltConstant = 25000 + 5000;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
DACReset = false;
}
}
else{
// output 100mV
INSTRUCTION.VoltConstant = 24999 + 500;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
// output 1V
if (DACReset) {
INSTRUCTION.VoltConstant = 25000 + 5000;
DAC_outputV(Usercode_Correction_to_DAC(INSTRUCTION.VoltConstant));
DACReset = false;
}
}
}
else if(INSTRUCTION.eliteFxn == CONSTANT_CURRENT){
CCModeVoltOut(CurrentUserCode);
// DAC_outputV(Usercode_Correction_to_DAC(CurrentUserCode->value));
if (DACReset) {
DAC_outputV(Usercode_Correction_to_DAC(25000));
DACReset = false;
}
CCModeVoltOut(WorkModeData);
}
else{
@@ -150,13 +160,17 @@ static void EliteDACControl(CURRENT_USER_CODE *CurrentUserCode) {
}
}
static void EliteADCControl(CURRENT_USER_CODE *CurrentUserCode) {
if (SampleRate_counter == INSTRUCTION.SampleRate) {
static void EliteADCControl(uint32_t **WorkModeData) {
if (SampleRate_counter == INSTRUCTION.SampleRate-1) {
switch (INSTRUCTION.eliteFxn) {
case IV_CURVE:{
IT_Plot();
break;
}
case CV_CURVE:{
IT_Plot();
break;
}
case IT_CURVE:{
IT_Plot();
break;
@@ -171,8 +185,7 @@ static void EliteADCControl(CURRENT_USER_CODE *CurrentUserCode) {
break;
}
case CONSTANT_CURRENT:{
CCModeReadCurrent(CurrentUserCode);
CCModeReadCurrent(WorkModeData);
break;
}
default:{
@@ -183,7 +196,7 @@ static void EliteADCControl(CURRENT_USER_CODE *CurrentUserCode) {
}
static void EliteNotifyControl() {
if ((INSTRUCTION.eliteFxn == IV_CURVE)) {
if ((INSTRUCTION.eliteFxn == IV_CURVE) || (INSTRUCTION.eliteFxn == CV_CURVE)) {
// output the last notify, and reset Elite
if (!PeriodicEvent) {
SendNotify();
@@ -551,14 +551,16 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
ZM_init();
Elite_SPI_init();
void *WorkModeData = malloc(sizeof(uint32_t));
CURRENT_USER_CODE *CurrentUserCode = InitCurrentUserCode();
WorkModeData = &CurrentUserCode;
uint8_t key = 0;
uint16_t counter6994 = 0;
bool EliteOn = 0;
// init DAC, set output ~= 0 V
DAC_outputV(Usercode_Correction_to_DAC(24999));
DAC_outputV(Usercode_Correction_to_DAC(25000));
elite_gptimer_start();
// Application main loops
@@ -634,7 +636,7 @@ static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1) {
// if there is periodic event
else {
// Perform periodic application task
SimpleBLEPeripheral_performPeriodicTask(CurrentUserCode);
SimpleBLEPeripheral_performPeriodicTask(WorkModeData );
key = PIN_getInputValue(switch_on);
EliteKeyPress(key); // onPress=> key = 0; 1.lighten LED 2.long press shut down 2650