BEMF with TCS problem - Page 2 - Model Train Forum - the complete model train resource
Model Train Forum - the complete model train resource

Go Back   Model Train Forum - the complete model train resource > Model Train Workshop > DCC Forum (Digital Command Control)
Forgotten your password?


Reply
 
Thread Tools Display Modes
Old 11-20-2019, 01:41 PM   #11
gregc
Engineer
 
Join Date: Apr 2015
Location: somerset, nj
Posts: 901
Quote:
Originally Posted by Severn View Post
However there's a definite lag that's audible when you coast the motor to get the voltage going.
can you explain this lag?

presumably you know the speed setting commanded over DCC, you have a measure of speed (BEMF) and a motor voltage (PWM) setting. you compare (or subtract) the measured and commanded speed and make a PWM adjustment. No doubt there may be some iterations for the measured speed to stabilize at the target speed, BEMF is not proportional to PWM, but make PWM adjustments proportional to the error (target - measured)

Quote:
Originally Posted by Severn View Post
I also wonder at this point why the sound decoder folks don't provide a "1 revolution pin input" for RPM sampling provided by some other device .... seems like that's the way to go in the end and hobbyists might enjoy providing the little bit of hardware to do it.
i believe BEMF is simple and requires no other components except for an connection between the motor armature and ADC input.

i thought some sound decoders require a metal pickup on the back of a driver with a sticky patch exposes metal every half or quarter.
gregc is offline   Reply With Quote
Sponsored Links
Advertisement
 
Old 11-20-2019, 01:59 PM   #12
Severn
Engineer
 
Join Date: May 2016
Location: Annapolis, Maryland
Posts: 548
I should have been more clear in my long winded explanation of the work. What I did was on the bench. There's no DCC involved. The motor commands are done through the arduino directly to a hardware motor controller. The controller changes its PWM freq depending on various inputs -- and you can set it to coast or even brake. I have not experimented with breaking.

Off the the input leads to the dc motor I've a voltage divide which is just a few resistors to keep the outputs done below 5v -- this does into the arduino's ADC pin. (note this an o gauge motor running on 20v DC... so yes HO motors are just a few volts in comparison)

Then I run the motors, and coast them in a loop every few moments -- which I can change the sampling rate.

And the end result is audible enough but works -- so I am definitely getting voltage read and you can clearly "see it" if you quickly print out a few voltages for a second or so during this loop...

But not doing that and actually calculating the RPM instead using some formulas and various constants measured on the motor -- I at least get a pretty good result in relation to the other method which is using IR to directly sample the turning motor for the RPM -- in other words they are very close (1% perhaps or around it).

It's quite good as I said "in the middle" and drops off noticeably at the ends.

I imagine the DCC decoder folks have spent a lot of money figuring out how to make it better, smoother and so on.

So when I read about one being jerky, I just wonder if they've done a good job. (since my amateur effort is clearly pretty poor although technically functional) I realize these things have been out for some time and so it may be there's been quite a bit of improvement over time.
Severn is offline   Reply With Quote
Old 11-20-2019, 02:09 PM   #13
gregc
Engineer
 
Join Date: Apr 2015
Location: somerset, nj
Posts: 901
Quote:
Originally Posted by Severn View Post
And the end result is audible enough but works
what do you mean audible? why do you think it is audible?

Quote:
Originally Posted by Severn View Post
So when I read about one being jerky, I just wonder if they've done a good job.
i believe the jerki-ness is the result of multiple locos coupled together and influencing each other. In this case, the motor speed (BEMF) is not solely dependent on the motor voltage (PWM).
gregc is offline   Reply With Quote
 
Old 11-20-2019, 02:13 PM   #14
Severn
Engineer
 
Join Date: May 2016
Location: Annapolis, Maryland
Posts: 548
audible -- you can hear the engine coast, and come back. I've a very short sample period that I conconcoted by simple hand tuning and even with that you can hear it. i suspect on the track the engine would surge a little, pause/surge ... you'd see it.

i can't see how multiple locos from different manufacturers would work very well at all except perhaps with a lot CV hand tuning -- due to different motors, and dcc bemf implementations. Or suspect it would be terrible.
Severn is offline   Reply With Quote
Old 11-20-2019, 02:16 PM   #15
gregc
Engineer
 
