motion simulator DIY community

From X-SIM DIY motion simulator community - international wiki

Contents

Servo Motor Control with a Basic Stamp2 Microcontroller

In this presentation I will try to give you an idea of the way my DC motor servo system works and how I interface it with x-sim software.

First of all, I used a Basic Stamp2 microcontroller to read the data from the USO (serial) interface of the x-sim. And the motors are driven with the use of Parallax's HB-25 motor controllers that converts the wiper motors to big servos! To position the motors using just the HB-25 is impossible so I wrote my own servo proportional code that does the job. The servo proportional code is implemented in p-basic and the bs2 runs it along with the demanding job of receiving the motion data from the computer.

To have feedback about the position of the motors I used special 90 degrees potentiometers (from hobby radio control unit) and ADC0831 to read them with the BS2. Then BS2 compares the motion data input with the pots feedback to calculate the speed of the motors and their direction. See sample code below:

Sample Code

  • SetPoint = bank 'Sets the seek feedback signal pointed to the bank input value from USO.
  • idx = 0 'Selects the apropriate ADC chip.
  • GOSUB Read_0831 'Reads the feedback potetiometer angle.
  • bankpot = adc(idx) 'Sets the feedback potetiometer angle into a variable.
  • SetPoint = SetPoint MIN 35 'Provides input that is inside the limits of the feedback so to protect from overshoot outside the feedback potentionmeters limits.
  • SetPoint = SetPoint MAX 220
  • error = SetPoint - bankpot 'calculates the difference between the received angle and the current angle.
  • p = Kp * error 'Calculates the proportional drive to the desired point.
  • bankpot = p + Offset 'Converts the proportional drive values to the servo pulses range.
  • bankpot = bankpot MAX 1000 'Limits the max speed that is feeded to the motors for either direction to the ones that the HB-25 can handle
  • bankpot = bankpot MIN 500
  • PULSOUT bankport, bankpot 'Finally pulses the HB-25 with the speed and direction we need

Settings

The settings I set on USO interface are shown in the photo. Be careful to check the Hexadezimal format for the output as BS2 is read them in values from 00 to FF (0 to 255) with 127 (7F) being its center.









 

Mechanicals

Feedback Potentiometer Placement

Below are the pictures of the way I placed the 90degree potentiometers inside the casters that is the actual rotation point (pivot) for the frames of the joyrider cockpit. This way I can easily measure -45 to +45 degrees of angle position of the frames and have this as feedback to drive the motors into the desired position angle.

Mounting the feedback potentiometer this way can leave me unlimited ways of motor mounting as I could easily use electric linear actuators instead simple car wiper motors...

Where can you find a 90 degree potentiometer?

I got my 90 degree pots from the stick mechanism of a toy RC controller as seen in the photo below.

Another cool alternate You can use, is a modern 90 degree Rotary Sensor that uses hall effect electronics like this one:

Hall Effect Sensor





Power

After a long time using computer PSU's to power the motors, decided to buy a car battery to power the motors with all the extra power that needed sometimes. I choose a 100Ah deep-cycle one to ensure long play time and endurance. I can use it for straight 8 hours in my simulator before charging is needed.







Parts List

Here is the list of materials for the above custom BS2 interface:

Qty IC's
1 Parallax Basic Stamp2 chip
1 ADC0831 chip
2 transistors BC547
2 transistors 2N2222
1 voltage regulator LM2940CT-5


Qty Resistors
3 220 Ohm 1/4w
3 470 Ohm 1/4w
4 10 KOhm 1/4w
2 1 kOhm 1/4w
1 39 KOhm 1/4w
1 47 KOhm 1/4w


Qty Capacitors
1 1000uF /16volt
5 10uF /16volt
2 104 ceramic (100nF, or 0.1uF)
2 103 ceramic (10nF, or 0.01uF)
1 1n2 ceramic (1.2nf, or 0.0012uF)
1 22 pF ceramic


Qty Other
2 Diodes 1N4001
1 Green LED
2 Relays double switch /5volt
1 ALPS button
1 16pin IC base (for max232)
8 8pin IC base (for ADC0831)
2 DB9 Female connector for PCB
1 20pin female row header
1 20pin male row header
1 20pin ic row header with long legs
1 Power jack for PCB



 

Layout

In these photos you can take a closer look on the basic stamp2 and its connections to the external peripherals like the HB-25 motor controllers an the potentiometers. As you can see I have the ADC chips temporally placed on the breadboard of the BS2 board of education and made an extra little board with MAX232 and the serial port that reads the data from the computer. Even if the Bs2 board of education has already serial port I had to add a new one with Max232 chip as it seems that the echo, that the Bs2's serial port is producing, is causing communication errors.








A new better version of the Max232 circuit that includes etchable PCB layout is this:





 

Downloads

BS2 Interface Open source

Project BS2 Firmware

Serial Max232 Interface

To see how to use this simple connection setup look into the next schematic, that, by the way, it uses a little different ports for the ADC from the ones shown on the photo to work with the firmware.

Simple Wiring Schematic

In a try to concentrate all the connections and add more features, I designed a dedicated board that connects other components too like relays to switch-on the computer PSU's from the BS2, extra ADC inputs with the use of more ADC0831, some switches and piezospeaker. I initially designed this interface board for flight sim and Portdrvr I used to read flight data was not needed any RS232 buffer. So I included in the final plans I give for x-sim the extra Max232 chip interface on the interface board too.

Bs2 Interface Schematic


Links

How to make the electronics and wire connections

Home Motion Flight Simulator By Thanos

A Guide Making PCB's at Home

MainPage | X-SIM 2.0 Manual | Projects | Tutorials | Forum 

Site Toolbox:

Personal tools
This page was last modified on 25 March 2009, at 21:54. - This page has been accessed 2,471 times. - Disclaimers - About X-SIM DIY motion simulator community - international wiki