We recently designed and released two new products into the market which are specifically aimed to work with Flowcode SE (School’s Edition). However, they are not exclusive to Flowcode SE use, so many other users may benefit from them. In a series of blog posts we will provide information on the new hardware in action to demonstrate some of their example applications.
In this article we will provide a working example and description of how to interface a stepper motor to the Prototype board. This can be performed to teach students about the operation of stepper motors, and the construction of simple electronic circuits.
The Prototype board is an exciting new product available from us. It features a small section of breadboard integrated onto the PCB and allows for rapid prototyping of simple electronic systems which directly and easily interface with a microcontroller. The Prototype board offers very similar functionality to the Arduino Uno and Prototype shield as seen in the picture above. It offers the advantage that it does not require an external shield to be placed on the board like is necessary with the Arduino for rapid prototyping.
Both the Prototype and Project boards (more discussion on the Project board will be provided in a later article) feature the exact same microcontroller, so embedded system designs can be interchanged simply and quickly between the boards.
For this example a basic Flowcode program was constructed to demonstrate and simulate the simple method in which we can control a stepper motor from within Flowcode. Alongside the stepper motor connections, we also connected 4 LEDs to monitor each of the four motor phases. These give a visual indication of the operation of the motor and allow us to verify the sequence in which each phase is activated in order to fault find if necessary. The plan was to also connect LEDs to the motor phases on the hardware, again to visually observe the status of the phases.
For the simulation we placed a generic stepper motor onto our simulation panel within Flowcode and created a flowchart to continually increment the step, that is, rotate the motor anti-clockwise. To achieve this a while 1 loop was implemented, and inside the loop was placed a component macro command to increment the step. Since motors have mechanical moving parts, a short delay must also be included to allow the motor position to turn before the motor phases are alternated. Failure to do so results in the motor vibrating back and forth, oscillating, rather than rotating.
In order to visually observe the status of the 4 phases of the motor, we placed 4 LEDs on the simulation panel also, connected to the same microcontroller pins as the stepper motor. We colour coded these within Flowcode to match the hardware. When we run the simulation we see that as the motor spins in an anti-clockwise direction the LEDs flash according to which phase is active. The default parameter set for the delay function is 10mS which provides a relatively fast rotation of the stepper motor, but is too fast for us to observe properly with the naked eye. In order to slow down the stepper motor, and visually observe the phases we increase the length of the delay up to as high as 1 second. The finished example program and simulation panel can be seen below;
With the flowchart finished it was time to construct the hardware onto the Prototype board, and download the example code to the microcontroller. The image below shows how the hardware was populated on the breadboard, and demonstrates how useful the integrated breadboard component is to ease interfacing with the microcontroller. In this example, four different colour LEDs were used, along with current limiting resistors. The LEDs light up when each motor phase is active. When the motor operates at ‘full speed’ the LEDs flash very fast and the pattern of flashing is difficult to observe, however, as mentioned we can slow the motor down by introducing a larger delay into the system and visually verify the operation of the motor.
With the stepper motor verified working with the Prototype Board we can progress the design onto the Project Board, which is covered in the next article. For more information relating to the new hardware boards visit our website here.
7,398 total views, 3 views today