Quadrature encoders and LCD


fiddler

Recommended Posts

Hi

Just ordered a  couple of papilio boards, first adventure into FPGA :-)

First project will be to collect counts from 2 high speed Quadrature encoders, with a potential count up to 80K/second per encoder which is a potential count of 360K pulses per channel per second.

After the data has been processed, a position of sorts will be sent to a Micro, properly an Arduino for starters.

Would like a LCD to display some basic data via menu, including some buttons.

Hope to be able to interface a LCD directly to the papilio

Have searched for fpga quadrature encoder on the site but to no avail.

Any suggestion on where to find info.

Sorry for the nobbie questions, just a bit exited :-)

K

Link to comment
Share on other sites

K.,

sounds like a fun project to start with. See my comments inline

Hi

Just ordered a  couple of papilio boards, first adventure into FPGA :-)

First project will be to collect counts from 2 high speed Quadrature encoders, with a potential count up to 80K/second per encoder which is a potential count of 360K pulses per channel per second.

--> U, this is serious. This is almost exactly what HDD servo controller has to do on a 24/7/365 basis. I wonder  whether Your project is HDD related...If You can do this, I can surely help You get

a recommendation for a job in HDD industry. Unless..

After the data has been processed, a position of sorts will be sent to a Micro, properly an Arduino for starters.

--> I think You mean AVR8 soft core. Yes, a great choice to start with, as Arduino IDE is a blessing.

Having a toolchain setup for Papilio is a big plus for a start project.

Would like a LCD to display some basic data via menu, including some buttons.

Hope to be able to interface a LCD directly to the papilio

--> I have seen many VGA modules around for Papilio, so this should be a no brainer.

Another advantage for Papilio. Get a VGA daugher card from Gadget or Sparkfun, and

search around for VGA code.

Have searched for fpga quadrature encoder on the site but to no avail.

Any suggestion on where to find info.

--> O, this You will have to do on Your own. I am working on uploading custom

core with Shifty AVR8, which is a full featured AVR8 with all the bells and whistles. Make

sure to buy 500K Papilio though.

Sorry for the nobbie questions, just a bit exited :-)

--> No problem, all Your questions are very good questions.

K

Link to comment
Share on other sites

Welcome K!

I haven't done anything with quadrature encoders yet so there is not much to find on the Papilio site. But I found what looks to be a beginner friendly project over at opencores.com:

http://opencores.org/project,quadraturecount

Take a look and see how it goes. :)

You might want to look at the thread about using the AVR8 soft processor in schematic mode. You can use the AVR8 soft processor just like you would an Arduino, but without having to wire stuff up in the real world. :)

Keep us posted!

Jack.

Link to comment
Share on other sites

Oh, about the LCD, there is code to drive a HD44780 LCD in the Papilio-Arduino IDE download. I also have some prototype wings to interface with a HD44780, I can send you one if you are willing to wait that long. It is pretty easy to wire one up and would be quicker. Send me a PM with an address if you want me to send a pcb.

Jack.

Link to comment
Share on other sites

  • 2 weeks later...

Cheers guys.

Still haven't got my boards yet, but been busy reading up on VHDL etc.

Scary thing is that, so far, I find it quite easy to comprehend and I'm telling you thats definitely not normal for me.

Will be interesting to see how far I get before the wheels fall off.......  LOL.

Kim

Link to comment
Share on other sites

Sounds good! I'm glad it is making sense, a couple things to watch out for:

1) Pay attention to the difference between VHDL for synthesis and VHDL for simulation. Many books teach VHDL for simulation which will not work on actual hardware.

2) Pay close attention to sections where things are inferred by the structure of the VHDL code. It's a little weird when you are learning, but if you want to make a register with VHDL you have to use a specific coding structure to infer a register.

3) When you start coding watch your error messages for any latches, if you need to store a bit you should do it with a register instead of a latch. If you see that latches are being inferred then stop and fix it so registers are inferred. Otherwise you will be very frustrated when everything works in simulation but does not work on the actual hardware...

Those are the things that tripped me up in the beginning.

Jack.

Link to comment
Share on other sites

  • 2 weeks later...

Hello Neon22,

I really like python, and I've seen some really cool work done with myHDL, so I think it could be good if it makes you feel more comfortable.

I think the biggest thing is not so much the language but instead shifting how you think about solving the problem. With VHDL, Verilog, or myHDL you need to get away from how you think about coding something. Instead think about how you would wire a schematic together, or breadboard a circuit board. Then how do you use VHDL, Verilog, or myHDL to accomplish those tasks.

Jack.

Link to comment
Share on other sites

Hi Jack,

Yes I see your point. While I am familiar with s/w design as well as h/w and circuits - I am not familiar with this change in thinking required to go from regular s/w design to h/w.

It seems to all be about clock edges.

Do you know of any article which tries to setup how to make the change in thinking from s/w programming to FPGA stye prgramming ?

Link to comment
Share on other sites

I think the thing that helped me the most was to do a lot of reading on digital electronics. I ended up going to amazon and buying a bunch of used digital electronics books for cheap. Then I read through them and kept them for reference. It really helps to have a clear understanding of the building blocks that are used in FPGA's, like shift registers, multipliers etc.

Jack.

Link to comment
Share on other sites

Got the boards last week, but work got in the way.

Then Xilinx decided to not install, so there went another evening.

Anyway, the boards are working in the Arduino setup with the LED/Button wing setup.

Can't believe how fast it downloads to the boards, i presume that the AVR8 softcore get downloaded each time as well.

Now that its working via the arduino, i'm trying to get a simple AND gate to work and download in the Xilinx suite.

This is going to be fun...

Kim

Link to comment
Share on other sites

  • 4 weeks later...

Hmm, this is something I started myself a while ago.

One of the problems with extending the AVR softcore is that it just didn't seem to be built for a peripheral rich setup (IO space, etc). But I didn't want to leave an open source GCC based solution. Which is why I've watched the ZPU work with interest.

I recently tried to use a quadrature interface from opencores, but it was far too featureful and resource heavy.

So instead, I created my own "simple" quadrature interface for the ZPU, and using the standard HD44780 code in the ZPUino IDE install, created a sketch to read the quad counter and write to the LCD.

It is so very nice to read a quadrature encoder as simply as:

unsigned int y=REGISTER ( IO_SLOT (8) ,0);
Serial.println(y);

And to know that it is being clocked at 96Mhz. :)

(Of course, I most probably have created a piece of junk, full of bugs - but I think it's cute)

The code's a complete mess, but if you're interested... it's attached.

This post has been promoted to an article

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.