Example Code

Differential Steering Example using a myRio

Code and Documents

Attachment

Overview

This is a real-time program. Sampling frequency 10kHz and uses two PWM outputs running at 10kHz for driving two front wheels of a cart (though it can be used for smaller vehicles or toys of course). The cart measures about 0.75m by 0.75m and has two 12v dc wheelchair motors with wheels and rubber tyres on the front. It has two freewheeling large castors on the back. The cart can easily take a human just like a wheelchair and is controlled using a myRio and an H bridge. The H bridge used is the Chinese one on ali-express which can handle 100A per channel.

 

https://www.aliexpress.com/item/DC-12V-48V-Stepper-Motor-Drive-Controller-Module-board-High-Frequenc...

 

 

 

Description

 

cart.JPG

 

Hardware and Software Requirements

 myRio,12V~48V 100A DC Motor Drive Module board High Frequency H-bridge dual channel Motor Module drive, Logitech Extreme 3D Pro Joystick or equivalent which works on a myRio. 12v sealed lead-acid battery. Two Jazzy wheelchair motors 12-24v + wheels and tyres.  Two large castors

 

Steps to Implement or Execute Code

The H bridge has 4 basic logic inputs. Each channel is controlled by two bits. If they are 01 then the motor turns say clockwise, 10 then anti-clockwise and 00 is halt. These are connected from the myRio on pins 11,13,15,17 of port A. We also need two PWM outputs which are pins 27 and 29 of Port A. You also need 5V and ground from the myRio.

 

Additional Information or References

 For steering we use differential steering - this link

http://faculty.salina.k-state.edu/tim/robotics_sg/Algorithms/steering.html

appears to work well but this is not like steering a car, it takes practice to steer with a joystick using this method.

We have 4 quadrant control meaning you can go forward right or left and backwards right or left continuous controlled.

We use the fire button on the joystick as a safety measure. The cart is halted until you press and hold  fire and move the joystick. We have a mouse alone setting for experimenting without the joystick.

 

See video demo:

https://www.youtube.com/watch?v=Jsb9baVYw0A&feature=youtu.be

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors