Shop OBEX P1 Docs P2 Docs Learn Events
DC Motors with Blocklyprop — Parallax Forums

DC Motors with Blocklyprop

Is anybody coding DC Motors with Blocklyprop? I know the S3 uses DC motors but I am going to use the MSR1 for this project.
The PWM blocks under the Analog/Pulses menu look like they could be used but I can not find any info on them. What channel
are they referring to in the PWM set box? Is it motor A and motor B?

Comments

  • I have the Stingray working with Blocklyprop. The main problem is I have no speed control over the motors. They are fully on or fully off.
    Does anybody have an idea how to change that? I have linked to a video of it careening around workroom and the code I am using.
    1041 x 1035 - 271K
    MSR1.jpg 271.2K
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    Carol,

    A and B refer to the two counter/timers within a given COG. If you assign each one to a pin and set the duty cycle you can vary the speed of a motor or the brightness of a light source. However to effectively change the direction of a motor you would have to assign one input of the H-Bridge to high/low while using PWM on the other side. To reverse direction swap pins. I don't recall on the MSR1 board which pins were connected to the H-Bridge, but there should be 4 total...2 per motor.
  • If you look at my code you can see where I did that with functions. The motor pins are 24 and 25 for motor A and 26 and 27 for motor B. the help I need is to figure out how to control the speed of the motors. Could the motor functions be made with the PWM blocks? My experiments did not work.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    Carol,

    So, for example where you have P24 low and P25 high, instead make P24 low and Send PWM to P25. Likewise on P26 send the B channel PWM and make P27 low. Let me know if this works for you.
  • Thank you Chris, I am going to try that immediately!
  • That did not work but this does! Thanks for the idea Chris.
    544 x 413 - 64K
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    Carol,

    I will have to look into this. I don't know what the PWM Frequency is. That may be the issue. I will do some testing tomorrow while I am in the office.
  • This is a robot I am working on for the Robothon 2017 Walker course. the robot has to walk in a straight line for 7 feet, see the end wall and execute a 180% turn and walk back to the start point. It does not have to do the turn if it can walk backward instead of turning. Mine is walking nice and straight but my turns are not consistent yet.

Sign In or Register to comment.