element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • 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
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • Product Groups
  • 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
Arduino Projects
  • Products
  • Arduino
  • Arduino Projects
  • More
  • Cancel
Arduino Projects
Blog Vidor4000 CAN-Bus Project
  • Blog
  • Forum
  • Documents
  • Events
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Arduino Projects requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: alisterw
  • Date Created: 27 Jan 2019 9:48 PM Date Created
  • Views 1930 views
  • Likes 4 likes
  • Comments 2 comments
  • mkr freedom
  • autohacks
  • programmablelogicch
  • mkr_vidor
  • arduinoday2019
  • mkr vidor 4000
  • mkr_freedom
  • autohacksch
  • vidor 4000
  • mkr_auto_hacks
  • obd-ii
  • mkr fpga challenge
  • mkr_shield
Related
Recommended

Vidor4000 CAN-Bus Project

alisterw
alisterw
27 Jan 2019

Master Plan: Plug a CAN-Bus MKR Shield onto Arduino 4000 and read car's OBD-II data so it could be displayed on an HDMI screen in graphical form. What could be simpler, it should only take 10 minutes to bolt together one of the many CAN-bus examples to a graphical HDMI driver. The FPGA section could be used to scroll the graphical section of the screen horizontally, at high speed, in the same manner as done on an oscilloscope. So the graphs of engine speed, mass air flow, throttle position etc would be displayed in real time. Additionally an accelerometer could be added.

 

Before the Arduino Vidor 4000 arrived, I purchased an OBD-II connector and wired up its crimp terminals to what should be CAN+. CAN-, Ground and +12V.

 

image

 

That master plan has kind of had to be diluted as at the moment, the graphical screen resolution of the FPGA code is rather low, and besides, the Police don't take kindly to people driving with a screen visible and I don't really wish to become a star on 'Police Interceptors' trying to explain that it is not actually a DVD player. Back-up plan is now to display CAN and OBD data in text format by bolting together the TEXT-DEMO FPGA code from Giacko68 to the OBD-II Arduino code from Loovee. This time the FPGA could be used to vertically scroll a central text display window by simultaneously moving each column up a row.

 

TEXT-DEMO was extracted from GitHub and it ran correctly. Two warnings:

1. My micro-USB cable was a bit wobbly and caused lots of problems with intermittent contacts. If you have trouble running published Vidor stuff then do try a decent cable,

2. Have patience! The FPGA loads itself on power-up via JTAG and THIS TAKES APPROX. 30 SECONDS! You should see the red led flash three times quickly then go off while the JTAG does its stuff. Finally the red led comes on and you will get HDMI video. Don't panic if you see no video during the JTAG load!

2.5 Purely as a comment, some time ago I purchased an HDMI cable from a '99p' shop. Sadly it did not work with a Raspberry Pi. However one bought from a Pound Shop did work...took a long time to figure out why the Pi wasn't working.

 

First problem to solve was to regenerate the FPGA file as required by TEXT-DEMO, so it could be modified. I used Quartus-II v18.1 on a Windows 10 PC. It would build the output file but that file would not run for some weird reason. After plenty of mucking about, I installed v18.0, and that generated a functional file, so I could run the TEXT-DEMO and get an HDMI text display on my HDMI monitor. Giacko also did some tests and had no problems using v18.0 and v18.1, but the subtle difference was his O.S. was Linux. Incidentally, some of the Vidor 4000 instructions state that a patch is required for v18.0, and that is supplied as shell scripts what Windows does not seem to like at all, so I didn't add these patches. I did try to run an old 32-bit laptop with Lubuntu to get round this problem, but many tools just don't play 32-bit mode any more, so I gave up on Linux.

 

As an experiment, it seemed a fun idea to use the FPGA's soft SPI ports, but I couldn't get any data from the MISO pin. Besides, the 'VidorPeripheral' FPGA code is not the same as the TEXT-DEMO FPGA code so I would have probably had to cut and paste some Verilog over. But the SAMD21's SPI port fired up immediately and I could get data in and out of the MKR CAN Shield. I tried the VidorPeripheral UART code as an experiment and that did work.

 

The next problem was that TEXT-DEMO now refused to display anything when the CAN Shield was plugged in. That was because both the MCP2515 CAN interface and FPGA text interface use the same SPI port and also some control lines e.g. INT and FPGA_CS (chip select) on the same pin. Because the Shield is hard-wired I had to move the FPGA_CS signal from Pin 7, to Pin 6, and that was very easy to do: in the Pin Assignment editor, change SPI_CS's pin from F16 to G16. The SPI port can talk to multiple devices provided chip selects are separated. To make debug easier, I soldered a 28-pin IC socket onto a piece of strip board and soldered in some pins on useful tracks viz. 0V, MISO, MOSI, SCLK and Pin 3 (CAN_CS). The switch was from a previous project! An HDMI converter is plugged in.

