Jump to content
 

Erik84750

Members
  • Posts

    19
  • Joined

  • Last visited

Profile Information

  • Location
    Ghent, B
  • Interests
    Model railroading, cooking, rowing, electronics and programming, photography

Erik84750's Achievements

0

Reputation

  1. Hi Phil, thanks for your feedback. The reason I would be going to design an optical detector board with individual sensors having the option to select OR-gated output was to allow individual detectors for other uses too. Having a design where sets of 2 sensors are hardwired in OR-pairs makes sense if you use these boards for isolated gap detection only. Using a single jumper per sensor to get pairing would accomplish my initial setup with individual sensors on the board For rising edge detection: maybe I should include the option for a hardware debounce of about 50ms, or nothing; again with jumper selection. For falling edge detection the same, but with much higher debounce time to allow for gaps in trains. The LDT and Massoth modules are short-circuit detection based, I think? Which is what I want to avoid. To John ks: that is the kind of concept I have in mind too; however I am experimenting with DCC++. And since I am several years for retirement and consequently have little time to spare at the moment, I can meanwhile do the necessary scouting of systems and concepts to find what would best suit me. Have you looked at DCC++? Any opinion? Personaly I think this is a fantastic system for those with computer and network knowledge and the time to invest in system setup. But I am getting off-topic. And I will get to work in my spare time on my goal set forward in post #17.
  2. Hi John, indeed. How do you control your DCC trains? Do you use some sort of train controller PC program? JMRI? What type of command station (DCC++, ..)? Just asking to find out what kind of train control would suit, and whether I need to output the detection device for TTL to cater for some bus system, or if straight HIGH and LOW of any voltage would be ok. Meanwhile I am considering using your idea from post #13 and simply wire the reversing relay to a relay coupled to the drive for the switch (in the case of reversing loop with a single switch). And for those who want to use some sort of automation but without the commecrcal units using short-circuit-detection I will develop a circuit taking into account: 1. detection on every isolation gap, and 2 detectors per gap 2. using different debounce delay for rising and falling detection edges 3. without microcontroller I will post it in this thread asap (couple of weeks?).
  3. Hi John, For classic loops & Y's where the third leg connects to no other part of the layout I would use a point operated switch to control the polarity/phase Point taken; indeed the most straightforward solution. And I will design a hardware solution for reversing loops taking previous posters comments into account: 1. use detectors for both sides for all isolation gaps 2. try and solve with a monostable relay but with a robust photodetector solution 3. involve debounce for rising edge to eliminate spurious detection and falling edge delay long enough to cover gaps between wagons, false "no-detections",... . Probably I will resort to a micorcontroller besides the photocell detection. This may be a trivial point but if a short train going anti clockwise in the loop stops over the detector, waiting for a second train to clear the point then the phase will be wrong for the next train entering the loop. I think I do not fully understand: 1. why would an anti-clockwise loco stop over the detector? Indeed in doing so the phase will be wrong for an incoming train entering over the non-detected isolation gap. 2. If you need a detector to indicate whether a train is present I would introduce a sparate detector. The easy fix would be to have a sign or signal to indicate where to stop ..or an additional detector with the relevant actions: light, automatic control via train control software, microcontroller, ..? Other wise this seems to be a very elegant solution It should also be possible to use these detectors to switch the polarity of frogs in electro frog crossings Right. As a result of all the constructive feedback I will design a photodetector pcb which will output both Vcc (15V, .. whatever) and TTL 5V HIGH/LOW signals; and with the possibility to hardware connect detector outputs on the PCB in OR gates.
  4. You are right, I overlooked that, thanks for that feedback.
  5. Hi Phil, yes indeed I rely on a continuous uninterrupted detection of any train coming by. For that I rely on the hardware for the detection circuit: 1. there may/should not be -and testing so far in closed room conditions show there is no- no influence of ambient light 2. detection start occurs with just enough debounce to avoid spurious signals (ie around 50ms: for the rising edge at start of detection) and after detection a hardware delay for the falling edge of about 1 to several seconds (user settable) is provided. And indeed I count on the steady state of the acting detector to keep the relay active. Is that a disadvantage? It might well be. I have to do further testing; at the moment this concept is in prototype testing mode: the hardware for optical detection works well but more is needed to make sure there are no spurious signals or interference from wagons passing by to cause embarassing shorts. To Dutch_Master: the concept is being tested and works so far so good, but I cannot say yet that it will work under enduring circumstances. Detection reliability is key here and I cannot say that this is the case yet.
  6. Sorry I use italics to quote: Phil: Try downloading this document: "Click HERE for Considerations when Converting an Analogue Layout to Digital" (3.pdf) which you will find oin this page: http://www.fillin.co...ent/index.htm below the 'Wickham Advert. In it you will find a series of diagrams showing options for analogue and digital reverse loops. This might help start your design again. (p15...) ok I will download and study asap. Currently dead link. I CLEARLY STATED CLOCKWISE - which you then ignored in your response - yet you claim the circuit is supposed to work in both directions !! It will work ONCE in the anticlockwise direction - but you appear to be missing many of the basic arguments. {you could re-edit your response to match the CLOCKWISE scenario I described 8-) ok, I edited the previous post with clear markers for what was edited. But I fail to see why this would work "only once"? (clueless). Phil: if I enter clockwise from left to right, the detectors will activate the relay so that the train travels without short. But as soon as the train has cleared the detectors the relay will be released again back to default state. Meaning now the reverse loop polarity is set to that of the Main track connecting to the isolated gap where no detectors are present. Meaning the train can leave over that part without any action needed. If I re-enter clockwise, left to right, the relay does not need to be set because the default state already allows entry without shorts over that part. With only 1 set of sensors for the 2 breaks involved - either as shown: you would have to fall back onto short-detection because you appear to be doing nothing to detect the the other break, OR you place 1 sensor AHEAD of each break ... YOU CANNOT ASSUME POLARITY (actually PHASE) is correct unless you have made it so. ... for every occurance. I must disagree: if my relay has in "rest" state (meaning not activated) the contacts wired so that the section without detectors are electrically alligned (ie same phase or polarity) I have to do nothing in order to let the train run over that isolated gap. The relay I use is a double pole relay with twice C, NC and NO. I use C and NC in the rest state to connect left and right Main tracks to their respective tracks behind the isolation (left to left, right to right). When the relay activates, then C and NO get connected: left and right Main tracks are switched around so that now NO gets connected like this: left to right en right to left. You could simply link the point change into 'presetting' the loop - but always for the single direction clockwise or anticlockwise UNLESS PERHAPS you had a 2 x train length loop, with the detector in the centre - so that whichever way the train came, it was clear of the point and adjacent rail break into the loop. I am afraid I do not understand you here. In my setup it is not possible to simply link the points to the detection system because only one side gets detected; unless now we have points with "default" settings which when in rest alwasy point one way, and only when activated (ie throught the detectors) point the other way; and when it reached the detector, it changed the point and the track phase (phase not polarity as we are talking AC waveform!) ..... assuming the train did not stop and reverse out the way it came in. 1. My system should work for both analog as DCC 2. Right: the detector activates the point, as long as the detector is activated. But here we have the issue of timing and location: the detector is way behind the point; I would introduce microcontroller automation and additional sensors. Which is why I would prefer to keep switch points seperate from reversing track control. Until this gets sorted out here and then I will introduce a microcontroller for the points; or you use the digital output from the detectors to drive whatever train control system is in use. Have you tried placing the sensor ahead of the point? (ie to its left) - it then triggers the point to STRAIGHT- the train reaches the point and always goes the same way - (and since I'm in the UK and brought up with anaologue clocks and driving on the left, I will default to going clockwise) - so the point is set to 'straight ahead' ..... as the train approaches the curved side of the point, on 'leaving' the reverse-loop - then yes, a detector ahead of the EXIT break can change both the point to CURVE and the phase of the reverse loop. .... this appears to be the sort of thing you have drawn for anti-clockwise ... Yes that is possible but it defeats my prupose: being able to drive around the reverse track any way you want. And again, I would prefer to keep switch point control and revering loop control initially separate.
  7. Hi Phil_S: I quote here in italics because I am not sure how to do it otherwise: Concurring with Dutch_Master; you need detection either side of each and every break to ensure that it is 'pre-selected' to the correct polarity AHEAD of any metal wheel bridging the gap. I assume that by using a double pole relay with contacts in only one and the same position when not energised that there always will be correct polarity/phasing over the non-detected gap when not energised As stated; Restriction on total-train-length must be within the physical breaks in case ANY item of rolling stock has a metal wheel...AND ALSO the inner-detection positions A small loco might be only 3cm long ! making that apparent requirement of BOTH detectors active from a single loco very close to the gap. I indeed assume loco's or any electrified rolling stock is indeed longer then 3 cm and long enough to allow practical installation of the 2 detectors. Cuts in rails do not actually need to be adjacent - as only a SINGLE WHEEL is needed to trigger a short circuit (and this was supposed to avoid that anyway). I think I do not understand this line. I assume that the gaps are adjacent; and that the detection occurs before (in time and in place) any electrified rolling stock crosses the isolated gap. Both gaps must simply lie within the 2 detectors - 'short' detection is from ANY single Wheel on any single rail !!! Right A caution with the single pair of detectors shown in the 'traditional' diagram: Stage 1 okay as train approaches left to right to clockwise loop - presets okay I take it you mean "counterclockwise" EDIT: this must be corrected in "clockwise": Edit: scrap following in that case no allignment needed because by default the polarity is correct: relay not activated = correct polarity for the track over the section without detectors EDIT (added text): Phil, if you approach clockwise from left to right then the presets are not ok, the relay must be activated for the train to travel without short circuits. And the relay will be activated because the detectors detect the train. End Edit Stage 2 wheel bridges gap which has already been preset -okay ok if you mean that the train enters over the isolation where no detection is present Stage 3 object covers detector 2 ... IS THIS MEANT TO change the EXIT polarity ??? Yes, beacuse this is when the train exits the reversing loop, this time over the isolation with the detectors .... it cannot be, because the train is still entering ..not right: because the reversing loop must be at least as long as the longest train that will run: so when any detector is covered there is no more train over the other isolation , and passing over the first detector and the track break (possibly with gaps in detection .... beware that 'delays' to de-bounce gaps between stock would also act as a delay on presetting polarity. Unless the "debounce" only acts when the train leaves the detection: this can easily be done electronically; no debounce or delay when the train "enters" the detection zone Stage 4 Train wholly within the reversable / inner-detected area. Did we not start leaving in stage 3? What happens now ? The train may stop. the train may reverse back to Detector 2, or continue Forward over the next (Exit) break approaching the point. If you exit the reversing loop over the isolation with the detectors then the relay will be activated to allign polarity/phasing between the reversing section and the maintrack that joins the loop at the isolation with the detectors. You may drive over the "detected isolation, reverse back, anything: it does not matter what you do as long as you cover the detectors the relay will take sure that phase/polarity are alligned for that section with the detectors Is the point also being controlled BY the LOOP, or is the POINT direction controlling the loop polarity?? or is it a tram-like Sprung point ?? The point is not controlled by the loop nor vice versa: you command the points and the train just goes where you "tell" it to go (by setting the switch points). The detectors take care of the polarity when covered, when the train enters the loop over the isolation that is not "detected", the relay already is by default set in the right polarity. [if, as implied, the loop is for 1 direction only no, for 2 directions - using only the 2 detectors by the 'last'/exit break (Anticlockwise) ... and this also changes the point to the exit position (straight in anti-clockwise) The swith points must be correctly alligned by you. But if required I can connect a little microcontroller that takes care of this for you .... what will change the point back for the next train/?? You; or the little microcontroller; or you just let the train enter in the same way as the last one exited (ie: if you exit counterclockwise, the next enters clockwise), but then you still have to take care to set the switch points correctly upon exit of this second train. Or I program a microcontroller to take care of that for you. ... or will it rely on time delays (time-interval signalling was abandoned on british railways in the early days because it was not fail-safe ... rather the opposite No; I would not do that; rather microcontroller automation. This situation is made worse by adding more parallel tracks within the reversing section - as the individual trains may depart in any direction - they may also, of not fully stopped clear of points, fowl passing trains (shortening the avaiable reversing length) or creep forward at minimal speed unoticed (the voice of experience 8-( ) Does not matter: either exit over the "non-detected" isolation, with track polarity alligned already due to the default relay setting; or over the "detected" isolation section and have the relay switch over (ie activate the relay during "detection"). These problems largely disappear by simply ensuring that EVERY BREAK has the 2 detectors needed** - on either side - not to do so is a false economy. My "precursor" is that the default relay setting does not require any action: the tracks on one side of the reversing loop will always be electrically in phase/right polarity between reversing loop and main track at that point This method is available commercially from Massoth Electroncs (aimed at G Scale - to avoid short circuit currents of over 10A ! ) or LDT as kit or prebuilt (5A rating) Then the restriction is the normal one of having only 1 train crossing joins at any one time. My requirements too (should, unless proven wrong) allows for only one train to pass over the isolating sections ("gaps") at any one time; but it can be done from either side (again, unless I am proven wrong). (Have you also considered the 'start-up' scenario when track power is reapplied WITH A TRAIN bridging the rail gaps??? - which way does it start up? It may have to 'reverse' from it's preferred dafault-position. If a train is across the detected section after a power failure then there will be a short circuit provided that electrically connected loco or wagon is across the gap; which will be a big coincidence. **IN addition to the short-circuit detection - in case the detection fails. I think i do not understand that line?
  8. Good morning Dutch_Master, the idea in my concept is that the track in the reversing loop always is in phase with the main track where no detection is present: for that end the relay is wired as per drawing 1. Any train entering or leaving using the section without detection is by default running over tracks that are "in phase" (for DCC) or in correct polarity (fro analog layouts): so no short circuit. When a train wants to enter or leave over the track where detectors are present then the relay is activated and the contacts are switched around so that the phases (or polarity) are in line between the reversing loop and the main track for the section where the train wants to run over. Therefor: 1. entry and exit possible from any direction: the sensors in front of and behind the one isolated part make sure the relay is activated before the train crosses the isolation 2. double crossover with reversing loop can do with 4 detectors only because the reversing loop track that runs straight ahead (instead of turning sideways at the switch) is by default in phase (or in same polarity) as the main track.
  9. Hi, some time ago I published a reverse loop control with 3 sensors and a microcontroller automation. After much discussions and forum input elsewhere I designed a automatic reverse loop control on the following requirements: 1. not short-circuit based 2. fully bi-directional (can be entered and/of exited from any direction 3. applicable to any kind of reverse loop including double crossovers with a reverse loop 4. any scale 5. any system: analog or DCC or both 6. indoor or outdoor 7. any number of trains allowed inside the loop 8. any format for reversing loop allowed, including parking tracks, loop inside loop (nested loops), complete tracksystems,.. 9. independent of ambient conditions (light, temperature,..) 10. not microprocessor controlled 11. can supply logic level feedbak for buscontrolled systems (ie LOW and HIGH output signals for "detection", "relay activation",.. etc). 12. full autonomous: the detection system drives the relevant relay for polarity change-over as well as digital status output for control systems The general idea is based on the fact that in a reverse loop there always is only ONE side that is going to be shortcircuited if you drive a train over it. So ONLY that one side needs to detect whether there is a train over it to change polarity. As far as traindetection is concerned I already have a fully tested detector system based on LDR's which is completely insensitive to lichting condition variations (ie. any change in ambient lighting does not affect detection capability). Please have a critical look at my idea, any feedback is greatly welcomed!
  10. Addition for double crossover with return loop: That is a special one because it contains two reversing loops in one when seen by the program. This can be solved by using 2 detectors called DET-a and 2 detectors called DET-b. Both pairs of detectors have to be connected to their respective controller inputs: both DET-a to PB1 and both DET-b to PB2. Since the controller inputs are high impedance these inputs don't care from which detector the HIGH or LOW signals come. However, to avoid conflicts between the detector pair outputs (since they are wired to the same input), it may be advisable to add a forward diode to each detector output before connecting them to their controller inputs. Updated diagram included. And a little addition to my previous post: The wiring in drawing 1 is pretty self-explanatory in that it shows each wire and each contact. However, this is shown for a 4-pole relay. If you want to keep it simple use a 2-pole relay and delete lower two poles in the drawing, delete the orange and brown wires, and delete the optional cuts (pink rectangles). If you want to use this autoreverser for circuit such as drawings 2 to 4: just use a 2-pole relay and connect the DET-a, DET-b and DET-1 sensors to the following controller inputs (italics copied from my initial post, but now with the correct detector designations in bold red so that it corresponds with the drawing 1): The ATtiny I used has following connections (see also the code): PB0 = LDR1 (the one inside the loop) PB0 to DET-1 (always use this one INSIDE the loop) PB1 = LDRa PB1 to DET-a PB2 = LDRb PB2 to DET-b PB3 = Relay output (EDIT: beware: a controller supplies a max of about 10 to 20mA safely per output: use a high impedance relay https://www.aliexpre...d-58936f8fd807 which in turn drives the power relay). And a little remark: in my program I designate DET-1 to variable LDR1, DET-a to variable LDRb; and DET-b to variable LDRb; in my next revision of the program I will change the variable names to those used in the drawings. If you want to control switch points too then you can use the relay contact; this is however a latching contact so it will burn switch contacts that just want a pulse. If it is desired I can add an extra output in the program (for example to PB4) to give a pulse of any length to it as soon as the RELAY output is activated.
  11. Hi, after reading hundreds of webpages and fora on the quest for a autoreversal controller I found there is an enormous load of talk but often either confusing, conflicting, contradicting, or marketing substance on this subject. So I decided to try and fabricate something using both my C++ programmer knowledge and my electronics knowhow. In my quest for the holy grail of reversal control I did discover that the most crucial part in any kind of model railroad automation is the detection part: what detector to use for what purpose? Any kind of detector has its pros and cons, its cost, its reliability, its electrical characteristics, etc.. What I absolutely wanted to avoid is "Short-Circuit Based Detection": that is similar to fighting fire with fire, and for an electrical engineer like me the idea of short-circuit based detection is the same as cursing in the church. To my complete surprise I did find most fo the commercial units based on this principle, and as well most of fora discussions assuming this would be the only saviour for those wanting reliable autoreversal control. As far as detection is concerned, some systems not using short-circuit detection would require sensors that do sense a train over it but sometimes do not work properly when gaps between the wagons are present. Other non-short-circuit detection AR units would depend on just one type of sensor, or worse: on a sensor sold by the manufacturer as the only saving grace but sold at a prohibitive cost. So I decided one of the design constraints of my fabrication should be the possibility to use any kind of capactive, inductive, optical or other sensor that senses a loco or a full train above or underneath or alongside it without being fooled by the gaps between wagons in the train, nor by spurious false detection spikes or pulses. Last week I posted a first attempt on this forum in a thread that was started several years ago. Since my post there I optimised my code and improved the related drawing. After a few days of testing I want to present to you my new version v2 of a full automatic bi-directional auto-reverser. The drawing (part of which is credited to Dutch_Master) shows multiple versions of reversing track schemes and the way to implement this control system to each of them (detector and gap placement). The new software version includes "debouncing": spurious detections, false contacts, train wagon gaps, etc.. are excluded in the detection software routines. The debouncing time is currently set at 1000 milliseconds ("unsigned debounceDelay = 1000;") but that value can be freely adjusted. I decided not to include frog powering because that is part of the switch command hardware. Design constraints: 1. create a full automatic autoreversing controller 2. for bi-directional use 3. with no stopping of the loco/train 4. without use of short-circuit detection (IMO this is a rather crude way of automating a project). 5. with the use of any type of sensor (optical, inductive, capacitive, reed-relay, current sensing, .. just anything that reliably detects a loco above, alongside or underneath it), with preferably (but not necessarily: I just need to change the code a bit) a LOW signal when nothing is detected and a HIGH signal when detection occurs 6. cheap (I used for testing a ATtiny85 (1.5EUR), and 3 LDR's (1EUR for 20) and a 1EUR DPDT relay (4-pole must be used if the optional tracks are cut): total cost less then 5EUR in hardware. 7. reliable: it all depends on the sensors used; the software is foolproof and thoroughly tested. 8. any type of Atmega controller can be used: Arduino, Pro-Mini, ATtinyxx, etc.. 9. 5V power supply for relay, sensors, controller 10. Must be able to be used for any kind of reversing loop (see attached drawing) If needed I can program the controller for you, just send me 2 units: one for return programmed and one to cover postage; just pm me. The ATtiny I used has following connections (see also the code): PB0 = LDR1 (the one inside the loop) PB1 = LDRa PB2 = LDRb PB3 = Relay output (EDIT: beware: a controller supplies a max of about 10 to 20mA safely per output: use a high impedance relay https://www.aliexpre...d-58936f8fd807 which in turn drives the power relay). Make sure you cut the trace to the LED connected to PB1 or the voltage divider used for the LDR will not work properly. But best of all is to use an LDR driving a comparator, no need for calibration. This is the controller I use: https://www.aliexpre...d3-7dd445f0e91d Sensors of any shape, type, price can be found on that site. So far I have ordered 450+ items from them and just a few never arrived for which I got my money back. Thanks for your attention, comments are greatly appreciated, Erik My code: const byte Relay = 3; const byte LDRa = 1; const byte LDRb = 2; const byte LDR1 = 0; boolean A = LOW; int stateLDRa; int lastStateLDRa = LOW; int stateLDRb; int lastStateLDRb = LOW; int stateLDR1; int lastStateLDR1 = LOW; unsigned long lastDebounceTimeLDRa = 0; unsigned long lastDebounceTimeLDRb = 0; unsigned long lastDebounceTimeLDR1 = 0; unsigned debounceDelay = 1000; void setup() { pinMode(Relay, OUTPUT); //setting the pin mode to Output digitalWrite(Relay, LOW); } void loop() { // read LDRa and debounce int readingLDRa = digitalRead(LDRa); //digitalWrite(ledPin, readingLDRa); if (readingLDRa != lastStateLDRa) { lastDebounceTimeLDRa = millis(); } if ((millis() - lastDebounceTimeLDRa) > debounceDelay) { if (readingLDRa != stateLDRa) { stateLDRa = readingLDRa; } } lastStateLDRa = readingLDRa; // read LDRb and debounce int readingLDRb = digitalRead(LDRb); if (readingLDRb != lastStateLDRb) { lastDebounceTimeLDRb = millis(); } if ((millis() - lastDebounceTimeLDRb) > debounceDelay) { if (readingLDRb != stateLDRb) { stateLDRb = readingLDRb; } } lastStateLDRb = readingLDRb; // read LDR1 and debounce int readingLDR1 = digitalRead(LDR1); if (readingLDR1 != lastStateLDR1) { lastDebounceTimeLDR1 = millis(); } if ((millis() - lastDebounceTimeLDR1) > debounceDelay) { if (readingLDR1 != stateLDR1) { stateLDR1 = readingLDR1; } } lastStateLDR1 = readingLDR1; if (stateLDRa == HIGH && stateLDR1 == LOW && stateLDRb == LOW) //condition 1; clockwise { digitalWrite(Relay, HIGH); A = HIGH; } if (stateLDRa == LOW && stateLDR1 == HIGH && stateLDRb == LOW && A == HIGH) //condition 2; clockwise { digitalWrite(Relay, LOW); } if (stateLDRa == LOW && stateLDR1 == LOW && stateLDRb == HIGH) //condition 3; clockwise and counterclockwise: set relay low { digitalWrite(Relay, LOW); A = LOW; } if (stateLDRa == LOW && stateLDR1 == HIGH && stateLDRb == LOW && A == LOW) //condition 4; counterclockwise: set relay high { digitalWrite(Relay, HIGH); } }
  12. Hi, after a few days of testing I want to present to you my version of a full automatic bi-directional auto-reverser. The drawing is based on a drawing by Dutch-Master who of course is given due credit in the attached drawing. The drawing I made with Adobe Illustrator, I am not too proficient with that program, it took me 6 hours to have it done. I decided not to include frog powering (see Dutch-Master diagram above) because that is part of the switch command hardware. Design constraints: 1. create a full automatic autoreversing controller 2. for bi-directional use 3. with no stopping of the loco/train 4. without use of short-circuit detection (IMO this is a rather crude way of automating a project). But if you definitely want to use short-circuit detection then this is also allowed, just make sure that proper HIGH or LOW signals are given. 5. with the use of any type of sensor (optical, inductive, capacitive, reed-relay, .. just anything that 100% reliably detects a loco above or underneath it), with preferably (but not necessarily: I just need to change the code a bit) a LOW signal when nothing is detected and a HIGH signal when detection occurs 6. cheap (I used for testing a ATtiny85 (1.5EUR), and 3 LDR's (1EUR for 20) and a 1EUR DPDT relay (4-pole must be used if the optional tracks are cut): total cost less then 5EUR in hardware. 7. reliable: it all depends on the sensors used; the software is foolproof and thoroughly tested. 8. any type of Atmega controller can be used: Arduino, Pro-Mini, ATtinyxx, etc.. 9. 5V power supply for relay, sensors, controller 10. Must be able to be used for nested reversing loops, sequenced reversing loop, multiple reversing loops, etc.. If needed I can program the controller for you, just send me 2 units: one for return programmed and one to cover postage; just pm me. The ATtiny I used has following connections (see also the code): PB0 = LDR1 (the one inside the loop) PB1 = LDRa PB2 = LDRb PB3 = Relay output (EDIT: beware: a controller supplies a max of about 10 to 20mA safely per output: use a high impedance relay http:// https://www.aliexpress.com/item/Smart-Electronics-5V-1-One-Channel-Relay-Module-Low-level-for-SCM-Household-Appliance-Control-For/32707870640.html?spm=2114.01010208.3.15.PhUyWN&ws_ab_test=searchweb0_0,searchweb201602_1_10152_10065_10151_10068_436_10136_10137_10157_10060_10138_10155_10062_10156_10154_10056_10055_10054_10059_10099_10103_10102_10096_10147_10052_10053_10142_10107_10050_10051_10084_10083_10080_10082_10081_10177_10110_10111_10112_10113_10114_10181_10037_10183_10182_10032_10078_10079_10077_10073_10070_10123,searchweb201603_2,ppcSwitch_5&btsid=e12d5bc7-2fcb-4393-a7f1-962add4c8dd9&algo_expid=80f49ff8-c3f2-46e0-b17d-58936f8fd807-2&algo_pvid=80f49ff8-c3f2-46e0-b17d-58936f8fd807 which in turn drives the power relay). Make sure you cut the trace to the LED connected to PB1 or the voltage divider used for the LDR will not work properly. But best of all is to use an LDR driving a comparator, no need for calibration. This is the controller I use: https://www.aliexpress.com/item/Free-shipping-GY-Digispark-kickstarter-miniature-minimal-development-board-TINY85-module-for-Arduino-usb/2053597206.html?spm=2114.01010208.3.230.SkLJ9m&ws_ab_test=searchweb0_0,searchweb201602_1_10152_10065_10151_10068_436_10136_10137_10157_10060_10138_10155_10062_10156_10154_10056_10055_10054_10059_10099_10103_10102_10096_10147_10052_10053_10142_10107_10050_10051_10084_10083_10080_10082_10081_10177_10110_10111_10112_10113_10114_10181_10037_10183_10182_10032_10078_10079_10077_10073_10070_10123,searchweb201603_2,ppcSwitch_5&btsid=f75f8d6b-a1bc-412f-bc15-ba5dbc74f73a&algo_expid=544ddd38-f756-42e3-8ad3-7dd445f0e91d-29&algo_pvid=544ddd38-f756-42e3-8ad3-7dd445f0e91d Sensors of any shape, type, price can be found on that site. So far I have ordered 450+ items from them and just a few never arrived for which I got my money back. My code (actually the code has just 4 read lines and 4 command lines, so fairly easy to read): const byte Relay = 3; const byte LDRa = 1; const byte LDRb = 2; const byte LDR1 = 0; boolean A = LOW; void setup() { pinMode(Relay, OUTPUT); //setting the pin mode to Output digitalWrite(Relay, LOW); } void loop() { int stateLDRa = digitalRead(LDRa); int stateLDRb = digitalRead(LDRb); int stateLDR1 = digitalRead(LDR1); int stateRelay = digitalRead(Relay); if (stateLDRa == HIGH && stateLDR1 == LOW && stateLDRb == LOW) //condition 1; clockwise { digitalWrite(Relay, HIGH); A = HIGH; } if (stateLDRa == LOW && stateLDR1 == HIGH && stateLDRb == LOW && A == HIGH) //condition 2; clockwise { digitalWrite(Relay, LOW); } if (stateLDRa == LOW && stateLDR1 == LOW && stateLDRb == HIGH) //condition 3; clockwise and counterclockwise: set relay low { digitalWrite(Relay, LOW); A = LOW; } if (stateLDRa == LOW && stateLDR1 == HIGH && stateLDRb == LOW && A == LOW) //condition 4; counterclockwise: set relay high { digitalWrite(Relay, HIGH); } } Any feedback is more than welcome! Rgds, Erik
  13. How do I add attachments? I made something applicable for this thread..
  14. Hi Suzie, can you plse explain what you mean by "polarity switch"? Do you mean a switch (for example DPDT) that is connected to the switch activation? And if I understand you correctly you mean to use the photocells to allign the switch for the outgoing loco? If so, I would have to insert an "or" function if I also want to allign the switch manually for incoming loco's?
×
×
  • Create New...