From 54949701d14f2d86b8c67d7707a358d656e6f150 Mon Sep 17 00:00:00 2001 From: Anders Sandstrom Date: Tue, 16 Mar 2021 16:53:29 +0100 Subject: [PATCH] WIP on basic config. Amplifier ON works.. WIP --- docs/readmeCanOpenSocket.md | 84 ++++++++++++- .../Db/pmu905BasicConfig.template | 119 ++++++++++++++++++ iocsh/pmu905.script | 1 + iocsh/pvs.log | 35 ++++-- 4 files changed, 226 insertions(+), 13 deletions(-) create mode 100644 ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/Db/pmu905BasicConfig.template diff --git a/docs/readmeCanOpenSocket.md b/docs/readmeCanOpenSocket.md index 3a7d756..71c1156 100644 --- a/docs/readmeCanOpenSocket.md +++ b/docs/readmeCanOpenSocket.md @@ -744,8 +744,28 @@ w 0x700 [1] 0x05 # Basic configuration write (maybe should write a 4800 (=48%) to byte 3 and 4) caput -a IOC_TEST:CAN03-SDO02-BasicConfig 7 0 0 0 0 0 0 + # or better 48000 VDC_CTRL (48%), fan stops of pmu and amplifier on is LED is not on anymore + caput -a IOC_TEST:CAN03-SDO02-BasicConfig 7 0 0 0 192 18 0 0 -# After basic configuration the r 280 will stop () this emans no basic configuration +This will happen: +WRITEVALUE basicConfig +STATE = WRITE_REQ_TRANSFER basicConfig +STATE = WRITE_WAIT_FOR_CONF basicConfig +w 0x603 [8] 0x21 0x90 0x26 0x01 0x07 0x00 0x00 0x00 +writeDataStateMachine basicConfig +STATE = WRITE_DATA basicConfig +r 0x583 [8] 0x60 0x90 0x26 0x01 0x00 0x00 0x00 0x00 +w 0x603 [8] 0x01 0x00 0x00 0x00 0xC0 0x12 0x00 0x00 +writeDataStateMachine basicConfig +STATE = WRITE_IDLE basicConfig +All data written to slave SDO. + +# Amplifier on is bit 0 of byte 0, so to power on just execute: +caput -a IOC_TEST:CAN03-SDO02-BasicConfig 7 1 0 0 192 18 0 0 + + + +# After basic configuration the r 280 will stop () this means the pmu now have basic configuration r 0x583 [8] 0x11 0x00 0xC5 0x00 0x00 0x00 0x88 0x13 r 0x703 [1] 0x05 w 0x7E5 [0] @@ -761,3 +781,65 @@ w 0x700 [1] 0x05 w 0x7E5 [0] w 0x080 [0] w 0x700 [1] 0x05 + + +# Some commands +IOC_TEST:CAN03-PowerOnCmd +IOC_TEST:CAN03-VrefPwrCmd +IOC_TEST:CAN03-VdcCtrlCmd + +## Turn amplifier on +caput IOC_TEST:CAN03-PowerOnCmd 1 + +WRITEVALUE basicConfig +STATE = WRITE_REQ_TRANSFER basicConfig +STATE = WRITE_WAIT_FOR_CONF basicConfig +w 0x603 [8] 0x21 0x90 0x26 0x01 0x07 0x00 0x00 0x00 +writeDataStateMachine basicConfig +STATE = WRITE_DATA basicConfig +r 0x583 [8] 0x60 0x90 0x26 0x01 0x00 0x00 0x00 0x00 +w 0x603 [8] 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 +writeDataStateMachine basicConfig +STATE = WRITE_IDLE basicConfig +All data written to slave SDO. +data[00]: 1 +data[01]: 0 +data[02]: 0 +data[03]: 0 + + +## Set VrefOwr to 100 +caput IOC_TEST:CAN03-VrefPwrCmd 100 + +NOT WORKING.. Will get the below??? + +r 0x583 [8] 0x11 0x00 0xC5 0x00 0x00 0x00 0x88 0x13 +WRITEVALUE basicConfig +STATE = WRITE_REQ_TRANSFER basicConfig +STATE = WRITE_WAIT_FOR_CONF basicConfig +w 0x603 [8] 0x21 0x90 0x26 0x01 0x07 0x00 0x00 0x00 +writeDataStateMachine basicConfig +STATE = WRITE_DATA basicConfig +r 0x583 [8] 0x60 0x90 0x26 0x01 0x00 0x00 0x00 0x00 +w 0x603 [8] 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 +writeDataStateMachine basicConfig +STATE = WRITE_IDLE basicConfig +All data written to slave SDO. + +## Set VdcCtrlCmd to 5000 +caput IOC_TEST:CAN03-VdcCtrlCmd 5000 + +NOT WORKING.. Will get the below??? + +WRITEVALUE basicConfig +STATE = WRITE_REQ_TRANSFER basicConfig +STATE = WRITE_WAIT_FOR_CONF basicConfig +w 0x603 [8] 0x21 0x90 0x26 0x01 0x07 0x00 0x00 0x00 +writeDataStateMachine basicConfig +STATE = WRITE_DATA basicConfig +r 0x583 [8] 0x60 0x90 0x26 0x01 0x00 0x00 0x00 0x00 +w 0x603 [8] 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 +writeDataStateMachine basicConfig +STATE = WRITE_IDLE basicConfig +All data written to slave SDO. + diff --git a/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/Db/pmu905BasicConfig.template b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/Db/pmu905BasicConfig.template new file mode 100644 index 0000000..02d09a7 --- /dev/null +++ b/ecmc_plugin_socketcan/ecmc_plugin_socketcanApp/Db/pmu905BasicConfig.template @@ -0,0 +1,119 @@ +########################################################################### +############## Byte 0 +record(bo,"$(P)CAN${CH_ID}-PowerOnCmd") { + field(DESC, "Power on") + field(VAL, "0") + field(ONAM, "On") + field(ZNAM, "Off") + field(OUT, "$(P)CAN${CH_ID}-BasicConfigB0_.B0") + field(FLNK, "$(P)CAN${CH_ID}-BasicConfigB0_.PROC") +} + +# Probably not valid for pmu905 (see note bottom in table) +#record(bo,"$(P)CAN${CH_ID}-PEAK_AV") { +# field(DESC, "PEAK/AV") +# field(VAL, "0") +# field(ONAM, "PEAK") +# field(ZNAM, "AV") +# field(OUT, "$(P)CAN${CH_ID}-BasicConfigB0_.B1") +# field(FLNK, "$(P)CAN${CH_ID}-BasicConfigB0_.PROC") +#} + +record(mbboDirect,"$(P)CAN${CH_ID}-BasicConfigB0_"){ + info(asyn:READBACK,"1") + field(DESC, "Basic Config B0") + field(PINI, "1") + field(VAL, "0") + field(OUT, "$(P)CAN${CH_ID}-SDO02-BasicConfig.[0]") + field(FLNK, "$(P)CAN${CH_ID}-SDO02-BasicConfig.PROC") +} + + +########################################################################### +############## Byte 1..2 Vref 0..5000 + +record(ao,"$(P)CAN${CH_ID}-VrefPwrCmd") { + field(DESC, "Vref 0..5000") + field(VAL, "0") + field(OUT, "") + field(EGU, "mV") + field(PREC, "0") + field(FLNK, "$(P)CAN${CH_ID}-VrefPwrCmdCalcB1_.PROC") +} + +# first byte +record(calc, "$(P)CAN${CH_ID}-VrefPwrCmdCalcB1_") { + field(DESC, "Calc byte 1") + field(CALC, "A && 0xFF") + field(INPA, "$(P)CAN${CH_ID}-VrefPwrCmd.VAL") + field(FLNK, "$(P)CAN${CH_ID}-BasicConfigB1_.PROC") +} + +record(ao,"$(P)CAN${CH_ID}-BasicConfigB1_"){ + field(DESC, "Basic config B1") + field(VAL, "0") + field(PREC, "0") + field(OUT, "$(P)CAN${CH_ID}-SDO02-BasicConfig.[1]") + #field(FLNK, "$(P)CAN${CH_ID}-SDO02-BasicConfig.PROC") # Only process when second byte is set +} + +# second byte +record(calc, "$(P)CAN${CH_ID}-VrefPwrCmdCalcB2_") { + field(DESC, "Calc byte 2") + field(CALC, "(A && 0xFF00) >> 8") + field(INPA, "$(P)CAN${CH_ID}-VrefPwrCmd.VAL") + field(FLNK, "$(P)CAN${CH_ID}-BasicConfigB2_.PROC") +} + +record(ao,"$(P)CAN${CH_ID}-BasicConfigB1_"){ + field(DESC, "Basic config B1") + field(VAL, "0") + field(PREC, "0") + field(OUT, "$(P)CAN${CH_ID}-SDO02-BasicConfig.[2]") + field(FLNK, "$(P)CAN${CH_ID}-SDO02-BasicConfig.PROC") # Process now! +} + +########################################################################### +############## Byte 3..4 Vref 4800..10000 + +record(ao,"$(P)CAN${CH_ID}-VdcCtrlCmd") { + field(DESC, "Vref 4800..10000") + field(VAL, "0") + field(EGU, "mV") + field(PREC, "0") + field(FLNK, "$(P)CAN${CH_ID}-VrefPwrCmdCalcB1_.PROC") +} + +# third byte +record(calc, "$(P)CAN${CH_ID}-VdcCtrlCmdCalcB3_") { + field(DESC, "Calc byte 3") + field(CALC, "A && 0xFF") + field(INPA, "$(P)CAN${CH_ID}-VdcCtrlCmd.VAL") + field(FLNK, "$(P)CAN${CH_ID}-BasicConfigB3_.PROC") +} + +record(ao,"$(P)CAN${CH_ID}-BasicConfigB3_"){ + field(DESC, "Basic config B3") + field(VAL, "0") + field(PREC, "0") + field(OUT, "$(P)CAN${CH_ID}-SDO02-BasicConfig.[3]") + #field(FLNK, "$(P)CAN${CH_ID}-SDO02-BasicConfig.PROC") # Only process when second byte is set +} + +# fourth byte +record(calc, "$(P)CAN${CH_ID}-VrefPwrCmdCalcB4_") { + field(DESC, "Calc byte 4") + field(CALC, "(A && 0xFF00) >> 8") + field(INPA, "$(P)CAN${CH_ID}-VdcCtrlCmd.VAL") + field(FLNK, "$(P)CAN${CH_ID}-BasicConfigB4_.PROC") +} + +record(ao,"$(P)CAN${CH_ID}-BasicConfigB4_"){ + field(DESC, "Basic config B4") + field(VAL, "0") + field(PREC, "0") + field(OUT, "$(P)CAN${CH_ID}-SDO02-BasicConfig.[4]") + field(FLNK, "$(P)CAN${CH_ID}-SDO02-BasicConfig.PROC") # Process now! +} + +# Byte 5..7 0 diff --git a/iocsh/pmu905.script b/iocsh/pmu905.script index 368772c..d7f6b39 100644 --- a/iocsh/pmu905.script +++ b/iocsh/pmu905.script @@ -85,6 +85,7 @@ dbLoadRecords(pmu905AnalogValues.template, "P=${ECMC_PREFIX},CH_ID=03") ecmcCANOpenAddSDO("basicConfig",3,0x583,0x603,1,0x2690,0x1,7,0) # WRITE dbLoadRecords(ecmcPluginSocketCAN_SDO_output.template, "P=${ECMC_PREFIX},PORT=${ECMC_ASYN_PORT},ADDR=0,TIMEOUT=1,T_SMP_MS=${ECMC_SAMPLE_RATE_MS},TSE=${ECMC_TSE},NELM=${NELM=1},CH_ID=03,DEV_ID=3,suffix=SDO02-BasicConfig,source=basicConfig,DTYP=asynInt8ArrayOut,FTVL=UCHAR,NELM=7") +dbLoadRecords(pmu905BasicConfig.template, "P=${ECMC_PREFIX},CH_ID=03") ############################################################################## ############# Go to realtime: diff --git a/iocsh/pvs.log b/iocsh/pvs.log index 6b9a741..0b6b142 100644 --- a/iocsh/pvs.log +++ b/iocsh/pvs.log @@ -1,7 +1,16 @@ IOC_TEST:CAN03-V_TEMP_ IOC_TEST:CAN03-AIR_INLET_ IOC_TEST:CAN03-AIR_OUTLET_ -REQMOD:raspberrypi-16923:exit +IOC_TEST:CAN03-VrefPwrCmdCalcB1_ +IOC_TEST:CAN03-VrefPwrCmdCalcB2_ +IOC_TEST:CAN03-VdcCtrlCmdCalcB3_ +IOC_TEST:CAN03-VrefPwrCmdCalcB4_ +IOC_TEST:CAN03-VrefPwrCmd +IOC_TEST:CAN03-BasicConfigB1_ +IOC_TEST:CAN03-VdcCtrlCmd +IOC_TEST:CAN03-BasicConfigB3_ +IOC_TEST:CAN03-BasicConfigB4_ +REQMOD:raspberrypi-20820:exit IOC_TEST:PLC-0-scantime IOC_TEST:PLC-0-error IOC_TEST:CAN03-PWR_A @@ -26,18 +35,20 @@ IOC_TEST:CAN03-V_5V_ACB IOC_TEST:CAN03-V_3V5 IOC_TEST:CAN03-AIR_INLET IOC_TEST:CAN03-AIR_OUTLET -REQMOD:raspberrypi-16923:BaseVersion -REQMOD:raspberrypi-16923:require_VER -REQMOD:raspberrypi-16923:ecmccfg_VER -REQMOD:raspberrypi-16923:asyn_VER -REQMOD:raspberrypi-16923:exprtk_VER -REQMOD:raspberrypi-16923:motor_VER -REQMOD:raspberrypi-16923:ecmc_VER -REQMOD:raspberrypi-16923:ecmc_plugin_socketcan_VER +REQMOD:raspberrypi-20820:BaseVersion +REQMOD:raspberrypi-20820:require_VER +REQMOD:raspberrypi-20820:ecmccfg_VER +REQMOD:raspberrypi-20820:asyn_VER +REQMOD:raspberrypi-20820:exprtk_VER +REQMOD:raspberrypi-20820:motor_VER +REQMOD:raspberrypi-20820:ecmc_VER +REQMOD:raspberrypi-20820:ecmc_plugin_socketcan_VER +IOC_TEST:CAN03-BasicConfigB0_ IOC_TEST:PLC-0-enable -REQMOD:raspberrypi-16923:MODULES -REQMOD:raspberrypi-16923:VERSIONS -REQMOD:raspberrypi-16923:MOD_VER +IOC_TEST:CAN03-PowerOnCmd +REQMOD:raspberrypi-20820:MODULES +REQMOD:raspberrypi-20820:VERSIONS +REQMOD:raspberrypi-20820:MOD_VER IOC_TEST:CAN03-PDO01-Array IOC_TEST:CAN03-SDO01-Array IOC_TEST:CAN03-SDO02-BasicConfig