Difference: BoardSupportPackageF405 (42 vs. 43)

Revision 432021-05-03 - PeterSchmid

Line: 1 to 1
 
META TOPICPARENT name="WebHome"
%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 Servo

https://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.

1 ms 50
45° 1.5 ms 75
90° 2 ms 100
180° 3 ms 150
270 4 ms 200

1 ms 50
90° 1.5 ms 75
180° 2 ms 100
270° 2.5 ms 150

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 .. 
;

 

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback