So Close- Just Need Help With Config and Firmware

More
13 Oct 2013 01:06 - 13 Oct 2013 01:09 #39802 by CalmofDawn
I used an oscilloscope and tested the step and direction pins for LinuxCNC under the hm2_stepper>7i43-big.ini configuration... and they were all working as expected. Default pinouts were:

IO (on 7i42TA)
0 (X Step)
1 (X Dir)
6 (Y Step)
7 (Y Dir)
12 (Z Step)
13 (Z Dir)

I navigated to /lib/firmware/hm2/7i43-400/ and was able to locate those .BIT files. I also downloaded and extracted the package from Mesa at www.mesanet.com/software/parallel/7i43.zip
and successfully located .vhd files and more at /7i43/CONFIGS/...

I'm trying to understand the system architecture between LinuxCNC and the FPGA and having a hard time deducing important points. A few questions come to mind:

Is the FPGA just configured by the firmware files and nothing else? Are .PIN and .BIT the file extensions the firmware extensions for the FPGA? Is firmware what sets the pinouts and determines which pins are "connected" to the quadrature encoder and PWM generator modules? Or can I set, for example, the X axis step gen pin through some config file on the LinuxCNC side?

Are .vhd files the project file extensions to be used with Xilinx Webpack Tools to generate .PIN and .BIT files? Are the Mesa utilities a method to flash firmware files to the FPGA? Are there other methods?

Since I see pinout drop-down menus on the PNCCONF wizard, does that mean the FPGA is configured by not only firmware but also a configuration that LinuxCNC communicates over to the 7i43? Or are the drop-down menus just for naming pinouts on the LinuxCNC side and that's why the options on certain pins are limited to what the existing firmware on the FPGA provides module connections to?

Haha it's just overwhelming at first trying to deduce which operations are handled by which code and files at first glance. Clarification on this would be awesome.
Last edit: 13 Oct 2013 01:09 by CalmofDawn.

Please Log in or Create an account to join the conversation.

More
13 Oct 2013 01:36 #39805 by PCW

Is the FPGA just configured by the firmware files and nothing else? Are .PIN and .BIT the file extensions the firmware extensions for the FPGA? Is firmware what sets the pinouts and determines which pins are "connected" to the quadrature encoder and PWM generator modules? Or can I set, for example, the X axis step gen pin through some config file on the LinuxCNC side?


The FPGA is configured by loading the .bit file. The I/O pinout is built into the FPGA configuration and cannot be changed except by using a different configuration. Any pin can be used as a GPIO pin however, this is one thing that can be changed dynamically.

.pin files are human readable text files that list the built in modules and pinout of a particular FPGA configuration.

Are .vhd files the project file extensions to be used with Xilinx Webpack Tools to generate .PIN and .BIT files? Are the Mesa utilities a method to flash firmware files to the FPGA? Are there other methods?


.vhd files are VHDL source files. Current Xilinx project files have a .xise extension. Note that with normal linuxcnc usage of the 7I43, the FPGA configuration is downloaded into the FPGA RAM every time LinuxCNC starts, no non-volatile flash memory writing is taking
place. The Mesa configuration utilities allow firmware downloading and Flash EEPROM FPGA configuration writing via USB or EPP.
The following user(s) said Thank You: CalmofDawn

Please Log in or Create an account to join the conversation.

More
13 Oct 2013 01:54 - 13 Oct 2013 01:55 #39806 by andypugh
Have you actually read the manual? www.linuxcnc.org/docs/html/man/man9/hostmot2.9.html

Is the FPGA just configured by the firmware files and nothing else?

It is a combination of the .BIT file and the configuration string passed to the driver. However, all the driver configuration string can do is turn "off" some of the modules and convert their pins to GPIO.

Are .PIN and .BIT the file extensions the firmware extensions for the FPGA? Is firmware what sets the pinouts and determines which pins are "connected" to the quadrature encoder and PWM generator modules? Or can I set, for example, the X axis step gen pin through some config file on the LinuxCNC side?

The .PIN file is purely for reading by humans. The computer doesn't use them. (And the XML files you may see are purely for use by the PNCConf Mesa-card configuration Wizard which is included with LinuxCNC)
Which physical pin is which on the 7i43 header is hard-coded into the BIT file. However this is rarely a huge problem as they match the Mesa daughter cards and so generally speaking if you were to move a pin function to another physical location it would no longer drive the daughter card properly. Once you are in HAL you can do lots of other data manipulations with the signals.

