rozważania o CNC

Grudnia 03, 2024, 06:41:15
Witamy, Gość. Zaloguj się lub zarejestruj.

Zaloguj się podając nazwę użytkownika, hasło i długość sesji
Strony: [1]   Do dołu
  Drukuj  
Autor Wątek: hal dla wrzeciona  (Przeczytany 11203 razy)
markcomp
Administrator
*****
Offline Offline

Wiadomości: 15146



WWW
« : Czerwca 20, 2011, 02:13:28 »

hal dla wrzeciona



konfiguracja HALa do regulacji prędkości przeciona przez sygnał PWM

Cytuj
loadrt pwmgen output_type=0
addf pwmgen.update servo-thread
addf pwmgen.make-pulses base-thread
net spindle-speed-cmd motion.spindle-speed-out => pwmgen.0.value
net spindle-on motion.spindle-on => pwmgen.0.enable
net spindle-pwm pwmgen.0.pwm => parport.0.pin-09-out
# Set the spindle's top speed in RPM
setp pwmgen.0.scale 1800


loadrt... - załadowanie modułu generatora pwm w trybie 0 (podstawowym)
addf pwmgen.update servo-thread - aktualizacja cech generatora w wolnym wątku servo-thread
addf pwmgen.make-pulses base-thread - generowanie pwm w szybkim wątek base-tread
net ... pwmgen.0.value - przekazanie do generatora parametru S z gcodu
net ... pwmgen.0.enable - włączenie wrzeciona
net ...  parport.0.pin-09-out - sygnał na zewnątrz
setp pwmgen.0.scale - ustawienie skali
« Ostatnia zmiana: Czerwca 20, 2011, 04:25:00 wysłane przez markcomp » Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

markcomp
Administrator
*****
Offline Offline

Wiadomości: 15146



WWW
« Odpowiedz #1 : Czerwca 20, 2011, 04:15:14 »

PWMgen



This component provides software based generation of PWM (Pulse Width Modulation) and PDM (Pulse Density Modulation) waveforms. It is a realtime component only, and depending on CPU speed, etc, is capable of PWM frequencies from a few hundred Hertz at pretty good resolution, to perhaps 10KHz with limited resolution.

Installing

emc2$ halcmd loadrt pwmgen output_type=<config-array>

<config-array> is a series of comma separated decimal integers. Each number causes a single PWM generator to be loaded, the value of the number determines the output type. For example:

emc2$ halcmd loadrt pwmgen output_type=0,1,2

will install three PWM generators. The first one will use output type '0' (PWM only), the next uses output type 1 (PWM and direction) and the last one uses output type 2 (UP and DOWN). There is no default value, if <config-array> is not specified, no PWM generators will be installed. The maximum number of frequency generators is 8 (as defined by MAX_CHAN in pwmgen.c). Each generator is independent, but all are updated by the same function(s) at the same time. In the following descriptions, <chan> is the number of a specific generator. The first generator is number 0.

Pins



Each PWM generator will have the following pins:

(float) pwmgen.<chan>.value -- Command value, in arbitrary units. Will be scaled by the scale parameter (see below).

(bit) pwmgen.<chan>.enable -- Enables or disables the PWM generator outputs.

Each PWM generator will also have some of these pins, depending on the output type selected:

(bit) pwmgen.<chan>.pwm -- PWM (or PDM) output, (output types 0 and 1 only).

(bit) pwmgen.<chan>.dir -- Direction output (output type 1 only).

(bit) pwmgen.<chan>.up -- PWM/PDM output for positive input value (output type 2 only).

(bit) pwmgen.<chan>.down -- PWM/PDM output for negative input value (output type 2 only).


Parameters



(float) pwmgen.<chan>.scale -- Scaling factor to convert value from arbitrary units to duty cycle.

(float) pwmgen.<chan>.pwm-freq -- Desired PWM frequency, in Hz. If 0.0, generates PDM instead of PWM. If set higher than internal limits, next call of update_freq() will set it to the internal limit. If non-zero, and dither is false, next call of update_freq() will set it to the nearest integer multiple of the make_pulses() function period.

(bit) pwmgen.<chan>.dither-pwm -- If true, enables dithering to achieve average PWM frequencies or duty cycles that are unobtainable with pure PWM. If false, both the PWM frequency and the duty cycle will be rounded to values that can be achieved exactly.

(float) pwmgen.<chan>.min-dc -- Minimum duty cycle, between 0.0 and 1.0 (duty cycle will go to zero when disabled, regardless of this setting).

(float) pwmgen.<chan>.max-dc -- Maximum duty cycle, between 0.0 and 1.0.

(float) pwmgen.<chan>.curr-dc -- Current duty cycle - after all limiting and rounding (read only).


Output Types

The PWM generator supports three different “output types”. Type 0 has a single output pin. Only positive commands are accepted, negative values are treated as zero (and will be affected by min-dc if it is non-zero). Type 1 has two output pins, one for the PWM/PDM signal and one to indicate direction. The duty cycle on the PWM pin is based on the absolute value of the command, so negative values are acceptable. The direction pin is false for positive commands, and true for negative commands. Finally, type 2 also has two outputs, called up and down. For positive commands, the PWM signal appears on the up output, and the down output remains false. For negative commands, the PWM signal appears on the down output, and the up output remains false. Output type 2 is suitable for driving most H-bridges.


Functions



The component exports two functions. Each function acts on all of the PWM generators - running different generators in different threads is not supported.

(funct) pwmgen.make-pulses -- High speed function to generate PWM waveforms (no floating point).

(funct) pwmgen.update -- Low speed function to scale and limit value and handle other paremeters.

The high speed function pwmgen.make-pulses should be run in a very fast thread, from 10 to 50uS depending on the capabilities of the computer. That thread's period determines the maximum PWM carrier frequency, as well as the resolution of the PWM or PDM signals. The other function can be called at a much lower rate.
« Ostatnia zmiana: Czerwca 20, 2011, 04:36:49 wysłane przez markcomp » Zapisane

MARKcomp77

http://oferta.forum-cnc.pl/
Sterowniki.Silniki

Strony: [1]   Do góry
  Drukuj  
 
Skocz do:  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC
Manuscript design by Bloc Strona wygenerowana w 0.048 sekund z 18 zapytaniami.