Forums » Support

Back To Topics

Varying PWM frequency

    • 178 posts
    January 25, 2021 2:25 PM CET

    :) I hope you'll find a solution.

    • 9 posts
    January 22, 2021 11:33 AM CET

    I've no idea how I overlooked the 0x01 command!

    I'll need to have another play with 0x33 to see what duration of drive I need.  It may be that with the lower speed I can get with lower PWM frequency that 0.2s is actually OK.

    • 178 posts
    January 21, 2021 11:18 AM CET

    That IS one possible use for 0x33, interesting :)

    Instead of "quick drive" we now recommend using the 0x00 "brake" and 0x01 "drive" commands, to be consistent with how SBrick Light will work, and to avoid problem with Android devices. (It is hard, or impossible to use a single BLE characteristic for sending AND receiving data concurrently.)

    I'm afraid you can't reliably turn a port on for such a short time using either quck drive or 0x01 due to the jitter introduced by the BLE protocol. We have been thinkig of improvements to the SBrick firmware that might improve your situation.

    What do you think, how short of a pulse would you need to turn the motor by the correct angle?

    • 9 posts
    January 21, 2021 10:59 AM CET

    Hi Tamás,

    Thanks for the reply.  I did a bit more testing after sending my message and figured out that there must be only one PWM counter.  In this case I don't need to run servos and M motors on the same SBrick, so I think it will still work.

    What is the preferred way to control SBrick outputs?  The documentation says that quick drive is deprecated for setting outputs, so i assumed that 0x33 was the alternative.

    Regarding possible uses for 0x33, I actually started looking at it because I wanted to be able to move the M motor a small amount so I was trying to send a higher power for a very short time, but it turned out that even the minimum 0.2s moves it more than I wanted if I use enough power to move it at the default PWM frequency.

    regards,

    Paul

    • 178 posts
    January 21, 2021 10:48 AM CET

    HI Paul,

    it is indeed hard to drive M motors because fo the large filter capacitor built into them. I'm glad you found a solution.

    You're right, the documentation has a typo, 0x1F takes a 

    The 0x1F "set PWM counter" command sets the frequency of the PWM signal on all channels simultaneously, thus effecting every motor (or other device) on the SBrick. Servo motors might not work well (or at all) at such a low frequency. If you don't have to use servos and M motors together on the same SBrick, then this is not an issue. If you do, then there might or might not be a frequency where those devices can be used together, and the frequency - if exists - might only be experimentally determined for each given pair of servo and M motor.

    This is the reason why the PWM frequency is not significantly lower by default than the current ~1KHz. Moreover, hardware version 4 (old, first series) SBricks cannot be set much lower than 500Hz due to the PWM hardware configuration.

    The 0x33 "Send Signal" command is turning on a port at a given frequency for a precisely controlled, short time. The purpose of this is to communicate with an adapter we designed and prototyped, but couldn't mass produce, so it's unavailable. The 0x33 command therefore has no use, at least not anything I can think of. The 0x33 command changes the PWM frequency for a short time, and this affects all ports, just like the 0x1F command.

    I hope this information is useful,

    Best regards,

    Tamas

    • 9 posts
    January 19, 2021 11:57 PM CET

    I've been trying to drive PF M motors slowly, and have been struggling because they seem to take a lot of power to get them moving.

    I've discovered that if I drop the PWM frequency right down (e.g. 100Hz) they reliably work at very low power.

    I have a few questions about the protocol:

    1. Command 0x1F (set PWM counter) says it takes 1 byte value: I assume that this is a typo, and it should be 2 bytes?

    2. How does this command interact with 0x33 (send signal)?  Is there a way to get the default value when using 0x33 or does 0x1F just provide a default for quick drive mode?

    3. Is there any reason not to use such low PWM frequencies?