I am a beginner trying to activate 2 sets of 3 air pistons sequentially by going through the YouTube Tutorials... Help, please, pretty please?? :-)
There are 3 sets of 2 pistons, each set working in opposition. So I have P1/P2, P3/P4, and P5/P6, each set working in opposition to squeeze at the center sequentially - Initial state at turn-on/Reset must be:
// Step 1 Run Once:
P1 Down/P2 Up // Move simultaneously (joining at the center) and HOLD in position -
P2 Up/P3 Down // Move simultaneously and HOLD -
P5 Up/P6 Down // Move simultaneously and HOLD -
// Wait for Start button -
I need to start/stop the sequencing with a toggle push-button - I have reed-switch sensors that will give me a set of two TRANSIENT contact closure for each piston moving to the Up and Down positions -
Once started, the sequence needs to be as follows:
// Loop until Reset button is pushed -
// STEP 2: -
P1 Down/P2 Up (HOLD) // Old Initial State, unchanged -
P3 Down/P4 Up (MOVE) // Piston 3 moves Down/Piston 4 moves Up and HOLDS -
P5 Up/P6 Down (HOLD) // Still Old Initial State, unchanged -
// PROBLEM: P3 Down AND P4 Sensors only give me a TRANSIENT closure: These two transients MUST occur to initiate Step 3, but they are not always exactly synched together, so my initial try by putting them in series fails... - // I need to use that set of contact closures to trigger the next command: -
// Step 3: -
// The transient closures of P3 Down/P4 Up Sensors is the trigger needed for -
P5 Down/P6 Up (MOVE) // P5 moves Down/P6 moves Up and HOLD -
P1 Up/P2 Down (MOVE) // P1 moves Up/P2 moves Down and HOLD -
P3 Down/P4 Up (HOLD) // P3/P4 HOLD -
// Back to Step 2 until the Reset button is pushed -
I can send you my attempt at coding for this, but it does not work unless the two sensors close simultaneously, which only happens in simulation... ARGH.. :-(
Can someone send me a piece of code that will work for this, please? I would really, really appreciate that... Very frustrated right now! You can email me at XXXXXXX.XXXX@XXXXX.XXX or text/call at (XXX)XXX-XXXX Thanks either way. Sincerely, Michael
PS: I tried to wire for a separate toggle switching for each sensor, but I run out of pins on my Arduino UNO R3... Looking into it via YouTube https://www.youtube.com/watch?v=cAT07gy4DII "Increase the digital outputs on an Arduino (PART 1 & 2)" but that is way more complex... Trying to wade my way through that now...
simultaneously
, what does that means in precision? down to microsecond? or millisecond? Without code and diagram it is hard to comment on how to improve it or solve your problem. All I could think of right now is that 1) you need to have a state machine to manage all the states and transitions, 2) to make sure all actuators acts together, you probably need to directly access the registers of the MCU for activating each pin than using Arduino commands likedigitalWrite()
. – hcheung Oct 9 '20 at 1:56