Arduino, CMRI and JMRI - Part 1 - Combined Sensors and Servos

Ғылым және технология

Previously we looked at how to control servos using an Ardunio and JMRI ( • Servo Motor Control fo... ) and we've looked at how to feed data from your layout into JMRI using an Arduino with a sensor shield ( • Model Railway Sensors ... ).
A lot of people asked if it was possible to combine the two projects into a single package and the answer is yes! And in this video I'll show you how you can have servos and sensors both running from the same Arduino.
Sketch Code is here: github.com/LittleWicketRailwa...
Videos on Servos: • Servo Motor Control fo...
Videos on Sensors: • Model Railway Sensors ...
In the servo videos we connected to JMRI using a system called CMRI and we'll be using that again, except in this series of videos we'll explore what CMRI can do a bit further by adding outputs that could be used to control lighting or motors. We'll also look at the benefits of connecting multiple Arduinos, called nodes in CMRI, together so that we can have small nodes placed around the layout serving their own areas.
Links to other videos in the series:
Arduinos, CMRI and JMRI - Part 2: To be released
Arduinos, CMRI and JMRI - Part 2: To be released
Ebay and Amazon Affiliate Links
(Full disclosure, as an Amazon Associate and Ebay partner I earn from qualifying purchases through these links and this helps to support the channel)
Arduino Mega:
amzn.to/3poEBQK
ebay.us/Zl3sDT
Mega Sensor Shield:
amzn.to/3rTq80V
ebay.us/M2VnYX
Servo Driver Board (PCA9685):
amzn.to/2NoTKo3
ebay.us/rVpaAJ
SG90 Servos:
amzn.to/2N3uzY4
ebay.us/Xvuu72
IR Sensors:
amzn.to/2LQJmVF
ebay.us/rnR5wn
Variable Voltage Power Supply:
amzn.to/3b4wtj9
26AWG Servo Cable:
amzn.to/3daEp55
ebay.us/L1q3FE
Crimping Tool:
amzn.to/3tRJXHE
ebay.us/XE2Dxl
Jumper Wires:
amzn.to/2N574Os
ebay.us/Ujpvxn
Chapters
00:00 - Introduction
02:45 - Components
03:33 - Step 1 - Assemble components
06:00 - Step 2 - Upload Arduino sketch
09:33 - Step 3 - Setup CMRI connection in JMRI
11:15 - Step 4 - Setup sensors and turnouts in JMRI
12:40 - Summary

