I am trying to create a PWM signal to step a stepper motor using my BBB. I am currently doing this by toggling the pin on and off, but when I look at the signal on an oscilloscope, the pwm is working, but about every 3.9ms there is a periodic disturbance that keeps the signal high or low longer than intended. I am guessing this is an issue with something going on in the background. Would it be possible to fix this?
You will never get a nice accurate square wave if you are doing this in code by toggling a GPIO pin.
You have 2 options.
- Use a real PWM output.
- Write some code to run on a PRU .
You may want to check the example qep, which uses the A and B output of a PWM module in the PWMSS-1 subsystem to simulate a quadrature encoder. The same signal can drive a (bi-polar) stepper motor.
No, however you can minimize what is going on. Nothing wrong with the behavior if it is acceptable for the design.
You might be able to kill processes that you do not need for you application.
The shorter the tree the lower the chances of ad hoc behavior. Keep in mind if you are using a desktop environment you will more than likely break the system if you shut down stuff.
Not sure how critical your timing needs are, so in other words, if the timing is within the design criteria just be aware of it and move forward with it. If not then look at some other options.