Join Date: Apr 2015
Location: somerset, nj
Posts: 901
how long did it take to make a measurement and was the motor unpowered (i.e. coasting) during that time.
gregc is offline   Reply With Quote
Old 11-20-2019, 09:06 PM   #16
Severn
Engineer
 
Join Date: May 2016
Location: Annapolis, Maryland
Posts: 548
fraction of a second. I don't have the time at my finger tips, I'll try to look at it tomorrow some time. but yes, put it in coast and very shortly you get the build up and can read solid makes sense voltages. I believe I averagd. I experiented with different sample times etc... what I did not do is put it on the scope because I was not getting paid and got lazy.
Severn is offline   Reply With Quote
Old 11-20-2019, 09:08 PM   #17
gregc
Engineer
 
Join Date: Apr 2015
Location: somerset, nj
Posts: 901
Quote:
Originally Posted by Severn View Post
fraction of a second.
1/10, 1/100, 1/1000 ?
gregc is offline   Reply With Quote
Old 11-21-2019, 06:33 AM   #18
Severn
Engineer
 
Join Date: May 2016
Location: Annapolis, Maryland
Posts: 548
Looking at the code... Once a second, I coast the motors. After 25 microseconds I start sampling voltage which I do for 3 milliseconds. [note: i played with various values, these are just where i left it which was working] I have no idea how many samples I take or any real details because I didn't actually really inspect it "to the metal".

But i do compare it to the IR sensor results. That works a bit differently. The IR sends a voltage to a pin on arduino. Over some amount its high, and below some amount it's low. I sample the motor 4 times per revolution in the current IR setup. (for bright reflecting patterns on the motor weight symmetrically positioned with black alternating) The pin goes to a interrupt handler in arduino and increments a counter. Once a second I calculate RPM based on the counter and time etc... I take into account (or try) to take into account counter wrap.

The BEMF RPM and IR RPM compare favorably except I said at the "ends" of the power and I don't mean this to be cast in concrete, those were my observations at the time.

On the IR -- one improvement I could make would be to get a solid square wave out the signal -- I didn't bother with this because what I did seemed to work. (I used a hand held RPM reader as a rough sanity check, and looked at the scope and the pin transitions which seemed to compare favorably to my RPM calcs).

Another better improvement there would be a smaller IR package. I looked at some options on digikey but since I actually have no idea what the <blank> I'm really looking for in terms of IR bands and what would be good, etc... I never went further with it.

For HO, I imagine a piece of black/white tape on the HO's motor to wheel connecting rod... and the IR sensor mounted on the chassis in some way to sense the transition in that manner. Many models seem to have this configuration with a motor in the middle and rods to the front/rear wheels -- I guess for diesels at least.


Obviously as you said, BEMF only needs the motor leads.
Severn is offline   Reply With Quote
Old 11-21-2019, 07:15 AM   #19
gregc
Engineer
 
Join Date: Apr 2015
Location: somerset, nj
Posts: 901
Quote:
Originally Posted by Severn View Post
On the IR -- one improvement I could make would be to get a solid square wave out the signal.
you might be interested in encoders attached to the shaft of a motor and used to measure position and speed. They use two optical sensors so direction can be determined as well as increased precision

but as I said, BEMF is well suited for regulating motor speed.

i'm surprised you can hear an audible effect if you simply suspend power for 3 ms while measuring bemf once every second
gregc is offline   Reply With Quote
Old 11-21-2019, 07:50 AM   #20
Severn
Engineer
 
Join Date: May 2016
Location: Annapolis, Maryland
Posts: 548
well its "surgey" -- I may now have to dust it off & investigate more deeply. I also did have the idea of moving it to HO and trying again.

as for motors with built in "encoders" -- I have thought of it. My original idea was just use what I had on hand & it was about learning about it not really the end result. I took apart on old williams engine, and scrounged the motors. Then I got a couple of new MTH motors and I have a couple of Lionel motors. They are all very similar models from that chinese dc motor company. cheap cr*p basically.

I did briefly make something for the track that could go back and forth from a wireless connection using a different motor controller and PI set up through wifi -- it was quite a mess, but it did work although it wasn't very responsive. I used a 18v DC battery back from a drill to make that go.
Severn is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


» Visit These Sites:
LGB World

Or Our European Train Website ModelRailForum




All times are GMT -5. The time now is 04:33 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
vBulletin Security provided by vBSecurity v2.2.2 (Pro) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.