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.
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
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.