I picked up a BeagleV-Fire to test the capabilities of the machine. Right now, I am moving slowly throughout the OS/server image from beagleboard.org.
One thing I found is a /dev/bone/pwm/ interface of files. I thought at first, "Oh, a way to reach the outside world from my BeagleV-Fire."
I could not get the bone-specification to work so far. I have been tinkering with the machine on and off for a few months or a year. Time goes by quickly...
Outside of the bone-specification, I learned about some other file system attributes located at /sys/class/pwm/. There are two pwmchip files in this location for testing.
I tested /pwmchip0/pwm0 and came to use P9_14 for this pwmchip0 set of files.
I also wanted to test some source code and random commands to handle a pwmchip or file of the specification at /dev/bone/pwm/. The latter is not something I will use just yet.
I have to wait for the developers to handle things while I play around and learn.
So, I attached a LED, a resistor, and two jumper wires in a circuit from/to the BeagleV-Fire. Then, I attached the probe and GND for my scope.
This boards from beagleboard.org are not plug and play so to say...
You cannot just power them on and expect them to work with "hot plugging" wires into the female or male headers. You may destroy a pin or even worse, you could ruin your processor.
I will list a schematic:
Say the battery in this photo above is a BeagleV-Fire instead and you need to plug in the cathode and anode of the LED along with the resistor...
I used GND on the BeagleV-Fire. P9_01 is a GND and I used that specific female header pin. P9_14 is the PWM peripheral I chose to use that is allocated to the female header at that pin.
So, in a circuit, add the anode of the LED to the resistor that leads to the PWM peripheral pinout on the BeagleV-Fire.
And...the other side of the LED goes to GND. Sorry for the mess. There is a lot going on in the photo but the red board, the BeagleV-Fire, is attached via jumper wires to the breadboard that holds the LED and resistor.
Now, at /sys/class/pwm/pwmchip0/pwm0/, we have some files that will allow us to change the peripheral state slowly through bash commands on the terminal.
Oh and do not forget to place a fan somewhere in close proximity to the BeagleV-Fire. The board at times gets somewhat heated and dissipates the heat. It needs cooling. Direct the fan at the board either on the top view or the bottom view.
That 5v USB can will keep your board cool and in working order...
Now, how do we get an image on this board? Do we use the micro SD Card slot or do we use the USB Device located at USB C to USB C? Honestly, I have been unable to get the micro SD Card images to work just yet. So, I have been using the machine via USB C and its built in USB device allocation for updating images on the development desktop to the target all via source code...
https://github.com/beagleboard/bb-imager-rs/releases/tag/0.0.20
That is the latest release on that page. Enjoy. It works on Windows and Linux.
It works with x86_64 and arm64 or aarch64. Well, you can review what they have made available.
So, this GUI availability from beagleboard.org seems aesthetically appealing and works seamlessly with Linux and Windows from what I can tell.
1. Pick the Board
2. Pick the Image
3. Choose your Destination
Number 3. is a bit iffy. I say iffy because you need to communicate to the board that you want it in a USB input state for writing the image to the eMMC on board the BeagleV-Fire.
So, choose the board, choose the image, and then when you choose the button for choosing the destination, Hold the USB Button while clicking the Reset Button a couple of times. Keep holding the USB button and wait until the USB activates after reset for input.
Then, once that pops up, choose that device in the list to write your image to the eMMC on the BeagleV-Fire.
If you need to find out what exactly is taking place, use a USB to UART Bridge adapter. I used the CP2102 family of debugging tools. When attaching the debugger to the BeagleV-Fire, make sure the board is off before attaching it to the board/target. Also, GND goes to GND. TX goes to RX. Then, RX goes to TX so communication can take place. At first this was a sure fire way to get support on the forums.
Now, the image just works which is a blessing if you want to explore this specific board.
So, click write and this will flash the image to the eMMC if indeed the USB C Device is in the correct mode.
Once done, I guess it would be time to set up the LED, resistor and oscilloscope tools for use.
We are using the PWM peripherals still and will be looking for a square wave.
If you know what you are looking at now, please write me a short message. I would love to find out what exactly you are seeing.
That was after running the commands below:
echo 25000000 > period
echo 7500000 > duty_cycle
echo 0 > enable
echo 1 > enable # Here is when we stop our oscilloscope to catch the wave
echo 0 > enable # Stop the LED and return it to the off stateThat should get your fingers tingling with understandings and give rise to more education needing to be made on the subject.
Anyway, the LED should lite up and then once the oscilloscope has been stopped, you can view the waveform a bit closer for inspection.
Oh and if you want to use a MaxBotix sensor for anything, here are some pointers that may or may not work. I have not tested it. So, I am out of the loop for now.
#!/usr/bin/python3
"""
This Code uses the:
* Maxbotic LV-EZ2 Ultrasonic Sensor
Tested with the BBBW
This sketch reads the LV-EZ2 by pulse count
Then prints the distance to the console
The circuit:
* 3.3v on the BBBW to LV-EZ2 Pin 7 Vcc
* GND on BBBW to the LV-EZ2 Pin 6 GND
* LV-EZ2 Ultrasonic Sensor PW pin to BBBW P9_14
* LV-EZ2 Sensor PWM usage!
"""
from time import sleep
import sys
PWM_E = "/sys/class/pwm/pwmchip0/enable"
PWM_P = "/sys/class/pwm/pwmchip0/period"
PWM_D = "/sys/class/pwm/pwmchip0/duty_cycle"
PWM_E == "0"
PWM_P == "25000000"
PWM_D == "7500000"
# calculated mode or median distance
mode_result = 0
# storing multiple pulses
# read in time for pin to transition
samples = 9
pulses = (PWM_E = "1", len==samples)
# sensor reads which are in range will be stored here
rangevalue = [0, 0, 0, 0, 0, 0, 0, 0, 0]
# 1s sensor power up pause
sleep(1)
def tof_cm(time_of_flight):
"""
EZ1 ultrasonic sensor is measuring "time of flight"
Converts time of flight into distance in centimeters
"""
convert_to_cm = 58
cm = time_of_flight / convert_to_cm
return cm
def tof_inches(time_of_flight):
"""
EZ1 ultrasonic sensor is measuring "time of flight"
Converts time of flight into distance in inches
"""
convert_to_inches = 147
inches = time_of_flight / convert_to_inches
return inches
def find_mode(x):
"""
find the mode (most common value reported)
will return median (center of sorted list)
should mode not be found
"""
n = len(x)
max_count = 0
mode = 0
bimodal = 0
counter = 0
index = 0
while index < (n - 1):
prev_count = counter
counter = 0
while (x[index]) == (x[index + 1]):
counter += 1
index += 1
if (counter > prev_count) and (counter > max_count):
mode = x[index]
max_count = counter
bimodal = 0
if counter == 0:
index += 1
# If the dataset has 2 or more modes.
if counter == max_count:
bimodal = 1
# Return the median if there is no mode.
if (mode == 0) or (bimodal == 1):
mode = x[int(n / 2)]
return mode
try:
while True:
# wait between samples
sleep(.5)
if len(pulses) == samples:
j = 0 # rangevalue array counter
# only save the values within range
# range readings take 49mS
# pulse width is .88mS to 37.5mS
for i in range(0, samples):
tof = pulses[i] # time of flight - PWM HIGH
if 880 < tof < 37500:
if j < len(rangevalue):
rangevalue[j] = tof_cm(tof)
j += 1
# clear pulse samples
pulses.clear() # clear all values in pulses[]
# sort samples
rangevalue = sorted(rangevalue)
# returns mode or median
mode_result = int(find_mode(rangevalue))
# python console prints both centimeter and inches distance
cm2in = .393701
mode_result_in = mode_result * cm2in
print(mode_result, "cm", "\t\t", int(mode_result_in), "in")
# result must be in char/string format for LCD printing
# digit_string = str(mode_result)
sleep(2)
except KeyboardInterrupt:
PWM_E == "0"
print("Yep and then some...")
passThat code should be something to debug and have a good time changing it up. I cannot remember who or where I got the source code. GPLv3?
Anyway, I have changed it to suit my needs for now.









Comments