element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
FPGA
  • Technologies
  • More
FPGA
Blog Arty S7 accelerometer-based pointer
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join FPGA to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: neuromodulator
  • Date Created: 5 Jan 2021 6:11 PM Date Created
  • Views 1388 views
  • Likes 7 likes
  • Comments 2 comments
  • virtual serial
  • s7
  • neuromod
  • serial port
  • fpga
  • game
  • arty
  • arty s7
  • mouse
Related
Recommended

Arty S7 accelerometer-based pointer

neuromodulator
neuromodulator
5 Jan 2021

Arty S7 Accelerometer-based pointer

 

In a little bit more than a year ago I began experimenting with my first FPGA, the Digilent CMOD S7. FPGAs are quite flexible and can be used as programmable logic devices, but also as microcontrollers, since the programmable logic can be used to build a microcontroller. The programmable logic is flexible enough to allow you to design your own microcontroller, but this is would be very time consuming. There are many microcontroller architectures that  are available for FPGAs, but 2 are very popular and well supported by Xilinx: Microblaze and ARM Cortex-M.

 

So far most webinars that I've seen on Element14 have focused on the high level side of the FPGAs. Since so far I only had experience with the lowest level side of FPGAs (Verilog), I thought it would be a good idea to take the 3 part webinar series to learn a bit about how to build a Microblaze microcontroller and program it to read sensor data from the PmodNAV (A 9-axis motion sensor + barometer PMOD board).

 

The webinars get you started on how to use an Arty S7 to read sensor data and print the values in the virtual serial port:

 

Arty-S7 Workshop: Part 1: Learn about Xilinx FPGAs and Embedded Processing

Arty-S7 Workshop: Part 2: Building a Custom Microcontroller in Minutes

Arty-S7 Workshop: Part 3: Rapid Sensor Prototyping with Digilent Peripheral Modules

 

By the end of the webinars we end up with the following synthesized Microblaze microcontroller:

 

 

image

 

 

The designed microcontroller uses the FPGA internal memory, and connects 4 LEDs, 4 push buttons, Digilent's PmodNAV and the virtual serial port. After building the microcontroller, one can program it using Vitis, an Eclipse-based IDE. In the webinar we learned how to use Vitis to program the microcontroller to read the sensor data and continuously print the data to the serial port.

 

While experimenting with the example program, I noticed that my mouse pointer tended to randomly jump across the screen. At the beginning I was a bit annoyed as I thought I would have to change my mouse, but later I found that Windows was for some reason detecting the FPGA virtual serial port as a serial mouse. The mouse pointer issue gave me an idea: to use the FPGA accelerometer and buttons as a pointer device.

 

I began exploring serial mouse protocols, but I could not get windows to detect the FPGA as a serial mouse. I ran into a few problems: I couldn't get any information on the communication protocol of the mouse detected when running the webinar example, and apparently Windows could recognize the serial mouse only when rebooting. After a few reboots I abandoned my attempts of trying make Windows detect the FPGA as a mouse, and decided to write my own Windows drivers.

 

Using the example as template I modified it to read the FPGA buttons, turn the LEDs on when they get pressed, and increased the reading speed of the PmodNAV accelerometer. The button and accelerometer data was packaged in a 10 byte packet. Only the first byte of the packet has the bit 7 set to 1, all the bytes have the bit 7 set to 0. This is done to synch the packets at the receiving end. The X, Y, Z gyro coordinates were encoded as a 17 bits (1 sign bit + 16 fixed point bits) and each axis required 3 bytes, the button status was sent in a single byte.

 

The driver was programmed using C++ and the win32 library, it was not a low-level driver, just a console program that read the serial port and updated the mouse pointer every time it read a complete package.

 

After some tweaking and the addition of acceleration I was able to use the accelerometer-mouse to move windows, and press icons and buttons. It was not as easy to use as a mouse, but it was by no means terrible; probably easier to use than my Thinkpad's pointing stick, but harder than its touchpad.

 

Here is a small video that shows the board on a game as a complete mouse replacement:

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

 

The code can be found here:

 

https://github.com/Neuromod/Accelerometer-Mouse

  • Sign in to reply

Top Comments

  • saadtiwana_int
    saadtiwana_int over 4 years ago +1
    That looks very neat, great job!! Thanks for sharing! Btw, curious what was your reasoning to choose Microblaze over the ARM as the soft processor? Until somewhat recently Microblaze has been the only…
  • neuromodulator
    neuromodulator over 4 years ago in reply to saadtiwana_int +1
    Thanks, as I explained in the blog, most of my FPGA experience has been with Verilog. So this was my first try on using a soft-processor. Microblaze appears to be able to run at a faster clock speed and…
Parents
  • saadtiwana_int
    saadtiwana_int over 4 years ago

    That looks very neat, great job!! Thanks for sharing!

     

    Btw, curious what was your reasoning to choose Microblaze over the ARM  as the soft processor? Until somewhat recently Microblaze has been the only option, and i have used that in the past, but i think i want to try out the ARM core next time i need to instantiate a processor inside the FPGA, instead of Microblaze. Mostly i have been using Zynq series FPGAs which meant I didn't have to go for a soft processor, but in some use-cases the power consumption is too high on the A9 inside Zynq7000.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • neuromodulator
    neuromodulator over 4 years ago in reply to saadtiwana_int

    Thanks, as I explained in the blog, most of my FPGA experience has been with Verilog. So this was my first try on using a soft-processor. Microblaze appears to be able to run at a faster clock speed and require less FPGA fabric than ARM.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • neuromodulator
    neuromodulator over 4 years ago in reply to saadtiwana_int

    Thanks, as I explained in the blog, most of my FPGA experience has been with Verilog. So this was my first try on using a soft-processor. Microblaze appears to be able to run at a faster clock speed and require less FPGA fabric than ARM.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube