alangdance
Members-
Posts
280 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Gallery
Events
Exhibition Layout Details
Store
Everything posted by alangdance
-
West Riding Terminus- Halifax Powell Street
alangdance replied to BurscoughCurves's topic in Layout topics
where did you get the winding assembly from. ? you mention RATIO BUT I CAN NOT FIND ANY REERENCE TO IT ON THE PECO SITE. -
Hi NinOz Please see below for the original sketch for the Bluetooth. All I have done is added it to the loop of Tender's Sketch that is on entry 48. I tested it also on other know working DCC sketch with the same outcome. If I check the serial monitor there is some messages but none sent from the sketch. It looks like they are coming from one of the libraries. Even if I sent a ON or OFF from the serial Monitor it still not working. Is the interrupt that the DCC is using causing the serial monitor not to work? Working Bluetooth sketch below:- /* This sketch is part of a tutorial for connecting to and communicating with an HC-06 or an RN-42 bluetooth module using a custom Android App. The bluetooth modules are connected to an Arduino and the Arduino is connected to an LED. The Android app is used to wirelessly turn on and off the LED using bluetooth. This code is in the public domain. */ // Pin 13 has a LED connected to it int led = 13; // the setup routine runs once when you press reset: void setup() { Serial.begin(9600); // initialize the digital pin as an output and set it low initially pinMode(led, OUTPUT); digitalWrite(led, LOW); } // the loop routine runs over and over again forever: void loop() { delay(30); String t; //create an empty string to store messages from Android while(Serial.available()) { //keep reading bytes while they are still more in the buffer t += (char)Serial.read(); //read byte, convert to char, and append it to string } if(t.length()) { //if string is not empty do the following if(t == "ON") { //if the string is equal to "on" then turn LED on digitalWrite(led, HIGH); //Set digital pin to high to turn LED on Serial.write("Moving to Main Track CW"); //Tell the Android app that the LED was turned on } else if (t == "OFF") { digitalWrite(led, LOW); Serial.write("Moving to Main Track CCW"); } // turn the LED off by making the voltage LOW } } Regarding your question about the DCC sketch you would be better asking Tender as this is his sketch Any help would be most grateful Alan
-
I have 2 sketches that I am using to control a turntable. One is Tender's DCC Turntable control and one that uses a Bluetooth module connected to the Arduino and controlled by an Android phone. Both sketches work on their own but when I combine the 2 sketches the Bluetooth sketch is not working. I have added the Bluetooth control to the Loop as this is only a serial Read but this does not seem to work. I have use pins 0 & 1 for the RX and TX for the Bluetooth and Interrupt 0 for the DCC signal. See code below // DCC Turntable Control Test Routines #include <DCC_Decoder.h> #include <AccelStepper.h> #include <Wire.h> #include <Adafruit_MotorShield.h> #include "utility/Adafruit_PWMServoDriver.h" ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Defines and structures // #define kDCC_INTERRUPT 0 typedef struct { int address; // Address to respond to } DCCAccessoryAddress; DCCAccessoryAddress gAddresses[8]; //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // // 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); } // Now we'll wrap the stepper in an AccelStepper object AccelStepper stepper2(forwardstep2, backwardstep2); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// int led = 13; int test = 0; int rotate = 0; int sensorVal = digitalRead(3); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // 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; for(int i=0; i<(int)(sizeof(gAddresses)/sizeof(gAddresses[0])); i++) { if( address == gAddresses[i].address ) { Serial.print("Basic addr: "); Serial.print(address,DEC); Serial.print(" activate: "); Serial.println(enable,DEC); if( enable ) { switch (i) { case 1: stepper2.moveTo(200); break; case 2: stepper2.moveTo(400); break; case 3: stepper2.moveTo(600); break; case 4: test = HIGH; Test(); break; case 5: stepper2.runToNewPosition(1600); break; case 6: rotate = HIGH; Rotate(); break; } } else{ switch (i) { case 1: stepper2.moveTo(1800); break; case 2: stepper2.moveTo(2000); break; case 3: stepper2.moveTo(2200); break; case 4: test = LOW; Test(); break; case 5: stepper2.runToNewPosition(-1600); break; case 6: rotate = LOW; Rotate(); break; } } } } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Setup // void setup() { Serial.begin(9600); // initialize the digital pin as an output and set it low initially pinMode(led, OUTPUT); digitalWrite(led, LOW); AFMStop.begin(); // Start the shield //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 //set stepper motor speed and acceleration stepper2.setMaxSpeed(30.0); stepper2.setAcceleration(20.0); // stepper2.moveTo(800); // if near reference point move away sensorVal = digitalRead(3); while (sensorVal == LOW) { sensorVal = digitalRead(3); forwardstep2(); delay(50); } // step forward to sensor index point while (sensorVal == HIGH) { sensorVal = digitalRead(3); forwardstep2(); delay(50); } DCC.SetBasicAccessoryDecoderPacketHandler(BasicAccDecoderPacket_Handler, true); ConfigureDecoder(); DCC.SetupDecoder( 0x00, 0x00, kDCC_INTERRUPT ); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Main loop // void loop() { static int addr = 0; //////////////////////////////////////////////////////////////// // Loop DCC library DCC.loop(); //////////////////////////////////////////////////////////////// // Bump to next address to test if( ++addr >= (int)(sizeof(gAddresses)/sizeof(gAddresses[0])) ) { addr = 0; } stepper2.run(); String t; //create an empty string to store messages from Android while(Serial.available()) { //keep reading bytes while they are still more in the buffer t += (char)Serial.read(); //read byte, convert to char, and append it to string } if(t.length()) { //if string is not empty do the following if(t == "Ton") { //if the string is equal to "on" then turn LED on digitalWrite(led, HIGH); //Set digital pin to high to turn LED on Serial.write("Moving to Main Track CW"); //Tell the Android app that the LED was turned on } else if (t == "Toff") { digitalWrite(led, LOW); Serial.write("Moving to Main Track CCW"); } // turn the LED off by making the voltage LOW } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Test(){ // step forward to sensor index point while (sensorVal == HIGH) { sensorVal = digitalRead(3); forwardstep2(); delay(50); } delay(5000); // set stepper speed, acceleration and position stepper2.setMaxSpeed(50.0); stepper2.setAcceleration(10.0); stepper2.moveTo(800); if (stepper2.distanceToGo() == 0) { delay(5000); stepper2.moveTo(-stepper2.currentPosition()); } //stepper2.run(); //maybe needed } void Rotate(){ if (rotate == HIGH ){ stepper2.runToNewPosition(3200); } else{ stepper2.runToNewPosition(-3200); } } Can anyone can point me in the right direction. Alan
-
Sorry forgot to add the code String t; //create an empty string to store messages from Android while(Serial.available()) { //keep reading bytes while they are still more in the buffer t += (char)Serial.read(); //read byte, convert to char, and append it to string } if(t.length()) { //if string is not empty do the following if(t == "Ton") { //if the string is equal to "on" then turn LED on digitalWrite(led, HIGH); //Set digital pin to high to turn LED on Serial.write("Moving to Main Track CW"); //Tell the Android app that the LED was turned on } else if (t == "Toff") { digitalWrite(led, LOW); Serial.write("Moving to Main Track CCW"); } // turn the LED off by making the voltage LOW } Alan
-
I have 2 sketches that I am using to control a turntable. One is Tender's DCC Turntable control and one that uses a Bluetooth module connected to the Arduino and controlled by an Android phone. Both sketches work on their own but when I combine the 2 sketches the Bluetooth sketch is not working. I have added the Bluetooth control to the Loop as this is only a serial Read but this does not seem to work. I have use pins 0 & 1 for the RX and TX for the Bluetooth and Interrupt 0 for the DCC signal. Can anybody point me in the right direction why the serial read is not working when joined to the DCC Turntable Sketch. Alan
-
TinySine 8-channel relay Bluetooth remote control
alangdance replied to 47137's topic in Computer Control
Richard do you have link on ebay for this board. I am unable to find any near that price, even from china Alan -
A never option is to connected together 2 or more Arduino boards using the IC2 connections. This is again a 2 wire system. I am at the moment looking into this as a possible solution. Alan
-
Just had a look at the Adafruit for myself looks like a good option but if your looking at costs then the Nano or Pro mini would be a better option. Can not seem to pick the Adafruit for less than a Tenner but you can pick up Nano's for about £2 pounds and Pro mini for less. Alan
-
Does anybody have any comments on the new Stainless steel rail from DCC Concept. Do we have an issue with electrical pick as SS does not conduct electricity as good as nickel silver? Can we overcome the pick up issue with more droppers? Does it actually require much less cleaning as stated by DCC Concept? Has anybody used the new SS. Regards Alan
-
HI Ray If I was to use your sketch for a traverser is there any parts from the sketch that would need changing. I think you mentioned that on setup the stepper motor will go forward and backwards to find it 's reference point. I think this may be a issue with a traverser. Any help would be most grateful. Alan
-
A Kind Of (Ballast) Magic?
alangdance commented on dseagull's blog entry in The Cuckmere Valley Railway
let's know what the out come is. does the ballast move when wetting it down. Does the ballast go rock hard like the old humbrol casmite. Can we have some more photos once it's dried and cleaned up. Alan -
Please Do Alan
-
Eastwood Town - A tribute to Gordon's modelling.
alangdance replied to gordon s's topic in Layout topics
Hi Gordon Thanks for the great tutorial. I have been thinking about building some 00-SF points. My only issue that I am not to sure of is all my stock is RTR and with the varing standards supplied my the manufactories will the be issues with the stock through the common crossing. Do you have any dos and don'ts for running RTR stock through the ))-SF points. Alan