kaufpark Posted June 19, 2018 Posted June 19, 2018 Hello Autoit community,I try to control a syringe pump via rs232. To do this, I have to send the syringe pump the command "suck 300 ml" (/ 1OA300R) and send the command "Press the syringe together to zero ml of contents" (/ 10A0R).The syringe pump should always suck or pump with a change of edge (0.2 Hz from a function generator). And the whole sucking and pumping should only begin when a checkbox of Gui is pressed.I thought you could solve this: While 1 $nMsg = GUIGetMsg() $CTS_PinState = _CommAPI_IsOnCTS ($gFile) ;get true or false from CTS-Pin Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then If $CTS_PinState == True And $CTS_PinStateOld == False Then ;edge $CTS_PinStateOld = $CTS_PinState _CommAPI_TransmitData($hFile, @crlf&"/1OA300R") ElseIf $CTS_PinState = False And $CTS_PinStateOld == True Then ;edge $CTS_PinStateOld = $CTS_PinState _CommAPI_TransmitData($hFile, @crlf&"/1OA0R") EndIf EndIf But unfortunately, the code works only if I press the checkbox exactly at a flank change.It seems to me as if I ask the checkbox event incorrectly.I hope you can help me.Thanks and regards
Developers Jos Posted June 19, 2018 Developers Posted June 19, 2018 7 minutes ago, kaufpark said: But unfortunately, the code works only if I press the checkbox exactly at a flank change.It seems to me as if I ask the checkbox event incorrectly. I am unsure what you mean here and what exactly you are expecting? It makes sense that the code only is executed at the time the checkbock gets checked as that is what you are telling it to do in the script. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
kaufpark Posted June 19, 2018 Author Posted June 19, 2018 (edited) Hi Jos, I would like to check the condition of the checkbox. If this "checked" should run a subroutine that constantly queries the CTS pin. The CTS pin delivers a square wave signal at 0.2 Hz. The value of the CTS pin can be true and false. And always just when a flank change happens on the CTS pin, the pump suck or squeeze. The pump should suck and press until the checkbox is "unchecked" again. Ok, somewhat complicated. In simpler terms, the pump should suck and pump permanently while the checkbox is active Edited June 19, 2018 by kaufpark
BrewManNH Posted June 19, 2018 Posted June 19, 2018 (edited) Something like this? While 1 $nMsg = GUIGetMsg() $CTS_PinState = _CommAPI_IsOnCTS($gFile) ;get true or false from CTS-Pin Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then If $CTS_PinState = True And $CTS_PinStateOld = False Then ;edge $CTS_PinStateOld = $CTS_PinState _CommAPI_TransmitData($hFile, @CRLF & "/1OA300R") ElseIf $CTS_PinState = False And $CTS_PinStateOld = True Then ;edge $CTS_PinStateOld = $CTS_PinState _CommAPI_TransmitData($hFile, @CRLF & "/1OA0R") EndIf EndIf WEnd Edited June 19, 2018 by Jos Tidy broken ? :) If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now