NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Project Help and Ideas » Water Curtain

February 22, 2011
by Ralphxyz
Ralphxyz's Avatar

I am going to make this a blog about my Water Curtain project:

So a lot of this is going to be my wondering out-loud.

It is definitely open to "Help and Ideas".

This started with my question about switching a solenoid valve.

Well actually this started when I saw this youtube video of this fantastic water curtain at a mall in Japan (Canal City).

So I have some solenoid valves and transistors or solid state relays. So I can build ten column concept.

I would like to expand this to at least 64 columns but that would take a financial investment that had best wait until I can see if I can make it work.

So this is all at the initial thinking stage nothing has been thought through besides purchasing the initial 10 solenoids, transistors and power supply.

I am going to start with just 8 columns, thinking that I might use registers and then be able to left shift and right shift to do the math. Timing is going to be critical so I do not know if using the built in timers would be best or if using interrupts would even be feasible as there will need to be near simultaneous switching of the solenoids.

What do you think, how might I be thinking about timing the solenoid on/off?

I suppose I will have to figure out the dimensions of my trial curtain so that I can time how long it takes for a drip to fall. I am starting with my guessing 500 ms so everything will need to be done in that time frame. so if I wanted to make the letter H:

(Assuming a | is a drop of water)

||||||||
| |||| |
| |||| |
|      |
| |||| |
| |||| |
||||||||

So I am picturing this as a binary representation, is that possible?

Could I put that in a register? Is that a good way or would just using a variable work just as well?

Timing (starting from the bottom) would be.

onononononononon
onoffononononoffon
onoffononononoffon
onoffoffoffoffoffoffon
onoffononononoffon
onoffononononoffon
onononononononon

using a 500ms window:

column one   on 500ms
column two   on 75ms  off 357ms on 75ms
column three on 214ms off 75ms  on 214ms
column four  on 214ms off 75ms  on 214ms
column five  on 214ms off 75ms  on 214ms
column six   on 24ms  off 75ms  on 214ms
column seven on 75ms  off 357ms on 75ms
column eight on 500ms

Is there a better way to be thinking of doing this?

Thanks so much for all of the help, I am really going to need it.

Ralph

February 23, 2011
by rkuykendall
rkuykendall's Avatar

Sounds like an amazing project Ralph. Once you complete this you'll have something to really show off and be proud of!

If your going to be driving 8 solenoids why not use the shift register that the guys used in the robotic xylophone? You could just shift in the bits you need at the timing that makes things work right. For instance for the H you show and using your 50ms timing. You'd shift in 11111111, 50ms later 10111101, 100ms later 10000001, 50ms later 10111101, 100ms later 11111111.

You could even program in a library with all the letters, numbers, and characters you'd want to use. Then you could build a function that will parse whatever string you enter and feed in the proper bits. It would be a lot of coding but well worth it in my opinion. Imagine having guests over and setting up your water curtain to say "Welcome John and Jane" or whatever. That would be sweet!

February 23, 2011
by Ralphxyz
Ralphxyz's Avatar

Ok while I was tyring to go to sleep last night I had some interesting thoughts about how to do this, or more specifically how to not do column addressing (individual solenoid) as I illustrated above but to do it like this:

(remember this was thought up while trying to go to sleep so besides the fact that I am just learning all of this as I go it might be a little fuzzy).

What if I did some thing like this?

PORTB = b11111111;  or PORTB = 0xFF;
delay_ms(75);
PORTB = b10111101;  or PORTB = 0xBD;
delay_ms(75);
PORTB = b10111101;  or PORTB = 0xBD;
delay_ms(75);
PORTB = b10111101;  or PORTB = 0xBD;
delay_ms(75);
PORTB = b10000001;  or PORTB = 0x81;
delay_ms(75);
PORTB = b10111101   or PORTB = 0xBD;
delay_ms(75);
PORTB = b10111101;  or PORTB = 0xBD;
delay_ms(75);
PORTB = b10111101;  or PORTB = 0xBD;
delay_ms(75);
PORTB = b11111111;  or PORTB = 0xFF;

Now why would I need a shift register or BCD-to-7Segment Decoder? Why couldn't I just drive the transistors directly?

I could see if I were to use relays I might need more current than the mcu should/could put out. But I am leaning towards using transistors.

I suppose the reason to use a external driver component, would be to save pin count, that I could drive more solenoids from one mcu.

But what about using multiple mcu's using SPI(?)? Or even TWI. What are the advantages one way or the other?

I am picturing having a "library" stored on a EEPROM. That will require a new thread as I know absolutely nothing about using/programming a EEPROM.

Thanks rkuykendall for the pointer to the xylophone phone project.

Any thoughts and comments are welcome and Thank You!

Ralph

February 23, 2011
by Ralphxyz
Ralphxyz's Avatar

That xylophone tutorial is really great. It pretty much explains what I am going to be doing.

It looked like they were only playing one note at a time. I will need to simultaneously trigger multiple solenoids ( eight to start with) it looks like the shift register should make multiple pins high triggering the solenoids well actually triggering the transistors which triggers the solenoid.

I will definitely be looking at the shift register but for now I think I will just drive the transistors directly from the mcu.

Ralph

February 23, 2011
by rkuykendall
rkuykendall's Avatar

I think the nice thing about starting out with the shift registers is it will easily scale to however large you want. I'm thinking specifically about how they talk about chaining them together. Plus they only cost about a quarter from Jameco so the cost is not prohibitive. You've inspired me Ralph, I'm gonna work on one of these myself.

February 23, 2011
by Ralphxyz
Ralphxyz's Avatar

That's great rkuykendall, thank you. It's so amazing (to me at least) the resources we have available because of the Nerdkits.

I went looking to buy some shift registers and found some on AVNET.com for 13¢. I am sure they have a minimum order so I'll have to wait. The same I am sure for JAMECO.

I am really excited about this, it doesn't really appear to be so hard. At least physical setup and initial coding to turn solenoids on and off appears to be very straight forward. Especially thanks to Humberto and Mike I have source code from similar projects like the xylophone.

Once I get the physical setup I need to figure out how to time a water drop.

If I turn the solenoid on for 75ms how much water will I get and how fast will it fall 3' or 6'?

I am picturing setting this up in the back of my pickup truck so that it will be mobile and I can possible use it for advertising.

It certainly should get peoples attention.

I was wondering if I used a accelerometer to turn it off while moving, I could turn it on when I came to a stop.

Then I was thinking about lighting it up, maybe using some laser pointers and Laser Line Generator Lenses

