I Am Using a Locking Solenoid With the BBAI-64 From Beagleboard.org

by functt in Circuits > Software

42 Views, 0 Favorites, 0 Comments

I Am Using a Locking Solenoid With the BBAI-64 From Beagleboard.org

bb64.jpg

This is a short of sorts. It is a small C/C++ file scripted to handle a locking/unlocking solenoid device from the BeagleBoneAI-64 and Motor Cape. The PWM peripheral onboard the BBAI-64 is used from the TDA4VM (the onboard main processor) to headers where the Motor Cape is attached. The Motor Cape then uses its L298 drivers to handle the Solenoid motor device for locking and unlocking. A 12v 0.04A PSU was used to handle the power to the Motor Cape...

Supplies

  1. 12v PSU at 0.04A for the Solenoid
  2. Beagleboard.org BBAI-64
  3. PWM
  4. Motor Cape
  5. Solenoid
  6. USB C to USB C cable for interfacing to Dev. Desktop
  7. Ethernet Cable
  8. Barrel Jack 5v 2-3A center positive
  9. Enjoyment
  10. Oh and a development Desktop, Linux preferably

Ideas

BBAI-64, "PWM", and the Motor Cape

So, I figured I would "show off" some ideas relating to a board from beagleboard.org, some C/C++ source, and some PWM peripheral access...


The video is a youtube video that is for a short explanation and dedication I have had to building around their boards.


See, I purchase them, use them, and learn while having them develop around their nice boards.


It is sometimes easier on the senses to just be patient rather than harass the development team from any business or organization. In the end, I have used what I have learned to make short of sorts on this building process.


C!


Seth


P.S. Also, I will be showcasing a way to add the required .dtbo file in the correct format within the right file on the BBAI-64 once the correct image has been ported to the BBAI-64 from the beagleboard.org website I have listed below...

Attach and Deploy

So, without further ado...

  1. Attach the Motor Cape with the L298 drivers onto the BBAI-64
  2. Attach the USB C to USB C cable into the BBAI-64 and then into the Dev. Desktop
  3. Once powered, type these contents to set up your board...
  4. ssh debian@192.168.7.2
  5. password: temppwd
  6. Change the temppwd password to your favorite or super secretive passcode
  7. write up the source of your use case
  8. sudo shutdown -h now will shutdown the board


Once the source is on the board and you have shutdown your device, attach a PWR and GND from your PSU to the correct connectors on the Motor Cape while the PSU is also shut down. This way, we do not have any live wiring while making connections.


Now, attach, in our case, the solenoid (a two wire module) to the correct connectors. I used Motor One for our connection interfacing. Motor One is P9_16 in this case which is a PWM peripheral from the TDA4VM to the headers on the BBAI-64. Now, if everything is connected correctly and while it has been totally powered down, apply power to your board via the USB C to USB C cable from BBAI-64 to Dev. Desktop.

Also, one thing to note here, the TDA4VM is a vehicle grade, dual core processor from TI.com. TI has put together many usable, really smart processors in time and some can handle high heat like the TDA4VM.

Since the TDA4VM is meant for high heat applications in real high heat settings, do not worry if the processor gets a little warm. Oh!


BeagleBone® AI-64 - BeagleBoard and go to Software Images. In the software images section, pick the latest-greatest with the 6.1.x kernel (this is a Linux based machine).


If you have not done so already, update to the latest use case of an image. This image is listed in the link provided.


You can use balena etcher or another form of flashing source or you can use dd on Linux.


I used etcher on a Debian Linux Distro to put the micro SD Card image on a micro SD Card. I then booted the board from micro SD Card. I then was directed to change my passcode, the board flashed to eMMC, and I then took out power once it completed, and finally removed the micro SD Card and booted into the eMMC image.


Although the few short sentences before this one should have been done and completed beforehand, it is a lesson. Read everything first, then apply knowledge after summarizing, and finally use at will! That is a little tidbit of data I have learned to be evident.


Not everything is an instruction. Summarizing data via real-world examples always holds true via reading, comprehension, and then application.

Alright, enough of lesson time here.

