-
-
Save mhaberler/fbadbb07f54cebde045fd9fff9d5f43a to your computer and use it in GitHub Desktop.
loadrt hostmot2 | |
loadrt hm2_soc config="firmware=socfpga/soc_system.rbf num_encoders=2 num_pwmgens=2 num_stepgens=2" | |
newthread servo-thread 1000000 fp | |
newthread slow 1000000000 fp # 1sec | |
# task1: blink the leds CR01 and CR02 | |
newinst not osci | |
newinst not inverter | |
net blink osci.in osci.out inverter.in | |
net blink-inverted inverter.out | |
addf osci slow | |
addf inverter slow | |
net blink hm2_5i25.0.led.CR01 | |
net blink-inverted hm2_5i25.0.led.CR02 | |
# task2: get some signal out of stepgen00 | |
# timing parameters | |
setp hm2_5i25.0.stepgen.00.dirsetup 650 | |
setp hm2_5i25.0.stepgen.00.dirhold 650 | |
setp hm2_5i25.0.stepgen.00.steplen 1900 | |
setp hm2_5i25.0.stepgen.00.stepspace 1900 | |
setp hm2_5i25.0.stepgen.00.position-scale 320 | |
setp hm2_5i25.0.stepgen.00.maxvel 250 | |
setp hm2_5i25.0.stepgen.00.maxaccel 1250 | |
setp hm2_5i25.0.stepgen.00.step_type 0 | |
setp hm2_5i25.0.stepgen.00.control-type 1 | |
# turn on: | |
setp hm2_5i25.0.stepgen.00.enable 1 | |
setp hm2_5i25.0.stepgen.00.velocity-cmd 100 | |
# hm2_5i25.0.stepgen.00.position-cmd | |
# hm2_5i25.0.stepgen.00.position-fb | |
# hm2_5i25.0.stepgen.00.velocity-cmd | |
# hm2_5i25.0.stepgen.00.velocity-fb | |
addf hm2_5i25.0.read_gpio servo-thread | |
addf hm2_5i25.0.read servo-thread | |
addf hm2_5i25.0.write servo-thread | |
addf hm2_5i25.0.write_gpio servo-thread | |
#addf hm2_5i25.0.pet_watchdog servo-thread | |
start |
machinekit@mksoc-dev2:~/machinekit-src/src$ DEBUG=5 halrun -I blinkenleds.hal | |
msgd:0 stopped | |
rtapi:0 stopped | |
blinkenleds.hal:1: Realtime module 'hostmot2' loaded | |
blinkenleds.hal:2: Realtime module 'hm2_soc' loaded | |
blinkenleds.hal:9: Realtime module 'not' loaded | |
blinkenleds.hal:11: Pin 'osci.in' linked to signal 'blink' | |
blinkenleds.hal:11: Pin 'osci.out' linked to signal 'blink' | |
blinkenleds.hal:11: Pin 'inverter.in' linked to signal 'blink' | |
blinkenleds.hal:12: Pin 'inverter.out' linked to signal 'blink-inverted' | |
blinkenleds.hal:13: Function 'osci' added to thread 'slow' | |
blinkenleds.hal:14: Function 'inverter' added to thread 'slow' | |
blinkenleds.hal:16: Pin 'hm2_5i25.0.led.CR01' linked to signal 'blink' | |
blinkenleds.hal:17: Pin 'hm2_5i25.0.led.CR02' linked to signal 'blink-inverted' | |
blinkenleds.hal:23: setting parameter 'hm2_5i25.0.stepgen.00.dirsetup' to '650' | |
blinkenleds.hal:23: Parameter 'hm2_5i25.0.stepgen.00.dirsetup' set to 650 | |
blinkenleds.hal:24: setting parameter 'hm2_5i25.0.stepgen.00.dirhold' to '650' | |
blinkenleds.hal:24: Parameter 'hm2_5i25.0.stepgen.00.dirhold' set to 650 | |
blinkenleds.hal:26: setting parameter 'hm2_5i25.0.stepgen.00.steplen' to '1900' | |
blinkenleds.hal:26: Parameter 'hm2_5i25.0.stepgen.00.steplen' set to 1900 | |
blinkenleds.hal:27: setting parameter 'hm2_5i25.0.stepgen.00.stepspace' to '1900' | |
blinkenleds.hal:27: Parameter 'hm2_5i25.0.stepgen.00.stepspace' set to 1900 | |
blinkenleds.hal:29: setting parameter 'hm2_5i25.0.stepgen.00.position-scale' to '320' | |
blinkenleds.hal:29: Parameter 'hm2_5i25.0.stepgen.00.position-scale' set to 320 | |
blinkenleds.hal:31: setting parameter 'hm2_5i25.0.stepgen.00.maxvel' to '250' | |
blinkenleds.hal:31: Parameter 'hm2_5i25.0.stepgen.00.maxvel' set to 250 | |
blinkenleds.hal:32: setting parameter 'hm2_5i25.0.stepgen.00.maxaccel' to '1250' | |
blinkenleds.hal:32: Parameter 'hm2_5i25.0.stepgen.00.maxaccel' set to 1250 | |
blinkenleds.hal:34: setting parameter 'hm2_5i25.0.stepgen.00.step_type' to '0' | |
blinkenleds.hal:34: Parameter 'hm2_5i25.0.stepgen.00.step_type' set to 0 | |
blinkenleds.hal:35: setting parameter 'hm2_5i25.0.stepgen.00.control-type' to '0' | |
blinkenleds.hal:35: Pin 'hm2_5i25.0.stepgen.00.control-type' set to 0 | |
blinkenleds.hal:38: setting parameter 'hm2_5i25.0.stepgen.00.enable' to '1' | |
blinkenleds.hal:38: Pin 'hm2_5i25.0.stepgen.00.enable' set to 1 | |
blinkenleds.hal:39: setting parameter 'hm2_5i25.0.stepgen.00.velocity-cmd' to '100' | |
blinkenleds.hal:39: Pin 'hm2_5i25.0.stepgen.00.velocity-cmd' set to 100 | |
blinkenleds.hal:46: Function 'hm2_5i25.0.read_gpio' added to thread 'servo-thread' | |
blinkenleds.hal:47: Function 'hm2_5i25.0.read' added to thread 'servo-thread' | |
blinkenleds.hal:48: Function 'hm2_5i25.0.write' added to thread 'servo-thread' | |
blinkenleds.hal:49: Function 'hm2_5i25.0.write_gpio' added to thread 'servo-thread' | |
blinkenleds.hal:52: Realtime threads started | |
halcmd: show sig blink | |
Signals: | |
Type Value Name (linked to) | |
bit FALSE blink | |
==> hm2_5i25.0.led.CR01 | |
==> inverter.in | |
==> osci.in | |
<== osci.out | |
bit TRUE blink-inverted | |
==> hm2_5i25.0.led.CR02 | |
<== inverter.out | |
halcmd: show sig blink | |
Signals: | |
Type Value Name (linked to) | |
bit TRUE blink | |
==> hm2_5i25.0.led.CR01 | |
==> inverter.in | |
==> osci.in | |
<== osci.out | |
bit FALSE blink-inverted | |
==> hm2_5i25.0.led.CR02 | |
<== inverter.out | |
halcmd: |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: 34 I/O Pins used: | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 000 (P3-01): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 001 (P3-14): PWMGen #0, pin Out0 (PWM or Up) (Output) | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 002 (P3-02): StepGen #0, pin Step (Output) | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 003 (P3-15): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 004 (P3-03): StepGen #0, pin Direction (Output) | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 005 (P3-16): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 006 (P3-04): StepGen #1, pin Step (Output) | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 007 (P3-17): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 008 (P3-05): StepGen #1, pin Direction (Output) | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 009 (P3-06): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 010 (P3-07): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 011 (P3-08): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 012 (P3-09): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 013 (P3-10): Encoder #0, pin A (Input) | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 014 (P3-11): Encoder #0, pin B (Input) | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 015 (P3-12): Encoder #0, pin Index (Input) | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 016 (P3-13): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 017 (P2-01): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 018 (P2-14): PWMGen #1, pin Out0 (PWM or Up) (Output) | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 019 (P2-02): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 020 (P2-15): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 021 (P2-03): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 022 (P2-16): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 023 (P2-04): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 024 (P2-17): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 025 (P2-05): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 026 (P2-06): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 027 (P2-07): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 028 (P2-08): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 029 (P2-09): IOPort | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 030 (P2-10): Encoder #1, pin A (Input) | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 031 (P2-11): Encoder #1, pin B (Input) | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 032 (P2-12): Encoder #1, pin Index (Input) | |
Apr 21 07:43:44 mksoc-dev2 msgd:0: hal_lib:29925:rt hm2/hm2_5i25.0: IO Pin 033 (P2-13): IOPort |
I see this: https://github.com/machinekit/mksocfpga/blob/master/docs/pics/Hostmot2-vhd_inst-pinouts.png
it still leaves me in the dark how the naming relation actually is
OK fast shiot:
The GPIO 34, 35 pins are the 2 led (pins) under MESA hostmot2 control.
All leds on the board are controlled by the cpu via standard gpio.. ?
Yes.. very unclear image because I'm not able to edit the netlist viewer, but here is the pin list for the gpio 0 port.
https://drive.google.com/open?id=0BwyLvgyVIdi8b0NUM0pwWkUxUXc
IO Pin 002 (P3-02): StepGen #0, pin Step (Output)
this pin naming is per the 5i25 mesa card , and bears no relationship to the pinouts used per the project here
this can probably be changed , to more suit the terasic de0-nano , at the moment iv'e not looked .
edited setp hm2_5i25.0.stepgen.00.control-type 1
since using velocity mode - works!
very confusing description in the manual:
- the photo on the top shows the GPIO0 header pin1 right bottom
- the pinout description GPIO0(JP1) shows pin1 left top and two unallocated pins at the bottom
ok, so the two LEDs need to be connected to the two top pins of the left GPIO header in the photograph
I put a 100ohm resistor in series pin -> resistor -> led+ , led- connected to ground
then run
halrun -I blinkenleds.hal
and the two leds should blink alternating in a 1 second cycle
this verifies that:
- the FPGA is loaded with the machinekit hostmot2 firmware
- HAL loads and runs the hm2_soc driver properly
- pins are actually wiggled ;)
here is my questions: