From e7c206102d520fd1a4b752b9692b353c3627dd5a Mon Sep 17 00:00:00 2001 From: Edward Emelianov Date: Fri, 8 Dec 2023 11:35:56 +0300 Subject: [PATCH] fixed bugs and update readme --- F1:F103/shutter/Readme.md | 41 ++++++++++++++++++++++++++++-------- F1:F103/shutter/flash.c | 2 +- F1:F103/shutter/main.c | 2 +- F1:F103/shutter/shutter.bin | Bin 12008 -> 12004 bytes F1:F103/shutter/shutter.c | 4 ++-- F1:F103/shutter/version.inc | 4 ++-- 6 files changed, 38 insertions(+), 15 deletions(-) diff --git a/F1:F103/shutter/Readme.md b/F1:F103/shutter/Readme.md index 999afd0..3519dc4 100644 --- a/F1:F103/shutter/Readme.md +++ b/F1:F103/shutter/Readme.md @@ -4,6 +4,21 @@ Shutter control Works with bi-stable shutter. You can find the device in `/dev/shutterX` (symlink to `/dev/ttyUSBX`). +After powered on, the device will try to close shutter (during one second). + +The CCD (or manual) controlled input allows to open/close shutter by changing its level (depending on `ccdactive` parameter). +If current configuration can't open or close the shutter immediately, it will be opened/closed as soon as possible, while the input holds its level. + +When the shutter is closed, the device will send over USB a message like +``` +exptime=10000 +shutter=closed +``` +with calculated value of opened time and current shutter state. +If the error occured and shutter can't be closed, user will read `exp=cantclose`, shutter will come into error state. You should close the shutter by external command in that case. + +After the shutter completely opened, user can read a message `shutter=opened`. + ## Pinout **PB0** (pullup in) - hall (or reed switch) sensor input (active low) - opened shutter detector @@ -58,20 +73,20 @@ You can find the device in `/dev/shutterX` (symlink to `/dev/ttyUSBX`). * 'v' - get Vdd (/100V) * 'V' - get shutter voltage (/100V) - -If you will enter wrong long message, will receive its echo back. Any wrong short command will show help list. +Any wrong long message will echo back. Any wrong short command will show help list. ## Shutter control -Commands '0', '1' and '2' should be used only for debugging purposes. +Commands '0' ... '3' should be used only for debugging purposes. To open/close shutter use only 'O', 'C' and 'E' commands. When opening or closing shutter you will first receive an answer: `OK` if command could be done or `ERR` if there's insufficient voltage on capacitor or shutter is absent. After opened the message `shutter=opened` will appear. After closing you will receive messages `exptime=xxx` (when `xxx` is approx. exp. time in milliseconds) and `shutter=closed`. Command 'E' could return `OK`, `ERR` or `ERRNUM`/`I32OVERFLOW` in wrong number format (number could be decimal, 0x.. - hexadecimal, b.. - binary or 0.. - octal). +"Status" command in this case will return `shutter=exposing` and `expfor=xxx` - the given exposition time. When exposition starts you will receive message `OK` and `shutter=opened`. After its end you'll got `exptime=...`, `shutter=closed`. -If shutter can't be closed, you will give a lots of "exp=cantclose" and different error messages until problem be solved. To stop this error messages give command 'O'. +If shutter can't be closed, you will give a lots of `exp=cantclose` and different error messages until problem be solved. To stop this error messages give command 'O'. ## Different commands * 'A' will show raw values for all ADC channels: 0. - capacitor voltage, 1 - MCU temperature, 2 - MCU Vdd. You will give messages like `adcX=val`. @@ -82,7 +97,7 @@ If shutter can't be closed, you will give a lots of "exp=cantclose" and differen * 'v' - `vdd=val`, val in V*100 -* 'V' - "voltage=val", val in V*100 +* 'V' - `voltage=val`, val in V*100 * 'S' - several answers: * `shutter=`: `closed`, `opened`, `error`, `process`, `wait` or `exposing` - shutter state @@ -104,9 +119,17 @@ workvoltage=700 shuttertime=20 waitingtime=30 shtrvmul=143 -shtrdiv=25 +shtrvdiv=25 ``` -* `` -* `ccdactive` - is level of 'CCD' input to open shutter (1 to open on high and 0 to open on low signal) -* `hallactive` \ No newline at end of file +* `userconf_sz` - "magick" number to determine first non-empty record in flash storage. The aligned size of one record in bytes. +* `ccdactive` - is level of 'CCD' input to open shutter (1 to open on high and 0 to open on low signal), change this value with command `c`. +* `hallactive` - the same for Hall sensor or reed switch mounted on shutter to indicate opened state, change with `h`. +* `minvoltage` - voltage level on discharged capacitor (V*100 Volts), when shutter is in opened/closed state, the power will be off from coils reaching this level. Can be from 1V to 10V. Change with `<`. +* `workvoltage` - minimal level (V*100 Volts) of charged capacitor to start process of opening/closing, you can open/close shutter only with higher voltage. Can be from 5V to 100V. Change with `>`. +* `shuttertime` - maximal time (milliseconds) of holding active voltage on shutter's coils. Can be from 5ms to 1s. Change with `#`. +* `waitingtime` - waiting time for the shutter to finish its job. The expose time can't be less than this value. Can be from 5ms to 1s. Change with `$`. +* `shtrvmul` - multiplier to calculate capacitor voltage from voltage on ADC input of MCU. Vcap = V*shtrvmul/shtrvdiv. Can be from 1 to 65535. Change with `*`. +* `shtrvdiv` - divider of capacitor voltage calculation. Can be from 1 to 65535. Change with `/`. + +All changes of configuration processed in RAM and acts immediately after changed. If you want to store changes, use command `s`. \ No newline at end of file diff --git a/F1:F103/shutter/flash.c b/F1:F103/shutter/flash.c index f400eb2..d67241c 100644 --- a/F1:F103/shutter/flash.c +++ b/F1:F103/shutter/flash.c @@ -187,6 +187,6 @@ void dump_userconf(){ USB_sendstr("\nshuttertime="); USB_sendstr(u2str(the_conf.shutterrime)); USB_sendstr("\nwaitingtime="); USB_sendstr(u2str(the_conf.waitingtime)); USB_sendstr("\nshtrvmul="); USB_sendstr(u2str(the_conf.shtrVmul)); - USB_sendstr("\nshtrdiv="); USB_sendstr(u2str(the_conf.shtrVdiv)); + USB_sendstr("\nshtrvdiv="); USB_sendstr(u2str(the_conf.shtrVdiv)); newline(); } diff --git a/F1:F103/shutter/main.c b/F1:F103/shutter/main.c index 4da817c..523a1fa 100644 --- a/F1:F103/shutter/main.c +++ b/F1:F103/shutter/main.c @@ -41,7 +41,7 @@ int main(void){ hw_setup(); USB_setup(); // close shutter and only after that turn on USB pullup - while(!close_shutter() && Tms < the_conf.waitingtime) IWDG->KR = IWDG_REFRESH; + while(!close_shutter() && Tms < 1000) IWDG->KR = IWDG_REFRESH; USBPU_ON(); uint32_t Terr = Tms + 2*ERRPERIOD; diff --git a/F1:F103/shutter/shutter.bin b/F1:F103/shutter/shutter.bin index 31e0f256d0ac17bc271ae049c7de516627a660b9..82e409526fbffb0cae9e225845c8386478b2ff5d 100755 GIT binary patch delta 2491 zcmcImeNaaT8cE@RPaa`@}EN+(&JLvQUBJUE*dwVV)jx+7f z?mwH%FXz7ByXW3>&-tDAa^vaI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L^hdZ(?EntD3Qil&dYo%7@6jzBAURh8{6$GKZ~}Vijnr-*OFk^DWaYD2L(HCGdn&R1fktcHwFlum9HfQL zg)`wcM|y2MR@iu?fE8RE|CW>K_tI;5d%>R@!97;#t$m8W((OnTE(aB1P=nK?ASOMQ zO@~E|bJKfF+kK*Ni@XrC%E5d9Q}S#+sfC!m(_!tO)#3t~Uo6ZoJy3eZk7bh4ZDmCP z+UAc}LH#JQg#MKAxf*o@ByG3Gk^ZL77C=Ax=DnJ{Im4Ot<5ghJmLS^=lTXKx{(IG@ zSwc+6P!#BEn@h#@aR|%9#zYzCZ+3!Ta%SYu!C!^X4Fz_>S#04fqHye9k-zC|pndlO z?ipJLi|3N+Sk;P_peX2r3UIS3X!DsTvE@TX6xO=KYXAY_D@+@et!TwWOI&RSWPSm0{Mi!JO(N6bdQ&&==3 zW9zC3i7QZ=gSG$<+)v;4%<{Y_{E>{r3CaNNV|jk7Yiv__hA$)x5uZBOF-T9m1~oAw z3V))HvYb)KGU}N^$Y|_2D+-jB1AB3v<>uMjv=rFi(oUKSnau?4_b3O91LjS-2ACFLRsjCLmn16N54)fZ`wq%2{`R)^ysyaQGt*Z7x!apUyN>=0TEc^v6TMvyF`PlHM9of!}E4%{QHgwx|^%9tBQ;4WgMT?x-w|1FyS z=V|=*H>jRR-hy-_znX^R1M2^THFc45EKazOT;#q?`F`%Wer}9t`M>KHeaXgC;5o`c{C?;2`u@rhTIE@#TaEE0^8M6A+(BMRwZ{IUoxS+F zp>N+FhFbFOGrttrg@gw{_Kw9v4S8ll z!fCQ4BW3OEjMOqU9ufqQXF*PZd=WlohURU#266~&=>u$p@j`hsyB;Q889SHdYdLM6 zF)u&cl$UK>?OFTanXvGhx}9s0=QG1iT+y0? the_conf.waitingtime){ + if(Tms - Tstart >= the_conf.waitingtime){ SHTRHIZ(); shutterstate = nextstate; int h = CHKHALL(); diff --git a/F1:F103/shutter/version.inc b/F1:F103/shutter/version.inc index 9e69f18..bf5098f 100644 --- a/F1:F103/shutter/version.inc +++ b/F1:F103/shutter/version.inc @@ -1,2 +1,2 @@ -#define BUILD_NUMBER "103" -#define BUILD_DATE "2023-12-07" +#define BUILD_NUMBER "107" +#define BUILD_DATE "2023-12-08"