Ready to go to the PCB shop if there is enough interest.
I like the reduction in parts-count and size of the microcontroller method. But if we're discussing alternatives, how about this.
If the concern is power dissipation (heat) when the 5V relay is on for extended periods, why not use the 12V version of the relay which is a drop-in replacement, same cost. The concern with the linear 7805 regulator method is the large voltage drop at high track voltages. For example, if powered by 18V AC, that's ~25V DC at the regulator input so a whopping 20V drop at a relay coil current of ~70mA for the SRD-05VDC-SL-C 10A relay. 20V x 70mA = 1.4 Watts which makes the 7805 quite toasty!
BUT, if using a 12V relay and a 7812 12V regulator, the voltage drop is 13V and the coil current is 30mA so the 7812 is a more manageable 13V x 30mA = 0.4 Watt. Probably doesn't even need a heatsink.
So while this approach may not be as power-efficient as a switching regulator, it should save cost and reduce parts-count meaning less soldering! The 7812 is inexpensive and widely available and takes less space than the combination of the switching transistor, Schottky diode, inductor, and feedback resistor network. As a bonus this frees up a PIC pin for a TBD application.
Attachments
I thought about that as I do have the 12V relays used for another application (solar battery vent). But my intent was to have this as versatile as possible so it can run off track voltage from 8V to 20V. (The EEU uses a low-dropout 5V regulator to work down to 6VAC, but they are on backorder into 2023.)
You also still need a diode to snub the voltage spike when the transistor turns off. The cost of the inductor and tantalum is almost the same as the 7812 (Mouser). The other components cost a few cents, so there is no significant savings except in board real estate.
Since I already use the switching regulator for the EEU, I'm going to stick with it.
OK, I created the 12V regulator version too. It is 1.6" by 1.35". Sim shows the 7812 will drop out of regulation at about 11VAC. That assumes a 470uF electrolytic, a fixed load of 15mA, and a 400 ohm relay load.
Attachments
I'm a tad curious on the where we're going with the microcontroller approach. If this is simply constructive dialog within the spirit of OGR being a discussion forum then I'm all-in and let the games begin/continue! But if we're talking about something a "typical" OGR reader can pick up and run with, then I have my concerns.
A few years back, I was convinced the 8-pin microcontroller chip was the cat's pajamas for O-gauge. That is, there are plenty of guys on OGR who can write custom code and would do so within the OGR domain. So it would simply be a matter of "transporting" the 8-pin DIP IC from point A to point B. A few years ago there was a marketing campaign from a major microcontroller mfr where you could buy an 8-pin microcontroller for 25 cents in ANY quantity! But the problem is now the MINIMUM shipping cost for USPS is $5 to send one 8-pin DIP microcontroller chip that weighs a few grams, but is unfortunately more than 1/4" thick, to your next-door neighbor.
So when you mention your design being a "kit" does this mean YOU are supplying the parts and PCB including a programmed PIC12F1822? I also think the enclosure design, which @Rod Stewart has grasped the proverbial bull-by-the-horns is a critical piece of the puzzle.
--------------------------
@SGJeff posted:OK, I created the 12V regulator version too. It is 1.6" by 1.35". Sim shows the 7812 will drop out of regulation at about 11VAC. That assumes a 470uF electrolytic, a fixed load of 15mA, and a 400 ohm relay load.
...
Separately, I don't think dropping out of regulation at 11VAC is a practical problem The relays themselves have a minimum pull-in voltage of 75% so they operate that 9V DC with corresponding less current (i.e., fixed coil resistance). I presume you "simulation" are with a pure sine transformer. But as I see it, most if not all pure-sine transformers for O-gauge trains provide an Accessory output port with, say, fixed 14V AC. Or, if the occupancy detector is powered by variable track voltage with a "budget" AC train transformer (NO Accessory output), the track voltage will be generated by a chopped-sine voltage which has peak voltages which will keep the 7812 from dropping out!
I guess what I'm suggesting is that there is a possible non-existent segment of users who would operate an occupancy detector at only 8V AC. The occupancy detector is obviously powering some accessory (signal, motorized gate, whatever) that is typically specified to require 14V AC in the first place. Not sure I'm crossing/dotting all my t's and i's...
FWIW, I ran my board with the larger 10A relay on 18VAC and continuously activated the relay. With a small U-shaped heatsink on the LM7085T, it hovered around 60C for fifteen minutes once it stopped increasing. So I don't see the big deal with saving power, unless you figure a couple of watts on your train layout is going to keep the grass green in the open areas between the tracks.
Regarding the microprocessor approach, if there is interest I will write the code. This is the same PIC I presently use for the EEU described in OGR issue 305. The PICs cost about 2 bucks plus shipping. And yes, shipping is about 4 bucks, including the package.
I had originally offered the EEU as a kit in OGR, but there was little interest. Most folks want an assembled and tested board ready to install. I can do either if there is sufficient interest.
I did additional testing on the relay after that post. Mine will pull in about 8V, but the spec is 9V. And even though the regulator drops out of regulation at 11VAC with the relay load, there should be sufficient energy in the capacitor to pull the relay in before the voltage sags too low. So it may indeed work down to 8VAC. (The EEU will work down to 6VAC.)
Jeff
I ordered a small batch of boards for the 12V regulator version. The sensors can be soldered directly into the board or a connector can be used. I was going to use a female connector so the sensor can plug directly in, but that costs more than the sensor. So I can add a header for a ribbon cable to the sensor.
It looks like a kit of parts including the programmed PIC, sensor, and ribbon cable would be about $20 with shipping. An assembled and tested unit a few bucks more.
Here is my last iteration of the sensor. This is a 1.5" x 2" board that accepts either the 3A or 10A relay, it also has the dual purpose holes for the two different pots.
I tested at 6VAC, 12VAC, and 18VAC. I left the relay triggered for ten minutes and then checked the temperature of the regulator. I made sure I was reading the hottest part of the regulator back to get a true reading of the maximum temperature.
At 6VAC input voltage the 3A relay board regulator ran at 35C at 6VAC, the 10A relay board ran at 47C.
At 12VAC input voltage the 3A relay board regulator ran at 48C, the 10A relay board ran at 63C.
At 18VAC input voltage the 3A relay board regulator ran at 65C, the 10A relay board ran at 81C.
It appears that all were well within the ratings of the regulator, so no heatsink is really needed. In truth, if I were running 18VAC, I'd probably put a small heatsink on the regulator.
<Click on graphic to expand.>
Attachments
The PCBs are here, but I'm still waiting for a couple of components. I'm working on the firmware now. Range will have two scales, selected by a jumper: 1-40cm and 10-400cm. Adjustment will be pseudo log, with highest resolution at the low end of each scale.
The hold delay after the object moves away will also have two ranges controlled by the same jumper: 1-10 seconds and 10 to 100 seconds.
I believe the higher range and longer delay will make it useful for other applications too.
I'm thinking about sampling every 100mS, but it could be increased to every 10mS on the shorter range. Thoughts?
Jeff I would have to guess that sampling 10 times a second would be more than enough?
Rod
@gunrunnerjohn posted:Here is my last iteration of the sensor. This is a 1.5" x 2" board that accepts either the 3A or 10A relay, it also has the dual purpose holes for the two different pots.
I tested at 6VAC, 12VAC, and 18VAC. I left the relay triggered for ten minutes and then checked the temperature of the regulator. I made sure I was reading the hottest part of the regulator back to get a true reading of the maximum temperature.
At 6VAC input voltage the 3A relay board regulator ran at 35C at 6VAC, the 10A relay board ran at 47C.
At 12VAC input voltage the 3A relay board regulator ran at 48C, the 10A relay board ran at 63C.
At 18VAC input voltage the 3A relay board regulator ran at 65C, the 10A relay board ran at 81C.
It appears that all were well within the ratings of the regulator, so no heatsink is really needed. In truth, if I were running 18VAC, I'd probably put a small heatsink on the regulator.
<Click on graphic to expand.>
John that new board of yours will easily fit inside the 3D printed base I made. Pictured below is a repeat from a couple of pages back in this thread, showing the sensor cabinet and the base.
The LM7805 Vreg would need to be bent over 90 degrees, as has been covered previously. This base is high enough to accommodate the 3A relay as is. It would need to be increased about 2mm to accommodate the 10A relay, which is a super-easy modification that can be done in any printer's slicer software package. Alternatively I can whip up a modified .stl file if needed.
The .stl files for both the upper cabinet shown and the base are currently in the 3D repository in the signs and signals category as mentioned earlier. If anyone has any questions shoot me an email and I will try to help.
John, is it safe to say that your new board uses all the same components as were available in your original kits??
Rod
Attachments
@Rod Stewart posted:John that new board of yours will easily fit inside the 3D printed base I made. Pictured below is a repeat from a couple of pages back in this thread, showing the sensor cabinet and the base.
The LM7805 Vreg would need to be bent over 90 degrees, as has been covered previously. This base is high enough to accommodate the 3A relay as is. It would need to be increased about 2mm to accommodate the 10A relay, which is a super-easy modification that can be done in any printer's slicer software package. Alternatively I can whip up a modified .stl file if needed.
The .stl files for both the upper cabinet shown and the base are currently in the 3D repository in the signs and signals category as mentioned earlier. If anyone has any questions shoot me an email and I will try to help.
John, is it safe to say that your new board uses all the same components as were available in your original kits??
Rod
Yep, same components, attached is the BOM and the Gerber files.
HC-SR04 Ultrasonic Train Detector 1.4 BOM.pdf
HC-SR04 Ultrasonic Train Detector 1.4.zip
Attachments
The microcontroller version is available. It samples 10 times a second.
Options:
Jumper installed - Low Range: 5 - 40 centimeters, 0.2 to 10 seconds release delay
Jumper removed - High Range: 5 - 400 centimeters, 1 to 100 seconds release delay
Range and Delay adjustments are pseudo-log scale with highest resolution at the low end of the scale.
Operates from 7 to 20VAC or 10 to 24VDC.
Presently available in kit form or 2 assembled versions with sensor hard mounted or connected through a 8" ribbon cable. Another PCB will be available to hard-mount the sensor at 90 degrees to the PCB.
Attachments
Just added this really neat project to the 'OGR Projects' list in the Electrical Reference Materials section. Here's a link to the Electronics Projects Developed on the OGR Forum by OGR Forum Members post where it was added (also in my sig below). Let me know if you find any errors and I will get them fixed.
Thanks to all involved here for this project! A really nice project and another great way to do block detection.
If anyone is interested, I have kits for the smaller board with all the parts and sensor, let me know if you're interested.
And for what it's worth I have been using 4 of these sensors (in two pairs) for over a year now, and I have to say they are the most reliable, most dependable and foolproof trackside sensors I have used. Best sensors ever. They never miss, never randomly trigger, fully adjustable for range and delay; they just do it all. And they are easy to disguise in a range of trackside cabinets, buildings, etc.
As time permits I plan to convert a few more signals over to these sensors.
Rod
@gunrunnerjohn posted:If anyone is interested, I have kits for the smaller board with all the parts and sensor, let me know if you're interested.
John: If you still have these, I am super interested. Let me know.
I have the kits and assembled units pictured above available.
Have you thought of de-coupling the outer rails and the wheels of the train will complete the circuit on the outer rails as a block detection? In my example (my layout) mine is a powered layout, and is PLC controlled. I used the concept of the accessory activator track section to detect a train on a given section of track. This works for sections of track that have no power. (such as when I have a train parked on the side track)
If you look at the screenshot of my HMI panel. Where the bars are white, this indicates a section of track that is powered up. Purple sections are "dead" (no track power) and green bars indicate detection of a train in the block. In this case a train is moving through what I call "Throughway West" and there is another train parked on the side track (no track power) Either case, the PLC is able to detect where the train is no matter what.
The picture of my layout running shows the opposite side, The train that is sitting in the "Throughway East" has no power and the running train is approaching the team track and will do a "run around" the parked train.
As a note, it is not possible to detect the train when it enters the remote switch area, this is why I have photoeye sensors before and after the switch, it is to prevent a switch throw if one of the photoeyes are blocked.
Mike
Attachments
I’ve found the isolation track would provide intermittent results, due to the wheels of locomotives and rolling stock do not make a sufficient ground connection within the isolated track section.
This along with a few other reasons is why I use HC-SR04 circuit for my block controls. It’s a nice reliable circuit.
Ron//
@sjbuff posted:I’ve found the isolation track would provide intermittent results, due to the wheels of locomotives and rolling stock do not make a sufficient ground connection within the isolated track section.
This along with a few other reasons is why I use HC-SR04 circuit for my block controls. It’s a nice reliable circuit.
One inexpensive workaround I've used is to feed the "intermittent" isolated track power through a buck converter with a fair sized capacitor, which will significantly smooth the output. I used this method to keep the crossing gates down and the bell audio modules powered that way. Couple of bucks each or less, if you can wait a few weeks for the slow boat to arrive . . .
Attachments
@SGJeff posted:
I must be missing something, I use LGB magnets under my engine to trip timed or direct relays. Also many LGB engines that use the power truck block will set the switches off, I still install a magnet for the (make sure) part of me.
One point: As simple and foolproof as the insulated outer rail method is, there is one major problem with it. If your layout is complete with track all layed and fastened down, the thought of tearing up long sections to create the isolated outer rail blocks might not be especially appealing. That was certainly the case at my address.
That's where trackside sensors such as the 153R, itads, DZ sensors etc. are especially handy. For my money the HC-SR04 sensors operate way better than anything else out there, just IMO of course. YMMV.
Rod
Hey All:
I have recently updated the Arduino sketch of the HC-SR04 block detection signal. I also created a new sketch for multiple control point junctions. The major change in the code was adding the feature where a train can enter and exit the block from either direction. Once the block is occupied the train can exit from any direction. Doesn't not matter which direction the train entered the block. The two tasks are now separate functions facilitated in the code.
I also created code for a multiple track junction signal block or control point. I incorporated this code to a CP of the main and spur track on my outdoor layout at Givan Junction. This circuit has three signals and is great to signal a siding at two control points. Another feature is each block section can function independently from each other, with its own Arduino nano microprocessor. I also ran 12v to power to the Arduinos, providing uninterrupted power. The signal block circuits operate on 5v output from the Arduino.
If you are interested adopting this type of signals, I've included the Arduino sketch links and few photos. This is circuit would work on an indoor layout as well. I know members of the forum SGjeff, gunrunnerjohn, stan2004, Rod Stewart, just to name a few had a big input in developing compact IC version after seeing the original design. I'm honored to have an idea to taken to next level. So, this post is my added contribution to the solution of adding the animation of signal control to our layouts. Enjoy! 🙂
Attachments
Rather than only reaching out to John, I thought I would post here. I recently bought 4 of the basic kits and put my first one together. To my chagrin, it did not light up my signal. I tried it with a simple 153 block signal and with my RK 30-11030 Pennsy Signal Bridge. Here is what I have done so far to troubleshoot:
- Verified both signals work when connected directly to transformer.
- Verified mounted components look like picture. My only question is related to C4, C5, C6; are these polarized because I could find no marking and the legs were the same length, so just installed them. C1, C2 and C3 are obviously polarized and installed to match picture and pwb.
- Inspected all solder joints and no issues.
- Powered unit up with Ultrasonic sensor attached and a signal. No signal lights. Using about 16V AC from transformer as input.
- When I put my hand in front of sensor I can hear the relay click, then after a period of time the relay clicks again. I can adjust the range and delay pots and they seem to work as expected.
I have a basic multimeter that I can use to troubleshoot. With 16VAC input, what should my output be? Open to suggestions and next steps.
Ken
I'm confused. If you hear the relay click, the pots adjust range and delay, all the electronics are working ! The only thing I can think of is a bad relay at this point. Check relay operation on the pins of the relay, maybe a bad terminal block at J2? You can trace back from the pins on J2 to the relay contacts.
Attachments
I have continuity between J2 and relay. With 16VAC input, what should my voltage be at J2?
Bad news now, I can not get the relay to switch. I'll try to replace the relay in a bit to see if I can get it operational.
You don't get any voltage at the relay, this is a passive switch. You need to supply the external supply voltage for the load.
You can measure across the relay coil and see if you're getting relay switching voltage there, should vary between 0VDC and a bit less than 5VDC. Read across D3, that's the anti-kickback diode across the relay coil.
Let me know if you have a bad relay, I have more.
With some effort I was able to replace the relay and now things work as expected. So I guess it was a bad relay.
Glad that resolved the problem and it wasn't my soldering skills.
Yes I could use another relay.
@Kenjr posted:Yes I could use another relay.
I'll send you a couple of spare relays.