So, we have our image, booted into the eMMC image via micro SD Card, and now we want to use the PWM to fade a LED or unlock our solenoid!

// Differences from Sean J. Miller on element14
// Since its conception, the links have changed and have since been lost!


#include <stdio.h>
#include <unistd.h>


void setupPWM() {
    FILE *period, *pwm;
    pwm = fopen("/dev/beagle/pwm/P9_16/enable", "w");
    fseek(pwm, 0, SEEK_SET);
    fprintf(pwm, "%d", 1);
    fflush(pwm);
    fclose(pwm);


    printf("Period...!\n");
    period = fopen("/dev/beagle/pwm/P9_16/period", "w");
    fseek(period, 0, SEEK_SET);
    fprintf(period, "%d", 2500);
    fflush(period);
    fclose(period);


}
void pwm_duty(int the_duty_multiplier)
{
    FILE *duty;
    duty = fopen("/dev/beagle/pwm/P9_16/duty_cycle", "w");
    fseek(duty, 0, SEEK_SET);
    fprintf(duty, "%d", 10 * the_duty_multiplier);
    fflush(duty);
    fclose(duty);
}


int main() {
     int ii = 0; int up = 0;
     printf("Setting up\n");
     setupPWM();


     while(1) {
        printf("Locking and Unlocking %d\n", ii);
         if (up == 1) ii++; else ii--;
         if ((ii) > 60) {
             up = 0;
         }
         if (ii < 3) {
             up = 1;
         }
         pwm_duty(ii);
         usleep(250000);
     }
}


I have tested other source recently to see if I can sort of comprehend what does what and how it does it:


You can find the source here: silver2row/BBAI_64_Motor_Cape: A Build for the Motor Cape and BBAI-64 from beagleboard.org (github.com)


Also...there are two photos for understanding the muxing of the BBAI-64 to Motor Cape. It was done for the BBB (BeagleBone Black) but works for the BBAI-64 now.

Coding and Application

So, that above source can be used to alter a LED in the form of fading it light to lit to off and back again.


But...we are dealing with a Solenoid, i.e. a motor of sorts.


What in that source would you call correct, what would you change, and what does the actual source do?


Think about it and post your replies. I think learning in time and effort creates a long awaited perspective where rejoicing is possible, e.g. especially when finalizing a summary on ideas, source, and building around specifics.

So, do we actually need all the source?


If not, what should be changed? Where should it be changed? What will happen when it is changed?


Seth


P.S. With the build and source and file descriptors, we can see where the files are located that we need to alter. How does one create an alteration on the BBAI-64 with the updated, eMMC image that got put on the eMMC from our micro SD Card image? Well, I have found recently, very recently, that a command will do it and create the files in available format for use to use:


sudo beagle-pwm-export --pin p9_16

also...if any of the above ideas are not working for you, DO NOT forget the .dtbo file...

So, in /boot/firmware/extlinux/extlinux.conf, add this dtbo file from your /boot/firmware/overlays/ files at the
precise location after putting the micro SD Card into the board and then booting into eMMC:

fdtoverlays /overlays/k3-j721e-beagleboneai64-BBORG_MOTOR.dtbo

That will make available a set up files that can be used to handle the PWM and GPIO of the board peripherals
and then allow you to make file descriptors to call them later in your source...

Some are located at /dev/beagle/pwm/ while the gpio files are located at /sys/class/leds/m* where /m* is /m1_high
to /m4_high. The brightness file is the GPIO in question for the Motor Cape.


capes/beaglebone/Motor/Motor_Cape_sch.pdf at master · beagleboard/capes (github.com)


That link will show a bit more definition on pins used and the Cape infrastructure and in PDF format!

Wrapping Up and a Brief Summary

So, we have current, power, and connections. We have used a couple of beagleboard.org technologies via their source to port a micro SD Card to eMMC onboard the BBAI-64. We have an attachment to help us with a L298 driver for using it to fade a LED or use as a solenoid locking device.

We have a couple commands and an image to utilize for porting C source and making that source usable.

So, all in all, the build is sort of complete. Are you going to build more? Are you going to port the source for LED usage or create a mutant robot that will take over the living room?


Seth