0

Different Express Airlift USB and barrel behavior
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Different Express Airlift USB and barrel behavior

by KQRR4449 on Mon Jun 10, 2019 5:28 pm

I just received my Metro M4 Express Airlift board.
When I plug it into just the USB connector, the board behaves as expected. The Neopixel slowly cycles through the colors and opening the virtual serial port repeatedly lists the Analog Voltage reading and the WIFI APs are listed periodically. This matches the code.py program.
When I plug just the power adapter into the barrel connector, the behavior is different. The power LED lights as expected, but the Neopixel blinks yellow rapidly several times, turns sold blue, and then repeats this pattern. Plugging in the USB connector does not change the behavior and I do not get any output from the virtual serial port. I have set my bench supply to 7.1 Volts and 8.1 Volts with identical results. The board draws about 30mA from the barrel connector when the Neopixel is blinking.
If I initially plug in the USB connector so it starts working as expected and then plug in the barrel connector, the board keeps working normally. The board draws about 130mA in this condition, indicating the barrel connector is supplying power.
Is this normal behavior or is something wrong with my Mertro M4 Airlift board?
Thanks very much,
Ken West

KQRR4449
 
Posts: 29
Joined: Tue Jan 17, 2017 7:45 pm

Re: Different Express Airlift USB and barrel behavior

by oesterle on Mon Jun 10, 2019 7:57 pm

Hi, Ken!

Can you post your code? (Be sure to highlight it and use the CODE button to format it here.)

I suspect you have a line or lines like this in your code, which wait for USB:
Code: Select all | TOGGLE FULL SIZE
while (!Serial) {
  ; // wait for serial port to connect. Needed for native USB port only
}

If that's so, try commenting that part out.

Cheers,

Eric

oesterle
 
Posts: 621
Joined: Tue Sep 17, 2013 11:32 pm

Re: Different Express Airlift USB and barrel behavior

by KQRR4449 on Mon Jun 10, 2019 10:28 pm

I am using the code that Adafruit shipped with the board. I just plugged it in for the first time. The code shipped with the board should run forever. I have uploaded and attached the OEM code shipped with the board.

I have made some progress. I saw it start blinking several times even when connected just to the USB. I got lucky and trapped a message in the Mu Serial window. The message shows the program crashed for some reason. It offered me the option of pressing any key to enter the REPL, or press CTRL-D to reload the program. I verified that I get the same when message and blink pattern when I interrupt the program with CTRL-C.. Here is the message:

Press any key to enter the REPL. Use CTRL-D to reload.
Adafruit CircuitPython 4.0.0 on 2019-05-20; Adafruit Metro M4 Airlift Lite with samd51j19

My guess that the OEM code crashes immediately when connected just to the barrel connector and crashes sporadically when connected just to the USB connector. I do not see any particularly reason that the OEM code would crash. It does call a fair number of libraries including the ESP32 libraries.

Thanks for the help,

Ken West

KQRR4449
 
Posts: 29
Joined: Tue Jan 17, 2017 7:45 pm

Re: Different Express Airlift USB and barrel behavior

by KQRR4449 on Mon Jun 10, 2019 10:44 pm

I just noticed that you can't post files with a .py extension. This seems like a strange limitation but...
I tried renaming the file several different ways including one with no extension at all. It always gave the same "Cannot use this extension" message.
I finally tried zipping it up into a file name code.zip. This worked. Unzip the attached file to get code.py.

It would be good if you loosened up the extension rules a bit.

Thanks for the help,

Ken West
Attachments
code.zip
Contains Adafruit OEM code.py file shipped with the M4 Express AirLift
(1.85 KiB) Downloaded 40 times

KQRR4449
 
Posts: 29
Joined: Tue Jan 17, 2017 7:45 pm

Re: Different Express Airlift USB and barrel behavior

by adafruit_support_mike on Tue Jun 11, 2019 3:53 am

We prefer to have code posted between CODE tags.. it's easier to read and refer to that way.

adafruit_support_mike
 
Posts: 58448
Joined: Thu Feb 11, 2010 2:51 pm

