dcc-ex / ex-turntable Goto Github PK
View Code? Open in Web Editor NEWTurntable-EX is a new feature to control a stepper motor based turntable from DCC++ EX
License: GNU General Public License v3.0
Turntable-EX is a new feature to control a stepper motor based turntable from DCC++ EX
License: GNU General Public License v3.0
As reported by Rico, with the homing sensor disabled and no steps stored in EEPROM:
License GPLv3 fsf.org (c) dcc-ex.com Turntable-EX version 0.2.1 Turntable-EX has not been calibrated yet Calibrating... Turntable homed successfully CALIBRATION: Phase 1, homing... CALIBRATION: FAILED, could not home, could not determine step count
Homing should have failed, and calibration should not have started.
There's an issue with the device driver and status whereby the WAITFOR() EX-RAIL command only works the first time it is used.
Not sure if this is a device driver or Turntable-EX issue at this point, but if a position is selected that has a WAITFOR() as the first turntable move, it works, where nothing after the WAITFOR() executes until the turntable has finished moving.
However, every other subsequent move does not correctly wait, and any subsequent activities happen immediately, not after the turntable has finished moving.
Testing without the homing sensor reveals an issue where homing will fail, yet calibration will still be initiate, resulting in an infinite loop attempting unsuccessfully to home.
Note that if homing fails, commencing calibration will never succeed, so this shouldn't happen either.
The device driver needs to be able to obtain the status of the turntable activities, so the Nano needs to respond to status requests.
States would probably include the below (or similar):
A request to access the code was made by Alex Shephard as he has a use case for a traverser that he's interested in seeing if Turntable-EX can support. Right now, this won't work, especially with the updated calibration sequence due to the fact that neither traversers, nor turntables that don't rotate a full 360 degrees can have a full rotation step count performed the same way.
We should be able to support these with an additional limit sensor, and enabling the calibration sequence to count the steps between the home and limit sensors, thereby achieving the same goal of automatic step calculation, and still being able to use the same step sequences etc. to move to the various positions.
A side effect of the improved homing logic is that the turntable will now rotate forever if the homing sensor is not triggered.
An unused counter homingSteps is available which can be used to count the number of steps taken during homing, and these can then be limited by extra logic in the homing function.
The simplest way to capture Beta testing results is to have testers complete the regression testing process, and provide a template for raising an issue in this repo for the test results to be captured.
Spotted by Rico:
Stepper pin names not updated for COUNTER_CLOCKWISE option.
Description of home sensor still mentions pin 2.
Looks like a lot of new relay boards are active LOW rather than active HIGH, need to enable support for these the same as we do for the home sensor.
Will fix with #37
Need to fix the logic that causes the code to still wait for a homing sensor to activate after the stepper completes two full rotations without activating the sensor.
When sending a SERVO command to trigger homing (currently by 0 steps and phase switch 0), the homing function doesn't actually do anything.
The code needs to stop accepting new movement directives while the turntable is still moving as these can be queued up and would cause issues on an actual layout.
Some users may wish to have an indicator LED or other accessory turned on or activated during, prior to, or after turntable movements.
This can be achieved by defining a digital output pin enabled by an activity flag.
Initial thoughts here:
Capture whatever information is relevant and required in order to complete this task.
Define what "done" looks like, what is the outcome of this task?
When merging a PR, they do not move to "Done" in the project Kanban.
Submit and merge a PR.
The PR should appear in the "Needs Review" column when submitted, then should move to "Done" automatically when merged.
N/A
N/A
N/A
The current README.md is just the default placeholder, this needs some real content, particularly to enable testing while the repo remains private and there is no published documentation on the website.
While creating the documentation, I've discovered it would be beneficial to have some tests available via the serial console to validate that the various components are connected and working correctly.
Tests should include:
Considering future potential to allow DCC control of Turntable-EX (may or may not be a good idea), we need to shuffle the homing sensor and relay pins to free up the interrupt capability of pin 2.
Moving the home sensor to pin 5 is all that's required here.
If you have edited config.h in Turntable-EX or myHalcpp or myAutomation.h in CommandStation-EX, please upload those to this issue also.
PASS
Any observations or comments:
PASS
Any observations or comments:
PASS
Any observations or comments:
PASS
Any observations or comments:
PASS
Any observations or comments:
PASS
Any observations or comments:
PASS
Any observations or comments:
PASS
Any observations or comments:
PASS
Any observations or comments:
Please share any general comments or feedback here:
Testing switch moment (calibrated at 4100 half step modus):
Homing started Turntable homed successfully CALIBRATION: Phase 1, homing... CALIBRATION: Phase 2, counting full turn steps... CALIBRATION: Completed, storing full turn step count: 4093 Manual override has been set for 4093 steps per revolution Automatic phase switching enabled at 45 degrees Phase will switch at 495 steps from home, and revert at 2475 steps from home Turntable homed successfully Received notification to move to step postion 495 Position steps: 495, Auto phase switch - moving 1 steps Setting phase switch flag to: 1 Received notification to move to step postion 2473 Position steps: 2473, Auto phase switch - moving 1978 steps Setting phase switch flag to: 1 Received notification to move to step postion 2474 Position steps: 2474, Auto phase switch - moving 1 steps Setting phase switch flag to: 1 Received notification to move to step postion 2475 Position steps: 2475, Auto phase switch - moving 1 steps Setting phase switch flag to: 0
config.h.txt
Instead of homing being triggered by sending 0 steps with activity 0, activate it by sending activity 2 and ignoring the steps sent. This will prevent inadvertent homing on startup or when the CS restarts as occasionally 0s are sent.
A few bugs have been cropping up post-release, time to define some proper unit and regression tests to ensure all items are tested completely prior to release.
The documentation refers to the "add-turntable-branch" of CommandStation-EX, but doesn't clarify the version should be displayed as "4.0.2".
https://dcc-ex.com/download/turntable-ex.html
https://dcc-ex.com/turntable-ex/get-started.html
https://dcc-ex.com/turntable-ex/troubleshooting.html
Need to provide guidance that the version displayed will be 4.0.2.
Add any other context or screenshots about the documentation request here.
It seems that when the CS starts up and loads the device driver, it sends a valid move to move to step 1 which needs to be disabled.
To make things easier for Conductor level users, relay pins and the home sensor should be statically defined, so these need to be removed from config.h and be defined directly in Turntable-EX.ino.
This will also help should we end up providing ready-to-go versions of this for sale.
During calibration, a NEMA17 connected to an A4988 driver does not rotate.
Simple fix, the stepper.enableOutputs() command is missing from the calibration sequence, not picked up with the ULN2003 as they enable automatically.
More feedback from Alex in Discord which is probably a great idea:
It's worth considering having the DCC phase automatically reversing when rotating 180 degrees to make it easier.
When a turntable rotates beyond 180 degrees, the DCC phase should automatically invert, and return to normal phase once rotating back to within the first 180 degrees.
N/A
Consideration during the remainder of the conversation is to have auto reversal as the default, but still enabling use of the Turn_PInvert command if users prefer, and an option to not invert at all which would be applicable in scenarios such as traversers that don't actually rotate.
README.md needs to be created, along with creating proper Turntable-EX documentation in the documentation repo.
A branch exists for this ready to start: https://github.com/DCC-EX/dcc-ex.github.io/tree/add-turntable-ex
The calibration sequence is overly complicated. The goal is simply to ensure that the provided steps for a full 360 degree rotation are accurate, meaning the only positions that need to be validated are home/360 degrees, and 180 degrees. Even 180 is probably unnecessary really, but good to have that extra validation.
Calibration cycle still returns ERROR: Turntable failed to home, setting random home position
in version 0.2.3
How to reproduce:
#define STEPPER_DRIVER ULN2003_HALF_CW
or #define STEPPER_DRIVER ULN2003_HALF_CCW
and saveTurntable-EX has not been calibrated yet
Calibrating...
Homing started
ERROR: Turntable failed to home, setting random home position
Missed creating a Beta release for Turntable-EX, need to do that.
If you have edited config.h in Turntable-EX or myHalcpp or myAutomation.h in CommandStation-EX, please upload those to this issue also.
Not Tested/Pass/Fail
Any observations or comments:
Not Tested/Pass/Fail
Any observations or comments:
Not Tested/Pass/Fail
Any observations or comments:
Not Tested/Pass/Fail
Any observations or comments:
Not Tested/Pass/Fail
Any observations or comments:
Not Tested/Pass/Fail
Any observations or comments:
Not Tested/Pass/Fail
Any observations or comments:
Not Tested/Pass/Fail
Any observations or comments:
Please share any general comments or feedback here:
@Kcsmith0708 raised the interesting idea of using a GC9A01 driver and a round display to represent the turntable activities.
Need to look into the feasibility of this, if it would require some more processing/memory than the Nano provides (references talk about ESP32), and what libraries etc. would be required to make this a reality.
YouTube reference: https://www.youtube.com/watch?v=Y0BGnHFuYBU
After the bug fixes in 0.2.1, active low relays are now activated during the calibration sequence.
Some stepper and turntable configurations end up being less accurate when turning in one direction vs. the other, or when alternating direction of travel, likely due to sloppiness in the internal stepper setup or the mating between the turntable components and stepper shaft.
We can enable a workaround for this by turning in the specified direction only (clockwise or counter clockwise).
Having the turntable driven via the SERVO macro in EX-RAIL is ok, but it really should have a specific command set to remove confusion for end users, and to enable future extensions.
Something like MOVETT(Vpin, steps, activity).
This also requires a debug command for tuning positions and general testing such as <D TT vpin steps activity>
.
Feedback received from Alex in Discord:
The need for an additional AVR board isn't clear in the overview, and the DCC phase inversion isn't clear enough.
https://dcc-ex.com/turntable-ex/turntable-ex.html
Reading the Overview Section, it wasn't immediately obvious to me that this was its own AVR board and completely separate to the Command Station and links via I2C. Not that it really matters as part way through that became obvious, but at an overview level might be useful to set things straight.
The description of the Phase Reversal seemed to finish without really saying how to select/set which of the 3 options the user wants to use and I presume its simply energises the relays when the turntable passes the 180 degree position. That could do with a few more sentences explaining the logic that will be applied or not.
Add any other context or screenshots about the documentation request here.
There may be some instances whereby automatic calibration is not desired, in which case a manual definition of the full rotation step count will need to be provided.
#define TURNTABLE_EX(route_id, reserve_id, vpin, steps, activity, desc) \
ROUTE(route_id, desc) \
RESERVE(reserve_id) \
MOVETT(vpin, steps, activit) \ <<<< activity
WAITFOR(vpin) \
FREE(reserve_id) \
DONE
While the code theoretically will support other stepper controllers and motors, it feels sub-optimal and probably a class or device driver type scenario is required to efficiently be able to use different controllers and motors.
There are some slight variances reported in gear ratios for the ULN2003/28BYJ-48 stepper combos which will likely cause issues if not accommodated for in the defined number of steps for a full rotation.
In addition, other turntable/stepper applications may have gearing to take into consideration.
The simple answer is to add a calibration routine as a separate activity.
This should be able to be run from the CS via an activity flag, and directly on Turntable-EX so users can see the step numbers at each degree position.
We should also provide a printable template with the various degrees that users can put around their turntable to perform the calibration.
To make it easier for Conductor level users, it's probably better to have activity flags written as text rather than integers to avoid confusion.
Suggestions:
Identify where the Nano randomly starts the homing sequence. Is it resetting or being triggered somehow?
A clear and concise description of what the bug is.
Steps to reproduce the behavior:
A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.
Include details of all hardware used such as microcontrollers, motorboards, stepper drivers/motors, turnouts, etc. as appropriate and applicable.
Add any other context about the problem here.
If you have edited config.h in Turntable-EX or myHalcpp or myAutomation.h in CommandStation-EX, please upload those to this issue also.
Pass
Any observations or comments:
Pass
Any observations or comments:
Pass
Any observations or comments:
Pass
Any observations or comments:
Pass
Any observations or comments:
Pass
Any observations or comments:
Pass
Any observations or comments:
Pass
Any observations or comments:
Pass
Any observations or comments:
Please share any general comments or feedback here:
Just a first name or nickname will suffice, something to put a personal touch on replies.
Optional, as this email address will be publicly visible on the internet if provided.
A brief title for the support request.
Please describe the issue being encounted as accurately and detailed as possible, and provide further specific information below to help us understand the nature of it, and the environment in which it was encountered.
CommandStation-EX/WebThrottle-EX/Turntable-EX/EX-RAIL
Arduino Mega/Arduino Nano/Arduino Uno/ESP32/Other
A clear and concise description of what the bug is.
Steps to reproduce the behavior:
A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.
Include details of all hardware used such as microcontrollers, motorboards, stepper drivers/motors, turnouts, etc. as appropriate and applicable.
Add any other context about the problem here.
RAM can be optimised with Serial.print(F("Text")) etc.
Also check out the CS code's string formatter.
Lower RAM usage will likely be required to allow for the display option.
If you have edited config.h in Turntable-EX or myHalcpp or myAutomation.h in CommandStation-EX, please upload those to this issue also.
PASS
Any observations or comments:
PASS
Any observations or comments:
PASS
Any observations or comments:
PASS
Any observations or comments:
PASS
Any observations or comments:
PASS
Any observations or comments:
PASS
Any observations or comments:
PASS
Any observations or comments:
PASS
Any observations or comments:
Please share any general comments or feedback here:
Testing switch moment (calibrated at 4100 half step modus):
Phase will switch at 495 steps from home, and revert at 2475 steps from home Turntable homed successfully Received notification to move to step postion 494 Position steps: 494, Auto phase switch - moving 494 steps Setting phase switch flag to: 0 Received notification to move to step postion 495 Position steps: 495, Auto phase switch - moving 1 steps
If you have edited config.h in Turntable-EX or myHalcpp or myAutomation.h in CommandStation-EX, please upload those to this issue also.
Not Tested/Pass/Fail
Any observations or comments:
Not Tested/Pass/Fail
Any observations or comments:
Not Tested/Pass/Fail
Any observations or comments:
Not Tested/Pass/Fail
Any observations or comments:
Not Tested/Pass/Fail
Any observations or comments:
Not Tested/Pass/Fail
Any observations or comments:
Not Tested/Pass/Fail
Any observations or comments:
Not Tested/Pass/Fail
Any observations or comments:
Please share any general comments or feedback here:
Need to add the issue templates and project workflows as per the Support-Planning repo, as these are now ready to be tested and demo'd as part of improving how we track and organise work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.