Arduino and current sensors to pilot pneumatic blast gates and dust extraction

You can play with the CT.
Look at how to wire it for an Arduino.
Over at

https://learn.openenergymonitor.org/electricity-monitoring/ct-sensors/inter

@dave-in-nj : I guess you meant to point me to this page : CT Sensors - Interfacing with an Arduino — OpenEnergyMonitor 0.0.1 documentation

I've been there before and it's about where I decided to try and find another solution... I try to be realistic regarding my skills in electronics (or the lack thereof). The project - as it is - is already quite challenging for me, so - for my first project - I'll skip the part where I have to manipulate signals.

There's one more reason I want to avoid this : This "thing" will end up in a woodworking workshop, with less dust than there is now, but dust nonetheless, and I'd really like to avoid having a totally "experimental" system with one or multiple breadboards, resistors, capacitors and a huge bunch of jumpers everywhere.

Regarding the coding part: Do you think using libraries for a project like this would help? And if so: which one(s) would you recommend?

PS: I'll favor "less but more detailed" answers from now on, because I already hit the 10 posts/day limit the forum sets for new members and it's not cool not to be able to answer to kind people helping me...

I can't think of any libraries that would be helpful. Most of them help you to use a piece of external hardware that's non-trivial to control such as LCD displays or PH meters.

Everything you'll be doing uses the basic building blocks of digitalRead, digitalWrite and analogRead. Some use of millis for timing perhaps and that's about it.

As to making more posts, it's very easy to get yourself to the next level of privilege:

  • Enter at least 5 topics
  • Read at least 30 posts
  • Spend a total of 10 minutes reading posts

Hi,

I don't know yet how to use it or if it will be important, but I found a library to use the ACS712 current sensor... I have no idea how to use it, but I'm not even there yet :wink:

Right now, I'm trying to create a function that is the initial state of the setup. Meaning : ALL GATES CLOSED !

Since want the system to return to this state when nothing is running, I thought it would be clever to use a function, but - of course - I'm stuck writing it...

Here's what I wrote so far:

Note: All blast gates (bg) are assigned to a Pin and this pin is set as pinMode OUTPUT.

int AllGatesClosed(){

  digitalWrite bg1_open=LOW;
  digitalWrite bg1_closed=HIGH;
  digitalWrite bg2_open=LOW;
  digitalWrite bg2_closed=HIGH;
  digitalWrite bg3_open=LOW;
  digitalWrite bg3_closed=HIGH;
  digitalWrite bg4_open=LOW;
  digitalWrite bg4_closed=HIGH;
  digitalWrite bg5_open=LOW;
  digitalWrite bg5_closed=HIGH;
  digitalWrite bg6_open=LOW;
  digitalWrite bg6_closed=HIGH;
  digitalWrite bg7_open=LOW;
  digitalWrite bg7_closed=HIGH;
  digitalWrite extractor=LOW;
  }

BUT...

  1. I don't know whether this should be an int in the first place. I guess it could be a boolean since either this is true (all gates are closed) or false (at least one gate is open).

  2. I don't know how to call this function of if it's really a function at all, since it doesn't really manipulate data.

Since I always make my best effort to try it alone first, I spent the last 2 hours reading all kind of articles and tutorials on functions and "states", but could not find something that would apply to my case...

I suggest that you start with a single blast gate. Add more when you can compile what you have.

Take a look at the example code that comes with the IDE - there are some programs that show the syntax required for digitalWrite.

Good Morning !

Well, you're right, it wasn't the right way to start, and beginning with activating 1 blast gate will definitely be something I'll do when I receive the missing hardware.

Note that I already played with the relays and basic delays (no input) to test the communication between PC & Arduino and between Arduino & relay module... it went fine (well... took me hours, but it went fine :smiley: !

As a person I really don't feel confortable working on tiny bits without having the big picture, so instead of starting with the syntax, I'll describe the overall structure of the instructions i'd like to code, then work my way down and write actual code.

Working that way should allow me to know which piece of the puzzle I'll be working on and what's the status of the project.

I'll also probably find a place to make the current version of my code available and avoid posting 1000 iterations here. Any suggestions on that?

It's a good idea to figure out the big picture and you clearly have that well in hand. I have found when it gets to coding, particularly for Arduino, that a bottom up approach helps. Common advice here is to take each hardware component and write a little program that exercises it. Later you can use the functions you wrote to do this in your main code.

Even having done that, I usually look at the task as a whole and pick the smallest thing I can find and get that working. When its tested thoroughly, I find another tiny piece etc. Then I find that the new piece works nicely, but it broke the first one. Fix that and move on.

You can write the whole thing up front, like a novel, but then testing is hell. YMMV.

As finding a place for your code, you could use GitHub, which will let you go back to earlier iterations when the code inexplicably stops working. Generally though, the people here who offer help are less likely to do so if they have to go off site to look at your code. There's no problem posting it repeatedly here. Indeed, whenever you have changed something and have a new question, there is an expectation that you will post the latest version.

When I was learning how to program, I was taught he old adage "Design top down, build bottom up". In other words when designing you application start with the bigger overview and go back adding more and more detail until you have a "complete" design. When you start programming choose the simplest parts that will be used by code higher up, write these (including comments as to how an why you do what you do) and importantly write a test app for these parts, before moving on to the next one. Once you have all the lowest level parts coded start on the next level, then the next working your way up.

This is the way Wildbill has said he usually works, as will many experienced programmers. Writing the whole application in one go and then trying to work out which piece is not working can result in spending a lot of time making no progress - it's always a problem in the piece of code you look at last and have avoided because "it's difficult/complicated".

I don't understand why I would be "trying to work out which piece is not working"... it will so obviously work perfectly the 1st time I try it... :thinking: :thinking: :thinking: :thinking: or maybe not :wink:

So far, I came up with this:

Code structure

  1. Include Libraries:
    Include ACS712 library

  2. List all the INPUT pins

  3. List all the OUTPUT pins:

  4. Create functions

  • Function "startExtractor" to start the extractor with a 5 seconds delay (avoid overload when machine starts)
  • Function "stopExtractor" to stop the extractor with a 5 seconds delay when last machine stops (to empty any dust present in the duct)
  • Function "closeBlastGate" to close a bg (or all bg) with a 8 seconds delay (to close it after the extractor is OFF)
  • Function "OffState" to stop extractor and close all blast gates when no machine is running (Maybe no need, depending on the use of the above 3 functions)
  • Function "LatheButtonPush" to store the state of the button and allow me to keep the blast gate open until another button push is detected
  • Function "ProximitySensorActivated" to define the distance values and when to start/stop extractor if proximity sensor is activated
  1. Set all PinMode in the void setup()
  2. Start use cases in the void loop ()
    1. I start the saw:
      --> Open BG2 and BG6
      --> Start the extractor unless it's already ON
    2. I stop the saw
      --> Close BG2 and BG6
      --> Turn off the extractor unless another machine is running
    3. I start the Router
      --> Open BG2 and BG7
      --> Start the extractor unless it's already ON
    4. I stop the Router
      ... etc

Those multi relay setups won’t last five minutes switching any decent sized load , especially an inductive one .
You need proper sized relays/contactors for the job

Hi,

I don't know what you mean by "decent sized load", but I don't think you analyzed the project correctly.

These relays must switch 2 type of loads:

  • 7x2 solenoid valves (24V DC 1.38W)
  • 1x 230v relay (a proper relay that switches the 400v 2,2kw 3 phase motor).

I don't think these loads are exaggerated... am I wrong?

The problem is those are cheap “ hobby” relays with exaggerated capabilities, limited number of operations, etc IMO.
Your loads are inductive and one DC which requires the relays to be considerably de rated ( use a fly back diodes on the dc valves )
Whatever , from using these and having experience of industrial control systems they won’t last and also have marginal isolation distances between coil and contact connections , so for this sort of job , I wouldn’t recommend them ( there are posts on here with them sticking switching light bulbs).

It’s my opinion, up to you

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.