Shop OBEX P1 Docs P2 Docs Learn Events
simple pwm coding — Parallax Forums

simple pwm coding

I am using detect to test for pulsewidth modulated signals and copying them to an output. I am sequentially testing eight inputs but when none of the inputs are active, I want to generate a pwm signal using 0-255 level. How would I go about doing this?

Comments

  • You need to provide much more information. What do you mean by "detect"? What are the parameters of the PWM signals? Are they standard servo control signals (positive going 0.5ms to 1.5ms pulses roughly every 20ms) or what? What does "active" mean? Where do you want to generate a pwm signal? What do you mean by "0-255 level"?

    What's hooked up to what?
  • let me try to make this more understandable. The command "if detect:= ina[x]" instructs the processer to test for the presence
    of a P.W.M. signal. If an input has a signal it is an active input. No signal, it is an inactive input. P.W.M. signal will be generated
    at the end of the instructions. For example elseif detect:=ina[5]
    outa[14]:=ina[5]
    outa[11]:=1
    else (generate P.W.M. =15/255)

    Hope this helps.
  • What determines the timing of this IF statement? Is it repeated as quickly as possible or is it repeated every millisecond or what? To generate a PWM signal, you have to have some way to do the timing so you get the active pulse for a certain amount of time, then the signal idles for a time. Also, how long must the PWM signal be absent for the program to fill in with its own generated signal?
  • Like Mike, I enjoy writing bits of code to help others but I have been completely lost by the requests in the threads (this is not the first, right?) on this topic.

    Perhaps a God's-eye description of the project is in order. What is the purpose of the code you're after? What kind of hardware are you dealing with?
  • kwinnkwinn Posts: 8,697
    JonnyMac wrote: »
    Like Mike, I enjoy writing bits of code to help others but I have been completely lost by the requests in the threads (this is not the first, right?) on this topic.

    Perhaps a God's-eye description of the project is in order. What is the purpose of the code you're after? What kind of hardware are you dealing with?

    No doubt in my mind that the hardest part of helping a poster is figuring out what they want to do and what hardware they have. Sometimes feels like pulling teeth.
Sign In or Register to comment.