Gray code 10bit SSI encoder project
OzStamp
Posts: 377
Hi All
Been testing a bit of stuff with a Propeller.
Need to read a 10BIT absolute encoder with SSI interface .
The absolute angular data needs to be send to a PLC.
Very expensive dedicated cards can be bought from all major PLC vendors
so thought try and do this with a Propeller.
Hacked some code in Spin to get the "Flow" of what is required happening.
Spin samples way to slow and this code needs to be ported to assembly.
The code sample attached as a PDF file shows only half what is required,
Getting the data from the SSI encoder is via a very fast Shiftin type routine
but the code the encoder sends is in GRAY code so it needs to be converted to BINARY.
Cannot use a "Look UP TABLE" as we may use the full 13 bit resolution of the encoder as we
progress to bigger and better things.
The lookup table would simply be too BIG
The 32bit longs and the incredible power to do complex calculations all in one line
make things a little easier in SPIN·... anyway need to port this to Assembly for speed
We need to shiftin data at frequencies over 100KHZ minimum ...
The code example ran about 2000 HZ ( inserted a toggle flasher at the end .. now removed)
See the screenshot of the scope also embedded in the document
Spin runs at about 80K instructions ... correct ??
Once we get one encoder working the Propeller should be able to do at least 3
Thought we share this stuff with you all.
Ronald Nollet·· OZ·
Been testing a bit of stuff with a Propeller.
Need to read a 10BIT absolute encoder with SSI interface .
The absolute angular data needs to be send to a PLC.
Very expensive dedicated cards can be bought from all major PLC vendors
so thought try and do this with a Propeller.
Hacked some code in Spin to get the "Flow" of what is required happening.
Spin samples way to slow and this code needs to be ported to assembly.
The code sample attached as a PDF file shows only half what is required,
Getting the data from the SSI encoder is via a very fast Shiftin type routine
but the code the encoder sends is in GRAY code so it needs to be converted to BINARY.
Cannot use a "Look UP TABLE" as we may use the full 13 bit resolution of the encoder as we
progress to bigger and better things.
The lookup table would simply be too BIG
The 32bit longs and the incredible power to do complex calculations all in one line
make things a little easier in SPIN·... anyway need to port this to Assembly for speed
We need to shiftin data at frequencies over 100KHZ minimum ...
The code example ran about 2000 HZ ( inserted a toggle flasher at the end .. now removed)
See the screenshot of the scope also embedded in the document
Spin runs at about 80K instructions ... correct ??
Once we get one encoder working the Propeller should be able to do at least 3
Thought we share this stuff with you all.
Ronald Nollet·· OZ·
pdf
23K
Comments
Graham
Presently using the below as we had one laying around .. there are amny SSI encoders
All use the same protocol
Sick/StegMann CoreTech series T21 series .. probably now different series as
the company Stegmann was bought by SICK (optic electronics) a few years ago now
10-32VDC >> with SSI interface clcok + data + remote zero function .
These encoders are real robust ..thick shaft and high IP rating..
The unit I have is 8192 resolution (13 bit)
Cheers
Ronald Nollet OZ
basic stamp completed project http://forums.parallax.com/forums/default.aspx?f=21&m=208940
quadrature encoder with spin files from Jeff Martin and Graham Stabler http://forums.parallax.com/forums/default.aspx?f=25&m=156619
When hand-translating SPIN to assembly I have generally gotten a speed-up of 80. But there is more potentiality in case of tight INA/OUTA handling.
en.wikipedia.org/wiki/Gray_code
has a decoding algorithm possibly similar to that posted by deSilva (I haven't stepped through it yet).
Graham
The file you pinted to is for 2 channel incremental encoders.(Jeff Martin one)
These just provide A and B phase ( some with zero marker as well)
These types of encoders do not provide absolute feedback .. non volatile..
Meaning when you turn the power off you loose where you are and need to
rehome for zero or reference to a datum switch...
The absolute encoder we use gives an unique code (13bit max res)at which
position it is ..
Hi Graham.
There are various methods to converting Gray to BIN all boil down to of course
achieving the same goal..My method is straight from the old Ronald Tocci digital
fundamentals book ( used at school many moons ago) I believe Don Lancaster had a similar
method in one his books as well.
Not being much of a C programmer .. seen some various short C code examples as well.
Hi De Silva.
Thanks for the starter.
Not being an expert assembly programmer I find it easier to get something happening in Spin
and then translate it to Assembly.. seems to work for me.
Now here is an idea .. what about a PropSpin to Prop Assembly compiler...?
Is that a stupid idea ?
Cheers to all
Ronald Nollet·· Australia
You can take a peek here:
http://hamster.foxhollow.ca/GrayCodes/GrayCodes.htm
http://hamster.foxhollow.ca/GrayCodes/GRAY-CODES-Final-Report.pdf
Had a peeky boo at your Final report Gray Code PDF.. a very neat document.
Downloaded it and with your okay will put on our CD that we post out sometimes to people
needing help with stuff...pm me or a quick post here is probably fine as well..
My posting here as above was a simple hey this is what we are up to and not asking for any help
but as usual and this is absolutely sensational about this Forum .. there are just so many people just wanting to
help and share what they have done.. this is truly reflecting the spirit of the Parallax company..
Cheers
Ronald Nollet Melbourne Australia
Nice. In your research did you find an algorithm for a single track gray code? Or is that a patented item?
Fred
The algorithm with the loop and bit flipping is a good way to convert natural binary to gray code binary otherwise you need to build a table.
I think the propeller could do this without grief. The algorithm is fairly lightweight. You would read the encoder, convert it to a binary code and you could send out the response on the serial port. I am not sure if spin allows variable-based access to pins. The loop accesses 2 pins based on where it is in the loop. Since it is only 10-bit, hard-code 10-lines of code instead of the following...
Some questions that you must ask yourself is how you want the data sent from the propeller and how often. You could have it sent with a timed interval (every 10ms ?), non-stop or perhaps only when the codes change (if new_code <> old_ code then send_new_code)
Post Edited (Mark Bramwell) : 9/26/2007 3:19:00 PM GMT
Regarding to a single track Gray code ??
This term is generally associated with a single track with 2 sensors slightly offset from each
to create 2 pulses that are 90 degrees out of phase with each other.
These encoders are commonly known as "Incremental encoders " or also as "Quadrature encoders."
Jeff Martin from Parallax has an object that does that .. goto the object downlaod section
Jeff references to it as a 2 BIT gray code .. his terminology is correct but it is not commonly used in the industry.
I have communicated with Jeff re this ...it is a very neat object for this type of encoder .. check it out.
Rgds
Ronald Nollet Australia
www.cs.technion.ac.il/~etzion/PUB/Gray2.pdf