Пікірлер: 126

  • @gregbowen617
    @gregbowen6173 жыл бұрын

    I’m hoping to install sensors and servos on my layout and your videos are so straightforward and informative! I’m following this series with great interest. Cheers from Melbourne Australia 🇦🇺

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Hi Greg! Glad you're finding them useful 👍

  • @hantercans
    @hantercans3 жыл бұрын

    This is superb and very timely as I'm working through learning JMRI (slowly). Thanks for your work on this, very very much appreciated :)

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Thanks Philip, glad you're finding it useful 👍

  • @rogthedodge99
    @rogthedodge993 жыл бұрын

    Great stuff Rob. Just what was needed

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Thanks Roger!

  • @ByronNgauge
    @ByronNgauge Жыл бұрын

    I thought I would try this as I wanted to control my layout using python.. this worked out great!! I am really happy with the results!! These videos have been a massive help and very informative!! Great vid!!!

  • @alexs5700
    @alexs57003 жыл бұрын

    cheer's rob nice work on the video looking forward to the others keep up the good work

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Thanks Alex! 👍

  • @mattsynth
    @mattsynth3 жыл бұрын

    Great post, I have had great success running multiple loops and systems on one Arduino. My coding is not that great so your post helped a lot and I was able to get it up and running. Thanks.

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Glad to see you're still going with it all Matt!

  • @diegocayonteran4172
    @diegocayonteran41722 жыл бұрын

    Thanks a lot for your videos and code, they are excellent and very easy to follow! You have really saved me a lot of time and money with them.

  • @LittleWicketRailway

    @LittleWicketRailway

    2 жыл бұрын

    Thanks Diego, glad you found it useful 👍 😀

  • @bobgreytak6953
    @bobgreytak69533 жыл бұрын

    Rob, all of your videos are great! They are concise with the right amount of technical detail. After being frustrated at not being able to get JMRI to recognize my sensors using the Sensor_Scan.py script, I tried the CMRI sketch from this video. It worked perfectly! Now my sensors are recognized by JMRI. Thank you very much for these videos. I've been able to get all the Arduino shields and parts here in the USA although I've had to use different brands than you used (which work just fine). I'll be looking forward to your next video.

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Thanks Bob 👍 Glad you got it all working. The CMRI setup seems to be more reliable than the script, but it might be slightly slower with a large number of sensors.

  • @jurgenbillhofer3207
    @jurgenbillhofer32073 жыл бұрын

    Great video's, please keep them coming.

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Thanks Jurgen 👍

  • @willsgrandad
    @willsgrandad3 жыл бұрын

    I have been following your previous videos, and I'm glad you are continuing your how to's. Very informative. I've completed the 4 aspect led light signal project and it worked. I am now trying to modify to my simple red/green led signals (without much success). I have watched the other videos but not tried them yet. Still trying to get my head around CMRI/JMRI programming. Keep up the good work.

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Thanks WillsGrandad! Glad you're finding them useful. I'm still learning and as I discover new ways of doing things I'll keep sharing them. I intend to have coloured light signals on the next incarnation of Little Wicket so this is a subject I'll be looking at more closely in future. Controlling them via the PCA9685 works well and I like that you can build in fade, but I'm going to need a large number of lights on the layout and that would take up a lot of slots on PCA9685s (which is acting as the address system), someone has pointed me in the direction of addressable LED strips and in the next couple of months I want to see if they hold any possbilities. If the address system can be built into the lights then that could save a lot of hassle (and money). I'll keep you updated.

  • @willsgrandad

    @willsgrandad

    3 жыл бұрын

    @@LittleWicketRailway Thanks for the reply. I acquired a mega shield and followed this video. After several attempts I’ve got it working and I understand the theory (I think). If someone else is having problems, like I was, I suggest you watch the video several times, then retry. My mistake was using the third pin on the shield for the sensor, instead of pin 3. The warnings are in the video!! Thanks again for the series and keep up the good work. Keep It Simple.

  • @johnjmc
    @johnjmc3 жыл бұрын

    Only recently started watching this channel, finding the vids very informative and inspiring. I've used servos before on my exhibition layouts with Tam valley depot modules. New layout is being built so been looking at different option, many thanks for producing these videos

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Thanks John! Just subscribed to your channel, I should have come to you for advice on speakers!!! Some lovely sound locos. In terms of point motors, I would never use solenoid motors again, I'm sure many people have excellent experiences with them, but I hated every part of it. Loads of people rave about Tortoise motors and they do seem great, but they're so expensive and they look massive. So servos seemed like the cheapest most reliable option to me. Interested to get your experience.

  • @johnjmc

    @johnjmc

    3 жыл бұрын

    @@LittleWicketRailway thanks, I'm the same never a solenoid again, we have the Smail motors at work, it's the tortoise with a DCC decoder built in, very nice but over £30 for one. My new layout I'm looking at a new type of motor a little bigger then a servo but should be interesting. The kit I've just ordered for my turntable has a Arduino and stepper motor control. Also coming with a new controller which I will be testing, might have to do a write for one of the magazine's too.

  • @johnjmc

    @johnjmc

    3 жыл бұрын

    @@LittleWicketRailway I have 5 servos on Halland and 3 on Byway MPD. I have used the quad pic board from tam valley depot and these have been super reliable.

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    @@johnjmc let me know how you get on with the stepper motor and the turntable, I'm interested. Is the stepper accurate enough to line up the rails each time or do you need something like a sensor to check positioning/calibrate? How does it deal with the polarity reversal? How is the speed like and how noisey is it?

  • @TechGirl792
    @TechGirl7923 жыл бұрын

    Hi Rob, I've been searching the internet and especially KZread for basic ways to set up computer control on a model railway that I am in the process of designing. All the other info I've found seems to be very disjointed or are directed towards people that are very familiar with JMRI. Your videos are very simple to understand and helped me enormously. Thank you

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Thanks Sally! Glad you're finding them useful. 👍

  • @modelrailwaytheeasyway9743
    @modelrailwaytheeasyway97433 жыл бұрын

    Nice explanation Rob look forward to the follow up videos I am about to test this setup out.

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Cheers John. Let me know how you get on 👍

  • @modelrailwaytheeasyway9743

    @modelrailwaytheeasyway9743

    3 жыл бұрын

    @@LittleWicketRailway will do Rob just working through the first setup of the servos from the first series so I know they are working correctly. Then will add the sensors and servos together. I enjoy the learning the code involved.

  • @modelrailwaytheeasyway9743

    @modelrailwaytheeasyway9743

    3 жыл бұрын

    @@LittleWicketRailway well Rob the script works a treat did not take long to set it up and working. Also using a raspberry pi to run JMRI so well pleased. Now to rewatch the part 2 again and work on using a micro switch I have connected to the servo mount. Thanks once again for the fantastic series of videos.

  • @brendanhannon1577
    @brendanhannon15773 жыл бұрын

    Thank you, up to your usual high standards

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Thanks Brendan 👍

  • @lfsrailroadmodeling2329
    @lfsrailroadmodeling23293 жыл бұрын

    Thanks for this, I wondered this exact thing. 😆

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    No worries. I wish I'd known how easy it would be to combine them earlier, but this is a learning experience for all of us...

  • @obtv6827
    @obtv68273 жыл бұрын

    Yeah one less kit to buy! Great videos are a standard for you Rob. Awesome job. Board set for the DCC++ build arrived today. I have never worked with an Arduino before, and would have never considered it , but your videos make it look so easy! Thanks

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Cheers 👍 enjoy the DCC++ project

  • @56NeilWatson

    @56NeilWatson

    3 жыл бұрын

    You really can't go wrong following Rob. I pretty much replicated all of Robs projects. Have joined MERG and built one of their block detectors. I bought two. it works a treat. Have the IR sensors and tested them but not used them on my board yet.

  • @regoroso
    @regoroso3 жыл бұрын

    Thanks this works like a charm. Just started with the DCC++ and it would save the hassle of running a second uno. In DCC++EX it is possible to combine it all, though for practical reasons I understand the choice.

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    👍 DCC++EX is something I'm going to look into. Wifi shield arrived a few weeks ago, but haven't had a chance to get onto it. The guys on that project sound like they've done some good stuff.

  • @regoroso

    @regoroso

    3 жыл бұрын

    @@LittleWicketRailway the Facebook group is really helpful.

  • @alanpennington8364
    @alanpennington83649 ай бұрын

    Hi, I am finding your information extremely helpful. I have not done any model railway for about 35 years and would like to get back into N gauge. This DCC is amazing with all the things that can be done. Keep up the good work. Alan

  • @LittleWicketRailway

    @LittleWicketRailway

    9 ай бұрын

    Thanks Alan 👍 Welcome back to the hobby!

  • @alanpennington8364

    @alanpennington8364

    9 ай бұрын

    I'm having problems with JMRI. I've no electronic gear yet, but I thought I'd download JMRI first (not knowing much about electronic stuff), I've downloaded the latest version, and it is asking for Java 11 but can I find it, no way, I can find version 8, I've downloaded it but that does not work.

  • @LittleWicketRailway

    @LittleWicketRailway

    9 ай бұрын

    I think JAVA 11 is available here: www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html#:~:text=Go%20to%20the%20Oracle%20Java,on%20the%20JavaTM%20platform. The JMRI website/forums are great for support with setup issues like this.

  • @alanpennington8364

    @alanpennington8364

    9 ай бұрын

    @@LittleWicketRailway Thanks, I will give it a go later.

  • @alanpennington8364

    @alanpennington8364

    9 ай бұрын

    @LittleWicketRailway I have downloaded Java, I think? Tried JMRI and it has opened up but yours seems to be a newer one to mine as if I remember yours has DCC+++ along the top of Panel Pro mine does not. Alan

  • @brucewoods9377
    @brucewoods93773 жыл бұрын

    Once again a very informative video/tutorial. I presume the interaction between the sensor and the servo will be discussed in a later video, or should I go back to the referenced “older” videos for that? Keep up the good work and I look forward to your follow up videos on this subject.

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Hi Bruce! The sensors and servos don't necessarily need to have an interaction. This way of setting it up just means that you can run your sensor system (IR sensors, switches, block occupancy current sensors, light sensors, etc.) and control your servos for signals/points from the same piece of kit rather that two separate systems. All the sensor data gets fed back into JMRI and that's where you can decide what to do with it. So if you did want there to be an interation then you can set this up in JMRI using Logix. The possibilites are endless, but as an example, you could have it so that when a sensor on the approach to a level crossing is activated, a servo closes the crossing gates in response. I started making these videos because they're the system I need for automation. Apologies if you've already seen it, but this is a basic example of what you can achieve once you have sensors and servos in place kzread.info/dash/bejne/Z6Cq2NF7c7TSabg.html

  • @raymondidleman3899
    @raymondidleman38993 жыл бұрын

    I finally figured a work around for the Sensor issue. I had to put my laptop to sleep in 1 min and then wake it and Poof the sensors are all reading perfectly. Feels like a com issue but I am not sure at least I can make it work now without waiting an hour. Now on to my latest problem. I added in some additional Occupancy blocks and Sections so that the system could switch all the turnouts prior to starting each Transit, New issue now is tough that all my signals are auto filling RV and FW sensors that keep them red all the time so nothing will run consistently. I go in and adjust them to clear out the logic to allow the signals to work as intended and as soon as I run an auto train through the area it adds back in the sensors that are jamming up the logic and everything comes to a halt again. Another issue I am having that may or may not be related is since the modifications trying to start an auto train on my section 1 prior to the turnout it will not start. It loads like it wants to go but never throttles up. I have to manually override it and as soon as it hits section 2 I can put it back in auto and it takes off. (Until the signals get botched again that is.) Any help or point me at a good location to get it would be very appreciated. I have been banging my head on the desk for 2 weeks and cant seem to sort this one out and before i go into a large scale with this I want this small layout to operate properly so I Know exactly how to troubleshoot problems on a larger layout.

  • @EsotericArctos
    @EsotericArctos3 жыл бұрын

    Timing is fantastic. I just received my sensor shield, servo boards and servos from AliExpress and was hoping to only need one Mega to run both, given the servo controller uses I2C

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    A big project weekend for you then! Good luck!

  • @deeprunrailroad_Mike
    @deeprunrailroad_Mike2 жыл бұрын

    Thanks!

  • @LittleWicketRailway

    @LittleWicketRailway

    2 жыл бұрын

    And thanks to you too! Very much appreciated! 👍

  • @davebareham1075
    @davebareham1075 Жыл бұрын

    Hi Rob - I've recently found your channel as I prepare to build my model layout from scratch (I must have helped your viewing figures!). I've thinking of starting with the DCC++Ex - in one of your episodes you talked about producing a video about that - did it happen or is it the same as the DCC++? Many thanks for all of your hard work.

  • @hantercans
    @hantercans3 жыл бұрын

    WooHoo! Got this latest project all working. Used your "back and forth" video with it as well. My little loco is happily trundling along my 1meter test track and back. Rob, I hope you know how much help your giving with your excellent videos :) One thing, could you lower the volume of the train whistle between chapters?

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Congratulations! Haha, sure, will do👍it wakes people up who have drifted off 😂😂

  • @user-gw9bb8th6b
    @user-gw9bb8th6b8 ай бұрын

    Dear Rob Please forgive me for asking this question in poor English from Japan. I watched Rob's video and am trying to make JMRI's CMRI recognize Servo and Sensor by combining Arduino Mage and Sensor Shield. I have watched many videos so far, and I believe that the reaction of Servo and Sensor and the trial of Signal Light were successful without any problems. This time I watched this video and tried to get Servo and Sensor to be recognized by CMRI. Servo moved from CMRI and I tried to see if the sensor's sensing was transmitted to CMRI, but it didn't work. Result is, 1. Servo recognizes and operates with CMRI. It also runs commands to the CMRI monitor. 2. Although the Sensor base is sensing, it is not recognized by CMRI. →The LED will light up. Commands do not run to the CMRI monitor. (No change will occur between active and inactive on the CMRI screen) Before starting JMRI, the Arduino IDE is closed, and the COM port of JMRI's CMRI is recognized correctly. I previously tested Signal Light, and all four color LEDs were recognized by CMRI and changed. Therefore, I suspect that it is only the Sensor that cannot be recognized by CMRI. Is there a solution? Please tell me. From Japan TAKU I have something to add as I understand it. The CMRI monitor goes out of control as soon as it registers the sensor. When using a converter, the information will be displayed one click at a time. that's all.

  • @jerrydowell5962
    @jerrydowell59623 жыл бұрын

    dcc++ is also defined to mega board as serial 3

  • @chrissharp6845
    @chrissharp68453 жыл бұрын

    Cheers Rob. Another great and easy to follow video in your series on Arduino and JMRI. One small request. Any chance you could increase your font size in the Arduino coding interface on future videos? Being a little older than you my eyes are showing my age and tiny text is not as clear as it once was. Thanks.

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Thanks Chris! Yes, I will do that, thanks for the suggestion. Appreciate that it might not be easy to see, apologies.

  • @benhyde3621
    @benhyde36213 ай бұрын

    Hi Rob - excellent information, refer to these videos all the time, I couldn't get the combined sensor servo hub to work on one Mega, weirdly it works fine as a servo output but as soon as I connect and start a sensor, it works once on initial setup, but as soon as I restart JMRI it seems to disconnect the board and neither servo outputs or sensor inputs work at all - very strange, don't know if anyone else reported this. I went back to separate boards using the python script - works fine. Thankyou again for all the information the videos are excellent.

  • @stuartcoopalnd6975
    @stuartcoopalnd6975 Жыл бұрын

    Hi Rob. Loving the videos. I am hooked. I am hoping I can use push buttons on a layout board to manually operate the points and lighting etc also. Is this pretty simple to achieve aswel as being automated in jmri please?

  • @LittleWicketRailway

    @LittleWicketRailway

    Жыл бұрын

    Thanks Stuart, you can have manual and automated control side by side, might be a bit more work and a few more wires, but doable.

  • @stuartcoopalnd6975

    @stuartcoopalnd6975

    Жыл бұрын

    @@LittleWicketRailway I since watched your mimic board videos and got the answer yes!! I’ve bought all the parts from your video lists for the command station and block detection. The Amazon guy is shattered 😂. I had a nightmare last night as using Firefox platform does not show the attached hardware when clicked connect on the throttle. Tried google chrome and voila!! Can’t wait to build the block detection and all the other parts you demonstrate. It is fantastic. I owe you a drink for sure. Your channel is purely inspiring. 🙌

  • @stuartcoopalnd6975

    @stuartcoopalnd6975

    Жыл бұрын

    @@LittleWicketRailway I also bought the uno initially from watching the dcc++ video as you used one on that but then I see you use a mega in this video. I tried the uno first and it did not allow me to select ‘compile’ after selecting WiFi option in the startup software. It simply greys the button out. The mega did and I am just waiting on my WiFi board. Does the uno not support WiFi do you know?

  • @coreygibson2590
    @coreygibson25903 жыл бұрын

    Hello. I finally got your setup to work. Thanks, it's a nice setup. My question is how do I add more servos? I changed the line in the sketch for 2 servos and removed the line you had commented out for 1002. Thanks in advance.

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Change the variable 'numServos' at the top to 2 and be sure to add in the throw/closed information: //Servo connection 1 - point motor Throw[1] = 1015; Close[1] = 1800; The numbering is a bit confusing, but this is for your 2nd servo which is connected to the position labelled 1 on the PCA9685. This tells the board what the throw and close positions are for the servo connected to the pins labelled 1. Hope that helps

  • @coreygibson2590

    @coreygibson2590

    3 жыл бұрын

    @@LittleWicketRailway Ahhh. Thanks.. I will give this a shot tonight. I'm working strictly with your video. Im getting closer on the automation. Thanks!!!!!

  • @regoroso
    @regoroso3 жыл бұрын

    I ran into one issue with the servos. Might be just me, or others would have the same issue, not sure just sharing. The first 4 servos went on without issue, though the 5th started to cause issues in JMRI. It was not moving. Normaly you would say numberofservo is 5, which I did. Chaning 5 into 15 made that JMRI recognized the 5th servo as well. All 5 Servos move and are working as intended. Now for the hard part, testing.

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    How odd?!? At least you managed to get it sorted. Was the 5th servo connected to the position marked 4 on the PCA9685? The NumServo variable needs to be higher than the highest position connected on the board if that makes sense. So if connected to pins marked 8 then NumServo needs to be 9 so that the loop looks at position 0, 1, 2, 3, 4, 5, 6, 7, 8.

  • @regoroso

    @regoroso

    3 жыл бұрын

    @@LittleWicketRailway it was on position 5 (listed as 4 on the board). In the calibration script there was no issue. Theoretical it makes no sense, at least it is solved. :)

  • @kejung1
    @kejung13 жыл бұрын

    great video as always! I have combed the Arduino site for the sensor shield and cannot find it! is the shield you are using made by Arduino or some other manufacture? many thanks!!

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Hi Karl, it's not an official Arduino sensor shield, it's an unbranded clone board. Here's a link to one that should work and (assuming you're based in the UK) will arrive in a reasonable time ebay.us/Mqlmxi (please check price and seller reviews/reputation before ordering) Here's an amazon link if that's better: amzn.to/36rvUOP You can get them cheaper if you're prepared for them to arrive from China. Note that some of these sensor shields suffer from common faults. Sometimes the solder points that sit above the Arduino USB input need to be trimmed down and insulated to avoid them making contact with the USB socket casing. Some of them are also missing a 5V supply to one of the blocks of pins, I can't remember which, bit you'll soon realise if you get a board with this issue and it's easily fixed with a jumper wire.

  • @geoffhutchinson1232
    @geoffhutchinson12323 жыл бұрын

    Hi Rob, Would this work as a replacement of the previous sensor hub, without having the servo part attached, it looks easier than having to load the JMRI program for the sensors on start? I have already got the other hub working, but this looks like it may be better to use.

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Yes, definitely. You don't need the servos connected, purely option, and you're right it's a lot easier than running that script in JMRI each time.

  • @robertstokes8431
    @robertstokes843110 ай бұрын

    Hi Rob, Great Vid how would this work on a Arduino Uno with the Shield for the Uno? I just cant get it to work :)

  • @robertschworm6036
    @robertschworm6036 Жыл бұрын

    Rob, After fighting a problem of the turnout table not moving the servos,I went back into your sketch and do not see a line for the AdafruitPWM Servo Driver - -including the variable WIRE. As a result - I2C is not being used to the PCA9265 and it is trying to fire a servo on a PWM pin right on the arduino itself. Please check this out on your sketch for the 5260 mega servo shield application. Bob S - cleveland

  • @raymondidleman3899
    @raymondidleman38993 жыл бұрын

    Rob, Love your videos you make it easy to follow things that are somewhat complicated. I am having a small problem though. Every time I shut down JMRI or loose the USB (Com Port) connection my sensors do not reload automatically. To get them working again I have to go delete them out of the JMRI sensor file and then re install them once i have saved the file with no sensors. Once its all clean I can re add them and they work perfectly right up until I shut down JMRI again. As you can imagine its not a huge deal when I am testing thing with 2 or 3 sensors but I really want to get this sorted out before I start trying to set it up on a whole layout. Any help will be greatly appreciated.

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    How odd. I've not encountered this. I'm working on pt3 at the moment so will see if I have the same issue.

  • @raymondidleman3899

    @raymondidleman3899

    3 жыл бұрын

    @@LittleWicketRailway So i have been tinkering a little more and what I have found is that if I let the Board sit connected to the PC with the JMRI software up and leave it for an extended period of time it eventually finds the sensors. Only downside is every time I want to make a change and restart the software I have to go watch a movie before I can see if the changes I made are working the way I want. I also set up the servo driver system as well and it also does not recognize the driver or at least doesn't communicate through JMRI. I haven't had a chance to let it sit and see if it too comes online if I leave it alone for awhile. I will probably do that today and see what happens. I did use the Script in the Adafruit PWM library as discussed in the other video and it ran the servos as intended. So I think it has to be some sort of communication issue from JMRI to the Mega2560 or another com issue that is resolving it self over time. Any input as to where you think the issue may lie will be greatly appreciated.

  • @raymondidleman3899

    @raymondidleman3899

    3 жыл бұрын

    Update. I did find that in fact if I walk away and leave the system for the same extended period of time it finds the servo driver system as well. So I am not sure what to make of the delay in communication.

  • @brendanpratt7760
    @brendanpratt7760 Жыл бұрын

    the mega sensor shield, you have v2.0 and I have a v2.4 still use the exact same pins, just the location on the board is different ?

  • @andywaring12
    @andywaring123 жыл бұрын

    Hi Rob - In your sketch you say not to use pin 13 as an INPUT but you have initialised it as one in the FOR loop - are you still advising not to use pin 13 or have you superseded that advice? Obviously not mission critical but curiosity drives me to ask. Brilliant video, as ever - had everything set up and working on a small test within an hour of receiving the board and shield! By following your videos I've got a complete DCC and automation system for less than £100 !!!

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Thanks Andy 👍 Pin 13 is a weird one because it's attached to the board's LED along with a resistor. I've had issues using it as an input, but thought that it might be ok to use as an output. However, I tried that and got some weird results, so unless you desperately need the extra pin I'd avoid using it. If I've initialised it in the for LOOP then that's probably me being a bit lazy 😕 Had I not discovered this technology then I would never have got into digital and I suspect I may have lost interest in the hobby after a while. It's incredible that this stuff has become to affordable and accessible.

  • @andywaring12

    @andywaring12

    3 жыл бұрын

    @@LittleWicketRailway Thanks Rob. No probs with initialising the pin and not using it - just wondered if I was missing something. Actually more efficient to do it this way than to have 2 FOR loops. Thank you for clarifying.

  • @sischsenalizacionferroviar345
    @sischsenalizacionferroviar345 Жыл бұрын

    hi how are things. I make a query. I built the servo motor control with arduino 1 and the sensor hub with arduino mega. Now I'm integrating everything into the sensor hub using cmri. The sensors work perfect but the tournouts don't. Is it necessary to recalibrate the servos by loading the calibration sketch in the arduino mega? Thank you very much for your answer and excuse me for my bad English.

  • @brendanpratt7760
    @brendanpratt7760 Жыл бұрын

    noticing differences between what you have done, and the mega sensor shield v2.4. Digital pins start at 14 and go through to 53. PWM pins start at pin 2 and go through to pin 9 green pins on digital are data, but on PWM pins the green ones are pwm. Would I be right in assuming connecting the pwm and ground pins on the set pins marked 3 ?

  • @mariorossi2557
    @mariorossi25573 жыл бұрын

    Hello, would using MQTT With Arduino a better solution for communication ? As i have seen, the upcoming release of JMRI is going to add support for MQTT Sensor, Lights and Turnouts. It would be amazing to have a tutorial of that or a comparsion. Thanks!

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Hi Mario! Yes, a network that uses MQTT is the ultimate aim, but rather than using Arduinos maybe using ESP32s that have wifi built in. I think JMRI already has some support for MQTT. It's not an area that I know much about at the moment. This series will probably be my last on using Ardunios for control. I'm planning a video on mimic panels that will work with the Ardunios, but after that I'll start researching MQTT. There's nothing wrong with using Ardunios, they've served me well and they're easy to use, but on my larger layout in future I want to go wireless if I can.

  • @mariorossi2557

    @mariorossi2557

    3 жыл бұрын

    @@LittleWicketRailway Thank you for your kind answer. I guess im gonna wait for the videos to show up, keep it up :)

  • @dannydzware2023
    @dannydzware20233 жыл бұрын

    Hey, I have a question, maybe someone can help me. I can save the tables, but after a restart of the program all tables are empty. Is there a tip?

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Hi! JMRI doesn't automatically load any panels or tables back in when you restart it. However, if you go to Edit -> Preferences and then go into the "start up" menu you can press the "add" button and select "open file". Then select your config/panel file to open. Hope that helps.

  • @nevbull1322
    @nevbull13223 жыл бұрын

    Hi Rob - thanks for the amazing videos - working on a whole new layout for my son & me - and wanted to get things automated. I'm currently stumped on this one though. I've worked through the previous videos and had things working fine. Got this one set up - one servo and two sensors. All was working fine, got switching working in JMRI. Then went back into Arduino to tweak the servo settings. Re-uploaded the sketch to the Arduino, and it took ok. The when I go back into JMRI - nothing happens. The switching does nothing and the sensors arnt seen. I've restarted everything, PC, Arduino etc. Tried uploading the sketch without the shield on. Tried a second shield. Nothing seems to work. Any ideas?? Nev.

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Hi Nev, sorry for the slow reply, are you still struggling? Here are a few things to try: Did you close the Ardunio IDE before starting JMRI? Sometimes having both open causes clashes. If everything is uploading without any errors then your board is probably fine. Is your CMRI node still setup correctly in JMRI and is the COM port the correct one? Are the addresses in JMRI correct for the new upload? JMRI usually complains if it can't see a board connected where it's expecting one. So if you're not getting an error when JMRI starts then that suggests it can see a board connected on the COM port that it's expecting? You can open the CMRI monitor from the CMRI menu in Panel Pro and check to see that signals are being sent out by JMRI. Does the Arduino have power? Are the LEDs on the sensors reacting and are the LEDs on Arduino on? When you send a command from JMRI by clicking a turnout does the LED on the Arduino flash.

  • @nevbull1322

    @nevbull1322

    3 жыл бұрын

    @@LittleWicketRailway hi Rob - looks like it was an issue with the PC I was using - quite an old thing. I've changed to something newer and it seems to be good now. Any ETA on Episode 3? Want to try to avoid a ton of cabling on our new layout - 23 points to wire!

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    @@nevbull1322 glad you've managed to fix that issue. I know there's been quite a delay geting part 3 out and I'm really sorry. We were meant to be exchanging on the house this week, but on Friday night our buyers pulled out 😡 So I spent all weekend when I should have been recording trying to find a new buyer. You might have realised that nothing went out on Saturday 🙁 Things are back on track with the house, but I'm behind on the videos. I will get back onto part 3 tonight and see where I get to, I don't want to rush it and give out bad info though. If you've got 23 points to wire and presumably plenty of sensors and other outputs then I think you'll find pt3 useful.

  • @MrSoldier333
    @MrSoldier3333 жыл бұрын

    Helle, greetings from Germany, unfortunately i have some problems where i can get CMRI and Auto4855.h? how can i install your sketch in IDE? always get an error message

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Hi Peter! Both are available from MadLeech's GitHub: CMRI.h - github.com/madleech/ArduinoCMRI Auto485.h - github.com/madleech/Auto485 Can you share the error message?

  • @Fer-mu3yq
    @Fer-mu3yqАй бұрын

    Actually I have a proyect (DCC EX) in Arduino Mega. How can I upload this sketch? Another question is: Can I connect the sensors and servos directly in Arduino into the digital pins?

  • @jerrydowell5962
    @jerrydowell59623 жыл бұрын

    Don’t understand why my servo arm move slow With sensor hub configure with cmri

  • @56NeilWatson
    @56NeilWatson3 жыл бұрын

    Rob, Just a query about your sketch code. The section testing/setting the sensors cmri.set_bit(0, !digitalRead(3)); //Bit 0 = address 1001 in JMRI cmri.set_bit(1, !digitalRead(4)); //Bit 1 = address 1002 in JMRI cmri.set_bit(2, !digitalRead(5)); //Bit 2 = address 1003 in JMRI cmri.set_bit(3, !digitalRead(6)); //Bit 3 = address 1004 in JMRI cmri.set_bit(4, !digitalRead(7)); //Bit 4 = address 1005 in JMRI cmri.set_bit(5, !digitalRead(8)); //Bit 5 = address 1006 in JMRI I cannot get my head around the logic of "NOTdigitalRead(x)" code. Is it a simple test/change? Or is to invert the signal?

  • @brice3011

    @brice3011

    2 жыл бұрын

    This is for inversion. Depends on the sensor wiring.

  • @brendanhannon1577
    @brendanhannon15773 жыл бұрын

    Hi Rob, I am finally trying out your sketch, however, an error is appearing when I attempt to load it, "error: 'class adafruit_pwmservodriver' has no member named 'writemicroseconds'". This is from the line " pwm.writeMicroseconds(i, Close[i]);". If you have any thoughts I shall be grateful. Brendan

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Hi Brendan, I think this must mean that an library that you need isn't available or hasn't been included. Can you check that you've got all the additional libraries installed that are included at the top of the code and that they're in the right folders for the IDE software to be able to include them? Do you get an errors when you verify and upload the sketch?

  • @brendanhannon1577

    @brendanhannon1577

    3 жыл бұрын

    @@LittleWicketRailway Hi Rob, Thank you. I do think the problem is at my end as I have been getting some strange results from previously working samples. Brendan

  • @jerrydowell5962
    @jerrydowell59623 жыл бұрын

    when i go to add cmri connection on serial 3 i get a port in use error

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Hi Jerry, make sure you close JMRI when you're using the IDE and close the IDE when you're using JMRI. They can't both communicate with the board at the same time, so will cause this error.

  • @maxlarsen1468
    @maxlarsen14683 жыл бұрын

    can you still be Linking Multiple PCA9685 Servo Driver Boards?

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Yes, just modify the sketch as shown in the video on linking boards together.

  • @maxlarsen1468

    @maxlarsen1468

    3 жыл бұрын

    ​@@LittleWicketRailwaythanks! but is it then possible to link to sensory boards together for cleaner wiring!

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    @@maxlarsen1468 this is what I will try to do in part 3

  • @IBOFSGUBK
    @IBOFSGUBK2 жыл бұрын

    Can somebody tell me how to upload the sketch code? Rob does not show how to do it on this project or the previous project on how to center the servos, so I'm stuck before I've started I'm sure it is a simple thing to do but I cannot fathom it.

  • @LittleWicketRailway

    @LittleWicketRailway

    2 жыл бұрын

    Hi Terry, hopefully you've sorted this now, but in the Arduino IDE software there is an upload button in the top left hand corner. If your Arduino is connect then it should transfer the sketch to the board. This video (not mine) shows a couple of ways to upload a sketch (kzread.info/dash/bejne/q2mu0Kh9nbybhpc.html).

  • @IBOFSGUBK

    @IBOFSGUBK

    2 жыл бұрын

    @@LittleWicketRailway Thank you for your reply I will have a go.

  • @IBOFSGUBK

    @IBOFSGUBK

    2 жыл бұрын

    @@LittleWicketRailway Hi Rob I can upload all the sketches in the first part and make the servos move as per your instructions. But I cannot upload the seperate code that you set out below your video. It sets up the servo position for the points.

  • @IBOFSGUBK

    @IBOFSGUBK

    2 жыл бұрын

    Hi Rob, All done everything works.Many thanks.

  • @jamescoleman7318
    @jamescoleman73183 жыл бұрын

    Hello I have downloaded your sketch when I verify it I have an error "class Adafruit_PWMServoDriver has no member named writeMicroseconds" any help would be appreciated Thanks James

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    Hi James, have you downloaded and installed all the libraries from the previous videos? It sounds like you're missing a library.

  • @jamescoleman7318

    @jamescoleman7318

    3 жыл бұрын

    @@LittleWicketRailway Thanks for the reply I re downloaded adafruit driver now it compiles now I have to get it hooked up and working

  • @rogthedodge99
    @rogthedodge992 жыл бұрын

    Hi Rob. Me again! Can I be a Pain!!?? You kindly put up the code for Slo-Mo sensors on your Git-Hub, using a button switch to control the servo. I'm trying to include the 'millis' function into this video's code for servo-sensor hub controlled from JMRI to slow the servo movement down. Not having much luck. As I'm 74 years old my coding brain has somewhat shutdown! Any chance of you showing the way to include slo-mo in this video's code? Would be eternally grateful. Thanks. PS. I'm sure you would wish to use such code for your points on your fab new layout plan?!?

  • @sr33nathx83
    @sr33nathx833 жыл бұрын

    can we combine this snsor sheild wiht motor sheilD L392d?

  • @LittleWicketRailway

    @LittleWicketRailway

    3 жыл бұрын

    I've heard that it's possible, but it's not something I've done. I prefer to keep my DCC base station and other control systems separate. You would need to re-write the sketch.

Келесі