LPT MSR - LauflichtSteurung

  • Guten abend zusammen habe da nen prop mit meiner schleife

    [autoit]

    #Include <Constants.au3>
    #include <GUIConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>

    [/autoit][autoit][/autoit][autoit]

    $DLLFileAndPath = @ScriptDir & "/inpout32.dll"
    $PortAddress = "0x378"

    [/autoit][autoit][/autoit][autoit]

    Dim $on = 1, $off = 0

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    #Region ### START Koda GUI section ### Form=C:\Dokumente und Einstellungen\tester\Desktop\LPT MSR - Lauflicht.kxf
    $Form1 = GUICreate("LPT MSR - Lauflicht Steuerung", 354, 266, 567, 275)
    $Slider = GUICtrlCreateSlider(16, 160, 158, 45)
    $multi = GUICtrlCreateInput("10", 16, 232, 45, 21)
    GUICtrlSetCursor (-1, 5)
    $Label1 = GUICtrlCreateLabel("Geschwindigkeit", 16, 136, 82, 17)
    $Label2 = GUICtrlCreateLabel("Time Multiplikator", 16, 208, 86, 17)
    $Label3 = GUICtrlCreateLabel("Zeit/ms", 120, 208, 40, 17)
    $output_T = GUICtrlCreateInput("", 120, 232, 50, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY))
    $Einzeln = GUICtrlCreateRadio("Einzeln", 16, 8, 113, 17)
    $Paarweise = GUICtrlCreateRadio("Paarweise", 16, 40, 113, 17)
    $Schlange = GUICtrlCreateRadio("Schlange", 16, 72, 113, 17)
    $Start = GUICtrlCreateButton("Start", 184, 232, 75, 25, 0)
    $Richtung = GUICtrlCreateCheckbox("Richtung", 16, 104, 97, 17)
    $Refresh = GUICtrlCreateButton("Refresh", 264, 232, 75, 25, 0)
    $Ausgabe = GUICtrlCreateGroup("Ausgabe", 192, 8, 137, 217)
    $B0 = GUICtrlCreateRadio("Lampe 1", 208, 32, 113, 17)
    $B1 = GUICtrlCreateRadio("Lampe 2", 208, 56, 113, 17)
    $B2 = GUICtrlCreateRadio("Lampe 3", 208, 80, 113, 17)
    $B3 = GUICtrlCreateRadio("Lampe 4", 208, 104, 113, 17)
    $B4 = GUICtrlCreateRadio("Lampe 5", 208, 128, 113, 17)
    $B5 = GUICtrlCreateRadio("Lampe 6", 208, 152, 113, 17)
    $B6 = GUICtrlCreateRadio("Lampe 7", 208, 176, 113, 17)
    $B7 = GUICtrlCreateRadio("Lampe 8", 208, 200, 113, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit][autoit][/autoit][autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit][autoit][/autoit][autoit]

    Case $Refresh
    SetLPTPortPins($PortAddress, $off, $off, $off, $off, $off, $off, $off, $off)

    EndSwitch
    $time = GUICtrlRead($Slider) * GUICtrlRead($multi)
    GUICtrlSetData($output_T, $time)
    Select
    Case $nMsg = $Start And BitAND(GUICtrlRead($Einzeln), $GUI_CHECKED) = $GUI_CHECKED
    einzeln()

    [/autoit][autoit][/autoit][autoit]

    Case $nMsg = $Start And BitAND(GUICtrlRead($Paarweise), $GUI_CHECKED) = $GUI_CHECKED

    [/autoit][autoit][/autoit][autoit]

    Case $nMsg = $Start And BitAND(GUICtrlRead($Schlange), $GUI_CHECKED) = $GUI_CHECKED

    EndSelect

    [/autoit][autoit][/autoit][autoit]

    WEnd

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    Func einzeln()
    GUICtrlSetData($Start, "Stop")
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Start
    ExitLoop
    EndSwitch
    SetLPTPortPins($PortAddress, $on, $off, $off, $off, $off, $off, $off, $off)
    Sleep($time)
    SetLPTPortPins($PortAddress, $off, $on, $off, $off, $off, $off, $off, $off)
    Sleep($time)
    SetLPTPortPins($PortAddress, $off, $off, $on, $off, $off, $off, $off, $off)
    Sleep($time)
    SetLPTPortPins($PortAddress, $off, $off, $off, $on, $off, $off, $off, $off)
    Sleep($time)
    SetLPTPortPins($PortAddress, $off, $off, $off, $off, $on, $off, $off, $off)
    Sleep($time)
    SetLPTPortPins($PortAddress, $off, $off, $off, $off, $off, $on, $off, $off)
    Sleep($time)
    SetLPTPortPins($PortAddress, $off, $off, $off, $off, $off, $off, $on, $off)
    Sleep($time)
    SetLPTPortPins($PortAddress, $off, $off, $off, $off, $off, $off, $off, $on)
    WEnd
    GUICtrlSetData($Start, "Start")
    EndFunc

    [/autoit][autoit][/autoit][autoit]

    ;Functions -> where the action happens!
    Func SetLPTPortPins($WriteAddress, $Bit0, $Bit1, $Bit2, $Bit3, $Bit4, $Bit5, $Bit6, $Bit7)
    ;Convert bits to BCD
    $BCD = 0
    If $Bit0 = 1 Then $BCD = $BCD + 1
    If $Bit1 = 1 Then $BCD = $BCD + 2
    If $Bit2 = 1 Then $BCD = $BCD + 4
    If $Bit3 = 1 Then $BCD = $BCD + 8
    If $Bit4 = 1 Then $BCD = $BCD + 16
    If $Bit5 = 1 Then $BCD = $BCD + 32
    If $Bit6 = 1 Then $BCD = $BCD + 64
    If $Bit7 = 1 Then $BCD = $BCD + 128
    ;pass the call to inpout32.dll
    DllCall( $DLLFileAndPath, "int", "Out32", "int", $WriteAddress, "int", $BCD)
    EndFunc ;==>SetLPTPortPins

    [/autoit]

    Einmal editiert, zuletzt von Martymco (3. Juli 2009 um 23:56)

  • eben, als ich das ding zum laufen gekrigt hab, war es klar...
    schau dir mal deine funktion an, deine überlegung ist leider nicht vollständig,
    Func einzeln()
    GUICtrlSetData($Start, "Stop")
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $Start
    ExitLoop
    EndSwitch
    soweit so gut, aber wie gehts weiter...
    SetLPTPortPins($PortAddress, $on, $off, $off, $off, $off, $off, $off, $off)
    Sleep($time)
    SetLPTPortPins($PortAddress, $off, $on, $off, $off, $off, $off, $off, $off)
    Sleep($time)
    SetLPTPortPins($PortAddress, $off, $off, $on, $off, $off, $off, $off, $off)
    Sleep($time)
    SetLPTPortPins($PortAddress, $off, $off, $off, $on, $off, $off, $off, $off)
    Sleep($time)
    SetLPTPortPins($PortAddress, $off, $off, $off, $off, $on, $off, $off, $off)
    Sleep($time)
    SetLPTPortPins($PortAddress, $off, $off, $off, $off, $off, $on, $off, $off)
    Sleep($time)
    SetLPTPortPins($PortAddress, $off, $off, $off, $off, $off, $off, $on, $off)
    Sleep($time)
    SetLPTPortPins($PortAddress, $off, $off, $off, $off, $off, $off, $off, $on)
    zwischen all diesen befehlen gibst du deinem Gui niemals die möglichkeit zu reagieren... (hopla)
    während jedem sleep ist das script gelähmt, zu keiner aktion fähig,
    ich kann dir vielleicht mit einer meiner alten udfs helfen, dauert aber nen bissel...

    Dies ist ein Arzeneimittel.
    Bei Risiken und Haluzinationen fressen sie die Packungsbeilage und schlagen Sie ihren Arzt oder Apotheker.
    Jede Haftung wird abgelent.

    Vielen Dank für Ihre Kundentreue.
    mfg. TimBlo

    Aperture Science

    http://www.youtube.com/watch?v=Y6ljFaKRTrI

  • Frage : was ist LPT MSR ? habe das noch nie gehört ,was macht man damit ?

  • Also, ich hab dir eine alte UDF von mir eingebaut... die funktion gettime ist also von mir
    es ist möglich dass du etwas zeit brauchst um den Funktionsablauf zu verstehen, aber funktionieren tut es.
    du findest nun in der Einzeln() deine While schleife und darin Do-Until schleifen von mir.
    Die Do-Until schleifen laufen solange bis die gewünschte zeit abgelaufen ist.
    und bei ExitLoop ist nun eine (2) weil es nun 2 schleifen verlassen muss. (Do-Until und While)
    Ich hab noch eine kleinigkeit eingebaut damit man während dem Lauflicht noch die geschwindigkeit ändern kann...

    Neuer Code
    [autoit]

    #Include <Constants.au3>
    #include <GUIConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $DLLFileAndPath = @ScriptDir & "/inpout32.dll"
    $PortAddress = "0x378"

    [/autoit] [autoit][/autoit] [autoit]

    Dim $on = 1, $off = 0

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    #Region ### START Koda GUI section ### Form=C:\Dokumente und Einstellungen\tester\Desktop\LPT MSR - Lauflicht.kxf
    $Form1 = GUICreate("LPT MSR - Lauflicht Steuerung", 354, 266, 567, 275)
    $Slider = GUICtrlCreateSlider(16, 160, 158, 45)
    $multi = GUICtrlCreateInput("10", 16, 232, 45, 21)
    GUICtrlSetCursor (-1, 5)
    $Label1 = GUICtrlCreateLabel("Geschwindigkeit", 16, 136, 82, 17)
    $Label2 = GUICtrlCreateLabel("Time Multiplikator", 16, 208, 86, 17)
    $Label3 = GUICtrlCreateLabel("Zeit/ms", 120, 208, 40, 17)
    $output_T = GUICtrlCreateInput("", 120, 232, 50, 21, BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY))
    $Einzeln = GUICtrlCreateRadio("Einzeln", 16, 8, 113, 17)
    $Paarweise = GUICtrlCreateRadio("Paarweise", 16, 40, 113, 17)
    $Schlange = GUICtrlCreateRadio("Schlange", 16, 72, 113, 17)
    $Start = GUICtrlCreateButton("Start", 184, 232, 75, 25, 0)
    $Richtung = GUICtrlCreateCheckbox("Richtung", 16, 104, 97, 17)
    $Refresh = GUICtrlCreateButton("Refresh", 264, 232, 75, 25, 0)
    $Ausgabe = GUICtrlCreateGroup("Ausgabe", 192, 8, 137, 217)
    $B0 = GUICtrlCreateRadio("Lampe 1", 208, 32, 113, 17)
    $B1 = GUICtrlCreateRadio("Lampe 2", 208, 56, 113, 17)
    $B2 = GUICtrlCreateRadio("Lampe 3", 208, 80, 113, 17)
    $B3 = GUICtrlCreateRadio("Lampe 4", 208, 104, 113, 17)
    $B4 = GUICtrlCreateRadio("Lampe 5", 208, 128, 113, 17)
    $B5 = GUICtrlCreateRadio("Lampe 6", 208, 152, 113, 17)
    $B6 = GUICtrlCreateRadio("Lampe 7", 208, 176, 113, 17)
    $B7 = GUICtrlCreateRadio("Lampe 8", 208, 200, 113, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

    [/autoit] [autoit][/autoit] [autoit]

    Case $Refresh
    SetLPTPortPins($PortAddress, $off, $off, $off, $off, $off, $off, $off, $off)

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    $time = GUICtrlRead($Slider) * GUICtrlRead($multi)
    GUICtrlSetData($output_T, $time)
    Select
    Case $nMsg = $Start And BitAND(GUICtrlRead($Einzeln), $GUI_CHECKED) = $GUI_CHECKED
    einzeln()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Case $nMsg = $Start And BitAND(GUICtrlRead($Paarweise), $GUI_CHECKED) = $GUI_CHECKED

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Case $nMsg = $Start And BitAND(GUICtrlRead($Schlange), $GUI_CHECKED) = $GUI_CHECKED

    [/autoit] [autoit][/autoit] [autoit]

    EndSelect

    [/autoit] [autoit][/autoit] [autoit]

    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func einzeln()
    GUICtrlSetData($Start, "Stop")
    While 1
    $time_onStart = gettime()
    SetLPTPortPins($PortAddress, $on, $off, $off, $off, $off, $off, $off, $off)
    Do
    Switch GUIGetMsg()
    Case $Start
    ExitLoop(2)
    EndSwitch
    $time = GUICtrlRead($Slider) * GUICtrlRead($multi)
    GUICtrlSetData($output_T, $time)
    Until gettime(1, $time_onStart, $time)
    SetLPTPortPins($PortAddress, $off, $on, $off, $off, $off, $off, $off, $off)
    Do
    Switch GUIGetMsg()
    Case $Start
    ExitLoop(2)
    EndSwitch
    $time = GUICtrlRead($Slider) * GUICtrlRead($multi)
    GUICtrlSetData($output_T, $time)
    Until gettime(1, $time_onStart, $time*2)
    SetLPTPortPins($PortAddress, $off, $off, $on, $off, $off, $off, $off, $off)
    Do
    Switch GUIGetMsg()
    Case $Start
    ExitLoop(2)
    EndSwitch
    $time = GUICtrlRead($Slider) * GUICtrlRead($multi)
    GUICtrlSetData($output_T, $time)
    Until gettime(1, $time_onStart, $time*3)
    SetLPTPortPins($PortAddress, $off, $off, $off, $on, $off, $off, $off, $off)
    Do
    Switch GUIGetMsg()
    Case $Start
    ExitLoop(2)
    EndSwitch
    $time = GUICtrlRead($Slider) * GUICtrlRead($multi)
    GUICtrlSetData($output_T, $time)
    Until gettime(1, $time_onStart, $time*4)
    SetLPTPortPins($PortAddress, $off, $off, $off, $off, $on, $off, $off, $off)
    Do
    Switch GUIGetMsg()
    Case $Start
    ExitLoop(2)
    EndSwitch
    $time = GUICtrlRead($Slider) * GUICtrlRead($multi)
    GUICtrlSetData($output_T, $time)
    Until gettime(1, $time_onStart, $time*5)
    SetLPTPortPins($PortAddress, $off, $off, $off, $off, $off, $on, $off, $off)
    Do
    Switch GUIGetMsg()
    Case $Start
    ExitLoop(2)
    EndSwitch
    $time = GUICtrlRead($Slider) * GUICtrlRead($multi)
    GUICtrlSetData($output_T, $time)
    Until gettime(1, $time_onStart, $time*6)
    SetLPTPortPins($PortAddress, $off, $off, $off, $off, $off, $off, $on, $off)
    Do
    Switch GUIGetMsg()
    Case $Start
    ExitLoop(2)
    EndSwitch
    $time = GUICtrlRead($Slider) * GUICtrlRead($multi)
    GUICtrlSetData($output_T, $time)
    Until gettime(1, $time_onStart, $time*7)
    SetLPTPortPins($PortAddress, $off, $off, $off, $off, $off, $off, $off, $on)
    Do
    Switch GUIGetMsg()
    Case $Start
    ExitLoop(2)
    EndSwitch
    $time = GUICtrlRead($Slider) * GUICtrlRead($multi)
    GUICtrlSetData($output_T, $time)
    Until gettime(1, $time_onStart, $time*8)
    WEnd
    GUICtrlSetData($Start, "Start")
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;Functions -> where the action happens!
    Func SetLPTPortPins($WriteAddress, $Bit0, $Bit1, $Bit2, $Bit3, $Bit4, $Bit5, $Bit6, $Bit7)
    ;Convert bits to BCD
    $BCD = 0
    If $Bit0 = 1 Then $BCD = $BCD + 1
    If $Bit1 = 1 Then $BCD = $BCD + 2
    If $Bit2 = 1 Then $BCD = $BCD + 4
    If $Bit3 = 1 Then $BCD = $BCD + 8
    If $Bit4 = 1 Then $BCD = $BCD + 16
    If $Bit5 = 1 Then $BCD = $BCD + 32
    If $Bit6 = 1 Then $BCD = $BCD + 64
    If $Bit7 = 1 Then $BCD = $BCD + 128
    ;pass the call to inpout32.dll
    DllCall( $DLLFileAndPath, "int", "Out32", "int", $WriteAddress, "int", $BCD)
    EndFunc ;==>SetLPTPortPins

    [/autoit] [autoit][/autoit] [autoit]

    Func gettime($flag=0, $pretime=0, $newtime=0, $gettime_calculate_msec_param=0)
    If $flag == 0 Then
    Global $gettime_day = @WDAY ; MASTER don't kill
    If $gettime_day = 7 Then $gettime_day = 0
    Local $gettime_min
    Local $gettime_sec
    Local $gettime_msec
    For $it = 0 to @HOUR
    $gettime_min += 60
    Next
    $gettime_min += @MIN
    For $it = 0 to $gettime_min
    $gettime_sec += 60
    Next
    $gettime_sec += @SEC
    For $it = 0 to $gettime_sec
    $gettime_msec += 1000
    Next
    $gettime_msec += @MSEC
    Return $gettime_msec
    ElseIf $flag == 2 Then
    Local $gettime_hour
    Local $gettime_min
    Local $gettime_sec
    Local $gettime_msec
    If @WDAY == $gettime_day+1 Then
    $gettime_hour = 24
    EndIf
    $gettime_hour += @HOUR
    For $it = 0 to $gettime_hour
    $gettime_min += 60
    Next
    $gettime_min += @MIN
    For $it = 0 to $gettime_min
    $gettime_sec += 60
    Next
    $gettime_sec += @SEC
    For $it = 0 to $gettime_sec
    $gettime_msec += 1000
    Next
    $gettime_msec += @MSEC
    Return $gettime_msec
    ElseIf $flag == 1 Then
    $gettime_acttime = gettime(2)
    If $gettime_acttime >= $pretime+$newtime Then
    Return 1
    Else
    Return 0
    EndIf
    ElseIf $flag == 3 Then
    Local $gettime_calculate_sec
    Local $gettime_calculate_msec
    For $it = 1 to $pretime
    $gettime_calculate_sec += 60
    Next
    $gettime_calculate_sec += $newtime
    For $it = 1 to $gettime_calculate_sec
    $gettime_calculate_msec += 1000
    Next
    $gettime_calculate_msec += $gettime_calculate_msec_param
    Return $gettime_calculate_msec
    Else
    MsgBox(16, "STOP", "Unbekannter Aufruf in Funktion gettime Parameter 1")
    EndIf
    EndFunc

    [/autoit]


    ich hoffe ich hab dir gut geholfen... frag einfach wieder ^^

    Dies ist ein Arzeneimittel.
    Bei Risiken und Haluzinationen fressen sie die Packungsbeilage und schlagen Sie ihren Arzt oder Apotheker.
    Jede Haftung wird abgelent.

    Vielen Dank für Ihre Kundentreue.
    mfg. TimBlo

    Aperture Science

    http://www.youtube.com/watch?v=Y6ljFaKRTrI

  • Samma... Ich bin grad dabei voll die Coole Schrittmotorsteuerung für eine unserer UUUUUUUUhhhhhr-Alten NC-Maschinen zu Scripten.
    Hat jemand von euch ne Idee, wie ich das schreiben (lesen ist nicht ganz soo wichtig) auf den LPT beschleunigen kann?
    Habe mehrere DLL-Aufrufe nacheinander und einer dauert ca 0,3 Sek.

    Das ist für einen 100-Schritt-Motor deutlich zu langsam, die Bearbeitung würde ewig dauern...

    Edit BugFix: Also ich finde es sehr unhöflich, dass du an ein fremdes Skript eine Frage anhängst. Dazu gibt es das Forum H&U! :thumbdown:

    ... wasweisichdennschon...

    Einmal editiert, zuletzt von BugFix (30. August 2009 um 16:41)