Skip to content

PMW for dc motor, servo-mechanisms in zetptoforth. #56

Answered by tabemann
photoplane asked this question in Q&A
Discussion options

You must be logged in to vote

@photoplane I cannot from the code you posted tell exactly what you are trying to do, but here is some code (note I have not tested it) which may do something like what you want to do:

pwm import

\ My PWM output pin
\ Note that this corresponds to my-servo-pwm-slice below; if you change this you will have to change that.
4 constant my-servo-pin

\ My PWM slice
2 constant my-servo-pwm-slice

\ Initialize the PWM for the servo
: init-servo ( -- )
  \ We want the PWM slice to be disabled at this point
  my-servo-pwm-slice bit disable-pwm

  \ We configure our GPIO pin to be for PWM; note that each GPIO pin is linked to a particular PWM slice and channel
  my-servo-pin pwm-pin

  \ Here we s…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@photoplane
Comment options

Answer selected by photoplane
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants