You will need just one detailed document to use this project - the document about ARISC driver. ARISC driver - it's a component of the LinuxCNC software. This component allows the software to talk with outside world using the build-in Allwinner RISC CPU core (ARISC). The driver contains 3 modules - arisc.gpio, arisc.pwm and arisc.encoder. arisc.gpio don't uses the ARISC core, other modules - uses the ARISC core. arisc.encoder module is WIP.

Driver startup parameters

Examples: # 2 input pins, 1 output pin, 4 PWM channels, 3 encoder channels loadrt arisc in=PA12,PA11 out=PD14 pwm=p,p,p,f encoders=3 # no input pins, 3 output pins, 3 PWM channels, no encoder channels loadrt arisc out=PA12,PA11,PD14 pwm=p,p,p


arisc.gpio HAL pins

arisc.gpio.X-out(bit, out) output pin.
arisc.gpio.X-out-not(bit, out) output pin, inverted.
arisc.gpio.X-in(bit, in) input pin.
arisc.gpio.X-in-out(bit, in) input pin, inverted.
arisc.gpio.X-pull(s32, in) pin pull down (-1), pull up (1) or without (0).
arisc.gpio.X-multi-drive-level(u32, in) pin multi-drive (open drain) level (0..3).

Replace the X chars with GPIO pin name, listed in the output/input list. Examples: loadrt arisc out=PA12,PA11,PA6,PA13 in=PA14,PA1,PA0 # --- IT'S OK --- net xstep => arisc.gpio.PA12-out net xdir => arisc.gpio.PA11-out-not net ystep => arisc.gpio.PA6-out net ydir => arisc.gpio.PA13-out net home-x <= arisc.gpio.PA14-in net home-y <= arisc.gpio.PA1-in-not net home-z <= arisc.gpio.PA0-in setp arisc.gpio.PA12-pull -1 # pull down PA12 to the GND setp arisc.gpio.PA12-multi-drive-level 1 # --- ERROR --- net xstep => arisc.gpio.PA36-out # there's no such pin net xdir => arisc.gpio.3-out # there's no such pin net ystep => arisc.gpio.PA14-in # there's no such pin net ydir => arisc.gpio.A13-out # there's no such pin net home-x <= arisc.gpio.PA12-out # there's no such pin net home-y <= arisc.gpio.57-in # there's no such pin net home-z <= arisc.gpio.P0-out # there's no such pin


arisc.gpio HAL functions

arisc.gpio.read(float:no) updates all input pins state.
arisc.gpio.write(float:no) updates all output pins state.

Examples: loadrt motion base_period_nsec=50000 servo_period_nsec=1000000 num_joints=1 loadrt arisc out=PA12,PA11 in=PA6,PA13 addf arisc.gpio.read base-thread # read all used pins state addf arisc.gpio.write base-thread # write all used pins state


arisc.pwm HAL pins

arisc.pwm.N.enable(bit, in) channel ON/OFF (1/0). Default is 0.
· · ·
arisc.pwm.N.pwm-port(u32, in) GPIO port number (0..7) for PWM signal.
arisc.pwm.N.pwm-pin(u32, in) GPIO pin number (0..23) for the PWM signal.
arisc.pwm.N.pwm-invert(bit, in) invert the PWM signal? (0/1). Default is 0.
· · ·
arisc.pwm.N.dir-port(u32, in) GPIO port number (0..7) for PWM signal.
arisc.pwm.N.dir-pin(u32, in) GPIO pin number (0..23) for the DIR signal.
arisc.pwm.N.dir-invert(bit, in) invert the DIR signal? (0/1). Default is 0.
arisc.pwm.N.dir-hold(u32, io) minimal pause (in nanoseconds) between last PWM pulse and a DIR signal change. Default is 50000 ns.
arisc.pwm.N.dir-setup(u32, io) minimal pause (in nanoseconds) between DIR signal change and next PWM pulse. Default is 50000 ns.
· · ·
arisc.pwm.N.dc-cmd(float, in) desired duty cycle (-1..1). 1 = 100%. Default is 0.
arisc.pwm.N.dc-min(float, io) minimum duty cycle. If dc-fb < dc-min, real duty cycle will be set to dc-min. Default is -1.
arisc.pwm.N.dc-max(float, io) maximum duty cycle. If dc-fb > dc-max, real duty cycle will be set to dc-max. Default is 1.
arisc.pwm.N.dc-max-t(u32, io) maximum time (in nanoseconds) of a PWM pulse duration. If value is 0, value is ignored. Default is 0.
arisc.pwm.N.dc-offset(float, io) simple offset for the desired duty cycle value. Default is 0.
arisc.pwm.N.dc-scale(float, io) simple scale multiplier for the desired duty cycle value. Default is 1.
arisc.pwm.N.dc-fb(float, out) real duty cycle feedback = dc-cmd / dc-scale + dc-offset. Then value will be limited by the dc-min, dc-max and dc-max-t values.
· · ·
arisc.pwm.N.freq-cmd(float, io) desired PWM frequency (in Hz). Default is 0.
arisc.pwm.N.freq-min(float, io) minimum PWM frequency (in Hz). If freq-fb < freq-min, real frequency will be set to 0. Default is 50 Hz.
arisc.pwm.N.freq-max(float, io) maximum PWM frequency (in Hz). If freq-fb > freq-max, real frequency will be set to freq-max. Default is 500000 Hz.
arisc.pwm.N.freq-fb(float, out) real PWM frequency feedback.
· · ·
arisc.pwm.N.vel-cmd(float, in) desired velocity (in movement units/second). Default is 0.
arisc.pwm.N.vel-scale(float, in) simple scale multiplier for the desired velocity value. Default is 1.
arisc.pwm.N.vel-fb(float, out) real velocity feedback (in movement units/second).
· · ·
arisc.pwm.N.pos-cmd(float, in) desired position (in movement units). Default is 0.
arisc.pwm.N.pos-scale(float, in) number of PWM pulses per movement unit. Default is 1.
arisc.pwm.N.pos-fb(float, out) real position feedback in movement units.
· · ·
arisc.pwm.N.counts(s32, out) real position feedback in PWM pulses.

