Jump to content
 

DCC Controlled (PECO) Turntable Project using a Arduino Uno


Recommended Posts

  • RMweb Gold

Good evening Ray,

 

I have arrived at position settings which give consistent alignment, with or without a loco on the table. They are 1078 and 2706, someway off a difference of 1600 but they work.

 

I then went on to testing the alignment with the motor powered down and that worked fine. Following that I shut down the Arduino software on the computer and the turntable continued to operate consistently. Finally I disconnected the usb connection, inserted the jumper link and powered the two boards from the Arduino power socket and that also worked nicely. The only negative, from my point of view, was that powering down the Arduino to swap the connections meant that the turntable moved to the sensor position on powering up again. That is not a major issue I guess.

 

Since I worry about the temperature of the motor I would like to be able to disconnect the power to the motor when I am not turning a loco so would it be feasible to remove the jumper link and tap off the power to the Arduino board and take a supply to the motor shield via a switch so that I can leave the Arduino powered up and just energise the shield when I want to turn a loco?

 

Once again I need to thank you and Ian for all the help and guidance you have given me with this project.

 

Geoff

Link to post
Share on other sites

Good evening Ray,

 

I have arrived at position settings which give consistent alignment, with or without a loco on the table. They are 1078 and 2706, someway off a difference of 1600 but they work.

 

I then went on to testing the alignment with the motor powered down and that worked fine. Following that I shut down the Arduino software on the computer and the turntable continued to operate consistently. Finally I disconnected the usb connection, inserted the jumper link and powered the two boards from the Arduino power socket and that also worked nicely. The only negative, from my point of view, was that powering down the Arduino to swap the connections meant that the turntable moved to the sensor position on powering up again. That is not a major issue I guess.

 

Since I worry about the temperature of the motor I would like to be able to disconnect the power to the motor when I am not turning a loco so would it be feasible to remove the jumper link and tap off the power to the Arduino board and take a supply to the motor shield via a switch so that I can leave the Arduino powered up and just energise the shield when I want to turn a loco?

 

Once again I need to thank you and Ian for all the help and guidance you have given me with this project.

 

Geoff

Hi Geoff.

 

Something I hadn't realised is there is a 'release' command in the Adafruit library which is supposed to power down the motor. I'm not sure if this relates to a stepper motor or a DC motor (or both) which the Adafruit board can also drive. I'll investigate when I get a few minutes and report back. This would be a more elegant solution.

 

Ray

Link to post
Share on other sites

  • RMweb Gold

Hi Geoff.

 

Something I hadn't realised is there is a 'release' command in the Adafruit library which is supposed to power down the motor. I'm not sure if this relates to a stepper motor or a DC motor (or both) which the Adafruit board can also drive. I'll investigate when I get a few minutes and report back. This would be a more elegant solution.

 

Ray

 

It certainly would Ray, thank you.

 

Geoff

Link to post
Share on other sites

Ok Geoff, here's something to be going on with, it's not perfect yet but it will power down the motor.

Add the following after:
void backwardstep2() {
myStepper2->onestep(BACKWARD, MICROSTEP);
}

void release2() {
mystepper2->release();
}


Then after your two 'stepper2.moveTo(xxxx);' commands add:

release2();

Finally after 'DCC.SetupDecoder( 0x00, 0x00, kDCC_INTERRUPT ); add:

release2();



This will power down the motor after finding the first reference position after switching on.
Then select a turntable road by sending a DCC accessory address. The turntable will power up and rotate to that position but the motor will stay powered while the loco is rolled on/off the turntable. Select the same turntable road again and the motor will power down.
Selecting a new turntable road and it will power up and rotate to the new position.

It's not a perfect solution but I'll work on it when I get a bit more time.

Ray.

Edited by tender
Link to post
Share on other sites

  • RMweb Gold

Ok Geoff, here's something to be going on with, it's not perfect yet but it will power down the motor.

 

Add the following after:

void backwardstep2() {

myStepper2->onestep(BACKWARD, MICROSTEP);

}

 

void release2() {

mystepper2->release();

}

 

 

Then after your two 'stepper2.moveTo(xxxx);' commands add:

 

release2();

 

Finally after 'DCC.SetupDecoder( 0x00, 0x00, kDCC_INTERRUPT ); add:

 

release2();

 

 

 

