Mecanum Wheel Robot...
 
Notifications
Clear all

Mecanum Wheel Robot Car & ESP-NOW Remote

47 Posts
9 Users
7 Likes
3,128 Views
(@tjblair1951)
Member
Joined: 11 months ago
Posts: 5
 

My ultimate goal is to use a PS3 controller once I figure out the speed/direction control using ledc.  I found an almost identical chassis kit to the one Bill used (my wheels are a different color) but I'm not planning to use the LEDs or anything else, just the basic car.  My grandson will have a lot of fun with it if I get it working. 

Reading the bits from the control byte works better for an H-Bridge that uses three pins for motor control but isn't quite as straightforward using my modules.  What Bill was able to do with three lines of code takes me several if statements to accomplish.  For example,

Bills code:

// Right Front Motor
digitalWrite(MF_AI1, bitRead(dircontrol, 7));
digitalWrite(MF_AI2, bitRead(dircontrol, 6));
ledcWrite(mtrRFpwmchannel, abs(speedRF));

My best attempt to reproduce that is this:

// Right Front Motor
if(bitRead(dircontrol, 7) == 0) ledcWrite(mtrRFpwmchannelA, 0);
else ledcWrite(mtrRFpwmchannelA, abs(speedRF));
if(bitRead(dircontrol, 6) == 0) ledcWrite(mtrRFpwmchannelB, 0);
else ledcWrite(mtrRFpwmchannelB, abs(speedRF));

Haven't had time to verify the syntax yet, or if it will do what I think it will, but that's the best I can come up with.  Note that I had to declare two PWM channels for each wheel instead of the single one that Bill had in his sketch.


   
ReplyQuote
(@tjblair1951)
Member
Joined: 11 months ago
Posts: 5
 

I checked the syntax and it compiled correctly.  I uploaded the code to the ESP32 and it goes through all of the motions correctly so my idea worked.  On to the next step.  Fortunately, Bill has another project to do just that.

If anyone is interested, I would be happy to share the code.


   
ReplyQuote
Page 4 / 4