Shop OBEX P1 Docs P2 Docs Learn Events
Interfaceing to a Quadrature Encoder — Parallax Forums

Interfaceing to a Quadrature Encoder

duckieduckie Posts: 12
edited 2005-03-22 04:45 in BASIC Stamp
Eventually, I would like to possibly use a basic stamp product to control·one or more·servo motor in a CNC application.· It seems to me, a good place to start is getting position data from a quadrature encoder.· The one I have is optical.· Has anyone had any luck trying this?

Thanks
·

Comments

  • BeanBean Posts: 8,129
    edited 2005-03-14 13:17
    I don't think the stamps are fast enough to directly read the quadrature from a servo motor. The SX would probably be fast enough. Do you know about how many pulses per second at full speed ?

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out· the "SX-Video Display Module"

    www.sxvm.com
    ·
  • duckieduckie Posts: 12
    edited 2005-03-14 13:29
    oh dear.. lots.. I think on the low end I'd like to see roughly 16000 pulses per second. which would give me about 4"/sec travel with a dirrect connection.
  • BeanBean Posts: 8,129
    edited 2005-03-14 13:41
    Oh, that's nothing for an SX running at 50MHz. The SX could execute over 3000 instructions per pulse.
    You could make an interrupt routine that runs at 48KHz (3x oversample), and still have lots of cycles for
    communicating with a stamp.
    I can whip-up some code if you want to see how.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out· the "SX-Video Display Module"

    www.sxvm.com
    ·
  • duckieduckie Posts: 12
    edited 2005-03-16 03:47
    Really? it will work?? Oh wait.. I guess I don't have an SX on hand. Gotta wait till the next payday for that new toy.

    So can I do everything onboard? read the pulses from quadrature, read commands (something simple, like step and dirrection, my cnc program is already set up for htat) do some math.. and output dirrection and PWM all from one SX?

    Thanks
    Dan
  • duckieduckie Posts: 12
    edited 2005-03-16 03:50
    Wait. I'm confused, the website says that the SX can execute 10,000 instructions per sec, and I'm trying to read 16,000 puleses per sec. How does that work?

    Dan
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-16 03:54
    You're mixing the BS2sx with the SX28 ... the BS2sx uses the SX28 as its core, but is running PBASIC. The SX28 running native assembly language -- especially at 50 MHz -- is a screamer and can handle your app handily. It's (the SX28) even easier to program now with our free SX/B compiler.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • duckieduckie Posts: 12
    edited 2005-03-16 23:17
    You're right, I was. Now that I have a better understanding of what's going on in your head, I have a whole new set of questions!

    1) Should this discussion be transfered to the SX board?

    2) <<blasphamy>> how does the sx28 compare to PIC microcontrollers (be honest) what are the achievements and shortfalls of each. areas of particular interest are a) ease of programming b) startup cost c) continued cost d) capabalities

    3) is assembly really all that bad? or is it just something that tends to scare away ppl who are used to high level programming languages. I personally don't have a great deal of programming experience, but firmly believe that anything can be achieved with enough time, modivation, and capital.
  • Robert SchwartzRobert Schwartz Posts: 141
    edited 2005-03-16 23:39
    1)Thats up to moderators, I think its fine here for now.

    2)
    a)Both have multiple high level compilers, so it depends on whether you can find a good free PIC complier. Many high level PIC ones are rather expensive, while SX/B is free

    b)Depends on whether you purchase a compiler for the PIC, if so than costs are way higher, otherwise, if you program in assembly, you can purchase very low cost compilers (hardware).

    c)About the same.

    d)SX's are than PIC's since they perform an instruction in 1 cycle. That means at 50Mhz, the SX will perform 50Million instructions a second (ie FAST!). PICs have many instructions requiring 2(+) instructions. Also, SX's can be run at higher speeds at lower voltages. Some PICs however have neat uses such as Micrchip's KeeLoq, USB interfaces, and integrated RF.

    3)Assembly isn't that bad. If you take time to learn the commands it pays off. However, don't expect to just learn it in a day. It will take many long hours to really get a firm grip on assembly programming.
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-03-17 00:02
    the SX and the PIC have alot of similarities, but there are a few critical differences, most pics operate upto 20MHz if I remember correctly, but here's the key difference, PICs don't do pipelined execution like the SX does, that means it takes a PIC four clock cycles for each instruction, the SX does one instruction for each clock cycle with the exception of program flow instructions (jump, call, skip if bit set etc) so an SX running at 20MHz with have 20MIPS but a PIC running at 20MHz will have 5 MIPS, theres a world of difference there. I maybe slightly off on my numbers and some newer PIC may have an instruction pipeline, Im too busy at the moment to go and verify the info.
  • hutdonhutdon Posts: 32
    edited 2005-03-21 14:42
    Another solution you may want to give a try with encoders is to use special purpose chips to read the encoder and output a pulse for each increment and direction. I have used a couple of the chips from US Digital at www.usdigital.com and found them to be very easy to use. Couple these with a PAK copressor from Al Williams and you can measure large increment changes with a BS2.
  • duckieduckie Posts: 12
    edited 2005-03-22 04:45
    Interesing.· I knew such chips had to exist, but I'd never bothered to find them before.· looks like US digital has a lot of interesting stuff, should I choose to persue this project to great lengths.· Unfortunatly, budget constraints insist I wait on that.· Thanks for the post.
Sign In or Register to comment.