Menu

Pulsein problem

Help
Keith
2026-03-24
2026-03-26
  • Keith

    Keith - 2026-03-24

    Im having a problem using the Pilsein command. Im' almost sure I have written the instruction an syntax correctly.

    What is happening is the program runs properly without the "Pulsein Flow, FlowRate, mS" line but as soon as I un-comment it, compile and upload it, it freezes or halts the the loop.

    the full program is attached below.

    define Flow PORTC.3

    Dim FlowRate as WORD

    Main: ;----- start main*******
    Do
    ; FlowRate = 0
    ; Count = Count + 1

      If ENCODER_SW = 0 Then
         Wait 400 mS
         Wait until ENCODER_SW = 1
         Locate 2,14
         LCDcursor FLASHON
         Wait 5 S                 ;Time to display Flasing Cursor
         Change_Temp
      End if
    
         Locate 0,0
           Print "VFD"
         Locate 0,9
           Print "|FAN"
         Locate 1,0
           Print "PUMP"
         Locate 1,9
           Print "|FLOW"
         Locate 1,17
           Print "L/M"
         Locate 2,0
           Print "THRESHOLD"
           Target_Temp
         Locate 3,0
           Print "COOLANT TEMP"
           Display_Temp
    

    '' *Switch Pump and San On/Off ******

         If TempT >= value Then
            Set Pump On
            Locate 1,5
            Print "ON "
         End if
    
         If TempT <= (value-5) Then   ;0.°5C Switching Hysteresis Bandwidth
            Locate 1,5
            Print "OFF"
            Set Pump Off
         End if
    
         If TempT >= value + 5 Then
            Set Fan On
            Locate 0,15
            Print "ON "
         End if
    
         If TempT <= (value-10) Then   ;1.0°C Switching Hysteresis Bandwidth
            Locate 0,15
            Print "OFF"
            Set Fan Off
         End if
    

    '' *Switch VFD and San On/Off ******

         If VFD = 0 Then
            Locate 0,5
            Print "ON "
         Else
            Locate 0,5
            Print "OFF"
         End if
    

    '' *END Switch Pump and San On/Off *****

    '' *Start Coolant Flow Rate *****
    ; Pulse:
    Pulsein Flow, FlowRate, mS
    FlowRate = FlowRate ;/5 ;Divide by 2
    Locate 1,15
    Print FlowRate
    Locate 1,16
    Print " "

      '' *******End Coolant Flow Rate ******************************
    

    Loop

     

    Last edit: Keith 2026-03-24
  • Keith

    Keith - 2026-03-25

    This has me really baffled ! it's working fine now - I don't understand...

    Don't believe in Code Gremlins and fairy's

     
  • Keith

    Keith - 2026-03-26

    Now for today's aggravation.
    The problem I'm having is reading the Pulsein signal output very occasionally throws 0 (zero) This can be seen in screenshot, Capture4 below.
    I'm driving the input wit a 1kHz signal from a signal generator The input is preconditioned with two gates of a 74HC14 Hex Inverter Schmitt Trigger.

    I need to be able to pick up the lack of coolant flow when the Pump and Spindle Motor VFD is on.
    This is the code I have so far. I think I need something that ignores the missing pulses for a minute or so. The entire projet so far is attached below.

           Pulsein Flow, FlowRate, uS
          FlowRate = FlowRate  
          Locate 1,15
          Print FlowRate
        ;  Locate 1,16
        ;  Print " "
    
          If FlowRate = 0 Then
              Flowcount = Flowcount + 1
          End If
    
          If FlowRate > 0 Then
             Flowcount = 0
           End if
    
          If  Flowcount = 50 then
              Flow_error = 0
          End if
    
    ;    Loop
    

    '' *End Coolant Flow Rate ********

        Do While VFD = 0 And Pump = On And Flow_error = 0
           Coolant_Error
    
     

    Last edit: Keith 2026-03-26

Log in to post a comment.

MongoDB Logo MongoDB