Oztrainz

Hi all,

I model a whole transportation system that is operated probably as prototypically as possible based on extensive research and given the technical impossibility of operating this transport system exactly prototyplcally. But for my transportation system there was no TT/TO, track warrant systems, no fixed signals or complicated train management system. Why?

Because the line was operated as "one locomotive in steam" - this meant that there was "nothing to hit" while the only operating locomotive was out there doing its stuff. Trains ran as often as the locomotive and its train could get from one end of the line to the other, and its train was swapped for another train going the other way. 

Is it likely that this layout of a transportation system will make much of an appearance here? So far, based on some of the comments I've received in various previous postings about the method of its build and logic behind how it was built as a sectional layout,  this is probably most unlikely.

After all, this layout is:

  • is based on a  "single industry" pike that hauled coal, a not very glamourous product, 
  • only ran just over a mile on the prototype,
  • only ever had 2 operational steam locomotives at any time in the 50 years of its operational life,
  • was narrow gauge, 
  • was not in the US/Canada,
  • is still small as a model layout in terms of overall footprint when compared to a larger "basement filler" layout
  • has a model train length limited to loco plus 11 small, identical-looking wagons
  • was built using a modified TOMA approach (staged construction of its modules) 
  • was planned for future exhibition use (and I've been told repeatedly here in response to some of  my previous postings that any techniques/approaches used have little or no relevance for a "home build" TOMA-based layout.)
  • probably not of much operational interest because it doesn't use US-based railroading operational practices (because it wasn't in the US? - strange that?)
  • and, was built for a different purpose than a home layout, This layout was built to do more than just "entertain the operators" as perhaps are most home layouts, when the purpose of a home layout is distilled to its essence.

The layout consists of 12 modules and covers a floor area of 23' by 17' (Hmm - starting to get towards a half-way decent sized "basement filler"  layout size). It will not grow any larger, because the logistics of moving and storing a layout of this size that doesn't have a permanent home define the layout size limits.  

Could it grow bigger? Undoubtedly yes. But should it grow bigger? No - this layout is at the limits of what can be easily stored, transported to a venue, speedily set up (in about 1 hour) and speedily dismantled for transport back to storage by a 2 person team.

Any given module can be separated from its neighbours in well under 5 minutes, and, in most cases under 2 minutes if work/running repairs are needed when the layout is together.. When not set up, any module or combination of adjoining modules can be easily pulled from its storage frame to have additional detailing work/running repairs done on it at the workbench. 

So just what did this sectionally-based, phased-build of model coal transportation system end up looking like?

_800x600.JPG 

Yes there is still more to do before this layout is fully exhibition ready, but it is almost there. How much more you see of this layout on here, and the saga of its build, is largely up to yourselves, given what I've listed above this photo,  

Regards,

John Garaty

Unanderra in oz

Read my Blog

Reply 12
Oztrainz

Re: Comments for Rev 4

 Re: Comments for Rev 4

Hi Dr Geoff and all,

All other things being equal this should be post #100, unless someone beats me to the punch. So it might as well be a long one.

To be honest, I'm quietly surprised that we got this far on here. Thanks to you all for staying with the thread. After we get the Arduino sorted, there is still much more to come on topics like coal skip design and build techniques, tipper-outer design, module construction and alignment, matching history with the model, scenery design, module storage and transportation, just to name a few of the topics that we have had to work through. 

So back to the Arduino. I have taken Dr Geoff's advice and gone off line to work through what each of the switches are doing at any time and what I "should" be telling the Arduino to do for me. 

So working through Revision 4 

Equipment definitions and pin assignments

Agree as suggested - The extra definition lines for "REED" and "SWITCH" were the missing link that helped me to get my head around "what happens where and when" as the sequence progresses. The tipple chain is intended to run ONLY when a skip arrives at the foot of the incline, which then nudges the parked skips forward a skip length, bringing the magnet under the skip in range of the SkipArrive reed switch that sets pin 4 as ON and turns MotorRelay pin 6 ON. After cycling through the sketch, at all other times it should be waiting for a skip to turn up. But we're getting ourselves ahead of the Arduino Sketch.

Set up

Agree as suggested - The  setup in the Arduino sketch allows me to set an "initial state" that will be carried forward into the Loop section of the sketch. In the old 555-based system, depending on where the chain stopped, on power-up, some of the equipment would cycle as the magnet on the chain returned to ChainHome. With the Arduino, I can just run the chain with a "WHILE" statement to get the magnet on the chain back to Chain Home. Once the magnet reaches Chain Home, the "WHILE" statement drops out, the motor stops and everything is at a known state, ready for the next skip to arrive from the incline. 

Loop 

Case 1 - Motor start and moves skip to CAGE when skip triggers SkipArrive reedswitch

change in BOLD- I want the chain t keep running without hesitation after the magnet gets to the Skip Arrive reedswitch

void loop() {
 
//Case 1 - Motor start and moves skip to CAGE when skip triggers SkipArrive reedswitch;
  // Skip arrives at SkipArrive, start chain by MotorRelay
 if ((digitalRead (ChainHome_pin) == Reed_ON) && (digitalRead (SkipArrive_pin) == Reed_ON))
 digitalWrite (MotorRelay_pin, Switch_ON);   // start motor
  //condition when magnet moves away from ChainHome
while (digitalRead (ChainHome_pin) == Reed_OFF); // Wait until skip leaves home
while (digitalRead (SkipArrive_pin) == Reed_ON) //magnet on way to pick up skip,
    digitalWrite (MotorRelay_pin, Switch_ON);   // Continue running motor
//  We get here when digitalRead ( SkipArrive_pin) == LOW));    //skip towed away towards CAGE, caused exit of "while"
    digitalWrite (MotorRelay_pin, Switch_ON);   //  Continue running motor 
  //condition after magnet picks up skip - both ChainHome and SkipArrive reedswitches go High
while (digitalRead (ChainHome_pin) == Reed_OFF);  
while (digitalRead ( SkipArrive_pin) == Reed_OFF);
digitalWrite (MotorRelay_pin, Switch_ON);   // run motor
if (digitalRead ( Cage_pin) == Reed_ON )     //magnet on chain arrives at CAGE reedswitch, causes exit of "while" 

Case 2 - Tip skip at CAGE

Agree - The ability of the Arduino to ignore inputs comes into its own here. On the previous 555-based system, we needed 3 555 chips:

  • Chip 1 set at 5 seconds for cage moving to tip position.
  • Chip 2 set at 10 seconds for cage moving back after being tipped.
  • Chip 3 set at 26 seconds to prevent cage re-arming before previous skip has cleared the kickback points. 

 

  // Start tip - Stop chain and set CageServo_pin LOW to start tipping cycle
digitalWrite( MotorRelay_pin, Switch_OFF);   // stop motor, prepare to tip skip
digitalWrite ( CageServo_pin, Switch_ON);    // Move cage to tipped position, will take 3.5 seconds to get there  
  //hold cage at Tip position for an additional 0.5 second
delay(4000);                  // waits for 4 seconds while cage is in motion to and stable at Tip position
  //return cage to Home position aligned with track  
digitalWrite( CageServo_pin, Switch_OFF);    // Move Cage back to Home position aligned with track, will take 3.5 seconds to get there
 //wait to ensure skip and cage are aligned with track for an additional 0.5 second
delay(4000);                  // waits for 4 seconds cage is in motion to and stable at Home position aligned with rails
Lines and comments deleted from here - 
// digitalWrite(Cage_pin, Reed_OFF);   // over-ride CAGE reedswitch to prevent re-triggering    
  //start chain
digitalWrite(MotorRelay_pin, Switch_ON);   // start motor, haul skip to kickback

Case 3 - Kickback points operation

The aim here is to simulate a gravity-biased turnout, where the blades are pushed over by the wheels of the incoming skip and then reset to divert once the wheels of the skip have passed. In this case, we don't want the chain to stop. The ANE SmartSwitch is set for speed 2 - "almost instantaneous". So by the time magnet on the chain starts to roll around the sprocket at the end of its run, the blades have been reset to the diverge route, When the skip loses attraction to the magnet on the chain, gravity takes over and the skip rolls away (rapidly!!) via the diverge route.

 //empty skip approaches kickback point blades
  //set to straight path with KickbackApproach
if (digitalRead (KickbackApproach_pin) == Reed_ON) //magnet on chain arrived at KickbackApproach reedswitch
     digitalWrite ( KickbackServo_pin, Switch_ON);   //  Set track to Straight
 

  //MotorRelay pin still LOW from previous case. motor continues to run
  //remain set and allow skip to pass Kickback point blades
 //MotorRelay pin still LOW. motor continues to run
  //set to divert path with KickbackDivert
if (digitalRead (KickbackDivert_pin) == Reed_ON)  //magnet on chain arrived at KickbackDivert reedswitch
     digitalWrite ( KickbackServo_pin, Switch_OFF);   // Set track to Divert

     //MotorRelay pin still LOW. motor continues to run
//wait with motor running until magnet reaches ChainHome reedswitch   

Case 4 - Chain magnet runs back towards ChainHome after releasing skip

Agree as suggested. This gets the magnet back to ChainHome

  //stop chain when magnet gets to ChainHome
while ((digitalRead (ChainHome_pin) == Reed_OFF))   // Magnet on chain is not at ChainHome
      digitalWrite( MotorRelay_pin, Switch_ON);   // Keep looping with Motor On until magnet on chain is at ChainHome reedswitch
      digitalWrite( MotorRelay_pin, Switch_OFF);   // Magnet at ChainHome, breaks  while loop, so turn off motor
  //Wait until Case 1, when next skip arrives from the incline.
} 

