Mechanical Flowswitch and attiny85

Home Forums Help and How To Machine Modifications and Add Ons Mechanical Flowswitch and attiny85

This topic contains 1 reply, has 1 voice, and was last updated by  LaserLarry Admin 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2081

    LaserLarry Admin
    Keymaster

    I added a flowswitch to my new laser. There is a lot of information out there on how to read the flow information using an Arduino. I just wanted a go no go using a mechanical movement flow switch. This guarantees a true flow verification, and cannot get stuck or give false information due to the failsafe design. I used a YF-S201 Flowswitch, digispark attiny85 USB development board and a keyes sr1y relay board.

    The flowswich sends out a pulse signal when it sees flows. The attiny85 senses the pulses and enables the relay. The relay normally open contacts are connected to the laser safety interrupt. Unless the relay is activated, the laser cannot fire.

    https://youtu.be/I5lgv0rzeaY

    • This topic was modified 4 days, 23 hours ago by  TechBravoTN.
    #2084

    LaserLarry Admin
    Keymaster
    // reading pulse output of the YF-S201 flow sensor 
    
    volatile int flowSignal; //measuring the rising edges of the signal                              
    int hallsensor = 2;   //The pin location of the sensor
    byte statusRelay = 3;    // flow is active
    byte alarmPin = 4;    // the number of the alarm pin
    
        void flow ()     //This is the function that the interupt calls 
        { 
        flowSignal++;  //This function measures the rising and falling edge of the hall effect sensors signal
        } 
    
            // The setup() method runs once, when the sketch starts
            void setup() //
            { 
             pinMode(hallsensor, INPUT); //initializes digital pin 2 as an input
             pinMode(alarmPin, OUTPUT); //initializes digital pin 4 as an output
             pinMode(statusRelay, OUTPUT); //initializes digital pin 3 as an output
             digitalWrite(statusRelay, LOW); //initializes digital pin 3 low
             attachInterrupt(0, flow, RISING); //interrupt is attached
            } 
               // the loop() method runs over and over again,
               // as long as the Arduino has power
               void loop ()    
               {
               flowSignal = 0;      //Set flowSignal to 0 ready for sensing pulses
               sei();            //Enables interrupts
               delay (500);      //Wait .5 second
               cli();            //Disable interrupts
    
                  { 
                  //read counts and outputs status:
                  if (flowSignal < 1) {
                  digitalWrite (statusRelay, LOW); //ouput low, relay off
                  } else {
                  digitalWrite (statusRelay, HIGH); // ouput high, relay on
                  }
     
                  }
                
                //read counts and alarm if counts less than 1:
                if (flowSignal <  1) {
                digitalWrite (alarmPin, HIGH); //ouput high if no flowSignal
                } else {
                digitalWrite (alarmPin, LOW); // ouput low if flowSignal present
                }
                }
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.