This will power down the motor after finding the first reference position after switching on.

The select a turntable road by sending a DCC accessory address. The turntable will rotate to that position but the motor will stay powered while the loco is rolled on/off the turntable. Select the same turntable road again and the motor will power down.

Selecting a new turntable road and it will power up and rotate to the new position.

 

It's not a perfect solution but I'll work on it when I get a bit more time.

 

Ray.

 

Gosh, that was fast Ray. I will give that a go tomorrow sometime. 

 

Thank you once again.

 

Geoff

Link to post
Share on other sites

  • RMweb Gold

Ray,

I managed to nip up to the railway this evening and make the alterations to the sketch and they work just fine. I tried them first with the computer hooked up and then with the link jumper in place and the power to the Arduino and everything worked as you predicted.

 

Thank you very much indeed.

 

Geoff

  • Like 1
Link to post
Share on other sites

Geoff,

When you release the motor it is no longer "locked" in place.

If it is moved accidentally and your code relies on the last known position then won't work too well.

For my controller, it releases after several minutes of inactivity but seeks a home position on reactivation.

 

CFJ

Link to post
Share on other sites

  • RMweb Gold

Geoff,

When you release the motor it is no longer "locked" in place.

If it is moved accidentally and your code relies on the last known position then won't work too well.

For my controller, it releases after several minutes of inactivity but seeks a home position on reactivation.

 

CFJ

 

Hello CFJ,

Yes I understand that the motor is not locked in place if it is released. In practice I find the table does not move when running locos on or off and so far I have found that it works reliably using that method and I don't have to fret about the temperature of the motor.

Ray has said he might investigate further when he gets time and he has given up so much time helping me with this already. If there is another sketch which will help to keep the motor cool while providing the quality of operation we are currently getting I am sure we would all appreciate finding out about it.

Thank you for contributing to the thread.

 

Geoff

Link to post
Share on other sites

and I don't have to fret about the temperature of the motor.

 

Why fret about it?  It is normal for stepper motors to be hot - uncomfortable to touch. Just make sure that the current-limit on the stepper driver board is adjusted to suit the motor.

 

...R

Edited by Robin2
Link to post
Share on other sites

  • RMweb Gold

They have one?

Will have to check mine and set.

Thanks.

 

CFJ

 

This thread has certainly thrown up some interesting snippets of information about the products which have been used. I received no documentation with my stepper motor and was very surprised and concerned when I discovered how hot it became with prolonged use. When looking for the information about connecting the motor shield to the Arduino I didn't see any mention of an adjustable current limiter. It must be that darned small print that I just cannot see even with my new glasses. We live and learn.

Thanks to all who have contributed I have a useable turntable now. I am very grateful for all the time and effort people have given over to this project and in particular with helping me get mine working.

 

Geoff

Link to post
Share on other sites

 When looking for the information about connecting the motor shield to the Arduino I didn't see any mention of an adjustable current limiter.

If it does not have an adjustment for the motor current then it is not a specialized stepper motor driver - such as a Pololu DRV8825.

 

As well as allowing for adjusting the current the specialized drivers relieve the Arduino of a lot of work as they only need step and direction signals.

 

...R

Edited by Robin2
Link to post
Share on other sites

  • RMweb Gold

If it does not have an adjustment for the motor current then it is not a specialized stepper motor driver - such as a Pololu DRV8825.

 

As well as allowing for adjusting the current the specialized drivers relieve the Arduino of a lot of work as they only need step and direction signals.

 

...R

 

Robin, mine is an Adafruit Industries Motorshield v2.3, DC motor, stepper and servo control for Arduino.

 

Geoff

Link to post
Share on other sites

Robin, mine is an Adafruit Industries Motorshield v2.3, DC motor, stepper and servo control for Arduino.

 

My internet was very slow yesterday so I could not visit the Adafruit website. As far as I can the TB6612 driver on that board is a dual Mosfet H-bridge really intended for driving DC motors. The specialized stepper driver chips have a lot of features specifically aimed at getting the best from stepper motors.

 

...R

Link to post
Share on other sites

  • RMweb Gold

My internet was very slow yesterday so I could not visit the Adafruit website. As far as I can the TB6612 driver on that board is a dual Mosfet H-bridge really intended for driving DC motors. The specialized stepper driver chips have a lot of features specifically aimed at getting the best from stepper motors.

 