Re: Different Express Airlift USB and barrel behavior

by KQRR4449 on Tue Jun 11, 2019 3:21 pm

I am sorry that I did not place it between code tags. Please note that this is identical to the Adafruit code shipped with my board. I have made no changes to it.
The MD5 checksum is "6B55EB60ACDB4FE26141B263C9B891DA". The code is below:

Code: Select all | TOGGLE FULL SIZE
# Metro M4 AirLift IO demo
# Welcome to CircuitPython 4 :)

import time
import board
from digitalio import DigitalInOut, Direction, Pull
from analogio import AnalogIn
from adafruit_motor import servo
import neopixel
import busio
import audioio
import pulseio
import simpleio
from adafruit_esp32spi import adafruit_esp32spi
import adafruit_esp32spi.adafruit_esp32spi_requests as requests
# keyboard support
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode

esp32_cs = DigitalInOut(board.ESP_CS)
esp32_ready = DigitalInOut(board.ESP_BUSY)
esp32_reset = DigitalInOut(board.ESP_RESET)
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)

# One pixel connected internally!
dot = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2)

# Built in red LED
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT

# Analog audio output on A0, using two audio files
audio = audioio.AudioOut(board.A0)
audiofiles = ["rimshot.wav", "laugh.wav"]

# Analog input on A1
analog1in = AnalogIn(board.A1)

# Initialize WiFi Module
if esp.status == adafruit_esp32spi.WL_IDLE_STATUS:
    print("ESP32 found and in idle mode")
print("Firmware vers.", esp.firmware_version)
print("MAC addr:", [hex(i) for i in esp.MAC_address])

# Digital input with pullup on D2, D3, and D4
buttons = []
for p in [board.D2, board.D3, board.D4]:
    button = DigitalInOut(p)
    button.direction = Direction.INPUT
    button.pull = Pull.UP
    buttons.append(button)

# Servo on D5
# create a PWMOut object on Pin D5
pwm = pulseio.PWMOut(board.D5, duty_cycle=2 ** 15, frequency=50)
servo = servo.Servo(pwm)

# NeoPixel strip (of 16 LEDs) connected on D6
NUMPIXELS = 16
neopixels = neopixel.NeoPixel(board.D6, NUMPIXELS, brightness=0.2, auto_write=False)

# Used if we do HID output, see below
kbd = Keyboard()

######################### HELPERS ##############################

# Helper to convert analog input to voltage
def getVoltage(pin):
    return (pin.value * 3.3) / 65536

# Helper to give us a nice color swirl
def wheel(pos):
    # Input a value 0 to 255 to get a color value.
    # The colours are a transition r - g - b - back to r.
    if (pos < 0):
        return [0, 0, 0]
    if (pos > 255):
        return [0, 0, 0]
    if (pos < 85):
        return [int(pos * 3), int(255 - (pos*3)), 0]
    elif (pos < 170):
        pos -= 85
        return [int(255 - pos*3), 0, int(pos*3)]
    else:
        pos -= 170
        return [0, int(pos*3), int(255 - pos*3)]

def play_file(filename):
    print("")
    print("----------------------------------")
    print("playing file "+filename)
    with open(filename, "rb") as wave_file:
        wave = audioio.WaveFile(wave_file)
        audio.play(wave)
        while audio.playing:
            pass
    print("finished")
    print("----------------------------------")

######################### MAIN LOOP ##############################

i = 0
while True:
  if i == 0:
      # Lets to a WiFi SSID scan
      for ap in esp.scan_networks():
          print("\t%s\t\tRSSI: %d" % (str(ap['ssid'], 'utf-8'), ap['rssi']))

  # spin internal LED around! autoshow is on
  dot[0] = wheel(i & 255)

  # also make the neopixels swirl around
  for p in range(NUMPIXELS):
      idx = int ((p * 256 / NUMPIXELS) + i)
      neopixels[p] = wheel(idx & 255)
  neopixels.show()

  # Read analog voltage on A1
  print("A1: %0.2f" % getVoltage(analog1in), end="\t")

  if not buttons[0].value:
      print("Button D2 pressed!", end ="\t")
      # optional! uncomment below & save to have it sent a keypress
      #kbd.press(Keycode.A)
      #kbd.release_all()

  if not buttons[1].value:
      print("Button D3 pressed!", end ="\t")
      play_file(audiofiles[0])

  if not buttons[2].value:
      print("Button D4 pressed!", end ="\t")
      play_file(audiofiles[1])

  # sweep a servo from 0-180 degrees (map from 0-255)
  servo.angle = simpleio.map_range(i, 0, 255, 0, 180)

  i = (i+1) % 256  # run from 0 to 255
  #time.sleep(0.01) # make bigger to slow down

  print("")