Replace N with channel number (0..15). Examples: loadrt motion base_period_nsec=50000 servo_period_nsec=1000000 num_joints=1 loadrt arisc pwm=p setp arisc.pwm.0.pos-scale [AXIS_0]SCALE setp arisc.pwm.0.pwm-port 0 # 0=PA setp arisc.pwm.0.pwm-pin 12 # PA12 setp arisc.pwm.0.pwm-invert 0 setp arisc.pwm.0.dir-port 0 # 0=PA setp arisc.pwm.0.dir-pin 11 # PA11 setp arisc.pwm.0.dir-invert 0 net x-enable arisc.pwm.0.enable joint.0.amp-enable-out net x-pos-cmd arisc.pwm.0.pos-cmd joint.0.motor-pos-cmd


arisc.pwm HAL functions

arisc.pwm.read(float:yes) updates all feedback pin values for the all channels.
arisc.pwm.write(float:yes) updates real frequency values for the all channels.

Examples: loadrt motion base_period_nsec=50000 servo_period_nsec=1000000 num_joints=1 loadrt arisc pwm=p addf arisc.pwm.read servo-thread addf motion-command-handler servo-thread addf motion-controller servo-thread addf arisc.pwm.write servo-thread


arisc.encoder HAL pins

arisc.encoder.N.enable(bit, in) channel ON/OFF (1/0). Default is 0.
· · ·
arisc.encoder.N.counter-mode(bit, io) Enables counter mode. When 1, the counter counts each rising edge of the phase-A input, ignoring the value on phase-B. This is useful for counting the output of a single channel (non-quadrature) sensor. When 0, it counts in quadrature mode. Default is 0.
· · ·
arisc.encoder.N.x4-mode(bit, io) Enables times-4 mode. When 1, the counter counts each edge of the quadrature waveform (four counts per full cycle). When 0, it only counts once per full cycle. In counter-mode, this parameter is ignored. Default is 1.
· · ·
arisc.encoder.N.index-enable(bit, io) When 1, counts and position are reset to zero on the next rising edge of INDEX (Z). At the same time, index-enable is reset to zero to indicate that the rising edge has occurred. Default is 0.
· · ·
arisc.encoder.N.reset(bit, in) When 1, counts and pos are reset to zero immediately. Default is 0.
· · ·
arisc.encoder.N.A-port(u32, in) GPIO port number (0..7) for the phase A signal.
arisc.encoder.N.A-pin(u32, in) GPIO pin number (0..23) for the phase A signal.
arisc.encoder.N.A-invert(bit, in) invert phase A signal? (0/1). Default is 0.
arisc.encoder.N.A-all-edges(bit, in) trigger phase A signal on any voltage edge? (0/1) This HAL pin uses only when counter-mode is enabled. Default is 0.
· · ·
arisc.encoder.N.B-port(u32, in) GPIO port number (0..7) for the phase B signal.
arisc.encoder.N.B-pin(u32, in) GPIO pin number (0..23) for the phase B signal.
· · ·
arisc.encoder.N.Z-port(u32, in) GPIO port number (0..7) for the INDEX signal.
arisc.encoder.N.Z-pin(u32, in) GPIO pin number (0..23) for the INDEX signal.
arisc.encoder.N.Z-invert(bit, in) invert INDEX signal? (0/1). Default is 0.
arisc.encoder.N.Z-all-edges(bit, in) trigger INDEX signal on any voltage edge? (0/1) Default is 0.
· · ·
arisc.encoder.N.pos-scale(float, in) number of encoder pulses per movement unit. Default is 1.
arisc.encoder.N.pos(float, out) real position feedback in movement units.
arisc.encoder.N.vel(float, out) real velocity feedback (in movement units/second).
arisc.encoder.N.vel-rpm(float, out) real velocity feedback (in revolutions/minute).
arisc.encoder.N.counts(s32, out) real position feedback in encoder pulses.

Replace N with channel number (0..7). Examples: loadrt arisc encoders=1 setp arisc.encoder.0.pos-scale [AXIS_0]SCALE setp arisc.encoder.0.A-port 0 # 0=PA setp arisc.encoder.0.A-pin 12 # PA12 setp arisc.encoder.0.B-port 0 # 0=PA setp arisc.encoder.0.B-pin 11 # PA11 setp arisc.encoder.0.Z-port 0 # 0=PA setp arisc.encoder.0.Z-pin 6 # PA6 net x-enc-en arisc.encoder.0.enable joint.0.amp-enable-out net x-pos-fb arisc.encoder.0.pos joint.0.motor-pos-fb


arisc.encoder HAL functions

arisc.encoder.read(float:yes) updates all feedback pin values for the all channels.

Examples: loadrt motion base_period_nsec=50000 servo_period_nsec=1000000 num_joints=1 loadrt arisc encoders=1 addf arisc.encoder.read servo-thread addf motion-command-handler servo-thread addf motion-controller servo-thread