Electronic Design

  
Reprints     Printer-Friendly    Email this Article    RSS        Font Size     What's This?


[Design View / Design Solution]
Mixed-Signal Processors Can Aid Visual Robotic Development
State-of-the-art tools make motion control and development a more abstract process.

Oliver H. Bailey  |   ED Online ID #18513  |   April 10, 2008


Though this project employs the accelerometer as an angle detector, the direction will also change when the g force exceeds the threshold value it’s compared against in the state machine. This creates the possibility of running into an object also changing direction.

Two “Continuous Interface Valuators” (integer values) were added to hold the values of X-axis and Y-axis accelerometer readings. Known as XAxis and YAxis, respectively, they hold the values read by the program each time through the main program loop, which in this case is every 16.5 ms (64 Hz).

These two values are preserved between each loop for display and monitor purposes. Such an approach enables the developer to use the board-monitor function of PSoC Express to view the live data while the program is executing.

As a result, accelerometer values can be seen and visually connected to the state transitions they trigger. This allows a visual method to see if the program logic is correct. The completed accelerometer logic is located in the box marked X-Y Inputs (Fig. 3, again).

MOTION CONTROL LOGIC
The final state machine in this project manages the motioncontrol logic (shown in the box marked “Motion Control Logic” of Fig. 3). The line between “MachineState” and “Direction” represents the state of “MachineState” as an input to the “Direction” state machine. Robot motion remains stopped until the “MachineState” state transitions to “Run.” The “Direction” state machine serves several purposes.

First, it serves as the brains of the motion-control system, taking inputs from the “Accelerometer” and “MachineState” state machine to determine if motion should be applied, and if so, which direction the robot should move in. The states of the “Direction” state machine are also used as inputs to the motor-control H-bridge driver circuit. We’ll look at the motor logic shortly, but the “Direction” state machine contains everything needed to determine motion control and direction. Figure 5 shows the actual “Direction” state-machine logic.

Though Figure 5 appears very busy, this state machine really isn’t difficult to understand. As shown, the “Direction” state machine contains seven states: Stopped, Forward, Backward, FwdLeft, FwdRight, BackLeft, and BackRight.

A Discrete Interface Valuator (Byte Variable) named TurnCount counts the number of loops after the YAxis value leaves the triggered threshold range. When TurnCount reaches a given value, the motion state is changed back to Forward or Reverse, depending on the original direction of travel.

“Stopped” is the default state at power-up and transitions to “Forward” after a 10-second startup timer has expired. The robot continues to go forward until one of the accelerometer values exceeds its threshold value. The lines between each state have the evaluation expressions that will cause a transition from one state to another. This can be illustrated with “StoppedTo- Forward” logic (Fig. 6).

Each state transition requires a unique name, and it’s located in the first line. In this case, the name is “StoppedtoForward,” which is also the name displayed on the connector between the “Stopped” and “Forward” states. The next item is the expression that will force the transition from one state to another. It simply evaluates the value of “MachineState” and forces the transition when “MachineState” transitions to the “Run” state.

What isn’t illustrated in Figure 6 is that acceptable expressions are displayed as the line is typed. Thus, the developer doesn’t have to remember unique naming schemes, which in this example uses transition names and underscore characters. The two lists are the “from” transitions on the left and the “to” transitions on the right. So, the program will go “from” a “Stopped” state “to” a “Forward” state.

MOTOR CONTROL
The final piece to this system puzzle implements the motor-control logic, which will simply turn on and off different portions of the H-bridge based on the current state of the “ Direction” state machine. Let’s refer back to Figure 6.

The “Direction” state machine has connectors to the four motor-control blocks: “Left_Forward,” “Right_Forward,” “Left_ Reverse,” and “Right_Reverse.” These four connectors are outputs from the state machine used as inputs to each motor control above to determine if that motor should be on or off. There are only two motors, but the speed and direction of the motors can be controlled based on the “Direction” state machine.

Each leg of the H-bridge is controlled via pulse-width modulation (PWM). Though you may be familiar with how an H-bridge works, its context in this development tool is slightly different from most other embedded environments. Let’s walk through this H-bridge control in the context of PSoC Express.

Continue on Page 3


<-- prev. page     1 [2] 3     next page -->

Reprints   Printer-Friendly  Email this Article  RSS    Font Size   What's This?



POST YOUR COMMENTS HERE
Name:

Email:
Your Comments:

Enter the text from the image below


Please refresh the page if you have trouble reading this text.

Search Electronic Design
     
  
 
Web Seminar
Sponsored By:
Title: Read Pacing: A Performance Enhancing Feature of PCI Express Gen 2 Switch Devices
Speakers: 
Date: 07/01/08
Register: 

Electronic Design Europe Electronic Design China EEPN Power Electronics Auto Electronics Microwaves & RF
Mobile Dev & Design Schematics Find Power Products Military Electronics EE Events Related Resources