Sorry i do not have the actual code but I have attached screen shots.
All of the while loops work fine except for the last one, it seems to be ignored. as soon as relay3 is switched low the code loops back to the beginning without waiting for AirCyl3T to turn high. I can verify this visually and with the serial print.
I'm confused why it is doing this as it looks just like the others that work...
What are you going to do if someone proposes a solution? Edit your screen shots and try to compile them?
[/quote]
I was looking for possible solutions as I cant find any in google searches that way I could think about them and have a game plan to try tomorrow instead of going in empty minded not having a clue and waisting another couple hours tiring to figure it out.
Kirkg:
...waisting another couple hours tiring to figure it out...
Speaking of wasting time, the least you could do so the people on this side of your monitor do not waste their time is format your post so the images are visible.
Yeah I'll post the code tomorrow...but thanks for the warm welcome. As you can see I don't post here much (only when needed) and I used the only spot that I saw available to attach files...I didn't know how they would be attached.
All of the while loops work fine except for the last one, it seems to be ignored. as soon as relay3 is switched low the code loops back to the beginning without waiting for AirCyl3T to turn high. I can verify this visually and with the serial print.
Sounds like you may have already done it, but I was going to suggest that you put a serial print statement immediately prior to the WHILE statement, and print out the value of digitalRead(AirCyl3T), because the only thing I could think of was that it was actually already HIGH.
Really hard to make much sense of the code without knowing what it is suppose to be doing. Presumably you have three air tanks, with some sort of sensor at the "nose" and "tail" of each tank, that are somehow interconnected, and somehow affected by three relays. Presumably from the code when AirCyl3N is HIGH, you are expecting AirCyl3T to be LOW, but whether or not that is a valid assumption requires more information.
These are relays actuating air cylinders with a sensor on the nose and tail. Once the relay has been triggered i want the code o wait for the air cylinder piston to trigger the sensor (THE WHILE LOOP) to ensure all parts are out of the way before turning on the next one.
As soon as relay is triggered the serial print begins so I know the last while loop does not work and I can clearly see and hear that the piston has not moved all the way back.
Code looks simple enough. I can't wrap my head around what the mechanism looks like though, so it's hard to verify the code. Perhaps a picture would help.
Can you try placing Serial.print statements inside each IF statement, to verify if the code is getting executed or not?
From the code, it appears the sequence of events is:
if cyl1 piston at nose end, turn on relay 1 and wait for piston of cyl1 to go to tail end.
if cyl2 piston at tail end, turn on relay 2 and wait for piston of cyl2 to go to nose end.
if cyl2 piston at nose end, turn on relay 3 and wait for piston of cyl3 to go to nose end.
(note this is referencing two different cylinders)
if cyl3 piston is at nose end, turn off relay 3 and wait for piston of cyl3 to go to tail end.
What is the output you are getting on the serial terminal? Are all the relays actually getting activated at some point, and the pistons moving?
Is it possible you have the nose and tail sensors on cylinder 3 reversed? If AirCyl3N were HIGH when relay 3 is LOW, its possible the previous WHILE statement will complete immediately, before the relay 3 HIGH command has time to move the piston, then the DELAY will give the piston time to move away and set AirCyl3N low, making the last IF statement FALSE.
UKHeliBob:
Print statements to show the values being tested before if and while can also be instructive
I will through the serial print in between just to further verify.
I agree but in this case the serial monitor starts to print immediately after the relay is triggered which tells me that it is skipping the while loop (It takes a few seconds for the the cylinder to cycle).
At the time of the relay3 trigger AirCyl3N must be high because thats what sent it into the if statement and means AirCyl3T must be low (because its at the opposite end of the cylinder).
I have also manually cycled all of the air cylinders )with serial print on) to verify that all of the sensors work...This is why I am so confused at to why it is no working.
What i have just noticed is that if I change the LOW to a 0 and load it it works correctly for one cycle but all the following cycles it does not. If I then change it back from 0 to LOW it will again work correctly for one cycle but not the rest.
It seems to have something to do with the process of the program being loaded.