🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)
🕵️ SicherheitslückenHak5: Hackers Just Poisoned the Rust Supply Chain | Threat Wire(01.09.2026 um 14:00 Uhr)
🕵️ SicherheitslückenHak5: Hackers Found a Way Into Humanoid Robots | Threat Wire(04.09.2026 um 15:04 Uhr)
🔧 AI Nachrichten Bits und so #1021 (Passwort für Laufwerk)(31.08.2026 um 22:15 Uhr)
🔧 AI Nachrichten Bits und so #1022 (Wie Weißbier)(06.09.2026 um 20:39 Uhr)
🍏 iOS / Mac OSHue-App 6.0 ist da: das sind die Neuerungen(07.09.2026 um 17:21 Uhr)

🔧 Programmierung 🕛 kürzlich 3 Min Lesezeit
0

Self-Aligning Satellite Dish in Rust: Servo

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

We'll use servo motors, specifically the SG90, to actuate our PTZ kit. Servo motors are driven by pulse width modulation(PWM) signals.






Table of Contents




  • Servo


  • Implementation



    • PWM






  • Final Code









Servo



The SG90 is a microservo that can rotate through 180 degrees. It is operated by pulse width modulation (PWM) signals oscillating at 50 Hz. A pulse with a period of 1.5 ms (7.5% duty cycle) will position it to 0 degrees, 2 ms (10% duty cycle) to 90 degrees, and 1 ms (5% duty cycle) to -90 degrees. Feeding a signal with duty cycles ranging from 5 to 10% should therefore sweep the motor from 0 to 180 degrees.





Under Pins configure the pin.




CODE
// Configure GP20 as PWM channel 1A
pads_bank0.gpio(20).modify(|_, w| w
.pue().set_bit()// pull up enable
.pde().set_bit()// pull down enable
.od().clear_bit()// output disable
.ie().set_bit()// input enable
);

io_bank0.gpio(20).gpio_ctrl().modify(|_, w| w.funcsel().pwm());// connect to matching pwm






The programming parameters for the RP2040's PWM are set using the below formula.







fPWM=fsysperiod=fsys(TOP+1)×(CSR_PH_CORRECT+1)×(DIV_INT+DIV_FRAC16)
\begin{split}
f_{PWM} &= {f_{sys} \over period}\\
&= {f_{sys} \over (TOP + 1) \times (CSR\_PH\_CORRECT + 1) \times (DIV\_INT + {DIV\_FRAC \over 16})}
\end{split}\\
fPWM=periodfsys=(TOP+1)×(CSR_PH_CORRECT+1)×(DIV_INT+16DIV_FRAC)fsys





Where:




  • TOP is the upper limit count of the PWM's counter,

  • CSR_PH_CORRECT is the phase correction selector that determines whether the PWM's counter counts backwards from TOP,

  • and DIV_INT and DIV_FRAC are further used in dividing the counter to acquire a final PWM output.



For a wrap value of 50,000 and with phase correction enabled we can get the divider values below:





DIV_INT+DIV_FRAC16=fsys(TOP+1)×(CSR_PH_CORRECT+1)×fPWM=125,000,000(49,999+1)×(1+1)×50=25+0
\begin{split}
DIV\_INT + {DIV\_FRAC \over 16}
&= {f{sys} \over (TOP + 1) \times (CSR\__PH\_CORRECT + 1) \times f_{PWM}}\\
\\
&= {125,000,000 \over (49,999 + 1) \times (1 + 1) \times 50}\\
\\
&= 25 + 0\\
\end{split}
DIV_INT+16DIV_FRAC=(TOP+1)×(CSR_PH_CORRECT+1)×fPWMfsys=(49,999+1)×(1+1)×50125,000,000=25+0




We will therefore set our DIV_INT as 25 and DIV_FRAC as 0.




CODE
// pwm2 set up
let pwm2 = dp.PWM.ch(2);// Acquire handle for pwm slice 2
resets.reset().modify(|_, w| w.pwm().clear_bit());// Deassert pwm

// Configuring pwm2
pwm2.csr().modify(|_, w| w
.divmode().div()// free runnning counter determined by fractional divider
.ph_correct().set_bit()// enable phase correction
);
pwm2.top().modify(|_, w| unsafe { w.bits(50_000) });// sets the wrap value: TOP
// For a fpwm of 50Hz w/ top of 50000 div need to be 25
pwm2.div().modify(|_, w| unsafe { w.int().bits(25).frac().bits(0) });
pwm2.csr().modify(|_, w| w.en().set_bit());// Enable pwm2











Final Code



Rearranging the code we get this final copy.



In the next part we shall run an example showing PWM in operation.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Hackers Just Poisoned the Rust Supply Chain | Threat Wire
1 Quelle
Hackers Found a Way Into Humanoid Robots | Threat Wire
1 Quelle
Bits und so #1021 (Passwort für Laufwerk)
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Self-Aligning Satellite Dish in Rust: Servo

Thematisch verwandte Begriffe: SelfAligning, Satellite, Dish, Rust · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...