

Lastly, two local variables, Time and Angle, are written into a file after press a STOP button.Įxp.We have started accepting articles by online means directly through website. To calculate experiment time, read a current time before while loop, and then subtract the time from a time updated in while loop. For example, at -100, a motor doesn't rotate and at 0, it can rotate. The motor power is in the range -100 to 100. NB: If motor terminals are hooked up to an oscilloscope, a motor power range becomes strange. Those constants can be determined by curve-fitting (see the Modeling section).įor safety and to limit motor rotation to a single direction, a motor power is constrained by in the range of 0 to 100. If a control frequency is changed, a value of dt also needs to be changed to a value of 1/frequency.Ī constant of 68.98519 is a proportional gain to convert from angle to motor power and another constant of 10 is bias for dead-zone. Moreover, to avoid getting mixed up with wires, I assign a local variable for the Angle.

To display angle in the range -180 to 180, when the angle is greater than 180, subtract 360 from that. In addition, here is the front panel of the LabVIEW program.Ī breakdown of the LabVIEW block diagram is shown as follows.īefore while loop, reset angle sensor and wait until its angle is within 1 degree.Īn angle from the angle sensor is measured in the range 0 to 359 degrees with 1-degree accuracy. The P, I, and D gain are 0.05, 0.8, and 0.05, respectively. Make sure that the USB-6211's wire connections are same as the picture.Ī LabVIEW program, which is similar to the before LabVIEW code, is employed to control the LEGO DCP at a control frequency of 40Hz. Wires of PFI 0, PFI 1, and DGND are hooked up to the USB-6211's terminal 1, 2 and 5, respectively. A resistor of 10k ohms and a capacitor of 10 nF are used in it. The schematic of the low-pass filter is presented as follows.

This is low-pass filters to get rid of the encoder's signal noise. Wires of AO GND and AO 0 are hooked up to the USB-6211's terminal 12 and 14, respectively. The connector #3 is for the USB-6211's analog output (AO) connection. The encoder needs 5V and I use two signals of A and B to read the pendulum rotation angle. As the base voltage of TR increases, the current through the motor increases. I use an NPN transistor (TR) to drive motor. The schematics of the motor driver and the connectors are presented as follows. I use a socket which is placed between connectors for easy wire routing. Here are top and down pictures of a circuit of a motor driver and connectors. Three schematics to construct a motor driver, connectors and low pass filters are shown following. There are circuits and devices what we need. This section gives step-by-step instructions along with photos to build circuits to drive a motor and read an encoder.
