Brilliant Rob, and exactly what I want my servos to do. I now need to get my head round the code!
@LittleWicketRailway3 жыл бұрын
Thanks Tony, I've uploaded the code here if you wanted to copy it github.com/LittleWicketRailway/SlowMoServos
@tonyrogerson37293 жыл бұрын
@@LittleWicketRailway I'm looking forward to getting time to look at it in detail. Can it be included in the sketch for multiple PCA9685 boards? I have 4 boards and would like to add "slow motion" to 2 of them. They all currently run on your previous sketch for multiple boards. I am VERY new to Arduinos and Python, so have only got this far by watching your videos and copying your sketches!
@tonywincott84483 жыл бұрын
Love your Videos, please keep them coming. Now i will try to understand what you did and how you did it. Thank you so much.
@medwaymodelrailway71293 жыл бұрын
Enjoyed the video you put today. Lots going on. Hope there more to come.
@medwaymodelrailway71293 жыл бұрын
Thank you very much for replying to my comment. I would love if you could take a quick look at my page and any feedback would be greatly appreciated. I have a new video out Friday. Hope you like and share.
@LittleWicketRailway3 жыл бұрын
Thanks Dave. In terms of feedback you've got over 1k subs in 8 months so you're doing something right! If you're looking to grow your channel then focus on the analytics, they'll tell you what's working. Although, no matter what analytics says, the most important thing is that you enjoy making the videos.
@medwaymodelrailway71293 жыл бұрын
@@LittleWicketRailway Thanks for info.
@WirenwoodModelRailway2 жыл бұрын
Great video and interesting start point. Just a word of warning though. The Arduino is pretty slow to assign PWM values and if you have several servos attached, the time it takes to throw a turnout using the millis approach grows exponentially when you're moving more than one servo simultaneously. Which can happen quite often with crossovers etc. So don't measure the time you think it will take to throw a turnout with just one servo attached to your board, if you intend for more than one turnout to be thrown at the same time on your layout. Two motors moving at the same time will move at a much slower rate than just one.
@RogerDiscombe3 жыл бұрын
Hi Rob, another very useful video. I can't find the link to the Adafruit tutorial you mentioned in the video. Roger
@LittleWicketRailway3 жыл бұрын
Hi Roger, should be in there, but here it is: learn.adafruit.com/multi-tasking-the-arduino-part-1/ditch-the-delay
@RogerDiscombe3 жыл бұрын
@@LittleWicketRailway Thanks
@mikeandrew4432 жыл бұрын
Really great Rob thanks. Lots of inspiration there. Do you have a reference fro the 3d printed servo mount?
@LittleWicketRailway2 жыл бұрын
Hi Mike, that mount is from MERG and I don't believe it is publicly available. There are free options on thingiverse I believe. John JMC has just shared a servo mount idea with me using Aluminium U profile which might be of interest to you. Hope to get a video out soon.
@alantrains2 жыл бұрын
Hi from Brisbane Australia Rob. I have enjoyed your Arduino videos very much. I've been wanting a sketch that operates the servos on my semaphore signal and the millisfunctionimproved sketch with some minor changes is just what I wanted. Thanks for the work you've put in to explaining your videos.
@LittleWicketRailway2 жыл бұрын
Hi Alan! Glad that you're finding the videos useful and have got it all working 👍
@peggyscharenbroch42103 жыл бұрын
Your Vid clip has a benefit that was not discussed. Replacing delay() with millis() makes the code processing so much more efficient. I have a question. In your list of materials needed, I do not see servo mounting bracket now is it displayed in your store on Amazon. Can you share where the mount is available? Don
@LittleWicketRailway3 жыл бұрын
Hi Don The servo mounting bracket is from MERG (Model Electronics Railway Group). You'd need to join them to order the mounts. They're a great group and they have lots of other kits, so it's worth joining, but if you're just after servo mounts then it's probably cheaper to find something similar elsewhere online.
@mattsynth3 жыл бұрын
Hi Rob, WOW that was great but very confusing to me. I understand the concept of moving in steps but I am terrible at understanding coding. I am using the multi PCA9685 code you posted in a earlier video (October 20, 2020) and find it hard to incorporate these steps into that original code. If you would please show this slow servo code incorporated into that original code I would be very grateful. Thanks.
@nedmerrill57053 жыл бұрын
Good stuff! Saves wear and tear on the turnouts themselves also.
@LittleWicketRailway3 жыл бұрын
Thanks Ned 👍
@nedmerrill57053 жыл бұрын
@@LittleWicketRailway I forgot to mention that's important to me especially, since I hand-lay my N scale turnouts.
@delboy17277 ай бұрын
Or you could use a MERG servo driver module. Allows you to program end of travel both ways as well as speed of travel, and no coding required. Downside, you have to be a member of MERG to purchase the modules, and they come as a kit of parts that you have to construct yourself (not a problem if you can follow instructions and know how to use a soldering iron.)
@MP25Productions3 жыл бұрын
Everytime I think of something Rob, you post a video. Here's a question though... did you produce a video about how to code multiple servos into the Arduino? I just got my first test bed switch working per your video but would like to add the other 2 on my test layout.
@LittleWicketRailway3 жыл бұрын
Hi! Here are a a few other videos on using servos that might help: Part 1 - kzbin.info/www/bejne/l6qyoIihmc97qsk Part 2 - kzbin.info/www/bejne/nHmkgYt3mLxskLM Part 3 - kzbin.info/www/bejne/n5rJZ59rZ9F_odU And if you want to link multiple PCA9685 boards together - kzbin.info/www/bejne/rGLJkHh6fbtmb5I
@davidgreen98662 жыл бұрын
Hi Rob thanks for all the great videos on the use servo's and Arduino. I have connected my layout with around 50 servos connected on four layout boards using 5 daisy chained PCa9685 servo driver boards using the the code you used on the multiple PCA9685's. I would like to incorporate a function into that code to slow down the point(turnout) motion. Motion is initiated using JMRI. Could you demonstrate what is needed please.
@toni-si2np3 жыл бұрын
I'm sure I won't be the last one to ask the question but are you intending to have the slow motion servo control incorporated into the Sensor/Servo hub sketch? I now have the Pi controlling three arduinos; two connected to servo/sensor hubs, and one connected to the DCC++EX system. All working but the slow motion control of the servos would be the icing on the cake. Cheers Toni
@dusseljeef Жыл бұрын
Great Video... thanks. Is it possible to move Signals as in real-life when they are set? Even so slow as in this Video but whipped in the end positions as well? Greetings from a Dutch Modelrailway fan.
@rogthedodge993 жыл бұрын
I've tried to work out which sketch you are modifying. Is it Adafruit example code, your part1 or part2? Help much appreciated. Thanks
@LittleWicketRailway3 жыл бұрын
Hi Roger, I've uploaded 3 files to github.com/LittleWicketRailway/SlowMoServos - one file contains the delay code - one file contains the code with millis function used for 3 servos and the LED - one file contains the improved millis function code in which we create the bespoke function Hope this helps
@johnjmc3 жыл бұрын
Great video I have a spare nano from my Turntable project but I have no idea when it comes to code etc
@brucewoods93773 жыл бұрын
Brilliant love your simple and easy to apply instructions
@robertschworm60362 жыл бұрын
Rob, Do you think you could whip up a sketch to check all the sensor inputs as required for CMRI? Would be handy to stick a sensor on a pin and see it reported in the serial monitor and then after it all checks out, take it to your layout and know that the arduino is set to go. Bob S - cleveland
@davidrobinson82243 жыл бұрын
Just what I was looking for, how to slow them down. Next thing is, how would you go about wiring the point servo up to operate via a SPDT switch instead of using the program, as illustrated in one of you previous videos.
@LittleWicketRailway3 жыл бұрын
When you say program do you mean JMRI? Is this useful? (kzbin.info/www/bejne/Y6KofWiDfL-LeJY) Just replace the PTM switch with a SPDT.
@davidrobinson82243 жыл бұрын
@@LittleWicketRailway Hi Rob, Yes, that's what I'm after. At the moment I've only got the Arduino Uno and the PCA9685 so I just need to get a few more bits to complete the job.
@Crookedriverandeasternrr2 жыл бұрын
Very informative information. For making this video. I’m new to your channel. I liked and subbed 👍 David
@LittleWicketRailway2 жыл бұрын
Thanks David
@rogthedodge993 жыл бұрын
Hi Rob. Great stuff again, but a bit fast for me! How about your new code example put on your GIT hub? From there I can modify the code to suit Thanks
@plymouthrovadventures.646 Жыл бұрын
Good morning Rob. Trying to incorporate this Slow Motion part of the code into into your most excellent "Servo Motor Control for Model Railways Part 2". Trying but struggling with this. Any help please.
@alexandergreig89463 жыл бұрын
Great video on slowing down point motors. Along with a few others I would love to see a video on controling electrofrog points ... i.e making a frog juicer with an Arduino...
@LittleWicketRailway3 жыл бұрын
Thanks Alexander 👍 I'll add electrofrog switching to the video list. It's something I'll need to think about for the new layout soon.
@anthonykochevar75212 жыл бұрын
First off, thank you for your videos on Arduino usage. Your past videos have helped me a lot. I'd like to use the code in this video with the clock check and function for moving servos and fading in and out LEDs. I'd like to make this code work as a CMRI node and JMRI. Do you have something in the works for doing that with this code for a future video?
@frankcorr65662 жыл бұрын
Rob, great videos. Rather than do all that complex multi tasking wouldn't ut be easier to have I e arduino handling all the servos and handling all the detectors. The detectors need an immediate response. Perhaps this way each set of point's in a coordinated change coukd change sequentially. This might be quite realistic.
@frankcorr65662 жыл бұрын
Typo - 1 arduino to handle all the detectors and another to do the servos.
@crescentjunction3 жыл бұрын
Great video! Is there any way you could share the three versions of code so we can better understand what is going on in it?
@LittleWicketRailway3 жыл бұрын
I've uploaded 3 files to github.com/LittleWicketRailway/SlowMoServos - one file contains the Delay function code - one file contains the code with millis function used for 3 servos and the LED - one file contains the improved millis function code in which we create the bespoke function Hope this helps 👍
@crescentjunction3 жыл бұрын
@@LittleWicketRailway oh, yes, Thanks!
@henrybest40573 жыл бұрын
Are the Mr. Nano animations yours? They're the ideal way to explain the problems of blocking code and why you should use non-blocking code where necessary.
@jackiedowse10973 жыл бұрын
Loved Mr Nano, as the rest is way over my head. 🤣🤷🏻♀️
@catchxxii44303 күн бұрын
Do you have to remove the spring from the points? I’m doing this for n gauge using peco pls-100 and they just aren’t moving them 😢
@donaldkormos55293 жыл бұрын
A great video ... lots for me to learn ... thanks so much, your efforts are very much appreciated!!
@paulhargreaves14973 жыл бұрын
This is gold! Please do more! Would love to sort out electrofrogs and what you do when you need more than one Arduino unit..........again, your presentation is perfect for my knowledge level 😍 EDIT " Just realised I have more than one USB terminal.......so OK on that! Electrofrogs, would like to use a servo too, but how do you change polarity at the same time?
@sawnofflockie71803 жыл бұрын
I have electrofrog points, and just used a relay that activates when the servo is triggered. Most relays have a 'normally open' and a 'normally closed' output. which is ideal for frog switching. Relays are better for this than Triacs as they will handle both DC and AC (for DCC systems).
@paulhargreaves14973 жыл бұрын
@@sawnofflockie7180 Thanks.... going to set up a small test track, then experiment with this kind of stuff. Fortunately, none of this is outrageously expensive....makes up for dcc loco costs! 😥
@WirenwoodModelRailway2 жыл бұрын
For electrofrogs you can just buy servo mounts that have space for an SPDT microswitch. Some, currently on eBay, come with one already fitted. The microswitch acts the same way (almost) as the accessory switch that you'd add to a Peco seep motor. The microswitch has the same three solder connectors - your positive and negative track power connectors and one that goes to the frog. The switch is placed on the mount so that when the servo arm moves, say to the right, the bottom of the arm will make contact with and press the switch down. The switch then switches which of its inputs is connected to the output to the frog. It's simple but effective. I'd gone down the relay route too and it's clever, bit way more complicated, takes up output pins and needs more code. I was also concerned about what state each frog would assume at startup. Would the relay remember the previous states after power loss? Would turning the system on result in servo movement that got them out of sync with the frog polarity? Because it's reactive code setting frog polarity at a single point in time, I think the solution could be prone to the two becoming out of sync, leading to short circuits. Whereas the microswitch solution is just beautiful in its simplicity!
@paulhargreaves14972 жыл бұрын
@@WirenwoodModelRailway Wallsrail has a nice DIY servo mount in plastic card. Just need to start trying some of this stuff!
@WirenwoodModelRailway2 жыл бұрын
@@paulhargreaves1497 I had a little play yesterday with a mounted servo motor, trying both the microswitch method and the relay. On the mount I had, the microswitch wasn't all that reliable, the servo arm could slip off it and not keep it pressed, which would mean a short. I put a lot of tape on the microswitch and that seemed to improve grip. The relay does seem to remember its previous state after loss of power, which is very encouraging.
@emmcommentary19003 жыл бұрын
I really love your videos and they helped me so much but i have an issue. I am trying to get 2 ardunio megas to work with JMRI. I have them both setup in preferences with different CMRI addresses but for love nor money can i make them work….nope. HELP.
@LittleWicketRailway3 жыл бұрын
Are they connected on different COM ports?
@emmcommentary19003 жыл бұрын
@@LittleWicketRailway they are yes and for some reason the second one will not respond. 1st one is on Com3 and is your fantastic shield of servos / sensors. 2nd one is on Com4 and i use it for Leds. But i might just combine them.
@tonyclixby9 ай бұрын
Excellent. Brilliant.
@bobbyboy19622 жыл бұрын
Thanks so much for this. I have tried to add this milli, (Milli improved sketch) to the servo sketch for my 20 servos using the servo sketch from you but i am not having any luck getting it to work. I have had both sketches opened and trying to figure it out but nope lol. I do have all the servos calibrated and working well through jmri and your vids but would like to get the servos to slow down for both appearance and i think the calibration on them would be better too, i think lol
@iainreeves57972 жыл бұрын
Try this: /* turnOp This sketch operates a number of servos at a realistic speed taking the close (maxValue) and throw (minValue) commands from JMRI. It also causes an associated relay to changes state as the turnout reaches its new position. This can be used for frog polarity switching, signals etc. The sketch is based on two sketches compiled by Rob at Little Wicket Railway (links below) github.com/LittleWicketRailway/ServoControl/blob/master/Servos.ino github.com/LittleWicketRailway/SlowMoServos/blob/main/MillisFunctionImproved.ino Starting with the servoControl sketch, sections from the MillisFunctionImproved sketch were added. Development was then carried out with a considerable amount of advice from Wildbill on the Arduino Forum. This sketch is currently running on a test bench operating four servos via an Arduino Mega with a PCA9685 NOTE: minValve drives the servo right/clockwise, maxValve is left/anti-clockwise Thrown sets the turnout to the divergent route. Closed sets the turnout to the straight route. Iain Reeves Jan 2022 */ #include #include #include #include #define CMRI_ADDR 1 #define DE_PIN 2 #define numServos 4 //The number of servos connected Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(); //setup the board address 0 Auto485 bus(DE_PIN); // Arduino pin 2 -> MAX485 DE and RE pins CMRI cmri(CMRI_ADDR, 24, 48, bus); int Status[numServos]; //Create a table to hold the status of each turnout //Create a table to hold the throw value for each servo int minValue[numServos] = {1000, //LY1(turnout ID) - enter values obtained from the Little Wicket calibration sketch 1100, //LY2 1200, //LY3 1300}; //LY4 //Create a table to hold the close value for each servo int maxValue[numServos] = {2000, //LY1 1800, //LY2 1900, //LY3 2000}; //LY4 int CurrentPosition[numServos]; // table to hold the current positions of each turnout int StepSize = 5; // if you require servos operating at varying speeds use an array here int StepSize[numServos] = {5, 5, 3, 2}; to create a table to hold the step size for each turnout. Also add [i] to each StepSize term. int DelayTime = 15; // if you require servos operating at varying speeds use an array here DelayTime[numServos] = {15, 15, 10, 5}; to create a table to hold the delay time for each turnout. Also add [i] to the DelayTime term. // Create a table to hold the output pin for each turnout relay int Relay[numServos] = {36, //LY1 38, //LY2 40, //LY3 42}; //LY4 unsigned long previousMillis[numServos]; // table to hold the previous movement time for each turnout void turnOp(int inputPin, int i) //function to drive servos at slow speed { unsigned long currentMillis = millis(); if (((cmri.get_bit(i) != Status[i]) && (currentMillis - previousMillis[i] >= DelayTime))) // compares CMRI signal against state of turnout and checks sufficient time has passed since last movement { previousMillis[i] = currentMillis; // updates last movement time if ((cmri.get_bit(i) == 1 )) // checks if (cmri.get_bit(i)is 1 { if (CurrentPosition[i] < maxValue[i]) // then checks if current position value is less than maxValue - 'maxValue' used to account for L/R turnouts { CurrentPosition[i] = CurrentPosition[i] + StepSize; // if both the above statements are true, moves turnout by one step (increasing) pwm.writeMicroseconds(i, CurrentPosition[i]); // updates current position } else { Status[i] = 1; // sets Status to 1 digitalWrite(Relay[i], LOW); // de-energises relay associated with turnout [i] } } else { if (CurrentPosition[i] > minValue[i]) // checks if current position value is greater than minValue - 'minValue' used to account for L/R turnouts { CurrentPosition[i] = CurrentPosition[i] - StepSize; // moves turnout by one step (decreasing) pwm.writeMicroseconds(i, CurrentPosition[i]); // updates current position } else { Status[i] = 0; // sets Status to 0 digitalWrite(Relay[i], HIGH); // energises relay associated with turnout [i] } } } } void setup() { Serial.begin(9600); bus.begin(9600); pwm.begin(); pwm.setPWMFreq(50); // This is the maximum PWM frequency int i; // centre servos when JMRI gives first command CurrentPosition[0] = 1500; CurrentPosition[1] = 1500; CurrentPosition[2] = 1500; CurrentPosition[3] = 1500; // set up relay pins { for (int i = 0; i < (numServos); i++) pinMode(Relay[i], OUTPUT); digitalWrite(Relay[i], HIGH); } } void loop() { cmri.process(); for (int i = 0; i < (numServos); i++) turnOp(2, i); }
@johnmarshall26603 жыл бұрын
Hi Rob, another great video, I used a PCA9685 to control 12 sets of points but found I was loosing servo's prob due to fast movement so eventually went for Servo 4 and Mega points controllers from MERG and was going to get 2 more Servo 4 boards but I think I will try your idea as I need 4 more points switching, also on one of my sketches I had 5 points to change at the same time so made a delay so they didnt all switch at once as would be in signal box .. regards John
@LittleWicketRailway3 жыл бұрын
Thanks John. I hadn't thought of that, but you're right, the points wouldn't move together would they as the signalman would need time to throw each lever. Interesting that you were losing servos. Could it be that they were burning out because they met resistance when turning? Presumably not if they're working fine with MERG controllers.
@johnmarshall26603 жыл бұрын
@@LittleWicketRailway Yes I think the reason was, I was using a PCA9685 with 8 point servo's connected to it and I think they had moved to Max position also they didnt disconnect after moving, Ive got a MERG Megapoint controller which I connected up but still to setup ... also monitoring current helps as I think they take about 150ma when moving so if goes up to say 350ma you know you have a problem ... Also just got my DCC++EX with Wifi working ...LOL Regards John
@frightrisk74073 жыл бұрын
How many hours did this one video take to make. I would love to know! Great job
@LittleWicketRailway3 жыл бұрын
Thanks! Waaaaay too long.
@nigelbroadhead18932 жыл бұрын
Thanks
@LittleWicketRailway2 жыл бұрын
Thanks Nigel 👍 much appreciated
@JoeHardy193 жыл бұрын
This is a brilliant video! Would it work the same way with the CMRI controlled code? Like, create the servo delay function and then make the references etc
@LittleWicketRailway3 жыл бұрын
Yep, sketch gets the data from JMRI and then you can process that however you want in the sketch.
@iainreeves57972 жыл бұрын
@@LittleWicketRailway I'm attempting to combine the slow-motion code with the previous servo control sketch as I'm looking to use CMRI to control the points rather than push buttons. I'm struggling to find the right code to do this and every where I look online seems to have a different method for control of the servos. Do you have any pointers?
@iainreeves57972 жыл бұрын
The script below is where I have got to. I'm guessing that the issue could be with setup statement, particularly "pinMode(DE_PIN, INPUT); ". I have also seen a lot of scripts using cmri.get_bit() but I have not ventured down that path yet..... I'm very much a beginner at this game so I appreciate any comments. // In this form the servos cycle once as sketch is uploaded and again as JMRI starts (before tables are loaded) but then fail to respond to CMRI commands #include #include #include #include #define CMRI_ADDR 1 #define DE_PIN 2 #define numServos 3 //The number of servos connected Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(); //setup the board address 0 Auto485 bus(DE_PIN); // Arduino pin 2 -> MAX485 DE and RE pins CMRI cmri(CMRI_ADDR, 24, 48, bus); int Status[numServos]; //Create a table to hold the status of each turnout (LY1, LY2, LY3). int Throw[numServos] = {1100,1100,1100}; //Create a table to hold the throw value for each servo - set to nominal values for now int Close[numServos] = {1700,1700,1700}; //Create a table to hold the close value for each servo int CurrentPosition[numServos]; int StepSize[numServos] = {10,5,20}; // various step and delay settings to compare and contrast int DelayTime[numServos] = {75,38,150}; unsigned long previousMillis[numServos]; void moveServos(int inputPin, int connection) { unsigned long currentMillis = millis(); if ((digitalRead(inputPin) != Status[connection]) && (currentMillis - previousMillis[connection] >= DelayTime[connection])) { previousMillis[connection] = currentMillis; if (digitalRead(inputPin) == 1) { if (CurrentPosition[connection] < Throw[connection]) { CurrentPosition[connection] = CurrentPosition[connection] + StepSize[connection]; pwm.writeMicroseconds(connection, CurrentPosition[connection]); } else { Status[connection]=1; } } else { if (CurrentPosition[connection] > Close[connection]) { CurrentPosition[connection] = CurrentPosition[connection] - StepSize[connection]; pwm.writeMicroseconds(connection, CurrentPosition[connection]); } else { Status[connection]=0; } } } } void setup() { pinMode(DE_PIN, INPUT); // Trying to get CMRI command into the Uno - also tried INPUT which resulted in no movement at all Serial.begin(9600); bus.begin(9600); pwm.begin(); pwm.setPWMFreq(50); // This is the maximum PWM frequency } void loop() { cmri.process(); moveServos(2,0); moveServos(2,1); moveServos(2,2); }
@bobbyboy19622 жыл бұрын
@@iainreeves5797 Hey Iain, did you have any luck with what you are trying to do as i think we are trying the same thing? I have tried what i thought may work but, no luck. I have my entire layout running on jmri and cmri as per the vids but would like to slow down the servos.
@iainreeves57972 жыл бұрын
@@bobbyboy1962 I have posted a sketch on the Arduino Forum which works on the test bench. I just need to transfer it to the layout now.
@andrewverden79653 жыл бұрын
Great video. I think you could improve things should mr nano get overwhelmed by adjusting the position of a servo relative to where it should be using the internal nano time you have. i.e. calculate the new servo position relative to the time you started the movement of the servo and how long it should take to move. So if there are a lot of servos they will be considered less often but the messages sent will require a great angle of movement. regards Andrew
@RobA5003 жыл бұрын
At the end I think all that coding has made you go loopy 🤪. Nice explanation none the less.👍
@LittleWicketRailway3 жыл бұрын
I'm not sure why, but making this video really did drive me a bit nuts 🥴 it just seemed to never be finished 😫
@JMACCSArmiesOfMiddleEarth3 жыл бұрын
This could be completely wrong but wouldn't it be easier to use float instead of int and go up in steps of 0.3 or something? You wouldn't need a delay or anything
@johnkenrick-oy9mk Жыл бұрын
Hi Rob Great videos I have went a lot. I am using your servo motor control code with PCA9685 works fantastic with Jmri. I have been trying to incorporate your improved slow motion server code into the servo motor code and not having much luck. Is there any possibility you could put some code on your git hub that has slow motion servos connected to PCA9685 controlled with JMRI. All the best John.
@stevebeckford67752 жыл бұрын
I have built crossing gates for my layout using Arduino and two servos, the problem I have is that when the system is first powered up the servos do a jump like they are resetting themselves and my gates crash into each other, causing damage, after that they work just as I want, can anyone help to stop the power up jump.
@iainreeves57972 жыл бұрын
I had a similar problem when working on a sketch to drive the servos slowly using JMRI to control them. You could try centring the servos in setup (I used CurentPosition[0] = 1500;). You do seem to have to do this for each servo. I did try a for loop and CurentPosition[i] = 1500; but it only fixed the issue on servo 0.
@LittleWicketRailway2 жыл бұрын
I'll look into this, it sounds like an issue I'll encounter too.
@BillyGates1721 Жыл бұрын
most experts are suffering from beginner-difficulties-blindness-of the expert. A tutorial video should either explain ALL details intensively or concentrate on the baiscs by leaving out additional details but not half of the first and half of the second. You should keep short on the pure function: controlling mutltiple things at the same time with leaving away details like the LED is connected to pin xy / how to control a PCA9685 or to expand on all these details including schematics. Me personal I prefer the reduced version that concentrates on the principle thing
@EsotericArctos3 жыл бұрын
If the real thing takes about 1.5 seconds, then to scale, it should move quicker to move the smaller scale I would think. What would the actual ratio be?
@LittleWicketRailway3 жыл бұрын
I did consider this, but I assumed that whilst distance would scale down time would remain the same. I've heard that some clubs simulate an hour of real time in 15 minutes for example, so they can get through a full simulated day of running in a few hours, but I wonder if they drive their trains at 4 times the scale speed to match?
@EsotericArctos3 жыл бұрын
@@LittleWicketRailway Interesting theory. Maybe they do, dependent on if the actual distances between the stations are to scale also :) It opens a whole can of worms there
@novakingood37883 жыл бұрын
I think of my 4mm layout as the real thing viewed from half a mile away, so everything should move at the speed they would if you observed the real thing from half a mile away. I suppose it's a moot point, but for me, everything rocketing around the layout if you were to scale time as well would look ludicrous. I've always assumed the 15minute/hour timetable is nothing to do with scaling time, but merely to ensure that there aren't hugely long periods when nothing happens as on the real thing.
@EsotericArctos3 жыл бұрын
@@novakingood3788 Speed is scaled down to match layout scale for loco speed. There is a formula for that. I was just raising a point that maybe point speed should be scaled, but to be honest, most use the "real" speed to do the points rather than any scaling. Still, the steppers are better than the old solenoid point switches. :)
@davidorf39213 жыл бұрын
It's an interesting topic, let's take a simple scale of 1:100 if the real point moves 200mm in 2 second (360m/h) then the scale point moves 2mm in 2 seconds (which after scaling the distance gives the same 360m/h) but if we scale the time by the same scale factor then it would be moving 2mm in 0.02 seconds which to scale is 36km/h by that same idea a real train moving at 100kph would at 1:100 scale have to move at 1kph if you only scale distance or 277mm per second but if we scale time down as well then it would be moving at 27.7 M/s probably a bit fast for most layouts ;-) Time is normally altered for convenience on layouts so that for those watching a country station you see more than a fast and a stopping service going each way over an hour, however if you were creating a model of a busy terminus station in any major city you might not want to speed time up because there's already plenty going on. Note that even on speeded up layouts the train speeds tend to be accurate, it's basically like watching a CCTV tape where the tape is sped up whilst no trains are in the station.
@squidgytop.20503 жыл бұрын
Do a video of the Eurostar train
@LittleWicketRailway3 жыл бұрын
If I can get my hands on one then I would, but unfortunately I don't have one at the moment 😦
@brucewoods93773 жыл бұрын
Care to share your code please?
@stevebeckford67753 жыл бұрын
Great videos can you publish the code It could solve my three year problem
@LittleWicketRailway3 жыл бұрын
Hi Steve, I've uploaded 3 files to github.com/LittleWicketRailway/SlowMoServos - one file contains the Delay function code - one file contains the code with millis function used for 3 servos and the LED - one file contains the improved millis function code in which we create the bespoke function Hope this helps 👍
@stevebeckford67753 жыл бұрын
Thanks for the upload. But cant get it to verify ( line 3 "exit status 1 stray '#' in program ), I don't understand , sorry to be a pain. All i want to do is open and close crossing gates.
@davidrobinson82243 жыл бұрын
Thanks!
@LittleWicketRailway3 жыл бұрын
Thanks David! Very much appreciated.
@tonyrogerson37292 жыл бұрын
Can this be adapted to work with CMRI?
@kaustubhponkshe61863 жыл бұрын
anywhere complete code is uploded?
@LittleWicketRailway3 жыл бұрын
I'll drop the code into github later today and share the link 👍
@kaustubhponkshe61863 жыл бұрын
@@LittleWicketRailway Yes please
@kennethoriel74633 жыл бұрын
@@LittleWicketRailway yes, please share - I am trying to get it from the video, but still can't quite decipher it. Thanks for your videos, they are uniquely informative.
@LittleWicketRailway3 жыл бұрын
Sorry for the delay. I've uploaded 3 files to github.com/LittleWicketRailway/SlowMoServos - one file contains the Delay function code - one file contains the code with millis function used for 3 servos and the LED - one file contains the improved millis function code in which we create the bespoke function Hope this helps 👍
@marcoferrari92053 жыл бұрын
Great !
@LittleWicketRailway3 жыл бұрын
Thanks Marco 👍
@MalcolmCrabbe3 жыл бұрын
I use arrays for the 16 servos, allows easy updating via for loops - This is the section in my controller code that can move upto 16 servos at the same time - no delays void updateServos() { // update any servos that are actively moving // or mark them as done for ( int i = 0; i < servonum; i++) { switch ( servoState[i] ) { case SERVO_MIN: break; case SERVO_MAX: break; case SERVO_INC: // servo is moving up so increment pulsewidth and stop if at max microsec[i] += config[i].SVspeed; if (microsec[i] >= config[i].SVmax) { microsec[i] = config[i].SVmax; // make sure we do not exceed max servoState[i] = SERVO_MAX; // mark servo as complete } break; case SERVO_DEC: // servo is moving down so decrement pulsewidth and stop if at min microsec[i] -= config[i].SVspeed; if (microsec[i]
@repeters13 жыл бұрын
Great video! I like the way you explain things in all of your video's that I've watched so far. Just one thing, in real life, wouldn't both gates go up and down at the same time insuring stopping of vehicles from getting stuck on the tracks? Wouldn't it be easier to operate both signals off the same command?
@LittleWicketRailway3 жыл бұрын
You're right, you would have both barriers in the same loop moving together, but I just wanted to demonstrate the principle with something visible. I should have used flashing red LEDs as another example where you want them to be activated at the same time as the barriers.
@sawnofflockie71803 жыл бұрын
When incrementing or decrementing a value by a known step size you can use += or -=, e.g. i += Step[0]; is equivalent to i = i + Step[0];, and i -= Step[0]; is equivalent to i = i - Step[0]; Saves a bit of typing when you have long variable names :-)
@robertschworm60362 жыл бұрын
Rob, I am looking at your servo slow down sketch. It would be very helpful if you could incorporate this into your last main modified sketch , where the first line of that sketch reads - -:This sketch combines servo turnout control, sensor inputs, and other outputs.". This is the sketch whereby you assigned the Servo Shield Pins to accomodate OUTPUTS. This servo slowdown sample sketch does not align with the needs of that sketch. Thanks much. Bob S - Cleveland, OH
@bobsmodelrailways3 жыл бұрын
Lost me in the first sentence ☹️ I just can’t puck it up these days.
@johnlong32143 жыл бұрын
👍 + 🔔
@LittleWicketRailway3 жыл бұрын
Thanks John 👍
@TimberSurf3 жыл бұрын
You should NEVER use "delay", first half of video was a bit pointless explaining it! lol
@LittleWicketRailway3 жыл бұрын
But if you've only got one point motor attached to your controller or you're not too bothered about having to wait then delay is all you need and it's very quick to implement.
@TimberSurf3 жыл бұрын
@@LittleWicketRailway Totally agree, but its a principle that we should be showing good practices rather than poor ones, plus most will copy and paste chunks of text from others so better its 20 lines of good code than 10 of "gona cause a problem"!