Are .vhd files the project file extensions to be used with Xilinx Webpack Tools to generate .PIN and .BIT files?

Yes. They define the various modules, and then the build script assembles them. Typically to create a different layout of functions and pin arrangements you would only create a modified PIN_XXXXXX.vhd file.
To complicate matters there are two ways to create firmwares, there is the Mesa way (that I don't understand) and the LinuxCNC way (that I do understand). The LinuxCNC build-system is here: git.linuxcnc.org/gitweb?p=hostmot2-firmware.git;a=summary and in that system you edit this file git.linuxcnc.org/gitweb?p=hostmot2-firmw...a660c71a48191b4d1a64 to say what firmwares you want to build (probably just your new one) then type "make". But I think that only works with an ancient version of the Xilinx tools.

Are the Mesa utilities a method to flash firmware files to the FPGA? Are there other methods?

"Mesaflash" is used to change the firmware on the 5i25 and 6i25 PCI cards.
The 7i43 loses its program every time it is powered-down, so can't be "flashed" as such. What happens is that the LinuxCNC driver uploads the BIT file to the FPGA as part of the start-up process.
Last edit: 13 Oct 2013 01:55 by andypugh.
The following user(s) said Thank You: CalmofDawn

Please Log in or Create an account to join the conversation.

More
14 Oct 2013 07:15 - 14 Oct 2013 07:24 #39818 by CalmofDawn
This clarifies a lot. Here is my updated understanding of the system:

High-level: The computer handles most of the information processing, the Mesa 7i43 is mainly a communication intermediary (hence "Anything I/O") between the computer and the driving electronics (motor drivers, switches, etc), the Mesa 7i42TA is a breakout board that contains protection circuitry for the application-side I/O pins of the 7i43 and also connects those pins to screw terminals for ease of custom wiring to the driving electronics.

High-level Diagram: Computer---7i43---7i42---Driving Electronics

The 7i42TA is mainly pin-to-pin connections with discrete protection components wired for each pin. Relatively simple.

The 7i43-U-4 uses the Xilinx Spartan III FPGA chip that operates at 50MHz frequency provided from an external onboard oscillator chip. This FPGA chip is programmable and is what provides the anything I/O function. The FPGA can thus be programmed to connect/communicate to various onboard modules such as the quadrature counter chips and PWM generator chips, or simply provide general purpose I/O as necessary. Programming the FPGA is about changing its pinout- which pins connect to which pins. The FPGA is programmed using code files that have the .BIT extension. For ease of development, .BIT files are complemented by .PIN files which are simply human-readable summaries of the .BIT file. .VHD files are VHDL source files, where VHDL is a standardized digital/logic hardware language ("Hardware Description Language"). These VHDL files can be processed through a build script to produce a .BIT file that works for the FPGA on the 7i43 board. The process of developing a .BIT file... I'll have to look into this in more detail.

The FPGA must be programmed each time it turns on. The FPGA can be programmed through EPP or USB. EPP configuration can be direct to the FPGA without intermediary chips, and uses the computer's parallel port. USB configuration involves a USB interface chip as an intermediary between the computer's USB port and the 7i43's FPGA chip. To subvert the need to program the FPGA from the computer upon start-up, the desired configuration can be stored on the 7i43's serial EEPROM (a part of the FPGA chip).

On the computer side, assuming a typical LinuxCNC-Ubuntu OS install, the default prepared .BIT configuration files for the Mesa boards are stored in /lib/firmware/hm2/... . These .BIT firmware files will called upon from the LinuxCNC configuration files (notably the .ini and .hal files) present in each LinuxCNC custom configuration folder /home/user/linuxcnc/configs/... (hence changing what .BIT file programs the FPGA can be as simple as changing the navigation path to a different .BIT file). These LinuxCNC configuration files draw information and call functions from all sorts of library and function files located elsewhere on the hard drive upon LinuxCNC start-up. For example, the configuration files call on HostMot2, a computer-side LinuxCNC driver that properly interfaces between the .BIT firmware file for the Mesa boards and the hardware abstraction layer for LinuxCNC.

A question- if I wanted to add on/off spindle control to the hm2_stepper LinuxCNC configuration, would I just have to edit the hm2_stepper.hal and 7i43-big.ini files? I guess what I would like to see is getting a HIGH signal from one of the screw terminals on the 7i42TA when I click on the spindle control button on the LinuxCNC Axis GUI. I tried making a LinuxCNC config with pncconf to test a spindle pin addition and it gave me a latency message upon LinuxCNC axis gui start-up for some reason. I assume there is some decent difference between the settings of the hm2_stepper config and the default-values pncconf config.

I checked out the hostmot2 doc and it's beginning to make a lot more sense than it did when I read it a while ago. I think I'm starting to get this.
Last edit: 14 Oct 2013 07:24 by CalmofDawn.

Please Log in or Create an account to join the conversation.

More
14 Oct 2013 16:36 #39823 by andypugh

A question- if I wanted to add on/off spindle control to the hm2_stepper LinuxCNC configuration, would I just have to edit the hm2_stepper.hal and 7i43-big.ini files? I guess what I would like to see is getting a HIGH signal from one of the screw terminals on the 7i42TA when I click on the spindle control button on the LinuxCNC Axis GUI.


This requires a line in the HAL file
net spindle-on motion.spindle-on => hm2_7i73.0.gpio-020-out
Here, "spindle-on" is a HAL 'signal' which can be any text label not otherwise in use.
motion.spindle-on is a HAL signal driven by the LinuxCNC 'motion' module: www.linuxcnc.org/docs/html/man/man9/motion.9.html
The => is ignored by the computer, but can be optionally added to aid human readability
hm2_7i73.0.gpio-020-out is the name of a GPIO pin in the 7i73. I guessed the name. You would need to choose a pin which is not otherwise in-use.

With LinuxCNC running you can do two things to determine the hardware and HAL pins of your system. Open a terminal window and type
dmesg
and near the end of the printout you will get a list of the 7i73 pin functions and which connectors they are on. This will depend on the firmware and also on how many of each module have veen enabled.
Then,
halcmd show pin *7i73*
will give you a list of all the 7i73-related HAL (software) "pins". In some cases there is a 1:1 correlation between HAL pins and Hardware pins, but in others there is not. For example the step-dir pins are not HAL pins, the interface into the module is the stepgen-position-comand pin.
The following user(s) said Thank You: CalmofDawn

Please Log in or Create an account to join the conversation.

More
15 Oct 2013 01:40 - 15 Oct 2013 01:51 #39836 by CalmofDawn
I navigated to /home/user/linuxcnc/configs/hm2_stepper/... , opened hm2-stepper.hal in gedit, and (after looking at "dmesg" and "halcmd show pin" in terminal) added:
net spindle-on motion.spindle-enable => hm2_[HOSTMOT2](BOARD).0.gpio.040.out
and got AXIS running without error. A side note was that in order to avoid the "Can't issue MDI command when not homed" error, I had to home the axes first by clicking on X, then Home Axis, Y, Home Axis, Z, Home Axis. This home forcing can be configured off by going to the configuration's .ini file (in this case 7i43-big.ini) and adding a line to the [TRAJ] section:
NO_FORCE_HOMING = 1
I confirmed that the motion.spindle-on HAL pin was working by clicking on the spindle button in the AXIS GUI, then running "halcmd show pin" again in the terminal, and the VALUE for that HAL pin changed from FALSE to TRUE. The VALUE for the hm2_7i43.0.gpio.040.out pin also changed from FALSE to TRUE, as expected. However, I noticed no changes upon spindle-button-click when I used an oscilloscope to test the terminals on the 7i42TA board. I checked dmesg and it too showed no IO PIN assignment to any kind of spindle switch function.

I assume there's a step missing that will "connect"(?) the gpio.040 pin to the 7i43, and hence produce the right output on the 7i42TA.
Last edit: 15 Oct 2013 01:51 by CalmofDawn.

Please Log in or Create an account to join the conversation.

More
15 Oct 2013 02:07 #39838 by PCW
Most likely you have left out the step that sets the GPIO pin into output mode.

something like:

setp hm2_7i43.0.gpio.040.is_output true

All GPIO pins start up in input mode and must be specifically switched to output mode

Also make sure that you wire output devices for active low actuation (the FPGA pins will be initially pulled high)
The following user(s) said Thank You: CalmofDawn

Please Log in or Create an account to join the conversation.

More
16 Oct 2013 02:16 - 16 Oct 2013 02:18 #39913 by CalmofDawn
Ah hah. I got the spindle button-to-GPIO output working.

To see how the wizard works with GPIO, I opened Applications>CNC>LinuxCNC Pncconf Wizard and made a configuration with many GPIO pins set to output and having the Spindle On function.

Then I navigated to /home/user/linuxcnc/configs/my_LinuxCNC_machine/my_LinuxCNC_machine.hal and opened in gedit to check the GPIO code. Expectedly, I got multiple lines like:
# --- SPINDLE-ENABLE --- 
setp hm2_7i43.0.gpio.026.is_output true
net spindle-enable hm2_7i43.0.gpio.026.out

For LinuxCNC to run the pncconf-created config I had to modify the ioaddress and 16/32-bit epp setting like before. Near the beginning of the my_LinuxCNC_machine.hal file:
.....
.....
loadrt hm2_7i43 ioaddr=0xE010 epp_wide=0 config=".....

And then I ran this config with LinuxCNC, and the spindle button worked. That is: after the AXIS GUI popped up, I clicked the E-stop button to release, clicked the power on button beside it, then clicked the spindle clockwise button- and at that moment the screw terminal IO2 on the 7i42TA board changed its output from LOW (0V) to HIGH (~3-3.3V), as noticed by my oscope.

Glad the gpio code was working, I copy pasted the pncconf's GPIO lines to the hm2_stepper configuration at .../linuxcnc/configs/hm2_stepper/hm2-stepper.hal to below the Z [2] Axis section:
.....
.....
setp hm2_[HOSTMOT2](BOARD).0.stepgen.02.step_type 0

# --- SPINDLE-ENABLE --- 
setp hm2_7i43.0.gpio.026.is_output true
net spindle-enable hm2_7i43.0.gpio.026.out

And to my surprise when LinuxCNC opened with the AXIS GUI there was no spindle button to press! So I compared the hm2-stepper.hal file with the my_LinuxCNC_machine.hal file and tried modifying the hm2-stepper.hal file, copy/pasting the spindle S section:
# ################
# Spindle
# ################

# --- SPINDLE-ENABLE ---
setp hm2_7i43.0.gpio.026.is_output true
net spindle-enable hm2_7i43.0.gpio.026.out

#*******************
#  SPINDLE S
#*******************

# ---setup spindle control signals---

net spindle-vel-cmd-rps    <=  motion.spindle-speed-out-rps
net spindle-vel-cmd        <=  motion.spindle-speed-out
net spindle-enable         <=  motion.spindle-on
net spindle-cw             <=  motion.spindle-forward
net spindle-ccw            <=  motion.spindle-reverse
net spindle-brake          <=  motion.spindle-brake
net spindle-revs           =>  motion.spindle-revs
net spindle-at-speed       =>  motion.spindle-at-speed
net spindle-vel-fb         =>  motion.spindle-speed-in
net spindle-index-enable  <=>  motion.spindle-index-enable

# ---Setup spindle at speed signals---

sets spindle-at-speed true

And when I ran the hm2_stepper config again, the AXIS GUI popped up with the spindle control buttons. So evidently the GUI adds buttons and additional interface when certain "net ....." lines of code are added to the configuration's hal file. And the output at screw terminal IO2 on the 7i42TA board worked properly as expected when clicking the spindle button on and off.

I wanted to check how the gpio pin numbers (ex. gpio.026, shown by the "halcmd show pin 7i43" command) correspond to the silkscreen IO numbers (ex. IO2, visible on 7i42TA board).

I have my 7i43-U-4 board connected via the P3 header to the 7i42TA.

I checked gpio pins 026, 027, and 028, and they corresponded to IO2, IO3, and IO4 on the 7i42TA. This indicates that the 24 IO pins (0-23) on the 7i42TA board are connected to the 24 gpio pins 024, 025, 026, ..... , 046 as viewable with the "halcmd show pin *7i43*" command.

This also implies that, if I had a second 7i42TA connected to the P4 header of the 7i43, the 24 IO pins (0-23) on that 7i42TA would correspond to the 24 gpio pins 000, 001, 002, ..... , 023.

In other words:

The 7i43 has 48 gpio pins, numbered 000 through 047. The first set of 24 gpio pins (000 - 023) are connected to the 7i43's P4 header. The second set of 24 gpio pins (024 - 047) are connected to the 7i43's P3 header.

When the 7i43's P3 and P4 headers are each connected to a 7i42TA, the P3 7i42TA will correspond its IO0 - IO23 to 7i43 gpio pins 024 - 047, and the P4 7i42TA will correspond its IO0 - IO23 to 7i43 gpio pins 000 - 023. Again emphasis on the command:
halcmd show pin *7i43*

To see the gpio pins when linuxcnc is running.

Thanks guys, another problem solved.
Last edit: 16 Oct 2013 02:18 by CalmofDawn.

Please Log in or Create an account to join the conversation.

Time to create page: 0.107 seconds
Powered by Kunena Forum