...R

 

Robin, thank you for taking the time to look into this.

Since I started on this project completely ignorant of Arduino, Adafruit motor shields, stepper motors and their application I felt I had to go with the original parts lists with which Ray started the thread. I now have a turntable which I can use and which seems to operate reliably for what I require so I am content to go with what I have. But my journey to this end and the other projects which have come up in the thread have no doubt enriched and enlightened anyone who has used the thread to further their own plans and for that I am grateful to all who have contributed.

 

Thanks again.

 

Geoff

Link to post
Share on other sites

i thought i would share my views.....

 

i have tried both the adafruit and the A4988 driver chip and i prefer the adafruit. I found it difficult to tune the a4988 chip with the stepper motor so that it would not cause any vibrations or jitter, however i could not, and so went back to the adafruit shield.

Link to post
Share on other sites

 I found it difficult to tune the a4988 chip with the stepper motor so that it would not cause any vibrations or jitter,

That seems very strange indeed. Both the shield and the A4988 just tell the motor to move one step, and then another step. I am not aware of any "tuning" that can be done.

 

I am assuming you were using a bipolar stepper motor.

 

...R

Edited by Robin2
Link to post
Share on other sites

you can tune the amount of current supplied to the stepper motor...

 

i could not get a setting that made the stepper motor perform well.

I just set it to whatever the motor datasheet says is appropriate for the motor. The motors I have can take 350mA so that's what I have set it to.

 

I'm not even sure that I understand how the motor would perform badly if the current limit was incorrect unless it was set so low that the motor could not generate enough torque and would miss steps. But missing steps is very obvious. The bigger risk is setting the limit too high so that the smoke escapes from the motor :)

 

I guess if you were using a motor that needed more amps than the A4988 could provide then the A4988 would protect itself by shutting down in what might seem like a random fashion. But the answer to that is a driver that can comfortably provide the current required by the motor.

 

...R

Link to post
Share on other sites

  • 3 weeks later...

Ok Geoff, here's something to be going on with, it's not perfect yet but it will power down the motor.

 

Add the following after:

void backwardstep2() {

myStepper2->onestep(BACKWARD, MICROSTEP);

}

 

void release2() {

mystepper2->release();

}

 

 

Then after your two 'stepper2.moveTo(xxxx);' commands add:

 

release2();

 

Finally after 'DCC.SetupDecoder( 0x00, 0x00, kDCC_INTERRUPT ); add:

 

release2();

 

 

 

This will power down the motor after finding the first reference position after switching on.

Then select a turntable road by sending a DCC accessory address. The turntable will power up and rotate to that position but the motor will stay powered while the loco is rolled on/off the turntable. Select the same turntable road again and the motor will power down.

Selecting a new turntable road and it will power up and rotate to the new position.

 

It's not a perfect solution but I'll work on it when I get a bit more time.

 

Ray.

 

Ray,

 

Can i get clarification on this please???

 

are you suggesting adding a release2(); after the moveTo in the BasicAccDecoderPacket_Handler method???

 

how does the stepper motor code handle this?? are they effectively queued up as otherwise, would a release not cancel out the moveto ?

 

Ian.

Link to post
Share on other sites

  • RMweb Gold

Ray,

 

Can i get clarification on this please???

 

are you suggesting adding a release2(); after the moveTo in the BasicAccDecoderPacket_Handler method???

 

how does the stepper motor code handle this?? are they effectively queued up as otherwise, would a release not cancel out the moveto ?

 

Ian.

Ian, I have implemented this and it works fine for me.

 

Geoff

Link to post
Share on other sites

Hi Ian,

That's correct, the stepper motor code will execute until the current position equals the goto position, the release2() command will do nothing as the motor keeps getting stepped until the goto position is reached. The next time the loop is executed (using the same Accessory address) the current position is already equal to the goto position so the stepper motor code isn't executed and drops through to the release2() command powering down the motor. 

It's not an elegant solution and was just done for quickness for Geoff but it works for now.

 

Ray.

Edited by tender
Link to post
Share on other sites

Thanks Ray. Thats what i thought...

 

i want to implement this also as the whine from my stepper motor gets a bit annoying. 

 

you could always have a couple of photo sensors at each end of the bridge to detect a logo coming on and off and activating the release that way!

 

e.g.

 

if train left bridge, release();

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...