[r13]: / trunk / gpiomod / GPIOMods / SoftAIN / svnobj  Maximize  Restore  History

Download this file

5 lines (5 with data), 7.1 kB

Gx_lб!0┘jЭo■/HГ┴еа═АSystem.StringL{6f9dac99-8de1-4efc-8465-68ac443b7d08}SpecialFuncL{0db3d7bb-cde0-4416-9a7b-ce49a0124323}NoneImplementationL{3b83b776-fb25-43b8-99f2-3c507c9143fc}TextDocument	L{f3878285-8e4f-490b-bb1b-9acbb7eb04db}
TextLinesL{a5de0b0b-1cb5-4913-ac21-9d70293ec00d}Id
longTagText.SysTimeGetUs(tCurrent);IF xInit THEN 	xInit := FALSE;(	tStart := tCurrent;END_IF	"IF xSampling THENd	// Reading the sampling pin, and measure the time	IF xInput THENj		/// capacitor is full, stop sampling, and discharge*		xSampling := FALSE;j		rVal := LWORD_TO_REAL(tCurrent - tStart) * crScale;*		tStart := tCurrent;	END_IFELSE 6	// Discharge the capacitor!P	IF tCurrent - tStart > ctDischarge THEN"&		// start sampling#$		xOutput := TRUE;$Interface%L{a9ed5b7e-75c5-4651-af16-d2c27e98cb94}&t/// This FB can be used to sample analog data by using two'/// GPIO Pins:(./// - one digital input)0/// - one digital output*///+n/// There are also other circuits out there, which only,|/// need one single GPIO. But they have the clear disadvantage-┬/// that they need to reconfigure this GPIO constantly. Additionally.┬/// you have to take care about the VRef, which you are using, as it/z/// will be pulled to ground by the GPIO acting as an output.0┼/// You need to take care to not destroy your board with that. In the1┬/// Circuit, recommended here, it is to my understanding much safer,2┼/// as we simply use the digital output as our VRef. Therefore we can3P/// easily and safely pull it to ground.4/// Wirering::56///   Digital Output (VRef)6///      v7&///   R1 (2,2kOhm) 8F///   Transistor / Poti / LDR / ...90///      |---> Input Pin:///   C1 (1uF);///     GND</// Scheduling:= /// The accuracy of the measurement relies in some aspects on the scheduling.>≤/// So it is recommended to schedule the task, which is driving this FB, as ?╒/// frequent as possible. It is generally OK to combine this FB with the SoftPWM.@ /// Just the sampling accuracy will slightly vary, depending on the frequencyA /// of the PWM. B C,FUNCTION_BLOCK SoftAINDVAR_INPUTEh	xInput : BOOL; /// This Pin will measure your inputFEND_VARGVAR_OUTPUTHf	xOutput : BOOL; /// This Pin will act as your VRefIP	rVal : REAL; /// Sampled, analog outputJVARK$	xSampling : BOOL;L$	tStart : SYSTIME;M(	tCurrent : SYSTIME;N*	xInit: BOOL := TRUE;OVAR CONSTANTP^	// Define time to wait for discharging (in us)Q<	ctDischarge : SYSTIME := 100;R$	// Scaling factorSD	crScale : REAL := REAL#1000000.0;T"UniqueIdGeneratorU131VPOULevelWL{8e575c5b-1d37-49c6-941b-5c0ec7874787}XStandardY ChildObjectGuidsZ8System.Collections.ArrayList[,AddAttributeSubsequent\boolпп-пп	E
пп
ґxзп-пп
ґtзп-пп
ґwзп-пп
ґyзп-пп
ґzзп-пп
ґ{зп-пп
ґsзп-пп
ґ	зп-пп
ґeзп-пп
ґfзп-пп
ґhзп-пп
ґjзп-пп
ґ─зп-пп
ґ┐зп-пп
ґiзп-пп
ґaзп-пп
ґgзп- пп
ґcзп-!пп
ґ~зп-"пп
ґ|зп-пп
ґзп-#пп
ґ}зп-пп
ґbзп-п$%п	E
7пп
ґ)зп-&пп
ґ*зп-'пп
ґ+зп-(пп
ґ,зп-)пп
ґ-зп-*пп
ґ.зп-+пп
ґ/зп-,пп
ґ0зп--пп
ґ2зп-.пп
ґ3зп-/пп
ґ4зп-0пп
ґ5зп-1пп
ґ7зп-2пп
ґ8зп-3пп
ґ?зп-*пп
ґ@зп-4пп
ґAзп-5пп
ґFзп-6пп
ґGзп-7пп
ґIзп-6пп
ґJзп-8пп
ґVзп-9пп
ґQзп-:пп
ґSзп-6пп
ґTзп-;пп
ґYзп-*пп
ґZзп-<пп
ґ[зп-=пп
ґ\зп->пп
ґ]зп-?пп
ґ_зп-@пп
ґ`зп-Aпп
ґNзп-Bпп
ґзп-Cпп
ґзп-Dпп
ґ
зп-Eпп
ґзп-Fпп
ґзп-Gпп
ґзп-Hпп
ґ>зп-Iпп
ґзп-Fпп
ґзп-Jпп
ґзп-Kпп
ґkзп-Lпп
ґlзп-Mпп
ґvзп-Nпп
ґзп-Fпп
ґnзп-пп
ґmзп-Oпп
ґqзп-Pпп
ґoзп-Qпп
ґ│зп-Rпп
ґ┌зп-Sпп
ґpзп-Fпп
ґзп-пT-UпVW-XYZп[\ґ