Jump to content
 

jbsorocaba

Members
  • Posts

    34
  • Joined

  • Last visited

Posts posted by jbsorocaba

  1. Hi guys

     

    DCC++ work very well and yo can find more project on Bodnar site.
     
    Last month i build a DCC++ wireless to work with Roco IOS application and tyhis way you can controll your trains with your smatphone
     
     
     
    Arduino has now a Mega with wifi  ( https://robotdyn.com/mega-wifi-r3-atmega2560-esp8266-flash-32mb-usb-ttl-ch340g-micro-usb.html ) and with a motor shield or ethernet shield you can build
     
    a wireless system or ethernet syste wit a router
  2.  

    just thought id upload some more pictures of my touch screen interface for the turntable...

     

    the main screen

     

     
     
    this is the 1st settings screen..
     
     
     
     
     
     
     
     
     

    The system uses the I2C interface to send commands, so hopefully should be easy to use for other projects too.

     

    Hi ianjeffery

     

    I made a system like this for my turntable and a traverser with 4x4 keyboard. 

    This is very interesting because you have a touch screen that gives a more beautiful layout, and dont have contacts like keyboard.

    Could you please if possible share with us the sketch of this interface..?

  3. Wow, that's fantastic. Would love to see it in action, can you upload to YouTube then post the link?

    Hi Deev

     

    Sorry but I dont know how to upload videos on You Tube. However, I have a little site about model railroad (google sites - restricted access) and you can see a little movie that I made last month when I was making the setup.  I have some others project there, but unfortunately they are in portuguese.  Sorry..!!
     

    site:   https://sites.google.com/site/dcceferromodelismo/videos

  4. Hi Deev

     

    Long time since my last post

    Some years ago, I saw your first post here showing a german traverser, and you wrote:" I want one." and I said to myself " I want one too" 

    So, after long time and a mixture of sketchs last year,  I finished my first traverser wit 8 tracks.  I am posting here some pictures during the setup, to show a little of my project. Unfortunately the traverser is not installed because I must to make some arrangement in layout to acomodate the traverser. 

     

    I want to post a movie here, but I dont have permission..!!!

    post-22473-0-05486000-1476045117.png

    post-22473-0-08553700-1476045145.png

    post-22473-0-42344200-1476045152.png

    • Like 3
  5. Hi guys

     

    I am introducing a keyboard and LCD for control of this turntable, using a sensor as a reference, connected to the Arduino pin 3 as partial sketch below.
    I would like to send a message to the LCD when the turntable reach the sensor so that I know that truntable stopped.
     
    I already burned the neurones but did not get anything until now. Can someone please give me a help.
     
    Tks
     
    //...

      void setup(){

       Serial.begin(9600);                             // sets up Serial library at 9600 bps for a serial monitor connected to the Artduino
       Serial.println("Stepper test for turntable");   // prints the comment between the "" on the serial monitor when starting.
        
       
      lcd.begin(20,4);                          // initialize the lcd for 20 chars 4 lines, turn on backlight
       
      for(int i = 0; i< 3; i++)                 // ------- Quick 3 blinks of backlight  -------------
      {
        lcd.backlight();
        delay(250);
        lcd.noBacklight();
        delay(250);
      }
      lcd.backlight(); // finish with backlight on  
      
      lcd.print("    MOVING");
      lcd.setCursor(0,1);
      lcd.print(" TO TRACK 1 ");
         
      AFMS.begin();  // create with the default frequency 1.6KHz
     
      Astepper1.setMaxSpeed(50.0);           // sets the maximum rotational speed of the stepper in steps per second.  
                                              // (the value of 50 will rotate the turntable for a full revolution 
                                              // in about 3200/50 seconds (i.e around 64 seconds).  
      Astepper1.setAcceleration(10.0);


      pinMode(3, INPUT_PULLUP);              //  INPUT PARA O SENSOR DE PARA INICIAL.  ADICIONADO NESTA VERSÃO
     
      int sensorVal = digitalRead(3);          //read the sensor (open collector type) value into a variable
         
      while (sensorVal == HIGH) {              // if near reference point move away
      sensorVal = digitalRead(3);
      forwardstep1();
      delay(50);
     
      Astepper1.setCurrentPosition(0);    //adicionado para posição zero ref. a todos

      }
      
       while (sensorVal == LOW) {                  // step forward to sensor index point 
       sensorVal = digitalRead(3);
       backwardstep1();
       delay(50);

     
      }
    }

    //..........................................................
  6. If xpressnet is your protocol - then you MUST check out Paco's terrific website - he has plenty of free designs for throttles, decoders, control stations, computer adapters and boosters for xpressnet/Roco/Lenz.

    You can find it here

    http://usuaris.tinet.cat/fmco/lokmaus_en.html

     

    Also check out his section on the xpressnet TCO project - it is the basis of a control panel for controlling turnouts and setting routes, etc.  Look at http://usuaris.tinet.cat/fmco/lokmaus_en.html#xbustco

    While it is not a keypad - it is the start of where you have switches on a panel that you can throw to control a turnout.

     

    If you prefer a keypad, you can build his minimaus V2B with the keyboard and mount it in the layout instead of making it portable - you can control turnouts (up to 999 turnouts!), set routes and even program from this keyboard.  As you can see it's only two chips some resistors and the keypad - SIMPLE!

     

    All of his designs are very simple to build and he outs it on the web free.  

    Hi gcodori

     

    Thank you so much for the informations.  I will see the sites.

    Cheers

  7. While this is loconet specific, you could most likely tweak this for your command protocol...

     

    http://model-railroad-hobbyist.com/node/26582

    It uses a 3x4 keyboard, and arduino to send a turnout number and command (open or closed) to the command station, which in turns, send this command to the turnout controller specified.

    gcodori

    Thank you so much for the information.  I will see the journal 

  8. Hi guys

     

    I am trying to insert servo in a Pandassum sketch,   ( # 38 ) to use in my traverser, and the servo will lock the table in position.
    At the time, I got the servo release and after reaching the sensor it returns the starting position (brake) during startup. The stepper also release during this process and after selecting the track.
    What I'm not getting, is to release the servo at the moment of selection the lanes.
    The stepper start but the servo  ( brake )continues to operate.
    Any help will be appreciated.
    Sorry for my english.. :help:
     
    The sketch:
     
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    #include <DCC_Decoder.h>
    #include <AccelStepper.h>
    #include <Wire.h>
    #include <Adafruit_MotorShield.h>
    #include "utility/Adafruit_PWMServoDriver.h"
    #include <Servo.h>
     
     
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //
    //       Defines and structures
    //
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    #define kDCC_INTERRUPT            0
     
    typedef struct
    {
      int               address;                // Address to respond to
     
    DCCAccessoryAddress;
     
    DCCAccessoryAddress gAddresses[1];
     
    const unsigned long releaseTimeout_ms = 2000; 
    boolean isReleased = false;
     
    //Servo Stuff
    Servo brakeservo;  // create servo object to control a servo
    const int servoBrake = 90;  //value for brake position
    const int servoRelease = 5;  //value for release position
     
     
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //
    //             Adafruit Setup
    //
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    Adafruit_MotorShield AFMStop(0x60); // Default address, no jumpers
     
    // Connect stepper with 200 steps per revolution (1.8 degree)
    // to the M3, M4 terminals (blue,yellow,green,red)
     
    Adafruit_StepperMotor *myStepper2 = AFMStop.getStepper(200, 2);
     
    // you can change these to SINGLE, DOUBLE, INTERLEAVE or MICROSTEP!
     
    // wrapper for the motor! (3200 Microsteps/revolution)
    void forwardstep2() {  
      myStepper2->onestep(FORWARD, MICROSTEP);
    }
    void backwardstep2() {  
      myStepper2->onestep(BACKWARD, MICROSTEP);
    }
    void release2()   {
      myStepper2->release();                //  COMANDO PARA LIBERAR SERVO E MOTOR
    }
     
    // Now we'll wrap the stepper in an AccelStepper object
     
    AccelStepper stepper2 = AccelStepper(forwardstep2, backwardstep2);
     
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //
    //          Variables
    //
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    long lngMotorPos;
    long lngTargetPosition;
    const long lngOneRev = 3200;    //  Essa é a linha de programação do curso: 400 é 45 graus  - 3200 DÁ UMA VOLTA
    int intPos = 0;               //set initial LED value
     
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //
    //        SETUP FOR LED DISPLAY
    //        Bits representing segments A through G (and decimal point) for numerals 0-9
    //
    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    const byte numeral[10] = {
      //ABCDEFG /dp
      B11111100,  // 0
      B01100000,  // 1
      B11011010,  // 2
      B11110010,  // 3
      B01100110,  // 4
      B10110110,  // 5
      B00111110,  // 6
      B11100000,  // 7
      B11111110,  // 8
      B11100110,  // 9
    };
     
    // pins for decimal point and each segment
    //                          dp,G,F,E,D,C,B,A
    const int segmentPins[8] = {
      7,11,10,9,8,6,5,4};//defines Arduino pins for each segment
    const int segmentSpin[6] = {
      4,5,6,8,9,10};// used to "rotate" the segments while motor is moving to sensor position
     
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //
    //            Decoder Init 
    //
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    void ConfigureDecoder()
    {
      gAddresses[0].address = 200;
      gAddresses[1].address = 201;
      gAddresses[2].address = 202;
      gAddresses[3].address = 203;                         
      gAddresses[4].address = 204;
      gAddresses[5].address = 205;
      gAddresses[6].address = 206;
      gAddresses[7].address = 207;
    }
     
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //
    //           Basic accessory packet handler 
    //
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    void BasicAccDecoderPacket_Handler(int address, boolean activate, byte data)
    {
      // Convert NMRA packet address format to human address
      address -= 1;
      address *= 4;
      address += 1;
      address += (data & 0x06) >> 1;
     
      boolean enable = (data & 0x01) ? 1 : 0;
     
      //  Check for DCC imput & determine entered address
     
      switch (address) {        //Set target position based on address selected
      case 200:
        lngTargetPosition = lngOneRev*0;   // ESSE VALOR FOI ALTERADO PARA QUE O ENDEREÇO 200 SEJA PONTO DE REFERENCIA  -  ERA 1 AQUI
        intPos=1;
        break;
      case 201:
        lngTargetPosition = lngOneRev*1;
        intPos=2;
        break;
      case 202:
        lngTargetPosition = lngOneRev*2;
        intPos=3;
        break;
      case 203:
        lngTargetPosition = lngOneRev*3;
        intPos=4;
        break;
      case 204:
        lngTargetPosition = lngOneRev*4;
        intPos=5;
        break;
      case 205:
        lngTargetPosition = lngOneRev*5;
        intPos=6;
        break;
      case 206:
        lngTargetPosition = lngOneRev*6;
        intPos=7;
        break;
      case 207:
        lngTargetPosition = lngOneRev*7;
        intPos=8; 
        break;     
      default:
        //nothing selected
     
        lngMotorPos=stepper2.currentPosition();
        Serial.println(lngMotorPos,DEC);
     
      }
      if ( enable )
      {
        Serial.print("Motor at: ");
        lngMotorPos=stepper2.currentPosition();
        Serial.println(lngMotorPos,DEC);
        Serial.print("Moving to: ");
        Serial.println(lngTargetPosition);
        showDigit(intPos);
        stepper2.moveTo(lngTargetPosition);
        while (stepper2.currentPosition() != lngTargetPosition) // move to target position
            stepper2.run(); 
        digitalWrite(segmentPins[0],0); 
        
        /////////////////////////////// NEW    //////////////////////////////////
     
        {  
          long lngTargetPosition;
     
        }
     
        //Set the servo brake
        brakeservo.write(servoBrake);
        delay(750);
     
        //release the motor
        release2();
        Serial.println("    Brake Set & Motor Released ");
     
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
      }
      else
      {
     
        // stepper2.moveTo(2000);
        lngMotorPos=stepper2.currentPosition();
        Serial.println(lngMotorPos,DEC);
        delay(1000);
        //  showDigit(intPos);
     
      }
    }
     
     
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //
    //        Setup
    //
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    void setup() //runs once to determine start position when sensor reached.
      Serial.begin(9600);
     
      AFMStop.begin(); // Start the shield
     
      //servo brake release before stepp moves
      brakeservo.attach(10);  // attaches the servo on pin 10 to the servo object
      brakeservo.write(servoRelease);
      delay (30);
     
      //configure pin3 as an input and enable the internal pull-up resistor
      pinMode(3, INPUT_PULLUP);
     
      //read the sensor (open collector type) value into a variable
      int sensorVal = digitalRead(3);
     
      //set stepper motor speed and acceleration 
      stepper2.setMaxSpeed(100.0);
      stepper2.setAcceleration(20.0);    
     
      for(int i=0; i < 8; i++)//assign pins for led display
      {
        pinMode(segmentPins, OUTPUT); // set segment and DP pins to output
      }
      showDigit(10);
      Serial.println("At switch off segments");
     
      delay(1000);
     
      // if near reference point move away
      Serial.println("Check for reference point");
      // sensorVal = digitalRead(3);  //    RETIRADO MOMENTANEAMENTE ATE CONCLUSÃO FINAL
      while (sensorVal == LOW) {
        sensorVal = digitalRead(3);  
        Serial.println("At Sensor");
        Serial.print("Motor at: ");
        lngMotorPos=stepper2.currentPosition();
        Serial.println(lngMotorPos,DEC);
        intPos=0;
        showDigit(intPos);
        forwardstep2();
        delay(50);
     
      }
     
      // step forward to sensor index point
      //  sensorVal = digitalRead(3);  //RETIRADO TEMPORARIAMENTE
      while (sensorVal == HIGH) {
        sensorVal = digitalRead(3);
        Serial.println("Moving to sensor");
        lngMotorPos=stepper2.currentPosition();
        Serial.println(lngMotorPos,DEC);
        intPos=0;
        showDigit(intPos);
        backwardstep2();  
        delay(50);
      }
     
      //when home- sets brake
      delay (500);
      brakeservo.write(servoBrake); 
     
      //release the motor
      release2();
      Serial.println("    Brake Set & Motor Released ");
     
      digitalWrite(segmentPins[0],0);    //DP off
      //digitalWrite(segmentPins[1],1);
      for(int i=0; i < 7; i++)    //Switch on segments
      {
        digitalWrite(segmentSpin,1);
        delay(50);
        digitalWrite(segmentPins[0],1);    //DP on
        //digitalWrite(segmentPins[1],1);
      }
     
     
      DCC.SetBasicAccessoryDecoderPacketHandler(BasicAccDecoderPacket_Handler, true);
      ConfigureDecoder();
      DCC.SetupDecoder( 0x00, 0x00, kDCC_INTERRUPT );
    }
     
    void showDigit( int number) //display number on seven segment display
    {
      boolean isBitSet;
     
      for(int segment = 0; segment < 8; segment++) //was 1
      {
        if( number < 0 || number > 9){
          isBitSet = 0;   // turn off all segments
          digitalWrite( segmentPins[segment], isBitSet);
        }
        else{
          // isBitSet will be true if given bit is 1
          isBitSet = bitRead(numeral[number], segment);
        }
        isBitSet = ! isBitSet; // remove this line if common cathode display
        digitalWrite( segmentPins[segment], isBitSet);
      }
    }
     
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //
    //        Main loop
    //
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    void loop()
    {
      static int addr = 0;
     
      ////////////////////////////////////////////////////////////////
     
      // Loop DCC library
      DCC.loop();
     
      ////////////////////////////////////////////////////////////////
     
      // Loop Stepper
     
      stepper2.run();
     
    }
     
    ///////////////////////////////////////////////   END    ///////////////////////////////////////////////////////////////////////////
     
  9.  

    Firstly I would like to thank Ray for his hard work in starting off this excellent post! also for Eric and friends for the various coding updates..  I have made a few changes to the code and managed to get a working turntable on my layout, including an OLED display to show the position and head/tail indication.  I only have 4 positions on my turntable and I didn't use the servo brake or manual pot but left these functions in.

     

    The display I used was a 1.3" I2C IIC Serial 128X64 OLED LCD LED Display Module Digital for Arduino W which can be obtained easily on eBay... the driver for this is U8glib.h https://code.google.com/p/u8glib/ and the other components as mentioned by others I ordered from Proto-pic.

     

    The revised coding is as follows, pictures to follow...

     

    Jonathan

     

     

    Jonathan

     

    Thank you so much to post the revision 17 here.
    This is what I was working for to merge 2 or 3 options in one sketch.
     
    I hope someone can still contribute to the enrichment of this work, and very rich in informations.
     
    I would like to thank to Ray to begin this project in a so detailed manner and to all that had give your contribution.  
    It was a fun and brilliant project.

    Sorry for my english.

     

     

     

    JB

  10. Hi JB - did it work

     

    Deev
     
    The sketch is working fine. I am having problem with my command ( Roco ) because when I choose the address 711 I dont have response of the traverser.
    I must use address 715 in my command, to have the position of address 711. i dont know what is happening, but the important thing is that the sketch is working,,,
    I must now adjust some parameters, to have the correct position of the tracks and something that show me where I am ( track ) when I start.
    But it is very easy,if i use a led panel.
    Again, thank you so much for expend time with me.
     
    Merry Christmas
    Cheers
  11. Hi JD,

     

    I'm curious as to why you're using a photo interruptor?  Can you explain?

     

    Anyway,  if you take a look at the link to my Filton Abbeywood thread (link on my signature) you'll find the code and some experimentation with the HES.  Note: the code is for RS485 and JMRI.

     

    Let me know if it works.

    Deev
    Excuse the mess I made regarding the photo interrupter.
    I'm working on two projects: the first is the traverser to be used as hidden station with 8 tracks, and the other is a project also  this site, for a turntable which, adapted after can be used also as traverser.
    In this project the choice was a photo interrupter instead of a Hall effect.
    This is the reason I mentioned the sensor. sorry     :senile:
    And sorry for my english...
  12. Hi JB,

     

    It'd be a useful skill - ou can tailor your own code that way, and use the Arduino to do pretty much whatever you want.  I've managed to get mine to work as a position feedback sensor!

     

    Dave

    Hi Deev

    I am using a ZD 1901 photo interruptor as a sensor, but untill now it didnot work.  Have you your sketch to post here..?

    cheers

  13. Hi Deev

     

    Thank you for your concern with me.  Unfortunately the sketch did not work. The old one "stepper6" works fine, thats means that my configuration is ok.
    The DCC monitor works fine and I suppose that my decoder is ok.  I dont now what is wrong.  I will try one more time next weekend.
     
    Thanks again
  14. Hi JB,

     

    Sorry, I can't because I don't have it any more.  Have a look at post #80 as there are links to some code there.

     

    You'll probably have to do some rewriting of the code as it is very unlikely that it'll do exactly what you want.  Always good to practice some Arduino code writing though!

     

    DAve

    Hi Deev

    Thank you for your prompt response. The codes at post #80 are about accessory decoder and stepper 6 ( the first one that you post here ) The challenge is to put all together ( if this procedure is correct ) to have a code
    just like in your post # 57 because I dont know nothing about Arduino language ( I only know to make connections ) lol....
  15. Hi Deev

     

    I am working in a traverser just like your, but I dont want to complicate the things.  My intention is to stop in position of post #57, using the arduino just like an accessory decoder, "calling " the tracks through the command.  But I am in bad situation, because the final code ( post# 57 ) is no more there.
     
    Could you please send me the code just like you made on the post # 57
     

    Tks

×
×
  • Create New...