-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added the common S88 sensors. #166
base: master
Are you sure you want to change the base?
Conversation
…als from the sensors back to the command station.
…ile (comment 2 line)
…ailable checkAll: Added S88Mega->loop if no int/timer is used checkAll: Check for changes of the S88 busses printall: Send the current status os all S88 sensors
…o use an int/timer or the arduino-loop
…the new base. Tested with / without int/timers on my railroad. The trains can now be completely driven by the computer software
Chris and Harald, where does this fit in our world? We did not have this on the roadmap. My main questions are:
|
@FrightRisk Hi, I hope I can give a few answers
I must confess that i'm relative new at arduino programming. I started for fun (dht22 measurement, smoke detector.... just small projects where you do not need a deep knowledge). So if you have comments about the code don't hesitate to contact me. I'm eager to learn ;-) The code was 99% from my father. He used just functions and just the timer. I put all the code inside a class and added the option to work with the main loop and without the timer. |
… according values
The reason for the not sending unpolled information over the ethernet is because the command station is acting as a server for multiple clients and they may be using mixed protocols so we can only send back what they adk for. Our strong recommendation is to run your jmri/rocrail over the same usb wire you already have to load the software. Get a longer one if necessary... but when you spend extra money to add an ethernet board you seriously degrade the capability and performance of the command station... increase the complexity of the setup and frankly I wonder why we bothered to implement it. |
As the code is always built on the PC of the user after download for the Arduino of the user (Mega, Uno, whatever) many variants to download are not a problem. This is only an option that needs to be written in config.h by the user or by the installer which writes config.h for the user. It does however increase the number of variants to test. What is the minimal setup to test S88. Can one make a "fake S88" just for test? The trick is how to write the code so that the #ifdef are minimized as otherwise the code may get messy. #ifdefs tend to do that... Reards, |
@habazut Testing. Well, please have a look at S88Mega::S88Read. A test could be to re/set one of the lower 4 bits of the RmBytes. A few milliseconds later a command <Q numberOfTheSensor> or <q numberOfTheSensor> should be sent to the computer by the usb-connection. |
I am new with DCC++ Ex can you help me how to connect the S88 connections to the Mega board (which pins are used on Arduino Board default) or how can I set the pins in which file? Or do you have an schematic how to connect? Have found the pin settings in your file. How do read the sensor data ( Arduino Serial monitor?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code contains explicit references to mega timers, it will not compile/work on megaavr or teensy processors.
Using a software interrupt at this frequency and doing this much work will destroy the dcc waveform unless the high accuracy pwn is active, in which case the dcc code needs to shout if low accuracy and s88 are on at the same time.
Given the timing and pin requirements of s88 I would suggest that a better solution would be to build an s88 monitoring nano which reported only sensor changes to dccex using the serial connection. This eliminates many potential complexities or testing issues.
To Asbelos, do you have some info about s88 monitoring nano which reported only sensor changes to dccex using the serial connection. |
My suggestion would be to use your s88 code in a stand alone sketch on any suitable cheap arduino and have it communicate sensor changes to the dccex arduino over a simple serial connection. Then these changes can be reflected to jmri or other sensor dependent systems. |
Thank you for thr info.
Johan
From: Asbelos ***@***.***>
Sent: Tuesday, July 27, 2021 4:38 PM
To: DCC-EX/CommandStation-EX ***@***.***>
Cc: Johanvd10 ***@***.***>; Comment ***@***.***>
Subject: Re: [DCC-EX/CommandStation-EX] Added the common S88 sensors. (#166)
My suggestion would be to use your s88 code in a stand alone sketch on any suitable cheap arduino and have it communicate sensor changes to the dccex arduino over a simple serial connection. Then these changes can be reflected to jmri or other sensor dependent systems.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#166 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AU7SH5SNWFCSMMREG722DOTTZ3ADJANCNFSM46DIU2DA> . <https://github.com/notifications/beacon/AU7SH5QAR3P3TG3XM3XMZHLTZ3ADJA5CNFSM46DIU2DKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOGTTTO4Y.gif>
|
We can have a repo, or a folder in another repo with code that runs on an external device to control S88. Some people have expressed a more modular approach would be better than trying to have the command station do everything. This "controller" could send and receive messages using the <DCC++EX> command language. A Mega has an open serial port to communicate. If wireless is truly important, the HC-12 USB to serial bridge boards may be an option. I should also mention that LCN is about to be released. That is a wireless, bi-directional accessory bus. I understand though that people who already have S88 want to use what they have. I wonder if the controller could use LCN with modifications for S88? |
For larger layouts, people use their own bus system or use these to expand the number of ports with this: https://create.arduino.cc/projecthub/xreef/pcf8575-i2c-16-bit-digital-input-output-expander-48a7c6 or this for servos: |
Please have a look at https://wiki.rocrail.net/doku.php?id=s88_lpt-en
So you need working S88 hardware (isolated tracks, a wire from that isolated place to the sensor-board. Mostly the board is using network-cables to connect to a S88-Bus-interface. So rj45-network cables goes into the s88-bus-interface and on the other side there's a parallel port to connect to an old computer. The Arduino is taking the part of the old computer by connecting the parallel-port-pins to the pins on the arduino |
Well, no problem, you can just uncomment #use_S88Timer in the config file and the data is read without timers. In the main loop the sensors are polled (sensors.cpp) and with every call the S88 sensors are read. That's slower, but fast enough to precisely catch every signal. We can also check the board type. If it is a mega, timers are used otherwise the loop. |
And that's exactly the reason why we tried to use the code with command-station. A Mega is big and fast enough to drive the trains and catch the sensors. |
This is only true if the mega motor-shield complies with the requirements for our high accuracy waveform algorithm. Otherwise, If your software uses interrupts you have LESS THAN 3uS to process your interrupt before you push the dcc waveform out of spec. We are also developing other features which would not interface cleanly with your code as-is and we are making all our code portable to other arduinos more powerful than the mega and your code will not compile on them. (Some features are not supported on uno/nano). So, I hope you understand why we can't merge in your existing s88 to CommandStation as it stands. My advice earlier would allow us to connect cleanly to s88 in a way that eliminates all the issues for the price of a nano (which probably costs less than the parallel plug you used to have for your pc). It would also allow easy stand-alone testing/configuring of your sensor network and easy testing of the dccex end. As Fred has noted, we would be happy for that to be a part of dccex and hosted on our github. Of course, being open source, you may continue to operate as now if that meets your needs. |
Asbelos, I have used google to find something about this s88 code in a stand alone sketch on any suitable cheap arduino and have it communicate sensor changes to the dccex arduino over a simple serial connection but still nothing found can you direct me to some documents or links? |
Hi Johan, we are discussing the possibility of making one here.. Micha10 has some working s88 code which he may share with you. I'm hoping we can cooperate to get it working in a way that we can incorporate within the dccex family. |
Asbelos, This is what I also hope then will the DCC++ EX compatible for everyone, but the option for S88 is something many people will use. |
Asbelos, Can i use this code https://github.com/dirkjankrijnders/Arduino-S88 and how then to read and send it to serial? |
|
Micha10, What are you using for software with the DCC command station to control trains and track and see the sensors from S88? Micha10 please contact me by mail johan@dijk-van.nl |
To be honest, I am also hesitating between S88 and I2C. The main reason is that the allocatable addresses that support I2C16bit I/O chips are only 0X20~0X27. That is to say, the maximum number of Senosr is 16*8, 128. I wonder if it is enough. |
As I alredy wrote to #249 I think the best is to do this on it's own mikrocontroller:
The mentioned software has shown in its current state (I2C interface is not implemented yet) that it can handle up to 64 (8*8) in/outputs on 8 lines (512 in/outs total). In maximum speed mode (only suitable for short cables to the chips) all the inputs can be read more than 7000 times per second (!).1 Additionally it has the feature of adding outputs. To use this with DCC-EX:
If you use only 3-5 s88 devices it should be possible to do this in CS, but for larger layouts this is not suitable. Maybe we should support both Footnotes
|
Why I do want to have a S88 Master on DCC++ Controller? |
Most of the content from CONTRIBUTING.md was already moved to docs/contributing/website.rst and updated.
Why isn't this implemented/merged into production yet? |
With not arduino based dcc command stations the computer generates the dcc signal which is sent through a booster on the serial com port. The S88 sensors are connected through a parallel port to the computer.
Nowadays the old ports are not supported.
Now the dcc signal is created by this software but the S88 bus was not supported.
With that change, you can connect the parallel port pins to arduino pins and the signals are sent to the connected computer which now can drive the whole fleet of trains fully automatically