Line: 1 to 1 | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
%DASHBOARD{ section="banner" | ||||||||||||||||||||||||||||
Line: 65 to 65 | ||||||||||||||||||||||||||||
pwmpin! ( u a -- ) sets the digital output port pin a (D5=5, D6=6, D9=9, D10=10, D14=14, and D15=15) to a PWM value u (0..1000). Default frequency is 1 kHz, TIMER1 | ||||||||||||||||||||||||||||
Changed: | ||||||||||||||||||||||||||||
< < | pwmprescale ( u -- ) Sets the PWM prescale for TIMER1. 32 kHz / prescale, default 32 -> PWM frequency 1 kHz | |||||||||||||||||||||||||||
> > | pwmprescale ( u -- ) Sets the PWM prescale for TIMER1. 42 kHz / prescale, default 42 -> PWM frequency 1 kHz | |||||||||||||||||||||||||||
Changed: | ||||||||||||||||||||||||||||
< < | ICOCprescale ( u -- ) Sets the input capture / output compare prescale for TIMER2. default 32 -> 32 MHz / 32 = 1 MHz, timer resolution 1 us | |||||||||||||||||||||||||||
> > | ICOCprescale ( u -- ) Sets the input capture / output compare prescale for TIMER2. default 42 -> 42 MHz / 42 = 1 MHz, timer resolution 1 us | |||||||||||||||||||||||||||
ICOCperiod! ( u -- ) Sets the input capture / output compare (TIMER2) period. default $FFFFFFFF (4'294'967'295). When the up counter reaches the period, the counter is set to 0. For prescale 32 the maximum time is about 1 h 11 m | ||||||||||||||||||||||||||||
Line: 246 to 246 | ||||||||||||||||||||||||||||
; | ||||||||||||||||||||||||||||
Added: | ||||||||||||||||||||||||||||
> > |
Control an RC Servohttps://en.wikipedia.org/wiki/Servo_(radio_control): The control signal is a digital PWM signal with a 50 Hz frame rate. Within each 20 ms timeframe, an active-high digital pulse controls the position. The pulse nominally ranges from 1.0 ms to 2.0 ms with 1.5 ms always being center of range. Pulse widths outside this range can be used for "overtravel" - moving the servo beyond its normal range. A servo pulse of 1.5 ms width will typically set the servo to its "neutral" position (typically half of the specified full range), a pulse of 1.0 ms will set it to 0°, and a pulse of 2.0 ms to 90° (for a 90° servo). The physical limits and timings of the servo hardware varies between brands and models, but a general servo's full angular motion will travel somewhere in the range of 90° – 180° and the neutral position (45° or 90°) is almost always at 1.5 ms. This is the "standard pulse servo mode" used by all hobby analog servos. The BSPs default PWM frequency is 1 kHz, 50 Hz is 20 times slower. The divider is therefore 42 * 20 = 840.
840 pwmprescale 5 5 dmod \ set D5 to PWM 5 6 dmod \ set D6 to PWM 5 9 dmod \ set D9 to PWM 5 10 dmod \ set D10 to PWM : servo ( u n -- ) \ u 0 .. ; | |||||||||||||||||||||||||||
|