I'm trying here is to let the real-time units of the BeagleBone generate the signals for a stepper motor.

In this post: it works! Let's put everything together.

 

 

Initialise the Sleep and Reset Signals

 

The pins P9_11 and P9_13 are used. I'm controlling them from the Linux command line.

 

BB MUXBB P9Driver function
GPIO_3011nSleep
GPIO_3113Reset

 

To start, set sleep on and reset off

 

sudo -i

# sleep on

echo out > /sys/class/gpio/gpio30/direction
echo 0 > /sys/class/gpio/gpio30/value

# reset off

echo out > /sys/class/gpio/gpio31/direction
echo 0 > /sys/class/gpio/gpio31/value

 

Set the PRU MUX signals and Load PRU Firmware

 

See the post on pin assignments for the PRU. I'm assuming that you created the binary in this post.

 

config-pin P9_31 pruout  
config-pin P9_29 pruout  

 

cp /home/debian/bin/bb_PRU_STEPPER.out /lib/firmware/bb_PRU_STEPPER.out  
echo 'bb_PRU_STEPPER.out' > /sys/class/remoteproc/remoteproc1/firmware  
echo 'start' > /sys/class/remoteproc/remoteproc1/state  

 

Initialise the Stepper Motor Driver via SPI

 

I'm assuming that you installed the SPI overlay as explained in this post and created the binary in this post.

 

/home/debian/bin/bb_LINUX_STEPPER_SPI

 

 

Wake Up the Stepper Motor Driver

 

# sleep off

echo 1 > /sys/class/gpio/gpio30/value

 

At this point everything is prepared, and you are ready to ....

 

Tell PRU to Step the Motor

 

This is it! Let's take 20 steps back and forth:

 

echo "120" > /dev/rpmsg_pru30  
echo "020" > /dev/rpmsg_pru30  

 

 

Submit as many commands as you want.

 

Motor Heat

Once you disable sleep mode, the motor will pull 600 mA. It's locked in position. It will get hot.

If you don't play with the motor, or your device doesn't need the motor be kept locked in position, put the driver back to sleep:

 

cd /sys/class/gpio/gpio30  
echo 0 > value  

 

 

 

 

Finished? Clean Up.

 

echo 'stop' > /sys/class/remoteproc/remoteproc1/state  

 

config-pin P9_31 default  
config-pin P9_29 default  

 

 

Related blog:
BeagleBone Control Stepper Motors with PRU - Part 1: Intentions
BeagleBone Control Stepper Motors with PRU - Part 2: Test Driving Outputs
BeagleBone: Enable SPI with Overlay and from Command Line
BeagleBone Control Stepper Motors with PRU - Part 3: Hardware Provisioning and Wiring
BeagleBone Control Stepper Motors with PRU - Part 4: SPI Setup
BeagleBone Control Stepper Motors with PRU - Part 5: It Works