Thanks for the help,

Ken West

KQRR4449
 
Posts: 29
Joined: Tue Jan 17, 2017 7:45 pm

Re: Different Express Airlift USB and barrel behavior

by KQRR4449 on Tue Jun 11, 2019 3:52 pm

I used my Tektronix DP2002B scope to compare the power on behavior and reset signal behavior when power is applied from the USB connector and when power is applied from the barrel connector. The following scope traces are in the attached .zip file:

"1 Power On Barrel 5V Top 3.3V Btm.bmp": This shows the power on behavior with the barrel connector. The input on the lab supply was 8.1V at 1 Amp.
The +5V supply comes up quickly and cleanly followed 440us later by the 3.3V supply. This seems reasonable.

"2 Power On USB 5V Top 3.3V Btm.bmp" This shows the power on behavior with the USB connector. The input is from the high power output of a USB hub.
The +5V supply comes up more slowly with a small dip followed 224us later by the 3.3V supply.
The slower +5V rise time and dip are probably due to USB negotiation. The 3.3V power on looks identical to the barrel connector.

"3 Reset Barrel 3.3V Top RST Btm.bmp" This shows the 3.3V power on to Reset with the barrel connector. The 3.3V power is on top and the RST pin is on the bottom.
The RST pin shows the expected exponential behavior, reading 2/3 of the supply Voltage in 1.14ms.

"4 Reset USB 3.3V Top RST Btm.bmp" This shows the 3.3V power on to Reset with the USB connector. The 3.3V power is on top and the RST pin is on the bottom.
This scope trace is identical to the one with the barrel connector.

The above scope traces do not explain why the code.py program runs when powered by USB but does not run when powered by the barrel connector. The 3.3V power on behavior is identical in both cases and the 3.3.V power on to RST behavior is also identical. I verified that pressing the Reset button with just the barrel connector attached results in the same blinking behavior. This makes it very unlikely that the problem is due to the difference barrel and USB in power supplies.

The obvious difference between the barrel and USB connector is that the USB connector also connects do the virtual Rx and Tx signals.
Is it posible the program crashes if Rx and Tx are not configured?

None of the above explains why the program crashes every hour or so when connected just to the USB connector.

I hope the above information helps track down the problem. Let me know if I can provide more information.

Sincerely,

Ken West
Attachments
AdaFruit M4 Express AirLift Scope Traces.zip
(47.55 KiB) Downloaded 41 times

KQRR4449
 
Posts: 29
Joined: Tue Jan 17, 2017 7:45 pm

Re: Different Express Airlift USB and barrel behavior

by KQRR4449 on Fri Jun 14, 2019 10:42 pm

I haven't seen any replies in a couple of days.
I really need to know if my Metro M4 Airlift board is working correctly.
I need to send it back for a replacement if it is broken.
Any help would be greatly appreciated.
Sincerely,
Ken West

KQRR4449
 
Posts: 29
Joined: Tue Jan 17, 2017 7:45 pm

Re: Different Express Airlift USB and barrel behavior

by adafruit_support_mike on Sat Jun 15, 2019 1:07 am

Sorry for the delay.

These lines are likely to be the ones causing the problem:

Code: Select all | TOGGLE FULL SIZE
# keyboard support
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode

[...]

kbd = Keyboard()
Those tell the microcontroller to act like a USB keyboard, and not having a connection to a USB host is a fatal error for a USB device.

adafruit_support_mike
 
Posts: 58448
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.