Servo Axis Simulator - Hardware version

NewValue=NewValue-(NewValue>>3)+AnalogIn

This is not right. You are effectively mulitplying by -7.

NewValue=(NewValue>>3)-NewValue+AnalogIn

is correct but loses too much resolution. My way is better. You should at least add a rounding term

NewValue=((NewValue+4)>>3)-NewValue+AnalogIn

This will keep from adding a negative bias to the output because of the continual truncating.

It doesn't surprise me that your compiler would automatically find the the best way to multiply by 7. Many compilers for small micros will convert multiplies to inline shift and adds or shift and subtracts rather than call a general multiply routine. You must have one of the better one though.
 
Can you explain why NewValue=NewValue-(NewValue>>3)+AnalogIn
is incorrect?

I am doing shift right, instead of left you did.
With Left shift I see your idea, but I am doing right shift!


Here is my calculation:
A, B, C unsigned integers
We need C=A*7/8+B.
Remember that C and A are 12 bit values (0-4095)
while B is only 9 bit (0-511) or 1/8th of A and C range

A>>3 = A/8
A-A/8 = A*7/8
so A-(A>>3)= A*7/8
and A-(A>>3)+B = A*7/8+B

here is example with numbers:
let say A=2000, B=100 (that is equivalent of command value "800")
(A>>3)=250
A-(A>>3)=2000-250=1750
1750+100=1850
- so where is *(-7) ?

===========

I actually found that compiler uses hardware multiplication unit for *7 and this will have same execution time as "shift-minus"
 
Last edited:
Thanks Peter
Ok, switching gears a little from filter to math:

Any good tips for integer unsigned math A=500,000/B?
where B is from 1 to 4096
Compiler has canned routines but they are quite large, so I am doing this with lookup table today.
But 8192 byte lookup table does not fit to the small(cheap) micro I want to use (4K only), so I will have to use math...
 
Last edited:
My first question is why?

First question is what does this calculation accomplish? Does this calculate the timer divisor for the PWM? If so there isn't much one can do because B will change each iteraton.

The divide subroutine shouldn't be that big. It is just a loop of shifting and subtracting.
 
Yes, this is divider calculation for timer interrupt routine - I am not using PWM, because with interrupt routine can generate all 4 phases at once plus zero marker.
C- compiler uses own divide routines and they are not bad, but lookup table is much faster.
 
Just want to bring old thread back: Servo Axis Simulator is finally ready.
sim1.jpg
 
Here is your chance to brag or advertise.

Why would someone want to buy one?
What does it do?
What does it cost?
What is the maximum frequency of encoder counts.
Can this maximum be changed? I see no interface.
Is there a lag or time constant? Is it adjustable?
Do you have a trend. I know you have access to Rockwell PLCs and should be able to demonstrate how the simulator works with a M02AE card or perhaps some other controller.
 
What does it do?
See very first post in this thread, I explained why I did it.
What is the maximum frequency of encoder counts.
16,250 Hz per channel, 65KHz in x4 mode
Can this maximum be changed?
Only slow down, this is a limit for this $2 microcontoller
I see no interface.
This version has no interface and uses all fixed values. Microcontroller has USB interface but it is not implemented to reduce cost. Adding USB interface is just a matter of writing nice GUI for Windows. All USB routines are available.
Is there a lag or time constant? Is it adjustable?
Yes there is a lag discussed above. Not adjustable at this point but can be changed via USB
should be able to demonstrate how the simulator works with a M02AE card or perhaps some other controller.
The original version used in 2003 with Indramat CLM Motion controller.
Do you have a trend
Yes, I have M02AE sample program but I don't have trend that I can publish today.
Here is connection example

c3.jpg
 
Last edited:
That is low enough

Those of you that don't have simulators built into your motion controllers can benefit from a simulator like this. You can test your PLC and motion control programs at the quiet and sanity of you your desk instead of in the din of the plant sitting on a spool of cable with your lap top on the top of an upside down garbage can. I am certain you would get a pay back after the first project.

I am a big believer in simulation. You look like a hero when you get on site and your program works right off.
 

Similar Topics

I have to rollout a common CLX PLC program to a dozen or more installations, but each installation uses a different HMI front end. Some WW, some...
Replies
8
Views
883
Dear All: I have the flashing red light on the FDBK indicator. The manual said that it means: The axis servo loop error tolerance has been...
Replies
2
Views
644
Hi PLC experts :) I’m working on a project in studio 5000 Logix designer with several servo motors, I'm trying to set the properties for them...
Replies
1
Views
826
Hello automation experts, I'm trying to learn about servo axis control in AB ControlLogix PLCs (L33ERMS). Attached is an example of a servo...
Replies
4
Views
1,077
I have a virtual master that drives all servos. How do I make Virtual Master or any Servo to follow regular encoder which is driven by Regular...
Replies
5
Views
3,176
Back
Top Bottom