Closed fire-bot closed 2 years ago
I'm afraid it's not quote as simple as the code above might suggest, the command station is extremly busy and a delay statement can cause loss of ethernet or wifi traffic and loss of throttle control. . We are in the process of implementing this kind of turnout control, amongst others, in a future release.
Thanks for the info. As a follow up idea. When I first started this project, I ordered a uno by accident. Based on https://www.instructables.com/I2C-between-Arduinos/ it would appear that I could use the mega as a master and the uno as a slave using ic2. Then commandstation could send a command to the uno using a modified "accessories" block to tell the uno to toggle a turnout using the relays without incurring any delay issues. I could use the 8 digital output pins on the uno to signal the relays. This code could probably include a response code indicating success or failure and a state code.
Does this sound feasible and fairly simple to code and integrate with commandstation?
Thanks for the info. As a follow up idea. When I first started this project, I ordered a uno by accident. Based on https://www.instructables.com/I2C-between-Arduinos/ it would appear that I could use the mega as a master and the uno as a slave using ic2. Then commandstation could send a command to the uno using a modified "accessories" block to tell the uno to toggle a turnout using the relays without incurring any delay issues. I could use the 8 digital output pins on the uno to signal the relays. This code could probably include a response code indicating success or failure and a state code.
Does this sound feasible and fairly simple to code and integrate with commandstation?
Get BlueMail for Android
On May 17, 2021, 2:27 PM, at 2:27 PM, Asbelos @.***> wrote:
I'm afraid it's not quote as simple as the code above might suggest, the command station is extremly busy and a delay statement can cause loss of ethernet or wifi traffic and loss of throttle control. . We are in the process of implementing this kind of turnout control, amongst others, in a future release.
-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/DCC-EX/Support-Planning/issues/138#issuecomment-842652454
Sent by Myles Moutoux (@mmoutoux). Created by fire.
So, I'm very confused. This is my first foray back into model railroading in a very long time and, obviously, 1st into dcc. I've managed to get the arduino mega, arduino motor shield, makerfab wifi shield and the engine driver android app working on my small layout with two dcc locomotives.
Now, I want to control the 4 atlas twin coil turnouts. I found an article on alfray.com that shows it to be possible using the sainsmart 5v 8 channel relay board mentioned in the article. I'd like to use this setup with commandstation-ex, but have no idea how. Looking at the code, with my very limited knowledge of c++, it appears that turnouts are supported, but that only pwm (?) is mentioned specifically. In the same code module, "accessories" are mentioned, but I don't know if that is relevant.
Following is a single relay version of the code from alfray.com:
define RELAY1_PIN 52
define RELAY2_PIN 53
define RELAY_TIME_MS 150
void setup() {
pinMode(RELAY1_PIN, OUTPUT);
pinMode(RELAY2_PIN, OUTPUT);
digitalWrite(RELAY1_PIN, LOW);
digitalWrite(RELAY2_PIN, LOW);
}
// Direction: 0=Normal (PIN1), 1=Reverse (PIN2)
void set_turnout(int direction) {
int pin = direction ? RELAY2_PIN : RELAY1_PIN;
digitalWrite(pin, HIGH);
delay(RELAY_TIME_MS);
digitalWrite(pin, LOW);
}
I presume it would be possible to integrate a multi relay version of this into commandstation-ex and engine driver, but I doubt that I'm capable of doing it. Any help would be much appreciated.
Thanks
Myles