Of course I am to cheap for that kind of money but I think I can cut a wine glass stem with my dremel and a diamond wheel and possible make my own lens (I didn't think up the idea of using wine glass stem I saw it quickly referenced in a forum somewhere, it was just a throw-off comment but it sure stuck with me).

If I get some fair weather I'll go out to my shed and start putting the framework together.

I still need to figure how I am going to plumb it all up (cheap) also.

Stay tuned, comments please.

Ralph

February 23, 2011
by rkuykendall
rkuykendall's Avatar

I agree it is amazing what you can learn around here. Great job to Humberto and Mike for putting together the kit, the tutorials, as well as this community!

As far as how much water you'll get in 75ms I'm not sure, it'll be a function of the pressure as well as the size of your valve. How far the water will travel is a little easier question to answer. Any object accelerates at 32' per second under the effect of earths gravity, and the equation for how far and object falls in a given time is d=Vi*T+1/2AT^2 where d = distance traveled, Vi = initial velocity, A = acceleration, T = time.

If you have a pressurized tube at the top then there will be an initial velocity component, and it may be significant. If you have an unpressurized feed at the top then the water will be under only the influence of gravity. I find it easier to think in terms of the length of column, and in the case of 75ms you will have a column aprx one inch long. It would be easy to calculate the timing once you figure out how large you want your letters or patterns. Of course there will be some fine tuning after everything is set up.

Have you emailed Mike or Humberto to get their take on this? I'd be interested to hear what they think of the feasibility, and of course any suggestions they had towards method. Again awesome project idea.

February 23, 2011
by Keyster
Keyster's Avatar

Ralph,

This is the coolest thing i have seen all day! very awesome. i have a few things bouncing around in my head.

I LOVE your idea of bit bashing the solenoids. the only problem i see with that is the granularity. what i mean by this is when you want to make a curve. if you have a 1 at 75ms ON (numbers from your example above) then when you try to make an 'O' i think it will look squared off. you will probably have to go small. of course i have no idea what the timing will end up being but instead of making a single character 7 bits tall make it 14 or even 21 and use 25ms on each "squirt". this way you could also make designs and not just letters.

another thing that popped into my head while reading this is lighting. i was thing you could run some LED's down the sides and, when viewing at night, you could strobe the lights at different times to make different designs. think of this, you send a design in water that looks like a clock BUT only strobe the lights for say 20ms about half way thru the "drop". move the clock a little and do the same thing. it would look like the water was stationary. granted you would not get a high "frame rate" out of it but it was just a thought to throw out there.

thank you for letting us all join in on your thought process Ralph!

bryan

February 24, 2011
by Ralphxyz
Ralphxyz's Avatar

Thanks everyone for the feedback and comments, rkuykendall thanks for the formulas, I was asked once to do the water flow calculations for a very extravagant fountain. I actually used the fountain came out beautifully.

Today I am thinking about the water flow and nozzle, as 6ofhalfdozen had mentioned in an email.

I have no idea how much water will pass through these particular solenoids.

The manufacturer list the orifice as 1.7mm.

So here is a question how much water @ 5psi passes through a 1.7mm orifice in 75ms? And then of course @ 1 psi and possible .5 psi?

The 5psi is a random number I grabbed as is the 75ms.

I was looking for battery powered pumps and they are expensive, relatively speaking.

I have a 12 volt pump from a RV (recreation vehicle) that I picked up at a yard sale so I have no idea if it even works.

SHURFlo Model # 200-21C-39

Voltage 12 VDC, AMPS 7.0, OPEN FLOW 2.8 and 10.6 GPM (gallons per minute).

I know these RV pumps have a limited head (vertical distance a pump can pump).

I ordered these to use as a nozzle.

I figure I can drill them out to get more water. I also have 1/8" NPT (National Pipe Thread) plugs which I could drill.

I think I am going to modify the body of the solenoid in order to pack them as tight together as possible:

I need to remove the lug on each side. it does not appear to be functional as the valve seat is beyond the lugs.

Without the lugs removed the nozzle center line would about 17 mm which is probable to far apart to make it appear as a solid curtain so I might need to make two rows with staggered center lines. This would get me about 13 mm.

What do you think about those coils being stacked so close together? Think that might cause a problem? The outside ones would probable be on constantly. I fact as a second thought I probable do not want solenoids on the outside just pipe them up for continuos flow. Once I have a larger count than just 8 I should be able to have maybe 4 columns on continuously on each side.

Of course if I wanted to do a bar all the way across then I would need solenoids on the end columns.

As far as making shapes and objects, luckily I can vary the time of each row so I'll be able to squish a row(s) to make shapes. There would be more rows than the 7 I have used for the H illustration.

This is reminiscent of the discussions going on (a long time ago) with making fonts for dot matrix printers, of course there we had a fixed rows and columns to work with. Of course every graphics program developer has to deal with boxy pixels. I will have a fixed number of columns but a variable row count.

Ralph

February 24, 2011
by mongo
mongo's Avatar

They should be fine, stacked up. The bigger problem is getting all the plumbing together in such a tight space.

February 24, 2011
by mongo
mongo's Avatar

A little trick I used in bakery equipment where water was used to slice into the top of the bread before baking was to put a little check valve just ahead of the nozzle. It gives you a positive stop when the flow stops instead of a dribble from the feed line.

February 24, 2011
by Ralphxyz
Ralphxyz's Avatar
||
||
\
V

Mongo that is interesting, probable not easy for me to implement unless I found the check valves somewhere.

I am not sure I have a good picture of what you are saying?

Ralph

February 24, 2011
by mongo
mongo's Avatar

We used water streams to slit the top of the dough for breads and rolls. At about 70 PSI, a stream of water about 1/32" does a nice job. You can control the depth of the slit bu increasing and decreasing the pressure.

Instead of letting the jets run constantly, we put them on solenoids. Although the solenoids were pretty quick acting, the nozzles would dribble when they shut off, causing water marks on the top of the bread that really showed up once it was baked. it became a quality issue.

I got some little check valves that fit right in front of the nozzles and it cured the problem. it takes a tiny bit of pressure to get past them and as the pressure drops, they basically slam shut. Being right at the nozzle, there is no extra water to dribble.

They are called "spring-ball and cone" type. It has a little ball that fits into a cone shaped indent inside the valve. A spring holds it in position. The water enters at the tip of the cone, like a funnel backwards. it overcomes the spring tension and flows through. When the water stops, the ball seats back into the funnel and positively stops any further flow. Capillary action does the rest under the very short distance left.

A good way to picture it is a rubber ball in a funnel, only really little.

February 25, 2011
by Ralphxyz
Ralphxyz's Avatar

Ah the check valve goes after the nozzle that makes more sense.

∏
V       nozzle
^
●       check valve
§       spring
∩
⋅
⋄       squirts 
⋄

Thanks again Mongo. The logic of this, make a defined pulse without any drips, is starting to sink in.

I can see where this would, as you said, make the pulse more defined.

Now to find some "spring-ball and cone" type 1/8" NPT check valves.

I just Googled "spring-ball and cone check valve" and searched ebay. Those are expensive items the cheapest I found were some 3/8" plastic ones from Grainger for $13.00. Well if anyone comes across some 1/8" spring-ball and cone check valves aka "poppet checks" or you have other ideas please let me know.

Ralph

February 25, 2011
by mongo
mongo's Avatar

Yep, not cheap at all... There is an alternative that can be made from junk around the house. Basically, a rubber flapper across an orifice. The rubber acts as the spring and the valve component together. I am sure that a little creativity and brainstorming can come up with all sorts of ideas.

February 26, 2011
by Ralphxyz
Ralphxyz's Avatar

Ok time for a update on my thoughts on the Water Curtain.

I should be able to makeup a framework to hold everything in the next two weeks, that is if the weather stays above freezing and it doesn't rain.

I can not decide between 5' or 6', what do you think?

I think I will have the two outside columns be a steady stream. That will give me 8 columns for the animation. For a total of 12 columns.

Speaking of the animation is there (could there) be a POV (Persistance of Vision) aspect to this. I wonder if something like Keyster had suggested doing with lighting. What is the POV hertz, seems like it is 60hz maybe less. so lets say 40hz or 40 frames per second. Would that be asking to much of the mcu? Probable the slowest component will be the solenoid with a 5-8 ms response time. I could just put each frame into a loop.

I have been experimenting with a water dropper. Drips are certainly move visible than squirts so it looks like I will need to use low pressure on the pump and possible nothing as a nozzle or at least something larger than the 1.7mm solenoid valve orifice so that I get more of a drip than a squirt.

I will have to have a solenoid hooked up to see the effects. I have also tried color back grounds so far a light yellow seems to be the best. While doing the background test I noticed that the shadow of the drip is as noticeable as the drip itself possible even more noticeable, I wonder if having a screen in front of the display might make the animations more seeable? Of course that would probable be a detriment to the whole effect of the Water Curtain. This certainly is interesting.

So here is what I can see that I need at the moment. If any one sees something and thinks "hey I could do that" or "hey that would be interesting todo" Please jump on in, there is plenty of things for everybody, no matter your skill level.

On a PC I need a script to processes a file (or take direct keystrokes) of the designs.

The file would look like my H in binary (if this is the best way to go)

11111111,75
00111100,75
00111100,75
00111100,75
00000000,75
00111100,75
00111100,75
00111100,75
11111111,75
11111111,75
11100111,35
11011011,30
10111101,35
10111101,35
01111110,30
01111110,35
10111101,35
10111101,30
11011011,35
11100111,30
11111111,750
11111111,750

So we have a binary number and time factor.

Now are binary numbers the best to use processing wise? Would: FF,75 or FF,4B or 255,75 be better than 11111111,75?

I like the binary besides you coud overlay a transparency of a objecct you want to have on the curtain over a sheet of ||||||||| and be able to get your number easily. this is doing it by hand, of course that's not complicated or challenging enough. I want to be able to scan a image taken from a tablet and send the output to the mcu. I had been deeply involved it the PDA (personal device appliance(?)) field. You know like the Palm Pilot and signature capture was always the most challenging application to accomplish, at least in the early days. Capturing a signature on a hand held device evolved down to very simple coding (but it took a lot of hard work to get there). Essentially you know the size of the signature box and then you would just scan that area for changes and record that change position as a dot on a graphic file. Then you would scan on, chances are once you got the first dot you would have more immediately following on the same line scan so depending on the stroke thickness you might have 5-10 dots. You would finish scanning that line and then scan the next. On and on you would go scanning and essentially build the signature on the graphics file. Easy right, well that is what I want. Anybody up for it? All you need to do is to scan for a change, you are not concerned with color or anything else you just see that it is no longer white at 35,79 36,79 37,79 38,79 etc. and then the next line.

Then on the mcu I need to take the UART download of the processed image and send it into EEPROM. I have absolutely absolutely no knowledge on EEPROM programming so I'll be looking for specific help on that in the Support and Programming forums.

Of course then I need to read the EEPROM and turn my solenoids on and off.

Sounds like fun.

Like I have said if anyone would like to take a piece of this I sure would appreciate it.

Ralph

February 26, 2011
by P_BM760
P_BM760's Avatar

I was fascinated by your water project idea and I had a thought. Can you treat the outputs like a dot matrix printer. That is how they do the smoke signs you see coming from planes that are advertising at sports events.

February 26, 2011
by Rick_S
Rick_S's Avatar

I kinda had a thought on this. What if instead of pumping the water through the valves, you built a collection trough that you filled with water. Then you could pipe the valves from the bottom of the trough and let gravity feed them. You would have a lot less issue with water pressure causing a 'squirt'.

What do you think?

February 26, 2011
by rkuykendall
rkuykendall's Avatar

I'm working on a trough idea like your suggesting Rick, unfortunately most of the solenoid valves require a certain amount of pressure to activate, and the gravity fed ones seem to be more expensive. After talking with an ME at work though I think I have a working idea but need to do some more testing. It will involve homemade solenoids like the NK guys did, nylon rods, and needle valves like set ups.

February 26, 2011
by Ralphxyz
Ralphxyz's Avatar

Doing a home made needle valve solenoid woud be so cool, it definitely would be doable especially if you had a lathe available.

I do not even have a drill press so a lot of my machining work is done with my dremel by hand and eyeball. Definitely not precision work.

I should be able to get water flowing within the week or two at most. I do not know when the transistors I ordered from ebay might arrive, they definitely are a Chinese issue but for $1.29 for 50 I figure hey go for it, if they ever show up that will be good. I have some 24 volt relays I got from SparkFun to use in the mean time but I think I prefer the transistors.

Using what I have around the house, I am going to build the framework out of 1 1/2" PVC Sch 40 PVC pipe. I will put a 3" PVC accumulator at the top and run the feed from the pump to the accumulator with a relief piped back down to the pan with a ball valve to control pressure. It would be fun to add a stepper motor to the ball valve to automate pressure control, I wonder what size stepper I would need to generate the necessary torque. Technically I should use a globe valve instead of a ball valve but that would require multi turns instead of a quarter turn which would be easier to automate with a stepper motor.

I have no idea what the solenoid valves I have will require. I doubt I will have even a half pound of pressure on the accumulator. I just happen to have a U-tube Manometer from another life so I'll be able to monitor pressure at the accumulator (solenoids) and control it with the relief ball valve. I could vent the accumulator and essentially have Rick's trough but I think having a closed system with the relief valve might give me more options, especially if I could have the relief valve under the control of the mcu.

Ralph

March 02, 2011
by Ralphxyz
Ralphxyz's Avatar

Well I should have my Water Curtain flowing this weekend. I am still missing the relay to turn on and off the pump and my water piping fittings should be in tomorrow also my shift registers have not arrived yet. Technically I'll be able to fill the accumulator with water by hand so I do not need the pump and water piping completed to see if this is going to work. Well I am sure it will "work" but to see how well it works. I still do not know if I will need a nozzle or if just letting the solenoid drip without a nozzle would work or possible just adding a nipple. I'll setup a variety of configurations. Now I still have to finish my coding for the test. I pretty much have inputting the letter H into the onboard EEPROM and then reading the EEPROM handled. It would be nice to have more figures added. I still need to code a "Playlist" of the shapes I want to display. I would like to do a double buffering routine so that I have the next figure stored in RAM instead of reading it from EEPROM while trying to display. Of course this is all speculation as I have no idea what reality will bring. Luckily I have the Nerdkits Tutorials as references, I definitely will be using them. I will start with the letter H and just loop it over and over. I'll try to use Rick's great button code to be able to vary the timing delays. The H I have pictured so far uses the same delay in it's seven steps so just changing a delay variable should change the figure. The water will be falling 5 feet so it will really be interesting to see what happens.

Ralph

March 02, 2011
by rkuykendall
rkuykendall's Avatar

Sounds like things are progressing well, I hope you'll be posting youtube video of it once you have it running. I'm waiting on some materials to see if my homemade stuff will work.

March 03, 2011
by Ralphxyz
Ralphxyz's Avatar

Well I only have a cell phone .AVI video source so it would be a huge download, but I certainly will have it posted. Things keep coming up so it might be a challenge to make it by this weekend but I should see water flow and then to see if I can make a object appear. It has to work, to flow and stop flow, so it should "easily" produce horizontal bars and then I'll try a forward and back slash and then my letter H. If that all works and is perceived then a O would be next. Timing is going to be the thing, that and water flow. I wonder if I will need to get into water chemistry in order to get the correct drip. Would soft water be better than hard water? I am picturing this as a accumulation and absence of drips, I have no idea if that theory is even valid.

I'll do a full makeup with links and prices for the whole build. Turns out I am going have a bit invested in this so I sure hope it works.

Ralph

March 03, 2011
by Ralphxyz
Ralphxyz's Avatar

For the first time I powered on one of the solenoid valves and I think I may have a problem.

Switching on power to the valve does not energize it instantaneously, there is a very slight delay until I hear the solenoid pull open. The spec on the solenoid valve called for 5 - 8ms actuation time which I think I can confirm but nothing was said about de-activating.

Then on power off there is a half second (500ms) delay between power off and the closing of the valve.

This is all done by ear with no instruments so all figures are just my judgement (guess).

When we are talking about flipping the valve on and off in 75ms cycles that gives about 500ms for the whole object composition.

So with a 500ms delay I will only get one drip per frame.

I think there is just going to be to much of a lag to build the object. But of course the timing cycles were just guesses about what would be required.

I can see where building horizontal bars will probable work as that would just be a on - off cycle but I just do not know how to speed up the closing of the valve.

rkuykendall spoke of building his own needle valves that seems to be what it would take. If I built my own then I could have a spring return speeding up the close.

Well I will proceed building the Water Curtain framework since I have all of the materials.

It would be interesting just to see it flowing and being able to turn it on and off. Possible if this was a pressurized system the water pressure would help close the valve but at the moment I am picturing this with maybe 6" of head so the pressure would be insignificant.

I do not know how I would find "fast acting" solenoid valves.

Possible servo motors mounted on ball valves would have snap action which I believe is what is needed but of course this is all speculation.

Well lesson learned, I hope but I doubt it.

Ralph

March 03, 2011
by Noter
Noter's Avatar

Take a look at this article ... says he's doing 7ms to 30ms drops. Lots of good technical info on making drops. Cool photos too.

http://www.scantips.com/drops/shako/

March 03, 2011
by rkuykendall
rkuykendall's Avatar

Thats a bummer Ralph, but I was afraid that you'd find it to be that way. Have you tried it with the water under pressure? If it will be fast acting in that configuration then you'll just have to use pressure. I was thinking about you saying that drips look better than squirts, and how you can get a drip from a pressure nozzle. What if you used some sort of "funnel" below each nozzle to collect and drip the water out? Even if it overflowed the water will lose it's velocity and drip off right? Just a thought.

I'm waiting on some materials but should be able to try out my homemade "needle valve" idea this weekend. If it works I should be able to build valves for about $2. I'll let you know how things turn out.

March 04, 2011
by Ralphxyz
Ralphxyz's Avatar

Noter that is a great link thank you, how did you find that? I sure found it hard to read, is he cycling the solenoid to get the individual drops? The timing information is priceless. I would have liked more information on the solenoid valve, it appears his has a 1.5mm orifice I have a 1.7mm I'll read the article a few more times. I would love more details on the the timing sensor I have some thoughts on making one.

Man, rkuykendall if you can make up valves for $2.00 that would be amazing.

I have been thinking about how one might make a valve it starts out simple and then gets complicated.

Ralph

March 04, 2011
by Noter
Noter's Avatar

I searched on "solenoid valve timing water drop" via google and it was the 1st one up. There are a few more in the list including an DIY ardunio project with schematics and source code that may save you some development time.

I believe he is cycling the solenoid for individual drops and has to change the nipple size as the drops get larger to produce good quality drops. Perhaps more quality than you need for your water curtain but good information to consider.

March 04, 2011
by 6ofhalfdozen
6ofhalfdozen's Avatar

Ralph,

I just had a thought. Dunno if its any good or not, but figured I would pass it along. Most of the solenoids I have worked on are all AC powered, so working on DC solenoids is new to me. But in theory, solenoids "hold power" in their coils, so is it possible that you need to give the solenoid a "high speed" discharge path when the power is off?? I don't remember you having anything like this in your setup, but I could be mistaken. You will also need to worry about reverse emf and all that if you do provide a "high speed" discharge path, but I wonder if it would greatly speed up the solenoid shutoff speed beyond just cutting off the power. The faster the magnetic field is fading, should be a faster valve closing. just a thought

March 04, 2011
by BStory
BStory's Avatar

I love this idea! It got me thinking about ways to control the water flow. What if you gravity fed the water through flexible rubber hoses and used a solenoid to squeeze the hole shut. I think this would work... This might work... Have you ever put your finger over your drink straw and pulled it out of the glass. To me it always seemed like a nice controlled stream coming out the bottom of the straw when I let my finger off.

I sketched this up in about 2 minutes using paint and my pen tablet so bare with me and I'll decipher the chicken scratchings. The yellow lines are hoses submerged in water. The little black things are the rods from the solenoids (The squiggly above is an inductor/solenoid symbol). When the solenoids get flow the rod comes out and squeezes the hose shut. The vacuum in the hose wouldn't let the water fall out the end. Also your solenoids wouldn't need to be close together. They could go anywhere as long as the hose are in a nice tight line.

Squeezing hoses might not give you good hose life but I'm sure a flap or something could be rigged in there.

March 04, 2011
by Ralphxyz
Ralphxyz's Avatar

Using the math and pictures from Noter's there might be lots of time. He has pictures labeled 7ms to 30ms with the drips 2-3cm apart. If 60" = 152.4 cm that gives me a good window it seems. Of course it will depend on the solenoid closing.

What would I have to do "to give the solenoid a "high speed" discharge path at power off?" As 6ofhalfdozen has suggested?

Or at least I think that is what I saw. I suppose now that I have the formulas I should do the calculations and then I would not have to be guessing which everything I have said to this point has been. I'll try to get something going this weekend, right now I am trying to wire up the transistors and seemed to have over amped my breadboard and blown a mcu and possible a LCD.

I have never wired a transistor or used one in a project so this is all new. I made the transistor turn a led on and off so it seemed I should be able to turn a solenoid on and off but I must have gotten the 24 volts misplaced as I definitely fried a mcu and the LCD has a whole bunch of black squares though the entire LCD is not covered. The mcu no longer has the correct Signature so it is lost unless someone knows how to restore the Signature, the device still powers up.

Yeah, BStory I was wondering about making a squeeze valve. I would need some squishy tubing and then of course a lathe would be nice but I have done some amazing things using my 3/8" drill and Dremel. I could put a magnet on the chuck and using a Hall Effect sensor count the revolutions so I could load some coils with a accurate count. I have seen a guy on line winding a coil by hand, I would think that 32 ga mag wire would start cutting after 300 turns.

Well here's hoping,

Ralph

March 04, 2011
by Ralphxyz
Ralphxyz's Avatar

Here is my Solenoid Control wiring, does it look OK?

Thanks,

Ralph

March 04, 2011
by Noter
Noter's Avatar

I think you may need a resistor between the mcu and the base pin on your transistor to keep it from frying. Also, you may need more current than that little transistor can supply. Look at the schematic from the DIY ardunio project. Notice that he is using a TIP121 which can drive up to 5 amps according to the datasheet.

March 05, 2011
by Ralphxyz
Ralphxyz's Avatar

Thanks Noter, I was wondering about having a resistor mcu to base. What Ω would that need to be? Also Mike has a 100k(?) Ω resistor from Base to ground in his motors Tutorial would this help? The current on mcu to Base is limited by the mcu, if anything I would think there might not be enough ampacity to trip 8 transistors. I will use a shift register but they have not arrived yet so I was thinking of driving the transistor directly from the mcu. I can easy enough add a resistor in line if needed but wonder about the size.

The solenoid is rated @ 6 watt (250ma) the transistor is rated @ 500ma so it seems I should be ok, but I have never done this. I don't know why I would need 5 amps to drive a 6 watt coil.

Every thing I have done and am doing is completely based on speculation and guesses on my part so possible I blew the transistor when testing and that is what shorted out the 24volts to the rails of the breadboard and blew the mcu. Could that be likely? Something certainly blew the mcu and probable the LCD. Though I suspect a wiring error caused the burn out. I ripped wires out when I felt the voltage regulator start to sizzle I didn't see any magic smoke but just passed my hand past the regulator and felt the heat two inches away so it was hot.

I am building the physical framework today. I would like to get water flowing this weekend even if it is not controlled yet. Just making a drip (turning the piped solenoid on and off) will be a big step in seeing what I am capable of doing.

I am going to use my modified tempsensor project code with the substituted potentiometer in place of the LM34 temp sensor in order to control the timing of the solenoid on off cycle instead of hard coding a value in the code. That way I will be able to try different scenarios.

Thanks again Noter, anybody else see anything or have words of advice, it's much appreciated (and needed).

Ralph

March 05, 2011
by Noter
Noter's Avatar

A 1k ohm should keep things from burning up but if you want to limit the collector current to around 400ma something more like 2k ohm should work. From the datasheet I think you want a base current of about 1.5ma but a bit more will for sure turn the solenoid all the way on so I'd start with a 2k ohm resistor.

I agreen with your assessment of what happened. I've fried a few transistors along the way too by forgetting to put the resistor on the base but I didn't have higher voltage anywhere so my mcu was ok.

March 06, 2011
by Ralphxyz
Ralphxyz's Avatar

Well I have most of the framework made up and assembled. I also wired up another solenoid using the above schematic and a 2.2k Ω resistor in line with the mcu to BASE. Now when testing I no longer hear the delay that I was hearing when I just had the solenoid wired up directly, without the transistor and diode so maybe these solenoids will work. Maybe the diode causes a rapid discharge like 6ofhalfdozen had suggested. It sounds instantaneous, so I am excited this might work.

Movin on,

Ralph

March 10, 2011
by rkuykendall
rkuykendall's Avatar

How are things coming Ralph? My first try at homemade needle valves failed but I haven't given up yet. I think I was using too small a diameter magnet wire to create the magnetic field I need.

March 11, 2011
by Ralphxyz
Ralphxyz's Avatar

I have the eight solenoids wired up and tested .

That was more work than I expected. In 20 20 hindsight I see that I should not put the transistor and resistor in the solenoid connector box. I got the idea seeing the manufacturer has a on/off led option and there was space. Every thing should be on the PCB board with just two wires to the solenoid then it would have been simple to wire up and the testing would not have been so tough.

I was getting a occasional short jamming the cover on.

So now I am learning how to use a shift register and the internal mcu EEPROM then I need to get the I2C external EEPROM working.

I should have water flowing this weekend if the weather is good. I don't know if I will have the programming done but I'll finish building the framework and get my pump setup and tested.

Of course I do not know if my pump will work. I powered the motor from my car battery and the motor turns but I have not pumped any water. Plus I might have a issue with the power supply I got off ebay. I powered it up and it is putting out 12 volts but when I powered a motor the motor ran in pulses. It would run for 5 seconds and stop for 5 seconds and then run for 5 seconds and stop it did this continuously. Now I have no idea if the motor is any good or if it is the power supply? The power supply is from a CCTV (Closed Circuit Television) system which I have never worked with so maybe they use pulsed power.

Ralph

March 11, 2011
by bretm
bretm's Avatar

Could it be thermal protection in the power supply causing it to shut down when it overheats?

March 11, 2011
by Ralphxyz
Ralphxyz's Avatar

That could be. The power supply is supposed to be rated at 10 amps. The motor is not big I'll put a amp meter on to see how much current is being drawn. The motor also does not seem to be spinning very fast or with much power I'll see if I can stall it.

Ralph

March 13, 2011
by Ralphxyz
Ralphxyz's Avatar

Well the power supply I got off ebay does not power the pump. So I need to get another one.

I made up the solenoid valves into a solid clump (all 8 together)

I used the "Amazing Goop" to cement them together. They really look very nice in place on the framework.

They are not precisely aligned but I do not know if that will be detrimental or not. I suppose each drip will have a different angle.

I will try those 1/8" NPT by 200 tube series adapters as nozzles (from the first picture).

Ralph

June 29, 2011
by Ralphxyz
Ralphxyz's Avatar

Well I am back on this project finally!!

I had actual water flow today.

I got the header plumbed up with the pump and actually pumped some water through.

So the 12 volt RV pump I got at a yard sale works!

I was just dumping the water through the nozzles so I got to see the effect of varying the pressure.

I definitely need some back pressure as with no pressure (just gravity) some of the nozzles did not even drip.

Now trying to do some safe wiring, water and electricity do not mix.

Geesch, now I can not find my code that I built last winter. I hope it is on my other computer.

I'll be posting some pictures and movies of my progress.

I have already seen that you will have to be within five feet to distinguish any thing. It definitely is a matter of scale.

So let me have your comments please,

Did any one else make any progress on the various components you were working on?

Also in looking at the Canal City video again

I see how they used lights to highlight the flow!

This opens a whole new arena for me to play in and also look for ideas from you all.

I wonder what I might do with a laser pointer (they are amazingly cheap).

What do you think a laser pointer with one of these lenses from [Edmund Optics](http://www.edmundoptics.com/onlinecatalog/displayproduct.cfm?productid=19100 might do?

Of course I am too cheap to pay their price but I do have my Dremel with a diamond blade and some wine glasses.

I actually tried making a laser line lens once and it actually sorta worked it changed the laser beam into a flat line, not very well defined or sharp but the effect was there.

So what do you think I should do about lighting?

I have a 24volt power supply which I do not "think" is heavily loaded.

It looks like the Canal City lights might be high intensity which would make sense which is why I was thinking abut using a laser pointer.

Please let me know your thoughts and questions.

Ralph

July 06, 2011
by Ralphxyz
Ralphxyz's Avatar

I Really need some help in determining the best way to proceed with generating letters and symbols.

Currently I am using PORTD with 8 leds for testing.

Here is my current working code, thanks to Noter, populating an array and lighting the leds 1 - 255 in binary.

// led7a.c
// for NerdKits with ATmega328p
// rhulslandergmail.com

//#define F_CPU 14745600
#include <stdlib.h>
#include <inttypes.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include "../libnerdkits/io_328p.h"
#include "../libnerdkits/delay.h"

int main (void)
{
    UCSR0B = 0;                                 // make sure USART is disabled

    DDRD = 0xFF;                                // set all PORTD output
    int16_t ON, OFF = 0, i;
    uint16_t line_display[256];                 // allocate array

    for ( i = 0; i < 256 ; i++ ){
        line_display[i] = i;                    // initialize array
    }
    ON = 20;                                    // initialize delays
    OFF = 20;

    while (1){
        for ( i = 0; i < 256 ; i++ ){
            PORTD = (line_display[i]);          // light the LEDs on PORTD
            delay_ms(ON);
            PORTD = 0;                          // turn'em off
            delay_ms(OFF);
        }
    }
}

This takes up about 7500 bits of ram so I extended it by hardcoding some symbols and letters.

I still have lots of space (ram) on my ATmega328p so I actually could use this but it is ugly and long and there has to be a better way.

For example, here is a display I call slantLeft. I am just placing it in line in place of the second for statement.

            PORTD |= (line_display[3]);                 // ON
            delay_ms(ON);
            PORTD = 0;                              // OFF
            delay_ms(shortOFF);
            PORTD |= (line_display[6]);                 // ON
            delay_ms(ON);
            PORTD = 0;                              // OFF
            delay_ms(shortOFF);
            PORTD |= (line_display[12]);                    // ON
            delay_ms(ON);
            PORTD = 0;                              // OFF
            delay_ms(shortOFF);
            PORTD |= (line_display[24]);                    // ON
            delay_ms(ON);
            PORTD = 0;                              // OFF
            delay_ms(shortOFF);
            PORTD |= (line_display[48]);                    // ON
            delay_ms(ON);
            PORTD = 0;                              // OFF
            delay_ms(shortOFF);
            PORTD |= (line_display[96]);                    // ON
            delay_ms(ON);
            PORTD = 0;                              // OFF
            delay_ms(shortOFF);
            PORTD |= (line_display[192]);                   // ON
            delay_ms(ON);
            PORTD = 0;                              // OFF
            delay_ms(shortOFF);

That produces this:

                             ||
                              ||
                               ||
                                ||
                                 ||
                                  ||
                                   ||

Now I can put this into an array.

    int8_t slantLeft[7]
            slantLeft[0] = 3;
            slantLeft[1] = 6;
            slantLeft[2] = 12;
            slantLeft[3] = 24;
            slantLeft[4] = 48;
            slantLeft[5] = 96;
            slantLeft[6] = 192;

But how would I use it and there might be a hundred arrays like this:

It needs to go here somehow:

PORTD |= (line_display[192]);                   // ON

Or is using an array not what I want to do?

Maybe I should just do as I originally speculated and just turn PORTD on and off directly?

            PORTD =3;                   // ON
            delay_ms(ON);
            PORTD = 0;                  // OFF
            delay_ms(shortOFF);
            PORTD =6;                   // ON
            delay_ms(ON);
            PORTD = 0;                  // OFF
            delay_ms(shortOFF);
            PORTD =12;                  // ON
            delay_ms(ON);
            PORTD = 0;                  // OFF
            delay_ms(shortOFF);
            PORTD = 24;                 // ON
            delay_ms(ON);
            PORTD = 0;                  // OFF
            delay_ms(shortOFF);
            PORTD = 48;                 // ON
            delay_ms(ON);
            PORTD = 0;                  // OFF
            delay_ms(shortOFF);
            PORTD =96;                  // ON
            delay_ms(ON);
            PORTD = 0;                  // OFF
            delay_ms(shortOFF);
            PORTD = 192;                    // ON
            delay_ms(ON);
            PORTD = 0;                  // OFF
            delay_ms(shortOFF);

Using this method would probable make for less mcu cycles as it would not have to do the math.

Right now I am using the mcu PORTD. I had planned on using a shift register or I2C port expander but the concept of using the mcu as a intelligent shift register or intelligent port expander has a certain appeal.

Of course I will eventually put something into an EEPROM for permanent storage if I do not hard code it as I am doing currently.

Thanks for the help, this is really getting close.

Ralph

July 06, 2011
by bretm
bretm's Avatar

Instead of storing bit patterns as is, you could store 16-bit opcodes. Something along these lines:

  1. If bits 14 and 15 are both "0", then bits 0-7 represent a pattern, bits 8-10 give you the on time (short, medium, long, extra long) and bits 11-13 give you the off time.

  2. If bit 14 is "1" and bit 15 is "0", the reader should save the current position on a stack and then jump to the array position indicated by bits 0-13, a signed value relative to the current position.

  3. If bit 14 and 15 are both "1", the reader should pop a saved position from the stack and return to that location in the array. The remaining bits are ignored.

  4. If bit 14 is "0" and bit 15 is "1", do something else fun with the other bits, like generate them randomly or according to some other rules defined by the other bits.

That way you can define "subroutine" patterns and loops and conditionals and whatever else you want.

July 06, 2011
by Rick_S
Rick_S's Avatar

Or you could treat it like an LED display and build a font file that you read to turn on/off each pixel/solenoid at a given time.

July 06, 2011
by Ralphxyz
Ralphxyz's Avatar

Thanks bretm and Rick.

Ok, now promise you will not laugh.

Here is my latest "working" code. It is kinda scary in that it works as I have neve used a ponter.

// led7a.c
// for NerdKits with ATmega328p
// rhulslandergmail.com

#define F_CPU 14745600
#include <stdlib.h>
#include <inttypes.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include "../libnerdkits/io_328p.h"
#include "../libnerdkits/delay.h"

int main (void)
{
    UCSR0B = 0;                                 // make sure USART is disabled

    DDRD = 0xFF;                                // set all PORTD output
    unsigned char *arrayName = 0;                                
    int16_t ON, OFF = 0, i;
    //uint16_t line_display[256];
//* 
    unsigned char _array[100];
            _array[0] = "slantLeft";
            _array[1] = "slantRight";
    int8_t slantLeft[7];                        // allocate array
            slantLeft[0] = 3;
            slantLeft[1] = 6;
            slantLeft[2] = 12;
            slantLeft[3] = 24;
            slantLeft[4] = 48;
            slantLeft[5] = 96;
            slantLeft[6] = 192;
    int8_t slantRight[7];
            slantRight[0] = 192;
            slantRight[1] = 96;
            slantRight[2] = 48;
            slantRight[3] = 24;
            slantRight[4] = 12;
            slantRight[5] = 6;
            slantRight[6] = 3;

    ON = 200;                                    
    OFF = 200;

    while (1)
    {
        for (i=0; i < 3; i++) {
            arrayName = _array[i];

            for (i=0; i < 11; i++) {
                PORTD = arrayName[i];
                delay_ms(ON);
                PORTD = 0;                          // turn'em off
                delay_ms(OFF);

            }

        }
    }
}

bretm you lose me on step 2. I really like step 1 that makes sense I can almost see how to implement it.

The whole concept really seems elegant.

Rick I have looked at font.h and was completely lost.

Ralph

July 06, 2011
by Ralphxyz
Ralphxyz's Avatar

And Noter just so you will not think that I am not thinking of you, here are my warnings, which I have not been able to fix yet:

WC.c:23: warning: assignment makes integer from pointer without a cast
WC.c:24: warning: assignment makes integer from pointer without a cast
WC.c:48: warning: assignment makes pointer from integer without a cast

            _array[0] = "slantLeft";
            _array[1] = "slantRight";
            arrayName = _array[i];

I really am over my head with this.

Oh when I say it works that just means something is happening and I am not getting errors on the compile.

I am testing now to see if it is actually doing what it is supposed to do.

Ralph

July 06, 2011
by bretm
bretm's Avatar

That's the idea behind pointers, but that's not really pointers. Does it even compile?

To use that technique, _array needs to be "*int8_t" instead of "unsigned char". And then instead of the values "slantLeft" and "slantRight" you would use &slantLeft and &slantRight to get the addresses of those arrays. They would have to be declared before _array. Then it would probably work, except that you go from 0 to 10 instead of 0 to 6 in the nested for loop.

To use my opcode idea, take a look at the actual bit patterns used in the AVR opcodes. These aren't in the regular Atmega168 manual, you need the AVR instruction set manual. See if that gives you any ideas.

July 06, 2011
by bretm
bretm's Avatar

Another problem is that you're filling the SRAM arrays at run-time. The code and values to do that ends up in program memory, and then the values are written to SRAM. Then you read them from SRAM. You're limited by program memory anyway so you might as well just use PROGMEM with array initializers (and make sure the make file includes the .data section in the hex file).

This problem goes away with external EEPROM.

July 06, 2011
by Noter
Noter's Avatar

Yep, you'll need to fix those warnings. Maybe you would make better progress if you use the nerdkit with the lcd so you can display things as you figure out arrays and pointers. It will be much easier to look at the data that way instead of the single byte at a time you can show with 8 leds. It will take some practice to master arrays and pointers so be prepared to spend some time on it.

July 06, 2011
by bretm
bretm's Avatar

Some pseudo-code behind the opcode idea:

// delay lengths
#define NONE 0
#define SHORT 1
#define MEDIUM 2
#define LONG 3
#define EXTRALONG 4
#define EXTRAMEDIUM 5

// instructions
#define SHOW(bits, onTime, offTime) pattern[offset++] = bits | (onTime << 8) | (offTime << 11)
#define GOTO(address) pattern[offset++] = 0x8000 | address
#define CALL(address) pattern[offset++] = 0xC000 | address
#define RETURN pattern[offset++] = 0x4000

// define the program
uint16_t pattern[4000];
int offset = 0; // instruction pointer

int start = offset; // a label
int slant;          // a label to be defined later
CALL(slant);        // create and store "call" instruction
GOTO(start);        // create and store "goto" instruction

slant = offset;     // another label
SHOW(0b11000000, MEDIUM, SHORT);
SHOW(0b01100000, MEDIUM, SHORT);
SHOW(0b00110000, MEDIUM, SHORT);
RETURN;             // create and store "return" instruction

// the stack--allows 8 levels of subroutine nesting
#define STACK 8
int stack[STACK];
int sp = 0;  // stack pointer

offset = 0;  // start at first instruction
while (1)
{
    uint16_t opcode = pattern[offset++];   // get opcode and increment IP
    uint16_t topBits = opcode & 0xC000;

    if (topBits == 0x8000) // goto instruction
    {
        offset = opcode & 0x3FFF;  // set new instruction pointer
    }
    else if (topBits == 0xC000) // call
    {
        stack[sp++] = offset;      // save current instruction
        offset = opcode & 0x3FFF;  // and jump to new location
    }
    else if (topBits == 0x4000) // return
    {
        offset = stack[--sp];  // go back to where we came from
    }
    else // bits
    {
        PORTD = opcode; // lower 8 bits only
        delay_ms(50 * ((opcode >> 8) & 7));
        PORTD = 0;
        delay_ms(50 * ((opcode >> 11) & 7));
    }
}

This raises the question of why not just write the commands as a "C" program to begin with? The answer is that the Atmega168 can't execute code out of EEPROM, but it can do this.

July 06, 2011
by Ralphxyz
Ralphxyz's Avatar

This is fun. I should code more often.

Yes the code compiled and ran with the noted warnings.

Of course the code did not run correctly :-(

I fixed the warnings!

line 23 and 24 became            unsigned char _array[100] = {"slantLeft, slantRight"};

line 48 became                        arrayName = &_array[i];

The code compiles without warnings or errors but the code does not run correctly.

Oh well back to the drawing board.

My fixes were just guesses.

Now bretm where is the opcode documentation?

Yeah Paul, I will put the I2C LCD on so I can do some debugging.

Now bretm, [quote]And then instead of the values "slantLeft" and "slantRight" you would use &slantLeft and &slantRight to get the addresses of those arrays.[/quote]

I was passing "slantLeft" and "slantRight" as literal text strings in order to name the array on line 48.

I'll have to work on understanding holding the address to an array in an array.

At the moment I do not know how to use it but again an interesting concept.

Moving on thanks everyone with your help I'magonna make it.

Ralph

July 06, 2011
by bretm
bretm's Avatar

Actually just slantLeft and slantRight without the quotes and without the "&" would be the addresses of those arrays. If _array is *int8_t instead of unsigned char, that should be about all you need to do (and fix up the for loops so they don't go past the ends of the arrays).

July 06, 2011
by bretm
bretm's Avatar

Oh yeah, the AVR instruction set documentation can be found here.

July 06, 2011
by Ralphxyz
Ralphxyz's Avatar

bretm, the compiler does not like *int8_t.

I get this error:

WC.c:28: error: expected expression before 'int8_t'

Line 28 reads:

*int8_t _array[100];

Ralph

July 06, 2011
by Noter
Noter's Avatar

Hey Ralph, watch some of these and see if all this array and pointer stuff makes more sense -

array tutorials

pointer tutorials

July 06, 2011
by bretm
bretm's Avatar

Sorry, int8_t*

July 14, 2011
by Noter
Noter's Avatar

Hey Ralph,

Here's antother use for your water curtain setup -

levitating water

July 14, 2011
by Ralphxyz
Ralphxyz's Avatar

Thanks Paul, that is fascinating.

I picked up a strobe light at a yard sale to see what effect there might be.

I have been thinking of incorporating your zero cross code and of course Rick's code from my Reflow Oven.

In order to syncronize the strobe with the mcu I "should" be able to time the strobe exactly to the drops of water, that is the mcu will be firing the solenoids so it should be able to fire the strobe at the same time.

I have never done anything with optics so I picked up a beginners optics kit from Edmunds Scientific to begin learning

at the simplest level. I also picked up a beginner fiber optics kits and some laser modules to see what effects I can build/have.

Of course I am completely stalled trying to get the I2C LCD working so that I can debug/learn how to produce my images.

I have my above code "almost" working.

I suppose I could use both PORTB and PORTC to get my 8 output pins but using one PORT is much cleaner and simpler.

I have never been able to use PB0 in order to use PORTB so using PORTD just makes sense.

I'll post my latest code but right now I am trying to get the I2C LCD working.

I just realized I can use the serial output and see the debug messages on my PC and not worry about the LCD.

Of course I have to get the LCD working.

Oh well it is an absolutely beautiful day and I get to spend it inside at my desk working on my Nerdkit.

I think I'll just go and mow the lawn or do some other outdoor project, it is a waste to be inside.

Ralph

July 14, 2011
by Ralphxyz
Ralphxyz's Avatar

Duh, of course I can not use serial output (USART) for debugging. I have to get the I2C LCD working for any output beyond the LEDs

which actually tells me quite a bit.

Ralph

July 25, 2011
by Ralphxyz
Ralphxyz's Avatar

bretm, I really like the opcode concept but just could not get my mind wrapped around to make something useful.

Now thanks to Cliff (clawson) over at AVRFreaks I have a great "Pattern Generator".

Now I'll ask over on Noter's I2C EEPROM how to get the pattern into EEPROM.

Of course then EEPROM to Shift Register.

I should be able to prove within the week if this will even work, it better I have a lot of time and probable $500.00 invested in it so far.

So if anyone would like to work on a section of the long list of things to do please let me know.

I need the EEPROM code.
I need the Shift Register code.
I need a button routine to select the patterns to display.
I need a PC interface to generate a pattern on a pc and send it to the EEPROM or mcu.
I need a texting interface so that someone could enter a text message on their cell phone and have it display on the water curtain.
I need a pc image scanner routine to scan a image drawn on a tablet to a pattern to be displayed on the water curtain.

Sounds like fun right.

Ralph

July 25, 2011
by Rick_S
Rick_S's Avatar

Sounds like you have your work cut out for you to me! BigGrin_Green

Rick

July 25, 2011
by bretm
bretm's Avatar

The opcode idea would only be useful if you run out of room to store the patterns by storing repeated patterns only once, or if you wanted to store "code" to generate patterns on-the-fly, e.g. showing the current temperature or showing randomized patterns, etc.

July 26, 2011
by Noter
Noter's Avatar

One advantage of using structures is having only one pointer for all your elements instead of each element having it's own pointer. This reduces the number of variables in your program and save's a little time since only one pointer value needs be calculated for an array or even better, passed to a function. Imagine you have a function that needs the values of 25 variables. You could pass the address of each in the call or if using a structure, only a single address to the structure containing the data.

You have a lot on your plate with your water curtain project. I think you should save the eeprom part of your application for last. After you get everything else working using PROGMEM/RAM to store your sample patterns, moving to and further populating eeprom would be the next/final logical step.

How did your feasability test using patterns from PROGMEM tables/structures come out?

July 26, 2011
by Noter
Noter's Avatar

By the way, did you get your I2C display going again? I think you're going to need it.

July 26, 2011
by Ralphxyz
Ralphxyz's Avatar

I am having problems picturing exactly how I am going to set up a sequence of patterns to display.

Most likely there will be times when I want to repeat the same patterns over and over but I might want random patterns of a certain group.

Or ...?

I know I want to press a button and bring up a list of all patterns and then step through the list selecting the patterns I want to display.

So I can see three buttons.

Button 1 bring up list and step through. 
Button 2 select pattern, and enter in to a display list. 
Button 3 save display list and run display.

I am definitely doing the PROGMEM method first, but I wanted to start thinking about how I would use the EEPROM.

No I can not get the I2C LCD to work.

Actually I do not need the I2C LCD as I was using PORTD only for a simplified testing method, having all 8 pins available helped me picture what I needed to do for the pattern generator.

I will be using a shift register (eventually two or three serially chained) so I can use the Nerdkits LCD code.

I would like to use the I2C LCD code but I am really getting pressed for time.

I need the LCD for my button selection routines, I will probable be able to modify Rick's Date/Time button routine from his I2C Real Time Clock project, he positions a list on the lcd for selection.

I need at least two more buttons Button 4 to set the ON delay and Button 5 to set the OFF delay.

I will do button 4 and 5 first I need to get that working for my initial testing.

I have had to completely rework my framework but I should have that done today or tomorrow then I need to wire everything up.

I have had water flowing but with out any control now I need to put my solenoids in line and set up the Nerdkit to generate the patterns to be displayed.

If I have the buttons to vary ON and OFF delay than I can make changes on the spot instead of hardcoding the timings as I have been doing.

So I will do something like:

   while (1) { 
      d_ptr = (uint8_t *)pgm_read_word(&patterns[current_pat].data); 
      for (   i=0; 
         i < pgm_read_byte(&patterns[current_pat].len); 
         i++) { 
         PORTD = pgm_read_byte(d_ptr + i); 
         delay_ms(ON); 
         PORTD = 0;
         delay_ms(OFF);
      } 
   }

With ON and OFF coming from Button 4 and 5 (0 - 255).

So far all of my timing values are just guesses.

So yes I have a lot to do so if anyone has any pointers to some clean simplified button routine code that would would help a lot as I really want to be able change my timings without have to recompile my code.

I will not have a PC at the initial testing water curtain display so it would be a bother to have to use inline hardcoded ON/OFF.

Ralph

August 02, 2011
by Ralphxyz
Ralphxyz's Avatar

Having a problem driving my transistors (BC337).

I was able to test each solenoid in the past but have forgotten how I did it and now I can not see if the transistor is firing to trigger the solenoid.

Here is link to the BC337 transistor spec sheet:.

Here is my wiring diagram: with a 2.2kΩ resister to the mcu.

My Base voltage is <=4.2v could this be the problem? The spec sheet calls for:

| Vebo   |      Emitter-Base Voltage    |     5 volts         |  there isn't a + - tolerance given.

I "think" when I was testing each solenoid was wired direct to Vcc at 4.89 volts.

I'll try to set that up again to test.

Any other ideas?

The solenoids have just been sitting in a box since I tested them at my desk three or four months ago so nothing" should" have happened to them.

Only the wiring is different and I am now going through the mcu.

Could I not be supplying enough current?

Currently I have LEDs in series which I'll remove.

Thanks for the help and any suggestions.

Ralph

August 02, 2011
by Ralphxyz
Ralphxyz's Avatar

Found my problem.

I needed a Common Ground between the mcu 5 volt power supply and the 24 volt power supply for the solenoids!!

I probable have a note somewhere about needing a common ground.

I will have water flowing later on this afternoon so I'll be able to see what will work.

Timing will be a issue, it's to bad right now I have to hard code all of of the timings but once I get the button routines worked out I'll be able to make dynamic changes.

I have 6 mcus so I can hard code different test scenarios but keeping track is a pain.

I am using little stickers on the mcus with the timings noted.

Well here we go, please stand by.

Ralph

August 02, 2011
by missle3944
missle3944's Avatar

Hi Ralph,

How High are you going to mount the water valves? I suppose you would have to bring in that consideration for timing to get a correct picture with the water?

-missle3944

August 02, 2011
by Rick_S
Rick_S's Avatar

See my thoughts were to let gravity feed the water rather than pressure. That way, since gravity is a constant, you should be able to calculate the rate of movement thus locking in a timing factor. No matter what you do, the water "display" will stretch the farther it travels if moving downward.

Rick

August 02, 2011
by missle3944
missle3944's Avatar

Rick,

That is a great idea. So are Ralph's valves would be not pressurized then right? I looked at this water curtain project and it looks like theirs too is gravity fed except for the pump circluating the water from the bottom container back to the top reservoir.

August 02, 2011
by Ralphxyz
Ralphxyz's Avatar

It's about 5 feet.

I can vary the pressure.

If I fully open the relief there will be minimal back pressure.

Of course once I solved the transistor problem all of a sudden one of my pins no longer gets energized.

This is using the exact same code as yesterday but now one pin no longer lights the led or switches the solenoid.

I am also "trying" to get a shift register working I'll probable post a new thread for that.

The preferred method is to use the shift register so that is what I am currently trying to get working!

I am using Rick's code from the Photography Club thread.

I have had the code working now it doesn't I am not sure of the pin outs.

Ralph

August 02, 2011
by missle3944
missle3944's Avatar

Ralph and Rick

What if you used relays instead of transistors. But you just put a tranistor in series with the relay and the mcu pin connected to the tranistor to drive the relay? I've done that and it seems to be fine. But relays aren't cheap sometimes. I know radioshack has some 120v ac ones for around $2 or $3 but I cant remember the current load. I don't know whats better but you might have less trouble with a relay. Just a suggestion,

-missle3944

August 02, 2011
by Rick_S
Rick_S's Avatar

Mosfets are fully capable of providing the current needed by the coils of the water valves. Relays would be an un-needed and slow addition. A relay being a mechanical device is too slow to provide the quick switching that would be required for the water to appear as pixels in a display.

Honestly I don't know if standard solenoid controlled water valves would be quick enough themselves to provide a good display. Not Sure I guess Ralph will find out. Plain Smiley

Rick

August 02, 2011
by missle3944
missle3944's Avatar

@Rick,

Thanks for the response cleared up my confusion on using them for different applications.

missle3944

August 03, 2011
by Ralphxyz
Ralphxyz's Avatar

The solenoids I have have a 5ms response time (I believe).

Ralph

August 03, 2011
by Rick_S
Rick_S's Avatar

You're telling me those can cycle on/off 100 times per second!! (5ms on+5ms off) If that's the case, you shouldn't have a hangup there.

August 03, 2011
by Ralphxyz
Ralphxyz's Avatar

Here is the spec sheet cut:

It list the "response time" as 5 - 8ms.

I got the solenoids off e-bay apparently they were made for a third party spec job as there is no labeling or direct specifications.

The seller said they were 24volt so that is what I have been going by.

They appear to be very high quality, made in Italy in fact.

As soon as I bought them at $5.00 the seller bumped the price to $8.00.

I will need 64 more of them once I have proof of concept. Another $500.00 is going to be tight.

I hope they will take a offer. I would really like to get more of the same valve.

Ralph

August 03, 2011
by Rick_S
Rick_S's Avatar

Sweet, I would think those should work fine. I will say though, you have your work cut out for you Eek

August 03, 2011
by Ralphxyz
Ralphxyz's Avatar

It is so unbelievable that every time I make a break through "something" will happen.

I really get depressed.

Usually and it did it again today well it started two days ago but today all of my mcu's or breadboards stopped working!

I had two breadboards, one I was using PORTD and driving the LEDs (in place of the solenoids for testing and development)

All of a sudden one led would no longer light running the same code I have been using for the past week. I switched mcus but with all of them the one LED failed to light which previously was working. The pin was not getting energized.

So I switched back to using the Shift Register. I once had the shift register working but this week I was having problems with remembering the pinout, so I tried re-wiring it and it just plain stopped working. I could no longer get any of the leds to light.

Then I sometimes could not program any mcu. This only happened occasionally, but more often I got the "Programmer Not Responding" error until today it totally stopped working.

So today I built a new breadboard and when I moved the USB cable from the breadboard that had been flaky and then stopped

I discovered that I had a bad wire on the USB cable there probable was only one strand of wire still connected.

The USB wire was acting so flaky that when I removed it from the breadboard it would send my mini MAC (OS X) into zombie land and I would have to reboot this also happened a couple of times today.

AND the bootloader got messed up on the mcus that were in place when the MAC got zapped so I had to fire up my pc to reload the bootloader.

I still have not recovered all of my mcu's nor do I have any running using PORTD or the Shift Register.

I would really like to get the shift register running.

I might not be able to work on this much as my first grandchild is coming to visit over the weekend, I would really like to show off my Water Curtain.

Oh well tomorrow will be a better day.

Ralph

August 09, 2011
by Ralphxyz
Ralphxyz's Avatar

Well I got a breadboard to work for a couple of days and actually have water flow and my solenoid valves working.

Now I am at the hard part, I knew the timing and pressure were going to be a chalenge.

My daughter says she can perceive some of the patterns in the water flow.

If I use 5ms on 2000ms off with 4" of water column pressure I can start to see a bar effect with PORTD = 0b11111111

on and off.

I definitely have my work cut out for me.

I have a U-tube manometer so I am able to precisely measure the pressure as long as I stay under 8inch water column.

Which is about a 1/4# psi.

If I use more pressure everything looks like a steady fluctuating water stream.


Now for more complaining about this darn ATmega AVR programing environment.

As I mentioned earlier working code stopped working or stopped working correctly.

Well now I had my Windows XP Pro tablet near where I had the water curtain setup "thinking" I could save some time with reprograming the mcu.

I haven't gotten a button routine running yet so I am having to hardcode all timings. Anyways when I tried to change and compile the working code only one pin was energised even thought the the code said PORTD = 0b11111111 it would come out as 0b00010000.

So I would have to go back to my house and compile the exact same code to get 0b11111111 output. This was code compiled on my Mac would run correctly code compiled on my tablet would not, the exact same code.

Yesterday the mcu/breadboard decided that it no longer wanted to be programmed so currently I can not change the code.

I have had to do a lot of dismantling and moving the breadboard back and forth so it is not surprising that it stopped working

but it is a pain. I really need a button routine so I could make timing changes in place.


Now as if I didn't have enough to do it appears I will have to make up my own valving system. I started a new thread asking for help in building a coil.

The original supplier of the solenoid valves only has 11 left and everything I am finding starts at $25.00 so I can not afford to purchase many more valves.

Did anybody make any progress with the needle valves you were trying to make?

I sure would like any feedback on what you found out.

I believe I can make up something along the lines of what Rick had described.

I now know I do not want a pressurized system so that simplifies the process.

I'll make up a drawing of what I am picturing so far.

The problem is I am not a precision kinda guy.

Close enough is normally fine by me, but if I am going to make up a valve assemble I am going to need a lot of precision.

I think I took Machine Shop 1 about 50 years ago so I have that experience to draw from.

Right now I am picturing a bunch of tapered pins in some tapered holes in a waterproof tray.

The tapered holes I can make with a ream it's the tapered pins I would have to turn on the lathe.

So anybody have any recommendations for a lathe, I have looked at the combo lathe and mill but I just do not know what I should get. Or if I should just get the lathe now and hopefully come up with some more money to buy the mill later on.

Then how would I make the coils?

I am in fact on a very limited budget.

Ralph

August 10, 2011
by Ralphxyz
Ralphxyz's Avatar

I swear this was working!

Definitely there is more grey in my hair.

Here is the "working" code:

#define F_CPU 14745600

#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <avr/io.h>
#include <avr/pgmspace.h>

#include "../libnerdkits/io_328p.h"
#include "../libnerdkits/delay.h"
#include "../libnerdkits/uart.h"

int main(void) 
{ 
    uint16_t ON, OFF = 0;
    DDRD = 0xFF; 
    UCSR0B = 0;             //Turn off UART

     ON = 1250;
     OFF = 1000;

    while (1) 
    { 
                    PORTD = 0b11111111; 
                    delay_ms(ON);
                    PORTD = 0;
                    delay_ms(OFF);           
    } 
}

This code produces this:

Notice LED1 (first on the right) PD0 is not lit!!

PORTD = 0b00000111;

Produces this:

PORTD = 0b00000011;

Produces:

and finally:

PORTD = 0b00000001;

Produces:

Only with PORTD = 0b00000001; is PD0 high!!

Please someone tell what I am doing wrong!

Or what I need to do to restore (it used to work) the code.

I am turning off the UART with UCSR0B = 0; so that should not be getting in the way.

Is there something else I need to do to enable PD0 when other pins are high?

Thanks for the help, I need it.

Ralph

August 11, 2011
by bretm
bretm's Avatar

Does is help if you turn off the uart before you mess with DDRD? The uart still controls part of port D at the point you're first touching it.

August 11, 2011
by bretm
bretm's Avatar

There's only one current limiting resistor? Am i seeing the picture right? Can you measure the current going through it with 0b11111111?

August 11, 2011
by Rick_S
Rick_S's Avatar

Ralph,

Try sinking your output from the micro. Turn your LED's around and put a current limiting resistor on each led to VCC. See what happens. With all going through one resistor, you as you light each LED, I believe the current gets divided to between them. So if your resistor limits the current to 20ma, when you light one led it gets 20, when you light 2 they get 10 ea, 4 would be 5 ea, and 8 would only be 2.5 ea. That is why it is always best to put current limiting resistors on each LED. Secondly the max current output when sourcing current for a port is (I'm at work so don't quote me) I think 100ma / port. So you should never drive 8 LED's at 20ma each on one port.

Rick

August 11, 2011
by Ralphxyz
Ralphxyz's Avatar

Apparently it was my attempt to use just the single current resistor as with 8 individual led resistors it works!!

I had been using the breadboard outdoors with the transistors also working off the pins so the Leds were just barely visible.

It was only when I brought it inside that I noticed the led was not lit, probable the solenoid also was not firing but I did not count water streams.

So once again I am indebted to you all, thanks a bunch.

Now I have to get the shift registers working.

Using PORTD was just because I could not get a shift register to work.

I have had Rick's code working but now it just will not show patterns.

I think I might have a problem with the pinout.


Oh I saw interesting things in measuring the current just lighting LED1 (PD0) pulls 49ma.

Light 8 leds pulls 99ma this is with 500ms ON and 1000ms OFF using the individual led resister.

Attempting to light the 8 leds with the single current resister pulled only 56ma.

On to the shift register enough time spent on this.

Thanks again,

Ralph

Post a Reply

Please log in to post a reply.

Did you know that one NerdKits customer discovered that his hamster ran several miles in a night using his kit and a Hall-effect sensor? Learn more...