Hi Paul, Merg use the mosfets for their pulsed accessory decoder DCC11/13 and drive them directly from a pic 16F628. I have hacked one of these boards and drive it from the Arduino. It works well so far. I used it because it had the CDU built in and saved me building another. The Mosfet is P36NF06 although the TB gives STP16NE06L or FP3055LE. Is this to be used to switch on the servos after the aduino boots. In the image the ribbon cable goes to the Arduino Mega. It's all hanging just now . Colin Attached files
Not much progress lately, as I had to relocate everything out of the Man Cave to put a bed in for my Mum to stay in over christmas. So I have been punted upstairs into the young lads bedroom, PC setup,so at least I can post. Few of arrivals from China / Hong Kong 20 x 5V trigger FETs, and 50 each of 40 pin Male and Female 0.1" headers No excuses now to get these babies started . Paul
Ohhhhh boy, I feel a migraine coming on we're going back to the dark side again. Looking forward to trying to understand this Paul. Cheers Toto
Toto wrote: Interesting times ahead with eletrickery ahead for both Vicky Road and Luib Bridge as well.
SMR CHRIS wrote: I have found the soldering Iron, just need to find the kettle lead to power it - and no I can't pinch it from the kettle - Toto will need the extra strong coffee it can provide Paul
Okeley dokely ....... The wire links for the servo signal output. Then the positive feed wires plus 1 of the negative links, as the design has been changed to allow a MOSFET to control the power to the servos to prevent twitching during the arduino boot process where the output may float. the diode and 3 resistors have also been fitted. Next the male and female header strips for the servo and arduino. I usually just solder the Optoisolator to the board, but have decided this time to fit a 8 port DIL socket. Back in a few mins Paul
Sockets in, terminal blocks and the wire link I missed from the optoisolator to D2 for the DCC commands input Now just have read up on the FET's to make sure I get this right. Later Paul
Imagine missing the optothingy. Geeeeeeshhhh. Not paying attention I suspect. Looks very neat Paul. ..... Eh ....... Do I need one of these. Cheers
Probably ......... It will control upto 10 servo's either individually or in multiples depending on how you want to operate them. You specify the DCC accy address to operate the servo(s) which means they can be controlled by your mini-panels to automate them as macros. The dark side beckons - the force may be strong in this one yet Paul
If I was only using say four servos, could I use the other six outputs simply as switches for lights say ? You were speaking of 7 or 8 servos for the hopper but I don't think it needs to have that many. I think I could get it down to say 4. I may look at motorising the lowering and rising of the lower hoppers. I think it would be smoother. I just need to get my head around it but generally, 1 motor, 1 shaft and two geared uppy, doonie things. Whatcha think ? I could build a motor housing on top of the roof. ......... Smashing or wot. S'pose it could be servos in the motor housings with linkages as well.: got me thinking now. This could turn out a bit of a teaser, but worth it.
I'd go for a motor, driving a scewed rod, with a T nut at the top of the hopper tube / shaft. The motor driven by a simple DPDT relay wired as a simple reverser, andwith a limit switch at each end to stop the travel, and a diode bypass to allow the motor to start when the current is reversed i.e. the relay changes state. 1 output from the arduino could control the motor via either an opto isolator, or a transistor to control the relay. On the circuit shown you have 10 digital outputs available for what you want, but would need a little fiddling. Instead of the jumpers going to the servo connectors, they would need routing to terminal connectors instead, and the arduino sketch altering to suit. Not a real big issue, just fiddling. I can feel the dark side getting stronger within this one, first O gauge and now electronics Paul
I can feel the force on this one. Only cos I have to. It's trying to picture some mechanism that will give the lower hopper a straight vertical lift. I'm not visualising it myself yet. As always, I need to be able to visualise it. I'll get there. A sketch of the up and doonie bit with the various gears, rods etc.
In laymans terms, Paul, how do you know what componentry to use and where to put it on the PCB? Feeling I should have done electrical engineering. I've done a bit of reading on the arduino gear. Love an elegant solution. Reidy
Hi Reidy I'm not electronics engineer either, just a self taught basher, so this is my way and very likely not the right or best way. I use the internet a lot, plus a couple of books on arduino programming and the MERG resources, each member gets a DVD with tutorials etc on basic electronics through to some very complex subjects. Most of the examples have the components identified, so screen shots and store for later. When working on a project, you need to write a specification of what you want the project to do, so for example, this one, needs to be controlled by DCC, and to operate servos. I then start put the bits together like a lego set. The Fritzing application is great for this once you know the bits. For new projects, I tend to use a bread board to assemble the components and test the theory, once its ok, then start up Fritzing and start to place the components on to the vero board and follow the wires on the breadboard and add them on to the fritzing drawing, it will take a few attempts, but it will become easier, and you start to understand your design a lot better. If you compare my traverser, dcc accy decoder and dcc servo diagrams you will see a lot of commonality between each board, as all have the same dcc input, if it works why reinvent the wheel. (I will post links when I get home) Paul
There is still the MOSFET to install and the rest of the negative return, more of which soon..... Now for the program bit - you'll see why I've jumped to here in a short while. Using Ruud Boer's RB_DCC_Decoder_Servo.ino file from his Arduino_DCC_S88.zip file downloaded earlier from his site. Opening up the sketch in the arduino program:- First the introduction ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Arduino DCC Servo and Function Decoder // Version: 1.4 - 2015-04-23 // Author: Ruud Boer // This sketch turns an Arduino into a DCC decoder with max 12 servo motor outputs combined with function outputs. // The DCC signal is optically separated and fed to pin 2 (=Interrupt 0). Schematics: www.mynabay.com // Many thanks to www.mynabay.com for publishing their DCC monitor and -decoder code, which is used in this sketch. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// And Ruud is giving a warning about - and this is the reason behind fitting the MOSFET to the circuit we will make changes to the sketch and hardware to overcome the twitching. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // IMPORTANT: GOTO lines 23 and 44 to configure some data! // IMPORTANT: To avoid servo movement and possible high current draw at startup: // - First start the Arduino, the software now sets the servo angle values to 'offangle'. // - After a few seconds, switch the servo power on ... they will possibly show just a minor jitter. // - This only works if you set all servo's to offangle before shutdown! ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Now some code - this is the libaries the sketch needs to load to be able to create the sketch. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include <DCC_Decoder.h> #include <Servo.h> #define kDCC_INTERRUPT 0 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// the DCC_Decoder.h is the libaries for the arduino to decode the DCC packets the Servo.h is the library to be able to control the servos and finally the "define kDCC_INTERRUPT 0", is telling the arduino that the DCC signal is being fed onto interupt 0 which is arduino pin D2. Lines 23 to 25 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// const byte maxservos = 10; //The number of servos you have connected to this Arduino const byte servotimer = 60; //Servo angle change timer. Lower value -> higher speed For the standard design I have built there are 10 servos on the board, If I only wanted to have 5 servos then maxservos = 10 would be changed to maxservos = 5 the servotimer value is a copromise value for all servos Based on the above information the sketch then builds up the data structure for each servo ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// unsigned long timetoupdatesetpoint = millis() + servotimer; struct servoItem { int address; // DCC address to respond to byte output; // State of DCC accessory: 1=on, 0=off (ECoS: on=straight, off=turnout) byte outputPin; // Arduino output pin for additional function (not where servo is attached to) byte angle; byte setpoint; byte offangle; byte onangle; Servo servo; }; servoItem servos[maxservos]; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Now the data structure has been created you need to populate it with the appropriate values for every servo. Note the servos are numbered from 0 to 9, not 1 to 10 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Fill in the data for every function and servo. // COPY - PASTE as many times as you have functions. The amount must be same as in line 22 above! // A servo is coupled to an accessory[n]. It rotates based on accessory[n].output = 1 (CCW) or 0 (CW) // If you have multiple servos you need to couple them to different accessories. However ... // accessories may switch the same output pin (e.g. pin 13, which has the on board led attached) ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void ConfigureFunctionsAndServos() { servos[0].address = 1; // DCC address for this accessory servos[0].outputPin = 13; // Arduino pin number for additional function output (not where servo is attached to) servos[0].servo.attach(3); //Arduino pin number where servo is connected to servos[0].offangle = 68; //Angle for DCC=off. For ECoS turnout is DCC off, straight is DCC on. servos[0].onangle = 126; //Angle for DCC=on. For ECoS turnout is DCC off, straight is DCC on. servos[1].address = 2; servos[1].outputPin = 13; servos[1].servo.attach(4); servos[1].offangle = 112; servos[1].onangle = 62; . . . . servos[9].address = 10; servos[9].outputPin = 13; servos[9].servo.attach(12); servos[9].offangle = 124; servos[9].onangle = 64; } // END ConfigureFunctionsAndServos() ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Lets look at one example servos[9].address = 10; the address is the DCC accessory address, these do not need to be consequtive numbers, but some DCC systemswork in block of 4 or 8. NCE doesn't care, so you allocate any address in the range 1 to 2044 servos[9].outputPin = 13; by using this additional output pin, Ruud gets the arduino to illuminate the onboard LED when the servo is in motion. But you could specify another pin to trigger additional actions, with the Nano and Uno weve not got a lot to spare servos[9].servo.attach(12); this is the actual output pin that supplies the signal out to the servo (all the wire links on the board) servos[9].offangle = 124; this is the position when the servo is in the off position servos[9].onangle = 64; this is the position when the servo is in the on position Note the off angle can be greater or less than the on angle. Part two will follow Paul
Part 2 has being delayed due to me running out of outputs and wanting to clear up a couple of point. I have been in touch with Rudy Boer - a very friendly and helpful person, and I hear you say..... Well first point, dfue to the way the servo library is written 10 servo's are the limit the library can handle. Next, and very important for me, the Analog ports can be used a Digital I/O So the updated circuit diagram The FET gate is connected to A0 (pin14). The source is connected to the common ground of the servos, and the drain to the board common ground. Two additional gap were cut on the board to insulate the grounds from the 3.3 and Aref pins on the arduino. Paul