So thank you again Dr Geoff for the detailed assistance. I have now have enough to programme the new Arduino 

I have one last trial to do before I de-commission the old 555-based control system. This trial involves attempting to cut in another magnet onto this chain. If (and it is a pretty BIG if) it is possible to cut in a second magnet directly opposite the first magnet on this loop of chain, then it depends just where the second magnet is when the other is at ChainHome. If the second magnet is far enough around the sprocket that it releases the skip at the top of the kick back, then it might be possible to bring the cycle time for this chain down to about 30 seconds rather than current 60 seconds or so. It currently with one magnet on the chain, it takes about 20 to 25 seconds from the time the skip rolls away at the kickback until the chain stops when the magnet reaches the Chain Home reedswitch.  

If this change is possible, then no Arduino re-programming will be required, because the second magnet will already be at Case 4 in the Sketch. When this magnet reaches Chain Home, that will stop the chain when the other magnet has gone past the kickback siding and rolled far enough around the sprocket to release the skip on the kickback (Case 4). This is going to be close. A link or 2 either way will determine if this possible. Visually I cannot afford to leave a skip "hung up" at the end of track here when  the chain stops. For an addition level of difficulty, where that second magnet stops is invisible because it and the sprocket is buried somewhere under the end of track here. 

1190096a.jpg   

Wish me luck...

So here ends Post #100. Until the next time, 

Regards,

John Garaty

Unanderra in oz

Read my Blog

Reply 0
Oztrainz

We have a win!!!

 We have a win!!!

Hi all again,

Today was a successful test after an initial hiccup of 2 (close to equally-spaced) magnets on the tipple chain. The module had to be flipped on its side 4 times. 

The first flip was to measure the length of the chain with some dobs of paint at known distances

1270450a.jpg 

That dob is 300 mm away from here - datum zero - the magnet at the ChainHome reed switch 

1270451a.jpg 

The dobs of paint help to work out where the half-way point is. There is approximately 1700 mm (5'7") of chain in this circuit and it is the smallest of the 3 skip-moving chains on this layout.

Here's what happens if you don't get the spacing right..

1270454a.jpg 

...with the skip still attracted to the magnet on chain at the far end of the kickback siding, hung up on a falling 1 in 7 (14%) grade. 

Another  2 flips were required to even the spacings of the magnets out. I'm probably within a link of being exactly evenly spaced. There is a variation in run time of about .3 of second between the 2 magnets. I can live with that. 

The start to stop time for this chain is down from about a minute to about 29 seconds as currently set up. With a planned delivery rate from the incline of about a skip a minute, the tipple chain is no longer the "rate-limiting step", because we can tip and clear the skip away and be ready to handle the next loaded skip well before it arrives off the incline.  

Next post will be more Arduino stuff,

Regards,

John Garaty

Unanderra in oz

Read my Blog

Reply 0
Oztrainz

Breadboarding done

 Breadboarding done

Hi all,

Breadboarding is now to to test the new Arduino "heart" is going to do what we think is is going to do

1270458a.jpg 

Inputs and outputs have been segregated for easier tracking of what's happening when. Outputs are LED's for indication only. Inputs have LED indication on the switch. So far no more magic smoke incidents. 

The UNO is now programmed with the final version of the sketch,  

Quote:

//  Corrimal Tipple Chain Control Circuit Final ver 1.0 ;
//  J. Garaty & G Bunza December 17 2017;
// Equipment definitions and pin assignments;
//
// Equipment definitions and pin assignments;
//
#define  ChainHome_pin   2        // D2 ChainHome has a reedswitch to ground
#define  SkipArrive_pin   4        // D4 SkipArrive has a reedswitch to ground
#define  Cage_pin   7        // D7 Cage has a reedswitch to ground
#define  KickbackApproach_pin   8        // D8 KicbackApproach has a reedswitch to ground
#define  KickbackDivert_pin   12        // D12 KickbackDivert has a reedswitch to ground
#define  CageServo_pin   3        // D3 output CageServo is output to ground for TipServo at ANE SmartSwitch
#define  KickbackServo_pin   5        // D5 output KickbackServo is output to ground for KickbackServo at ANE SmartSwitch
#define  MotorRelay_pin   6        // D6 output MotorRelay is output to ground for a relay
// defined servo pins only provide input to ANE SmartSwitch and do not drive servos
// defined MotorRelay pin interrupts supply to tipple chain motor only. Speed control is elsewhere.
// Determine chain magnet location as part of setup;
#define Reed_ON   LOW   // When a reed switch turns ON it connects to Ground GND setting pin LOW
#define Reed_OFF  HIGH  // When a reed switch is OFF the input floats open with internal pullup setting pin HIGH
#define Switch_ON  LOW   // Setting output pin LOW turns relay ON
#define Switch_OFF HIGH  // Setting output pin HIGH turns relay OFF
 
void setup() {
  // Set up conditions for power up:
pinMode ( ChainHome_pin, INPUT_PULLUP);
pinMode ( SkipArrive_pin, INPUT_PULLUP);
pinMode ( Cage_pin, INPUT_PULLUP);
pinMode ( KickbackApproach_pin, INPUT_PULLUP);
pinMode ( KickbackDivert_pin, INPUT_PULLUP);
pinMode ( CageServo_pin, OUTPUT);
pinMode ( KickbackServo_pin, OUTPUT);
pinMode ( MotorRelay_pin, OUTPUT);
digitalWrite ( CageServo_pin, Switch_OFF);       // Intialize to a known state, CageServo OFF, cage aligned with track
digitalWrite ( KickbackServo_pin, Switch_OFF);   // Intialize to a known state, kickbacksServo off, track set to Divert
digitalWrite ( MotorRelay_pin, Switch_ON);   // Intialize to a known state, MotorRrelay ON, motor start
//chain will run until magnet reaches ChainHome reed switch
while ((digitalRead ( ChainHome_pin) == Reed_OFF)) // Magnet on chain is not at ChainHome
      digitalWrite( MotorRelay_pin, Switch_ON);    // Keep looping with Motor On until magnet on chain is at ChainHome reedswitch      
      digitalWrite( MotorRelay_pin, Switch_OFF);   // Magnet at ChainHome, breaks  while loop, so turn off motor
//setup complete - ready for skips from incline
}

void loop() {
  
//Case 1 - Motor start and moves skip to CAGE when skip triggers SkipArrive reedswitch;
  // Chain is stopped with magnet at ChainHome - ChainHome reedswitch is ON, MotorRelay is OFF
  // Skip arrives at SkipArrive, SkipArrive reedswitch is ON, start chain by MotorRelay
if ((digitalRead ( ChainHome_pin) == Reed_ON) && (digitalRead ( SkipArrive_pin) == Reed_ON))
digitalWrite ( MotorRelay_pin, Switch_ON);   // start motor
  //condition when magnet moves away from ChainHome
while (digitalRead ( ChainHome_pin) == Reed_OFF); // When magnet leaves ChainHome
while (digitalRead ( SkipArrive_pin) == Reed_ON) //magnet on way to pick up skip parked at SkipArrive,
    digitalWrite ( MotorRelay_pin, Switch_ON);   // Continue running motor//  We get here when digitalRead ( SkipArrive_pin) == REED_OFF));    
    //skip towed away towards CAGE, caused exit of "while"
    digitalWrite ( MotorRelay_pin, Switch_ON);   //  Continue running motor 
  //condition after magnet picks up skip - both ChainHome and SkipArrive reedswitches go OFF/High
while (digitalRead ( ChainHome_pin) == Reed_OFF);  
while (digitalRead ( SkipArrive_pin) == Reed_OFF);
digitalWrite ( MotorRelay_pin, Switch_ON);   // run motor
if (digitalRead ( Cage_pin) == Reed_ON)     //magnet on chain arrives at CAGE reedswitch, causes exit of "while" 
 
//Case 2 - Tip skip at CAGE
  // Start tip - Stop chain and set CageServo_pin LOW to start tipping cycle
digitalWrite( MotorRelay_pin, Switch_OFF);   // stop motor, prepare to tip skip
digitalWrite ( CageServo_pin, Switch_ON);    // Move cage to tipped position, will take 3.5 seconds to get there  
  //hold cage at Tip position for an additional 0.5 second
delay(4000);                  // waits for 4 seconds while cage is in motion to and stable at Tip position
  //return cage to Home position aligned with track  
digitalWrite( CageServo_pin, Switch_OFF);    // Move Cage back to Home position aligned with track, will take 3.5 seconds to get there
 //wait to ensure skip and cage are stable and aligned with track for an additional 0.5 second
delay(4000);                  // waits for 4 seconds while cage is in motion to and stable at Home position aligned with rails
// CAGE reedswitch ignored to prevent re-triggering Tip Cycle   
//start chain
digitalWrite( MotorRelay_pin, Switch_ON);   // start motor, haul skip to kickback

//Case 3 - Kickback points operation
  //MotorRelay pin still LOW from previous case. motor continues to run
  //empty skip approaches kickback point blades
  //set to straight path with KickbackApproach
if (digitalRead ( KickbackApproach_pin) == Reed_ON) //magnet on chain arrived at KickbackApproach reedswitch
     digitalWrite ( KickbackServo_pin, Switch_ON);   //  Set track to Straight 
  //remain set and allow skip to pass Kickback point blades
  //MotorRelay pin still ON. motor continues to run
  //set to divert path with KickbackDivert
if (digitalRead ( KickbackDivert_pin) == Reed_ON)  //magnet on chain arrived at KickbackDivert reedswitch
     digitalWrite ( KickbackServo_pin, Switch_OFF);   // Set track to Divert
  //MotorRelay pin still ON. motor continues to run
  //wait with motor running until magnet reaches ChainHome reedswitch
 
//Case 4 - Chain magnet runs back towards ChainHome after releasing skip
  //stop chain when magnet gets to ChainHome 
while ((digitalRead ( ChainHome_pin) == Reed_OFF))   // Magnet on chain is not at ChainHome
      digitalWrite( MotorRelay_pin, Switch_ON);   // Keep looping with Motor On until magnet on chain is at ChainHome reedswitch
      digitalWrite( MotorRelay_pin, Switch_OFF);   // Magnet at ChainHome, breaks  while loop, so turn off motor
  //Wait until Case 1, when next skip arrives from the incline.
}

 We also now have a QAD  (Quick & Dirty) video of the revised set-up with 2 magnets in action, 

At the start of the cycle both magnets are beyond the kickback siding and in Case 4. 

Regards,

John Garaty

Unanderra in oz

Read my Blog

Reply 1
Oztrainz

Well that was fun - not..

 Well that was fun - not..

Hi all,

Testing resumed in earnest today after several sporadic attempts to get stuff to happen Arduino-wise. 

At close of play today, the heart transplant looks like it is on indefinite hold. 

So far I have not been able to get a valid output for the motor relay and the other 2 servo outputs aren't doing what they're supposedly being told either.  The frustration level is compounded because the telltales on the breadboard aren't telling their tales either...So I now have a black box doing unspecified and undesired black magic.

Some pictures that might tell the story - an overall view. Pin numbers have been added to each input and output, with inputs on left and outputs on right of the central divide in the breadboard.

1270596a.jpg 

 Kickback and Cage Servos are energised and the 5V Arduino-friendly relay is active. The whole shebang is powered via the Arduino under another shield.

Now according to my reading of the way we wrote the sketch, this outcome with the Cage Servo permanently on should not be possible. 

A closer view showing the unlit motor Servo indicator and the yellow Chain Home and  white Skip Arrive switches

1270597a.jpg 

The yellow and white leads heading out the the right connect to the Arduino. 

I'm open to suggestions - this type of stuff should not be happening and I'm not cutting wires for the heart transplant until I've got something that looks like it is doing what it is told. 

Regards,

John Garaty

Unanderra in oz

Read my Blog

Reply 0
Geoff Bunza geoffb

@John re:Wiring Problems

@John re: Wiring Problems

Hi John,

I think you need to re-look at your wiring again.

First, I think you have confused the labeling and pin locations on your prototyping board. All my observations are from your last pitures, and many of the wiring locations are obscured and out of focus, so I may not be correct in all comments, but I will try to explain nonetheless:
-- I assume you are connecting to the prototyping board via the sockets/pins which extend down to the Uno.
-- Look at the yellow wire -- it does not look like it goes into D2 but rather D1 or D0. Before you disassemble the wires, look at the Arduino Uno picture you posted and note the numbers on the Uno board. At the top right of your pic it starts with D0, D1, D2, ... to the left. This is the correct order and numbering which works up to your prototyping board on top. The numbers on your prototyping board refer to the added holes/pads NOT the original sockets you are connecting to. Go back and re-check all the pin connections for errors against the UNO pin numbering only. Your connections in your new pic don't look right, but they may be obscured.
-- Now it looks like you wired your pushbuttons like this:
ohn-PBng.jpg not like ohn-PBok.jpg 
The left pic is wrong, the right pic is correct.
The wiring errors will give you untold grief.
If you still have problems, please take more pics and post them. Try to get pics where the wiring connections are absolutely clear.
 
Have fun! 
Best regards,
Geoff
 

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Oztrainz

The saga continues...

 The saga continues...

Hi Dr Geoff, and all those who are hanging in there watching from the sidelines,

On checking the switches were wired incorrectly so they all got re-wired like the yellow ChainHome switch

1270601a.jpg 

Where - for INPUT (switches) :

60j = +5V feed from adjacent 60Red+

60h = jumper to switch input at 57j

60f = from Arduino Pin2

​55j = switch output tell-tale with resistor on anode leg of LED

53i = cathode leg of LED

53j = jumper to ground at 53Blue-

RED+ and BLUE- are respectively fed from +5v and GROUND at the Arduino

For OUTPUTS (feeds to relay and servo controller​)

53a - MotorRelay output from Arduino Pin 6

The LED tell-tale is lit when a switch is depressed. This verifies that the switch is working to Ground

1270602a.jpg 

I think all switches are now correctly wired. All tell-tale LED's light when the respective switch is activated. 

And now to the Arduino bit - The shield was removed and the wires were directly connected to the Arduino as shown below

A wider view shows the orange +5v and blue Ground wires at bottom of the photo. These power the +5V and - (Ground) feeders on the breadboard. The green ON and yellow L LED's were steady and not flickering. The knurled silver blob at bottom left is the regulated 12V supply.

1270598a.jpg 

A closer look at the top    

1270599a.jpg 

Pin 2 - Yellow to yellow ChainHome switch on breadboard

Pin 3 - Purple to CageServo output

Pin 4 - White to white Skip Arrive switch on breadboard

Pin 5 - Brown to KickbackServo output

Pin 6 -Grey to MotorRelay output

Pin 7 - Red to red Cage switch on breadboard

Pin 8 - Green to green Kickback Arrive switch

Pin 12 - Black to black KickbackDivert switch 

All pins verified as correctly placed at Arduino and at breadboard

and got exactly the same result as yesterday 

1270603a.jpg 

with the kickback and cage servo outputs permanently lit and the MotorRelay LED unable to lit. The LED was checked in one of the other 2 outputs. No the fault was not that LED. 

Various switch combinations were tried both according to the script supposedly contained in the sketch and later as unscripted random combinations in unsuccessful  attempts to get "anything" to change. This included multiple power-up cycles that should have triggered the "setup" part of the sketch which should have triggered MotorRelay according to the Sketch. 

The tipple servo should only go on for 4 seconds when the Cage switch is activated - not be permanently on as indicated by the lit tell-tale LED

The KickbackServo output LED should only be alight when the KickbackApproach switch is activated and should go out the the Kickback Divert switch is activated. It remained stubbornly lit at all times.   

On Power-up, the Arduino LED indicators would come up then about 2 seconds later the LED's on the breadboard would light up. 

There is some black magic happening around this black box that I can't get my head around. 

So later tonight I plugged the Arduino in to the USB on my computer and attempted to reload the sketch. At first the sketch complied OK but failed to load with a .COM error.

The Arduino was de-wired unplugged and reattached to the computed and the IDE was shut down and restarted. This time it looked like the sketch was reloaded to the Arduino  And then I got the same result as in the last photo above 

Einstein had something to say about repeating experiments and expecting different outcomes. I'm rapidly starting to agree with him.

It looks like the heart transplant for the tipple is on hold for the immediate foreseeable future.  

Someone once said you can make systems fool-proof but you can't make the idiot-proof, because idiots are too darn inventive. I didn't think I was that inventive, but I could be wrong...

Regards,

John Garaty

Unanderra in oz

Read my Blog

Reply 1
Craig Townsend

John,Keep plugging along,

 

John, Keep plugging along, you will get it. Eventually. Craig

Reply 0
Geoff Bunza geoffb

@John G re:Wiring Errors

@John G re: Wiring Errors

Hi John,

You're not quite there yet.
Here is what you wired:
hn2wired.jpg 
Unfortunately, this always provides a "HIGH" or logical 1 to the Arduino. If you want to keep the LED indicator use:
John2ok.jpg 
After rewiring all the pushbuttons correctly, power on the Arduino and do not touch the pushbuttons.
Please describe exactly what happens. Then activate only one pushbutton at a time as the sensors ought to behave and describe each reaction.
 
Have fun! 
Best regards,
Geoff

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 1
pierre52

Patience Grasshopper.

Patience Grasshopper

John you will get there. It will be an interesting and frustrating journey but the elation when it works will make it all worthwhile.

Dr Geoff is your Mr Miyagi so just remember " wax on, wax off"

Peter

The Redwood Sub

Reply 0
Oztrainz

Hmmm

 Hmmm - The Clarkson Effect

Hi all,

Maybe I shouldn't have asked previously "How hard can it be?? I've been nobbled by the Clarkson effect. 

(For anyone who doesn't get the gag - try a YouTube search for Jeremy Clarkson and "Top Gear")

There's probably a few more mistakes out there that I have yet to make...Thanks Dr Geoff for your patience and forbearance. 

Rewiring about to commence before breakfast..."Wax on.. Wax off"

Regards,

John Garaty

Unanderra in oz

Read my Blog

Reply 0
Oztrainz

Report Back

 Report Back

Hi Dr Geoff and all,

Tell-tales on switches have been re-wired. On powering up via USB from computer: 

  1. the same result as last time with CageServo and Kickback Servo outputs live as indicated by tell-tale LED's.  MotorRelay LED remained unlit
  2. On pressing ChainHome switch - No effect  This should simulate the chain running and being stopped with the magnet at the ChainHome reed switch in Set-up
  3. On pressing ChainHome again - No effect 
  4. On pressing both ChainHome and SkipArrive switches to simulate the start of Loop: CageServo output goes out for 4 seconds (This should happen from the Cage Switch) No other change, MotorRelay remains unlit and Kickback Servo remains lit
  5. On Pressing Cage switch  -  NO change  MotorServo unlit, both CageServo and KickbackServo LED's remain lit
  6. On pressing Kickback Arrive switch - NO change  MotorServo unlit, both CageServo and KickbackServo LED's remain lit
  7. On pressing KIckbackDivert switch - NO change  MotorServo unlit, both CageServo and KickbackServo LED's remain lit
  8. On pressng ChainHome switch - NO change  MotorServo unlit, both CageServo and KickbackServo LED's remain lit

​This should end the sequence. 

I'm not sure where this leaves us?

Regards,

John Garaty

Unanderra in oz

Read my Blog

Reply 0
Geoff Bunza geoffb

@John G

@John G

Hi John,

Please post the exact, unmodified sketch you loaded into your Uno, or check that it is exactly the last one you posted.

Best regards,

Geoff

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Geoff Bunza geoffb

@John G

@John G

One more point: Please note that your motor relay LED indicator (gray wire) was wired backwards from the other 2 LED indicators. You had the other side of the LED to +5V not Ground like the lower two.

After all your changes you should post new overall pics too.

Best regards,

Geoff

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Geoff Bunza geoffb

@John G

@ John G

One more thing John, when you finish rewiring and start to "simulate" the operation, remember since you are using pushbuttons for the sensors, and the Arduino is running about 1,000,000 times as fast as your finger reaction time, you will have to keep pressing the pushbutton to hold the "sensor" in place. Even a little jiggle will be picked up as a "move" off the sensor. The cage home button is one such obvious issue.

Best regards,

Geoff

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Oztrainz

RE grey wiring and Sketch

 RE grey wiring and Sketch

Hi Dr Geoff,

Just checked

grey wire from Arduino > anode leg of LED> cathode leg of LED> blue wire jumper to Ground. 

Here is what I think we have loaded into the Arduino, copied from the IDE this morning after loading to Arduino was successfully completed last night. No changes or saves have been done since loading.  

Quote:

//  Corrimal Tipple Chain Control Circuit Final ver 1.0 ;
//  J. Garaty & G Bunza December 17 2017;
// Equipment definitions and pin assignments;
//
// Equipment definitions and pin assignments;
//
#define  ChainHome_pin   2        // D2 ChainHome has a reedswitch to ground
#define  SkipArrive_pin   4        // D4 SkipArrive has a reedswitch to ground
#define  Cage_pin   7        // D7 Cage has a reedswitch to ground
#define  KickbackApproach_pin   8        // D8 KicbackApproach has a reedswitch to ground
#define  KickbackDivert_pin   12        // D12 KickbackDivert has a reedswitch to ground
#define  CageServo_pin   3        // D3 output CageServo is output to ground for TipServo at ANE SmartSwitch
#define  KickbackServo_pin   5        // D5 output KickbackServo is output to ground for KickbackServo at ANE SmartSwitch
#define  MotorRelay_pin   6        // D6 output MotorRelay is output to ground for a relay
// defined servo pins only provide input to ANE SmartSwitch and do not drive servos
// defined MotorRelay pin interrupts supply to tipple chain motor only. Speed control is elsewhere.
// Determine chain magnet location as part of setup;
#define Reed_ON   LOW   // When a reed switch turns ON it connects to Ground GND setting pin LOW
#define Reed_OFF  HIGH  // When a reed switch is OFF the input floats open with internal pullup setting pin HIGH
#define Switch_ON  LOW   // Setting output pin LOW turns relay ON
#define Switch_OFF HIGH  // Setting output pin HIGH turns relay OFF
 
void setup() {
  // Set up conditions for power up:
pinMode ( ChainHome_pin, INPUT_PULLUP);
pinMode ( SkipArrive_pin, INPUT_PULLUP);
pinMode ( Cage_pin, INPUT_PULLUP);
pinMode ( KickbackApproach_pin, INPUT_PULLUP);
pinMode ( KickbackDivert_pin, INPUT_PULLUP);
pinMode ( CageServo_pin, OUTPUT);
pinMode ( KickbackServo_pin, OUTPUT);
pinMode ( MotorRelay_pin, OUTPUT);
digitalWrite ( CageServo_pin, Switch_OFF);       // Intialize to a known state, CageServo OFF, cage aligned with track
digitalWrite ( KickbackServo_pin, Switch_OFF);   // Intialize to a known state, kickbacksServo off, track set to Divert
digitalWrite ( MotorRelay_pin, Switch_ON);   // Intialize to a known state, MotorRrelay ON, motor start
//chain will run until magnet reaches ChainHome reed switch
while ((digitalRead ( ChainHome_pin) == Reed_OFF)) // Magnet on chain is not at ChainHome
      digitalWrite( MotorRelay_pin, Switch_ON);    // Keep looping with Motor On until magnet on chain is at ChainHome reedswitch      
      digitalWrite( MotorRelay_pin, Switch_OFF);   // Magnet at ChainHome, breaks  while loop, so turn off motor
//setup complete - ready for skips from incline
}

void loop() {
  
//Case 1 - Motor start and moves skip to CAGE when skip triggers SkipArrive reedswitch;
  // Chain is stopped with magnet at ChainHome - ChainHome reedswitch is ON, MotorRelay is OFF
  // Skip arrives at SkipArrive, SkipArrive reedswitch is ON, start chain by MotorRelay
if ((digitalRead ( ChainHome_pin) == Reed_ON) && (digitalRead ( SkipArrive_pin) == Reed_ON))
digitalWrite ( MotorRelay_pin, Switch_ON);   // start motor
  //condition when magnet moves away from ChainHome
while (digitalRead ( ChainHome_pin) == Reed_OFF); // When magnet leaves ChainHome
while (digitalRead ( SkipArrive_pin) == Reed_ON) //magnet on way to pick up skip parked at SkipArrive,
    digitalWrite ( MotorRelay_pin, Switch_ON);   // Continue running motor//  We get here when digitalRead ( SkipArrive_pin) == REED_OFF));    
    //skip towed away towards CAGE, caused exit of "while"
    digitalWrite ( MotorRelay_pin, Switch_ON);   //  Continue running motor 
  //condition after magnet picks up skip - both ChainHome and SkipArrive reedswitches go OFF/High
while (digitalRead ( ChainHome_pin) == Reed_OFF);  
while (digitalRead ( SkipArrive_pin) == Reed_OFF);
digitalWrite ( MotorRelay_pin, Switch_ON);   // run motor
if (digitalRead ( Cage_pin) == Reed_ON)     //magnet on chain arrives at CAGE reedswitch, causes exit of "while" 
 
//Case 2 - Tip skip at CAGE
  // Start tip - Stop chain and set CageServo_pin LOW to start tipping cycle
digitalWrite( MotorRelay_pin, Switch_OFF);   // stop motor, prepare to tip skip
digitalWrite ( CageServo_pin, Switch_ON);    // Move cage to tipped position, will take 3.5 seconds to get there  
  //hold cage at Tip position for an additional 0.5 second
delay(4000);                  // waits for 4 seconds while cage is in motion to and stable at Tip position
  //return cage to Home position aligned with track  
digitalWrite( CageServo_pin, Switch_OFF);    // Move Cage back to Home position aligned with track, will take 3.5 seconds to get there
 //wait to ensure skip and cage are stable and aligned with track for an additional 0.5 second
delay(4000);                  // waits for 4 seconds while cage is in motion to and stable at Home position aligned with rails
// CAGE reedswitch ignored to prevent re-triggering Tip Cycle   
//start chain
digitalWrite( MotorRelay_pin, Switch_ON);   // start motor, haul skip to kickback

//Case 3 - Kickback points operation
  //MotorRelay pin still LOW from previous case. motor continues to run
  //empty skip approaches kickback point blades
  //set to straight path with KickbackApproach
if (digitalRead ( KickbackApproach_pin) == Reed_ON) //magnet on chain arrived at KickbackApproach reedswitch
     digitalWrite ( KickbackServo_pin, Switch_ON);   //  Set track to Straight 
  //remain set and allow skip to pass Kickback point blades
  //MotorRelay pin still ON. motor continues to run
  //set to divert path with KickbackDivert
if (digitalRead ( KickbackDivert_pin) == Reed_ON)  //magnet on chain arrived at KickbackDivert reedswitch
     digitalWrite ( KickbackServo_pin, Switch_OFF);   // Set track to Divert
  //MotorRelay pin still ON. motor continues to run
  //wait with motor running until magnet reaches ChainHome reedswitch
 
//Case 4 - Chain magnet runs back towards ChainHome after releasing skip
  //stop chain when magnet gets to ChainHome 
while ((digitalRead ( ChainHome_pin) == Reed_OFF))   // Magnet on chain is not at ChainHome
      digitalWrite( MotorRelay_pin, Switch_ON);   // Keep looping with Motor On until magnet on chain is at ChainHome reedswitch
      digitalWrite( MotorRelay_pin, Switch_OFF);   // Magnet at ChainHome, breaks  while loop, so turn off motor
  //Wait until Case 1, when next skip arrives from the incline.
}

Is there something hokey about which pins I have assigned to to what?? There shouldn't be, but??  

Regards,

John Garaty

Unanderra in oz

Read my Blog

Reply 0
Geoff Bunza geoffb

@John G

@John G

OK. Check the following - DO NOT LET GO BETWEEN THE FOLLOWING STEPS:

When you power up, no buttons pushed you should get: top to bottom 3 LEDs

Power on -- off-on-on

push AND hold yellow PB -- on-on-on

hold yellow PB now push and hold white PB -- off-on-on

now continue holding white PB and release only yellow PB -- off-on-on

now release white PB - on-on-on

Does all this happen?

Now look at this section of the sequence:

while (digitalRead ( ChainHome_pin) == Reed_OFF);  
    while (digitalRead ( SkipArrive_pin) == Reed_OFF);
    digitalWrite ( MotorRelay_pin, Switch_ON);   // run motor
    if (digitalRead ( Cage_pin) == Reed_ON)     //magnet on chain arrives at CAGE reedswitch, causes exit of "while"
     
    //Case 2 - Tip skip at CAGE
      // Start tip - Stop chain and set CageServo_pin LOW to start tipping cycle
    digitalWrite( MotorRelay_pin, Switch_OFF);   // stop motor, prepare to tip skip
    digitalWrite ( CageServo_pin, Switch_ON);    // Move cage to tipped position, will take 3.5 seconds to get there  
      //hold cage at Tip position for an additional 0.5 second

This does not look correct to me. What is the correct action at this point? That is what do you want it to do in plain words?

Best regards,
Geoff

 

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Oztrainz

Still no joy

 Still no joy

Hi Dr Geoff,

power-up: off - on- on 

Press and hold yellow ChainHome - no change  - off - on- on

Press and hold yellow ChainHome and white SkipArrive - Off - out for 4 seconds and then continuously on - on

(Comment - this looks like the tipple servo firing. That should happen from the red Cage switch)

Release yellow ChainHome but hold white SkipArrive -  no change  - off - on- on

Release white SkipArrive -  no change  - off - on- on 

 

As an additional test of the wiring for the output tell-tales - I swapped the grey and red wires at the breadboard. Both tell-tales are correctly wired and functional. The grey lead from the Arduino is as dead as a dodo. 

I also tested: 

Press red Cage and hold for 5 seconds or so - no change  - off - on- on

Press green KickbackApproach and hold for 5 seconds or so - no change  - off - on- on

Press black Kickback Divert and hold for 5 seconds or so - no change  - off - on- on. 

What should happen: 

At powerup - setup is triggered and MotorRelay should trigger the motor moving the chain to run until Chain Home is activated. 

The trigger for everything else in Loop is when:

ChainHome is activated  AND SkipArrive is activated by an incoming skip. This should trigger MotorRelay and start the motor moving the chain. 

As soon as the chain starts to move ChainHome will deactivate but SkipArrive still is activated. MotorRelay remains active and the motor moving the chain continues to run.

When the magnet on the chain passes SkipArrive and picks up the skip, Skip Arrive will deactivate but MotorRelay should remain active and the motor moving the chain continues to run, moving the skip along the tipple deck towards the tipple cage. 

The complication starts when the skip arrives at the tipple cage and activates the Cage reedswitch. Cage does 2 things:

  1. stops the chain by turning MotorRelay off for a defined time of 8 seconds composed of 2 by 4 second "delay" intervals, then restarts the chain after the 8 seconds times out. 
  2. initiates the tip cycle by passing a signal via Pin 3 CageServo to the ANE Switchmaster controlling the tipple Servo.The tip cycle commences immediately but takes approx 3.5 seconds for the cage to travel to the "tipped" position. At the end of 4 seconds, the CageServo signal is removed. This allows the tipple servo to bring the cage back to the home position so that the skip will be settled and aligned with the rails by the time the 8 seconds times out and the chain restarts by MotorRelay going active again.

The motor continues to run after it is restarted and moves the now empty skip towards the kickback siding.

When the skip arrives at KickbackApproach Pin 5 triggers Pin 8  which feeds a signal to the ANE Switchmaster servo controlling the kickback points to set the road to straight. This signal remains on until Kickback divert turns it off. The ANE SwitchMaster settings for this servo are set at "almost instantaneous" so the blades at the turnout do not need a delay built in like at the tipple cage. 

The motor continues to run until a magnet on the chain reaches ChainHome. This stops the motor by setting Motor Relay to off. 

The cycle is complete. Nothing can (should) happen until the next skip arrives triggering the AND condition of both Chain Home and Skip Arrive being activated.  

I hope that this is starting to make some sense. I know what I want to do and it looks like the sketch "should" do it (at least it does in my head).

Regards,

John Garaty

Unanderra in oz

Read my Blog

Reply 0
Geoff Bunza geoffb

@John G re: Updated Sketch

@John G re: Updated Sketch

Hi John,

Your last post was most instructive. Please find below an updated sketch that should do precisely what you specified. Please note that I have incorporated in the comments all of your directions in the last post as step by step comments below. Try it out, and review the comments. I think they are completely consistent with the code.
You used a couple of "if" statements which make only one test and then continue without waiting. There were some redundant statement too which I eliminated. If you remove all the comments you will find this is actually a fairly simple sketch!
 
The key for you to remember is that the following example statement:
while ( digitalRead ( ReedSensor_pin ) == Reed_OFF )  ;
will wait looping at this statement until the ReedSensor at the specific pin turns ON
If this were an "if" statement the ReedSensor would be tested once with no looping/waiting involved.
The sketch was checked for correct compilation. If it does not do what you need, go back and change the English (Australian) in your last post and we can go from there.
Let us know how it goes. Have fun! 
Best regards,
Geoff
 

    //  Corrimal Tipple Chain Control Circuit ver 4.0
    //  J. Garaty & G Bunza   January 29 2018
    // Equipment definitions and pin assignments
    //
    // Equipment definitions and pin assignments
    //
    #define  ChainHome_pin   2        // D2 ChainHome has a reedswitch to ground         yel
    #define  SkipArrive_pin   4        // D4 SkipArrive has a reedswitch to ground       wht
    #define  Cage_pin   7        // D7 Cage has a reedswitch to ground        red
    #define  KickbackApproach_pin   8        // D8 KicbackApproach has a reedswitch to ground       grn
    #define  KickbackDivert_pin   12        // D12 KickbackDivert has a reedswitch to ground           blk
    #define  CageServo_pin   3        // D3 output CageServo is output to ground for TipServo at ANE SmartSwitch       prpl
    #define  KickbackServo_pin   5        // D5 output KickbackServo is output to ground for KickbackServo at ANE SmartSwitch   brn
    #define  MotorRelay_pin   6        // D6 output MotorRelay is output to ground for a relay               gry
    // defined servo pins only provide input to ANE SmartSwitch and do not drive servos
    // defined MotorRelay pin interrupts supply to tipple chain motor only. Speed control is elsewhere.
    // Determine chain magnet location as part of setup;
    #define Reed_ON   LOW   // When a reed switch turns ON it connects to Ground GND setting pin LOW
    #define Reed_OFF  HIGH  // When a reed switch is OFF the input floats open with internal pullup setting pin HIGH
    #define Switch_ON  LOW   // Setting output pin LOW turns relay ON
    #define Switch_OFF HIGH  // Setting output pin HIGH turns relay OFF
    void setup() {
      // Set up conditions for power up:
    pinMode ( ChainHome_pin, INPUT_PULLUP);  //yel
    pinMode ( SkipArrive_pin, INPUT_PULLUP); //wht
    pinMode ( Cage_pin, INPUT_PULLUP);       //red
    pinMode ( KickbackApproach_pin, INPUT_PULLUP);  //grn
    pinMode ( KickbackDivert_pin, INPUT_PULLUP);    //blk
    pinMode ( CageServo_pin, OUTPUT);        // prpl
    pinMode ( KickbackServo_pin, OUTPUT);    // brn
    pinMode ( MotorRelay_pin, OUTPUT);       // gry
    digitalWrite ( CageServo_pin, Switch_OFF);       // Intialize to a known state, CageServo OFF, cage aligned with track
    digitalWrite ( KickbackServo_pin, Switch_OFF);   // Intialize to a known state, kickbacksServo off, track set to Divert
    /*
    At powerup - setup is triggered and MotorRelay should trigger the motor moving the chain to run until Chain Home is activated.
    */
    while ((digitalRead ( ChainHome_pin) == Reed_OFF)) // Magnet on chain is not at ChainHome
          digitalWrite( MotorRelay_pin, Switch_ON);    // Keep looping with Motor On until magnet on chain is at ChainHome reedswitch      
    
    digitalWrite( MotorRelay_pin, Switch_OFF);   // Magnet at ChainHome, breaks  while loop, so turn off motor
    //setup complete - ready for skips from incline
    }

    void loop() {
    //ChainHome is activated  AND SkipArrive is activated by an incoming skip. This should trigger MotorRelay and start the motor moving the chain.   
    while ((digitalRead ( ChainHome_pin) == Reed_OFF)

|| (digitalRead ( SkipArrive_pin) == Reed_OFF)); // wait
    // when we get here ChainHome is ON and SkipArrive in ON
    digitalWrite ( MotorRelay_pin, Switch_ON);   // Turn motor ON and it stays ON
    //As soon as the chain starts to move ChainHome will deactivate but SkipArrive still is activated.
    //MotorRelay remains active and the motor moving the chain continues to run.
    while (digitalRead ( ChainHome_pin) == Reed_OFF); // When magnet leaves ChainHome deactivates wait for it
    // When the magnet on the chain passes SkipArrive and picks up the skip
    // Skip Arrive will deactivate but MotorRelay should remain ON and
    //the motor moving the chain continues to run, moving the skip along the tpple deck towards the tipple cage.
    //The complication starts when the skip arrives at the tipple cage and activates the Cage reedswitch
    
    while (digitalRead ( Cage_pin) == Reed_OFF) ;     //wait until magnet on chain arrives at CAGE reedswitch
    // We get here when magnet on chain arrives at CAGE reedswitch
    
    //Case 2 - Tip skip at CAGE
    // Cage does 2 things:
    // stops the chain by turning MotorRelay off for a defined time of 8 seconds
    // composed of 2 by 4 second "delay" intervals, then restarts the chain after the 8 seconds times out.
    // Start tip - Stop chain and set CageServo_pin LOW to start tipping cycle
    // initiates the tip cycle by passing a signal via Pin 3 CageServo to the ANE Switchmaster controlling the tipple Servo.
    // The tip cycle commences immediately but takes approx 3.5 seconds for the cage to travel to the "tipped" position.
    digitalWrite( MotorRelay_pin, Switch_OFF);   // stop motor, prepare to tip skip
    digitalWrite ( CageServo_pin, Switch_ON);    // Move cage to tipped position, will take 3.5 seconds to get there  
    //hold cage at Tip position for an additional 0.5 second
    delay(4000);                  // waits for 4 seconds while cage is in motion to and stable at Tip position
    //return cage to Home position aligned with track  
    // At the end of 4 seconds, the CageServo signal is removed.
    // This allows the tipple servo to bring the cage back to the home position
    // so that the skip will be settled and aligned with the rails by the time the 8 seconds times out
    // and the chain restarts by MotorRelay going active again.
    digitalWrite( CageServo_pin, Switch_OFF);    // Move Cage back to Home position aligned with track, will take 3.5 seconds to get there
    //wait to ensure skip and cage are stable and aligned with track for an additional 0.5 second
    delay(4000);                  // waits for 4 seconds while cage is in motion to and stable at Home position aligned with rails
    // CAGE reedswitch ignored to prevent re-triggering Tip Cycle   
    //start chain
    digitalWrite( MotorRelay_pin, Switch_ON);   // start motor, haul skip to kickback
    // The motor continues to run after it is restarted and moves the now empty skip towards the kickback siding
    
    //Case 3 - Kickback points operation
      //MotorRelay pin still LOW from previous case. motor continues to run
      //empty skip approaches kickback point blades
      //set to straight path with KickbackApproach
    // When the skip arrives at KickbackApproach Pin 5 triggers Pin 8  which feeds a signal to the ANE Switchmaster servo controlling
    while (digitalRead ( KickbackApproach_pin) == Reed_OFF) ; // wait until magnet on chain arrives at KickbackApproach reedswitch
    // We get here when magnet on chain arrives at KickbackApproach reedswitch
    // the kickback points to set the road to straight. This signal remains on until Kickback divert turns it off.
    digitalWrite ( KickbackServo_pin, Switch_ON);   //  Set track to Straight
    //remain set and allow skip to pass Kickback point blades
    //MotorRelay pin still ON. motor continues to run
    //set to divert path with KickbackDivert
    // The ANE SwitchMaster settings for this servo are set at "almost instantaneous" so the blades at the turnout do not need a delay built in like at the tipple cage.
    while (digitalRead ( KickbackDivert_pin) == Reed_OFF) ;  //wait until magnet on chain arrives at KickbackDivert reedswitch
    //we get here when magnet on chain arrives at KickbackDivert reedswitch so KickbackDivert is now ON
    digitalWrite ( KickbackServo_pin, Switch_OFF);   // Set track to Divert
    // MotorRelay pin still ON. motor continues to run
    
    //Case 4 - Chain magnet runs back towards ChainHome after releasing skip
    //stop chain when magnet gets to ChainHome
    // The motor continues to run until a magnet on the chain reaches ChainHome. This stops the motor by setting Motor Relay to off.
    while ((digitalRead ( ChainHome_pin) == Reed_OFF)) ;  // wait until Magnet on chain is  at ChainHome
    // we get here when Magnet on chain is  at Magnet on chain is  at ChainHome so ChainHome is ON
    digitalWrite( MotorRelay_pin, Switch_OFF);   // Magnet is  at ChainHome, so turn off motor
    // This ends the loop so go back and restart at Case 1 above  when next skip arrives from the incline.
    // The cycle is complete. Nothing can (should) happen until the next skip arrives triggering the AND condition
    // of both Chain Home and Skip Arrive being activated.  
    }

 

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Oztrainz

Some overnight changes

 Some overnight changes

Hi all again,

Thank you again Dr Geoff. I'm digesting the revised sketch. I'll try to upload the new sketch later today. After testing and when most of the process comments are removed, yes the sketch should compact down considerably.. I'll give it a go on the current breadboard later today.

Overnight, in consultation with my build partner, Guy, we decided to take the breadboarding one step further. We will set up another ANE Switchmaster and servos to replicate the set up on the layout. We will also set up a spare motor and the relay controlling the motor. This will also replicate what we have on the layout. The tell-tale LED's on the outputs will be replaced with the real gear that the outputs have to drive. 

It may take a couple of days for me to track down and set up all this other gear for a full test. 

Once we have all this running satisfactorily, only then we'll look at doing the heart transplant.   

Thanks again,

Regards,

John Garaty

Unanderra in oz

Read my Blog

Reply 0
Geoff Bunza geoffb

@John G re: Updated Sketch

@John G re: Updated Sketch

John,

You do not have to remove the comments (in fact it is a bad idea to do so) -- they are for the readers eyes only. The compiler building the code ignores every one! I was only trying to point out the amount of comments.
Good luck! and have fun! 
Best regards,
Geoff

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Oztrainz

Yeah

 Yeah (programme comments)

Hi Dr Geoff and all,

I realize that the comments play no part in the actual program that drives the Arduino, but...

I do seem to have this innate ability to over-describe what probably should have been:

Start Here> pick up skip when it arrives> go to There> STOP> tip coal out of skip> go back to Here the long way round> change a turnout as you arrive> change a turnout after you've passed it> Stop Here and wait for the next skip..  

Simple isn't it?? The key is to realize that the skip is simply along for the ride. Getting the under-track chain to do the moving at the right time to the right place is the key to a successful "Hands-off" tipple operation (automation?).

It took weeks with another of the team to describe that, and, then to design and build the original 555-based control circuitry as well as concurrently build a "tipper outer" that actually would tip coal without  spraying it everywhere, and then to try and tie it all together. And concurrently, we had to design and build the skips, That's all part of the build saga that is yet to appear here, if anyone hangs around to read all about it. . 

At present I'm kind of glad that I have a few of you here looking over my shoulder,

Regards,

John Garaty

Unanderra in oz

Read my Blog

Reply 0
Oztrainz

Report Back - A stumble in Case 3

 Report Back - A stumble in Case 3

HI Dr Geoff and all, 

Almost got there and I'm not too sure why we didn't. 

I'm using these to control the outputs of the Arduino. They have a red indicator LED when the relay is energised. 

For the controlling the the power to the 12V DC chain motor, they are an obvious choice. For the outputs going to the SmartSwitch, the relay on each output is effectively working as a toggle switch to control the ANE Smartswitch servos at the tipple cage and kickback. 

So on Power-up, Set Up is initiated. 

  • MotorRelay indicator light - Off - Motor is running
  • CageServo indicator light - On - Cage at home position and aligned with track
  • KickbackServo indicator light - On - Track set to Divert route 
  • expected outputs - PASS

On pressing Yellow ChainHome switch: 

  • MotorRelay indicator light - On - Motor is stopped
  • CageServo indicator light - On - Cage at home position and aligned with track
  • KickbackServo indicator light - On - Track set to Divert route 
  • expected outputs - PASS
  • This is (should be) the default start position for Loop every time.

On pressing BOTH Yellow ChainHome and White SkipArrive switches:

  • MotorRelay indicator light - Off - Motor is running
  • CageServo indicator light - On - Cage at home position and aligned with track
  • KickbackServo indicator light - On - Track set to Divert route 
  • expected outputs - PASS
  • This is the AND condition that triggers the Loop part of the sketch. - PASS

On pressing Red Cage switch: 

  • MotorRelay indicator light - is On for 8 seconds and then goes out (Motor stopped for tip cycle)
  • CageServo indicator light - is Off for 4 seconds and then comes back on  - Tipple cage travels to Tip position, holds and returns to Home position aligned with track
  • KickbackServo indicator light - On - Track set to Divert route 
  • expected outputs - PASS

On pressing Green Kickback_Approach switch:

  • MotorRelay indicator light - Off - Motor is running
  • CageServo indicator light - On - Cage at home position and aligned with track
  • KickbackServo indicator light - Off - Track set to straight route 
  • expected outputs - PASS

On pressing Black Kickback_Divert switch:

  • MotorRelay indicator light - Off - Motor is running
  • CageServo indicator light - On - Cage at home position and aligned with track
  • KickbackServo indicator light - OFF - Track fails to reset to Divert route, 
  • FAIL - Sketch stalls and is unable to exit to Case 4. Yellow ChainHome switch fails to operate to stop the motor.. We now have a runaway system where the motor continues to run but everything else is disabled
  • The FAIL is repeatable. Either using the Reset switch on the Arduino or a power disconnect/reconnect, Relays have been swapped to prove that its not a flaky relay. Using just the Arduino itself or with the extra shield to power the relays,. the sketch always breaks in the same place... 

Case 3 part of sketch is as follows:

Quote:

//Case 3 - Kickback points operation
      //MotorRelay pin still LOW from previous case. motor continues to run
      //empty skip approaches kickback point blades
      //set to straight path with KickbackApproach
    // When the skip arrives at KickbackApproach Pin 5 triggers Pin 8  which feeds a signal to the ANE Switchmaster servo controlling
    while (digitalRead ( KickbackApproach_pin) == Reed_OFF) ; // wait until magnet on chain arrives at KickbackApproach reedswitch
    // We get here when magnet on chain arrives at KickbackApproach reedswitch
    // the kickback points to set the road to straight. This signal remains on until Kickback divert turns it off.
    digitalWrite ( KickbackServo_pin, Switch_ON);   //  Set track to Straight
    //remain set and allow skip to pass Kickback point blades
    //MotorRelay pin still ON. motor continues to run
    //set to divert path with KickbackDivert
    // The ANE SwitchMaster settings for this servo are set at "almost instantaneous" so the blades at the turnout do not need a delay built in like at the tipple cage.
    while (digitalRead ( KickbackDivert_pin) == Reed_OFF) ;  //wait until magnet on chain arrives at KickbackDivert reedswitch
    //we get here when magnet on chain arrives at KickbackDivert reedswitch so KickbackDivert is now ON
    digitalWrite ( KickbackServo_pin, Switch_OFF);   // Set track to Divert
    // MotorRelay pin still ON. motor continues to run

If the comments are removed the programming part of this bit the sketch condenses to::

Quote:

//Case 3 - Kickback points operation
     
    while (digitalRead ( KickbackApproach_pin) == Reed_OFF) ; // wait until magnet on chain arrives at KickbackApproach reedswitch
    digitalWrite ( KickbackServo_pin, Switch_ON);   //  Set track to Straight
    while (digitalRead ( KickbackDivert_pin) == Reed_OFF) ;  
    digitalWrite ( KickbackServo_pin, Switch_OFF);   // Set track to Divert
    // MotorRelay pin still ON. motor continues to run 

This part of the sketch looks like a Flip/Flop that should function as a Flip/Flop and reset after every time a skip is tipped. 

 Logically it looks OK with the process comments and SHOULD do the job. Maybe the reset to Divert needs to be forced with an "IF" statement? It looks like this part digitalWrite ( KickbackServo_pin, Switch_OFF);  is being ignored for some reason. If this statement fails to execute, then the sketch does not progress to case 4 (which ends the cycle). I can't see  anything after throwing the Kickback to straight that would disable this digital write action. 

Cuurioser and Curiouser...Looks like I have found another rabbit hole

Regards,

John Garaty

Unanderra in oz

Read my Blog

Reply 0
Geoff Bunza geoffb

@John G

@John G
 
Hi John,
Your description:
Quote:
On pressing Black Kickback_Divert switch:
  • MotorRelay indicator light - Off - Motor is running
  • CageServo indicator light - On - Cage at home position and aligned with track
  • KickbackServo indicator light - OFF - Track fails to reset to Divert route, 
  • FAIL - Sketch stalls and is unable to exit to Case 4.
Applies to this code:
while (digitalRead ( KickbackDivert_pin) == Reed_OFF) ;  //wait until magnet on chain arrives at KickbackDivert reedswitch
 //we get here when magnet on chain arrives at KickbackDivert reedswitch so KickbackDivert is now ON
 digitalWrite ( KickbackServo_pin, Switch_OFF);   // Set track to Divert
 
The skecth stalls at the:
while (digitalRead ( KickbackDivert_pin) == Reed_OFF) ; 
So it never sees the Pushbutton pressed at the KickbackDivert_pin
 
When you pushed the Black Pushbutton did its corresponding LED go off?
The ONLY conclusion is that the Arduino never sees you press the Black Kickback_Divert switch
So check the switch and the wiring to the Arduino for continuity. Change the switch, replace the switch with a wire. Check the pin it is connected to and that continuity is good.
There is something wrong here. Don't even bother going past here with anything until you clear this problem first.
The behavior is entirely consistent with not being able to read the Black pushbutton.
There is no magic to this. You are very close to the finish line!
 
Let us know what you find. Have fun! 
Best regards,
Geoff

Geoff Bunza's Blog Index: https://mrhmag.com/blog/geoff-bunza
More Scale Model Animation videos at: https://www.youtube.com/user/DrGeoffB
Home page: http://www.scalemodelanimation.com

Reply 0
Oztrainz

Found the bottom of the rabbit hole

 Found the bottom of the rabbit hole

Hi all,

For those of you still tagging along. Dr Geoff had it right. Not one but 2 errors around the black push-button switch  

One of the hardest things you can do is to check your own work (both in wiring and blog wording). Part of the problem is that your eyes "see" what they "think is there" rather than what is "actually there". Maybe it was too many black wires around a black switch that I had somehow inserted 90 degrees out? I'd looked at that switch at least 4 times and didn't pick either of the wiring errors. The "head" says "I've already checked that wiring so it can't be wrong - the problem MUST be elsewhere". Sure got that wrong  But at least I didn't let any more magic smoke out.   

So how did all this finish? The following photo shows the entire board that I used as a mirror (as in looking-glass??) of the final system as installed on Corrimal.  

1270621a.jpg 

Working left to right,

  • Bread board with switches, powered by orange and blue wires
  • Arduino - 
  • Relays - from top to bottom  (Motor, Tipple Cage, Kickback)
  • ANE Switchmaster
  • the same type of gearhead motor used on the under-track chain with potentiometer speed control 
  • Servos - working top to bottom Tipple Cage and Kickback

From top top to bottom, the three red lights on the three relays indicate that:

  • Motor is stopped, awaiting the arrival of another skip of coal
  • Tipple cage is at Home position aligned with the tracks, awaiting the arrival of another loaded skip for tipping
  • Kickback is set to divert, simulating gravity-biased turnout favouring for the diverge route 

I'll step through a more pictorial view of how everything happens in the next post. We now have simulated a motor that starts and stops when it should, a tipple that tips when it should, and a kickback turnout that kicks-back when it should.  HUGE 

Thank you once again to Dr Geoff for his persistence and his gentle prodding. The heart transplant is now ready to go, but other scenery stuff elsewhere on the layout needs to happen first. 

Regards,

John Garaty

Unanderra in oz

Read my Blog

Reply 1
pierre52

Joyous

Joyous

How does that feel John?

Peter

The Redwood Sub

Reply 0
Reply