image

 

Then I rebuilt the FPGA project. Copy the .SVF file from output_files up a couple of directory levels to where MakeImage.py lives. This python file can be run from the Command Prompt. I use Python 3.7.1 by the way.

 

The Python warnings about not being able to find the path specified may be ignored as they expect a Linux command line. I have slightly modified this program; as an aside, Python is a very useful language and can run fancy graphics and games, with upside-down text if you like(!) on both Windows/Linux, but sadly keyboard input is not so compatible. It takes about 30 seconds for this Python program to run. Patience! End result is an RLE-encoded header file FLGA_Image_RLE.h which the Arduino code loads into the FPGA.

 

Changing the Arduino program to use CS on pin 6 was easy as adding

const int SPI_FPGA_CS_PIN = 6; to TEXT.ino.

 

Next interesting problem to solve was running two slaves from one master SPI module in the SAMD21. The FPGA uses an active high chip select, whereas the MCP2515 is active low. MKR pin 3 is hard-wired as the MCP2515 CS pin, so uses:

const int SPI_CAN_CS_PIN = 3;

 

The chip select signal have to be set or reset before SPI transactions, so I have made some minor changes to do this. I then used an MSO to ensure that the two chip selects were never active at the same time, and the results looked good as there were no obvious occasions where both chip selects were active.

 

Sunday 27th Jan, and one day before the deadline of 28th Jan. Bit of partying last night until 2am and there is some more work to do:

Set up some rectangular panels on the display to hold text messages (title, keyboard command entry, received CAN message display and possibly their meaning), modify the Verilog code to scroll one of the panels, add the scroll command to the Arduino software, and test it. The TEXT-DEMO uses an ASCII character set containing some simple graphic shapes that can be used to draw lines to define each panel.  This technique was used in the days of DOS, and Teletext before pixels could be individually set.

 

I have not learnt Verilog, or C++ for that matter, but I have used programmable logic devices before. Altera's EP300 was my first venture if I remember correctly, and used various tools such as PALASM and schematic entry. Another device we used was Philip's Coolrunner. But FPGAs don't seem to like PALASM and even though I recently tried schematic entry of a couple of NAND gates on a Cyclone II, that didn't work.

 

Due to not understanding enough Verilog, I did not manage to do the scroll in FPGA, but had to use the SAMD21 for that. Maybe I will get an idle moment and revisit it. I will also revisit the JTAG loading and see if it can be speeded up. Here is a view of the board ready to be plugged in the car...

 

image

And here is the test-based screen display:

image

It was a bit wet and windy this afternoon as I tried to install the Arduino etc and monitor in my car. That is when a slight nooby problem came along...eagle-eyed readers will have noticed that the sex of my connector is wrong! It would not plug into the female connector on the car! So I will have to order a male connector before I can test it.

  • Sign in to reply

Top Comments

  • Fred27
    Fred27 over 3 years ago +1
    some time ago I purchased an HDMI cable from a '99p' shop. Sadly it did not work with a Raspberry Pi. However one bought from a Pound Shop did work That extra penny obviously makes all the difference.
  • nacnac42
    nacnac42 over 1 year ago

    I am attempting to use a mkr can shield to pull data from my vehicle.. not as extensive as your display system! I am attempting to pull certain data for a smart autostart system. i have used loovee ELMduino as well as sandeepmistry can and obd2.  I am new to this so i apologize. Based on my multiple attempts without receiving any response data (however, i know that i am interacting with the can bus data due to the software freezing when can data is available), and the lack of info i can find relating to using the mkr can shield; i have an assumption that you may be able to confirm.. i am lacking on hardware? an elm327 is required in line with the can/ obd2 interface? i assume that the cable that you have has this built in? any confirmation to the fact that my hardware is incomplete or source to library files that could help me in my project are greatly appreciated.

    current configuration is mkr gsm 1400 and mkr can shield.. the gsm 1400 appears to become obsolete this year witb dropping 3g so starting from scratch for the entire build is not out of the question. I do prefer to maintain a hardwire instead of a bluetooth adapter as many of the projects i run across seem to lean towards.

    thx

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Fred27
    Fred27 over 3 years ago

    some time ago I purchased an HDMI cable from a '99p' shop. Sadly it did not work with a Raspberry Pi. However one bought from a Pound Shop did work

    That extra penny obviously makes all the difference. image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
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 © 2023 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

  • Facebook
  • Twitter
  • linkedin
  • YouTube