reading from Text file to control Multiple Relays.. help nee

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
andesignlab
 
Posts: 29
Joined: Thu Aug 04, 2016 6:57 pm

reading from Text file to control Multiple Relays.. help nee

Post by andesignlab »

Hello All..

I am stuck and would like to get some thoughts on how to setup a solution to this problem.

Problem:
I am building a system of multiple relays.. 10 to be exact.

In order to control when those relays open and close, I would like the arduino to read a text file line by line, as new lines are added to the text, do that operation.. ( I am considering the serial monitor as the input... If there inst a better option)

The operations would be as follows. ( this is one examples of 10.. each would be the same format.. but a different time variant)

Operation #1.

Open Relay #1 in 30 seconds for 2 seconds and then turn off.


I would like it so I can have multiple operations running at the same time, basically opening and closing the relays at the set operation.

To trigger the arduino to read the next line of text, I will use a light sensor and use a laser beam break to trigger the next operation to start.


I have explored many parts and pieces, and even went through many multitasking tutorials, but I am stuck as to what the correct approach is..

Looking for any and all feedback please!
anything helps!

User avatar
zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: reading from Text file to control Multiple Relays.. help

Post by zener »

Take a look at this tutorial series. It has some good ideas for running multiple simultaneous timed events:

https://learn.adafruit.com/multi-taskin ... for-timing

User avatar
andesignlab
 
Posts: 29
Joined: Thu Aug 04, 2016 6:57 pm

Re: reading from Text file to control Multiple Relays.. help

Post by andesignlab »

Hi all,

I did some work on the mechanical side and wanted to share that do you have a better idea of what I am working on.
IMG_5055.JPG
IMG_5055.JPG (314.86 KiB) Viewed 216 times
IMG_5056.JPG
IMG_5056.JPG (392.56 KiB) Viewed 216 times
Basically, a bunch of air valves controlled by relays.

I am stuck on how to start the Code..

I want to be able to have the relays all firing together, so I cannot use delay to manage the timing...

I am exploring Millis, but its getting crazy complicated since i want to control 8 valves..

also, i am not sure what is the best way to tell it what to do.. i was planning on having the system read from a text file.. or have the scanner side output directly tot he serial command window.

Stuck here too...

Any advice is appreciated!!

User avatar
zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Re: reading from Text file to control Multiple Relays.. help

Post by zener »

Is this an Arduino? You need some basic code skills of course. How do you control the relays? Do you write a word to an address?
andesignlab wrote: I am exploring Millis, but its getting crazy complicated since i want to control 8 valves..
You need to build the code a piece at a time. First just control one relay. You need to write or draw out an algorithm. Maybe something like:

Look for input that signals next command
Get command for valve 1. You could use a variable called delay1
Set variable named beginvalve1 to millis. (beginvalve1 = millis)
Set variable named endvalve1 to beginvalve1 + delay1. (endvalve1 = beginvalve1 + delay1)
Turn valve 1 on
In your loop compare millis to endvalve1. This will tell you when to turn valve 1 off.

This looks like maybe a school project. Do you have any faculty who can help as well?
andesignlab wrote: also, i am not sure what is the best way to tell it what to do.. i was planning on having the system read from a text file..
Initially at least, it would probably be easier to hard code your "instructions" into some variables or an array and just read them sequentially as you receive your light beam break signal or whatever it was that was triggering the next command.

Once you get 1 valve working then you can add a second. If you can do 2 then 10 shouldn't be much harder.

User avatar
andesignlab
 
Posts: 29
Joined: Thu Aug 04, 2016 6:57 pm

Re: reading from Text file to control Multiple Relays.. help

Post by andesignlab »

Hi and Thanks for the response!!

Not quite a school project.. more like and after school.. hahaha

I have a few basic projects under my belt.. and then this one came along...

I think your layout is similar to what I am thinking.. and now seeing it with millis it makes sense!!

Ill do some work on it now and post what is get...

Totally like the approach to get one first!!!

Ill keep you posted!!

chat soon!
a

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”