Two Issues about autostart

General discussion about topics related to OpenMV.
PKUEcho
Posts: 4
Joined: Sat Jun 29, 2019 11:03 am

Two Issues about autostart

Postby PKUEcho » Sat Jun 29, 2019 11:12 am

Hi all, I just bought two OpenMV H7 and they are great.

I have two questions regarding the auto-start:
1) When I click "Save Open Script to OpenMV Cam", I saw the file is flushed to another of my mounted storage disk on Mac (a new "main.py" generated) instead of the OpenMV disk.
2) I manually updated the main.py on OpenMV and click "Reset OpenMV Cam". When I powered my OpenMV again, the script didn't start. Instead, it just has the blue LED keep blinking... Waiting to connect to IDE.

What should I do? Thanks!
User avatar
kwagyeman
Posts: 3504
Joined: Sun May 24, 2015 2:10 pm

Re: Two Issues about autostart

Postby kwagyeman » Sat Jun 29, 2019 1:02 pm

Hi, the issue is that you have another disk that OpenMV IDe thinks is your OpenMV Cam disk. You can fix this by clicking on the disk drive path in the status bar and selecting the right disk and the IDE will remember that. They the IDE can save the script to the right disk.

There's no method for me to associate the disk with the serial port of the OpenMV Cam other than guessing. If you have two FAT drives plugged into the PC the IDE needs you to pick the correct one.
Nyamekye,
PKUEcho
Posts: 4
Joined: Sat Jun 29, 2019 11:03 am

Re: Two Issues about autostart

Postby PKUEcho » Sat Jun 29, 2019 1:20 pm

Thanks for your help. I have another question.

I'm testing the sleep/wakeup function. I want OpenMV to periodically wakeup and give LED signal. My code is following:

Code: Select all

def capture_img():
    pass
def test_led():
    intvl = 0.5
    red_led.on()
    utime.sleep(intvl)
    red_led.off()
    green_led.on()
    utime.sleep(intvl)
    green_led.off()
    blue_led.on()
    utime.sleep(intvl)
    blue_led.off()


rtc = pyb.RTC()
rtc.wakeup(2000, capture_img)

while (True):
    test_led()
    pyb.stop() # sleeping mode, 500 uA
I flushed it into my OpenMV (w/o sd card). However, now everytime I try to open it it will switch between the three LED and then go off, and my IDE cannot recognize it. Seems like the wakeup function doesn't work? And now I cannot even flush another script because it quickly goes off...
User avatar
kwagyeman
Posts: 3504
Joined: Sun May 24, 2015 2:10 pm

Re: Two Issues about autostart

Postby kwagyeman » Sat Jun 29, 2019 3:41 pm

Um, yeah, the code is working exactly as you want. Your firmware has complete control over he camera so it's turning the power off on the camera and kicking the IDE off.

You need to reflash the firmware to fix this. I need to add a disk erase method to get around this issue. I will do that. Basically, your script you are running has effectively bricked the camera. That said, the bootloader is still fine. So, you can erase the built-in disk onboard via that.

I highly recommend not putting power control code on the device without an SD card.

Anyway, to fix your camera, click the connect button without the camera plugged into the PC. Say your camera is bricked. Then select the right version, then plug your camera in and it will get reset back to the factory default state.
Nyamekye,
User avatar
kwagyeman
Posts: 3504
Joined: Sun May 24, 2015 2:10 pm

Re: Two Issues about autostart

Postby kwagyeman » Sat Jun 29, 2019 3:42 pm

Regarding wakeup. I have to check on that. Did you follow how the RTC example works? (Answering this from my phone while out at an event. Please forgive me not being able to give exact code help).
Nyamekye,
User avatar
iabdalkader
Posts: 1028
Joined: Sun May 24, 2015 3:53 pm

Re: Two Issues about autostart

Postby iabdalkader » Sat Jun 29, 2019 6:09 pm

Hi, I tested your code and it works fine on the F7 but not on the H7. It seems the low-power modes are broken on the H7 (I think it's the RTC), anyway I'll fix this in the next release.

EDIT: You should open an issue on github to make sure we don't forget to fix this.
PKUEcho
Posts: 4
Joined: Sat Jun 29, 2019 11:03 am

Re: Two Issues about autostart

Postby PKUEcho » Sat Jun 29, 2019 6:28 pm

Thanks guys for your help!

Now I have a micro sdcard and get my camera back to normal. My goal is simple: I want to measure the power (via Monsoon meter) consumed by OpenMV from (deep) sleep -> wake up -> capture an image -> store it on sdcard -> go to (deep) sleep. According to iabdalkader, it seems like I cannot get it done without a new release?
User avatar
iabdalkader
Posts: 1028
Joined: Sun May 24, 2015 3:53 pm

Re: Two Issues about autostart

Postby iabdalkader » Sat Jun 29, 2019 7:03 pm

That's true, I confirmed there's an issue with RTC waking up the MCU. It will be fixed in the next release.
PKUEcho
Posts: 4
Joined: Sat Jun 29, 2019 11:03 am

Re: Two Issues about autostart

Postby PKUEcho » Sat Jun 29, 2019 8:29 pm

May I ask when the new release will come? I'm relying on this measurement for my research project. Thanks!
User avatar
iabdalkader
Posts: 1028
Joined: Sun May 24, 2015 3:53 pm

Re: Two Issues about autostart

Postby iabdalkader » Mon Jul 01, 2019 11:38 am

It could take a while we have a lot of issues to fix.
otills
Posts: 16
Joined: Fri Aug 09, 2019 4:42 am

Re: Two Issues about autostart

Postby otills » Mon Aug 12, 2019 7:45 am

Has the issue with RTC been resolved as I cannot get rtc.wakeup() working at all?
User avatar
iabdalkader
Posts: 1028
Joined: Sun May 24, 2015 3:53 pm

Re: Two Issues about autostart

Postby iabdalkader » Mon Aug 12, 2019 9:30 am

No not yet, sorry for the delays but it's not an easy bug and I have to fix it upstream as well. The release should be out in two weeks, I'll have it fixed before then.
otills
Posts: 16
Joined: Fri Aug 09, 2019 4:42 am

Re: Two Issues about autostart

Postby otills » Mon Aug 12, 2019 9:42 am

OK - I would really appreciate an update when this is fixed - thanks for working on it.

I am trying to deploy some OpenMV's to run in the environment for many weeks (with periodic video acquisitions)- are there any other approaches to reducing power consumption to levels that will make this possible in the interim while I wait for this fix? I need to get these deployed this week really.
User avatar
iabdalkader
Posts: 1028
Joined: Sun May 24, 2015 3:53 pm

Re: Two Issues about autostart

Postby iabdalkader » Mon Aug 12, 2019 10:35 am

Not unless you control power to the camera with another board. I'll try to work on this today.
otills
Posts: 16
Joined: Fri Aug 09, 2019 4:42 am

Re: Two Issues about autostart

Postby otills » Mon Aug 12, 2019 2:04 pm

Thanks.

I really appreciate you doing what you can. I have 8 x H7s all requiring this feature ASAP.
User avatar
iabdalkader
Posts: 1028
Joined: Sun May 24, 2015 3:53 pm

Re: Two Issues about autostart

Postby iabdalkader » Mon Aug 12, 2019 4:27 pm

Hi, the attached firmware should fix the issue. Note while sleep/stop mode now works, deepsleep is still not supported on the H7.
Attachments
firmware.zip
(955.06 KiB) Downloaded 529 times
otills
Posts: 16
Joined: Fri Aug 09, 2019 4:42 am

Re: Two Issues about autostart

Postby otills » Tue Aug 13, 2019 4:24 am

Hi, thanks for this - seems to work now.

Do you have an eta on deep sleep? Or, suggestions on any kind of intermediate steps to a low power state. I have tried the sensor.sleep() and sensor.shutdown() - directly from the Deep Sleep Mode Example script, and get "OSError: Reset Failed Reset Failed".
otills
Posts: 16
Joined: Fri Aug 09, 2019 4:42 am

Re: Two Issues about autostart

Postby otills » Tue Aug 13, 2019 4:57 am

OK - I thought that I had fixed that sensor.reset() issue by using the IDE for doing a board reset (thinking that I must have broken something - perhaps attempting the deepsleep), but apparently not. Any attempt to put the sensor to sleep then throws this OSError: Reset Failed when it attempts to wake.

Should sensor sleep using the code from the Example scripts work following an rtc.wakeup call?

# Enable sensor softsleep
sensor.sleep(True)

# Shutdown the sensor (pulls PWDN high).
sensor.shutdown(True)

My script works fine until I introduce these sensor sleep functions to the end of the acquisition which then throw errors when the sensor is asked to reset at the beginning of the next acquisition!!
otills
Posts: 16
Joined: Fri Aug 09, 2019 4:42 am

Re: Two Issues about autostart

Postby otills » Tue Aug 13, 2019 8:50 am

Apologies for the multiple posts, but this also relates to RTC.

No matter what I do with rtc.datetime, I get the date time (2000, 1, 1, 1, 0, 0, 0, 0) returned. I have tried various of the Example scripts in case the issue was with my own code, but as far as I can see this appears to be an issue with rtc..

Code: Select all

import pyb

rtc = pyb.RTC()
rtc.datetime((2019, 8, 12, 1, 11, 10, 10, 10))
print(rtc.datetime())
Returns:

Code: Select all

>>> (2000, 1, 1, 1, 0, 0, 0, 0)
MicroPython v1.9.4-4571-g45deee14f-dirty on 2019-08-12; OPENMV4 with STM32H743
Type "help()" for more information.
Any ideas? This is using the firmware provided by iabdalkader yesterday.
User avatar
iabdalkader
Posts: 1028
Joined: Sun May 24, 2015 3:53 pm

Re: Two Issues about autostart

Postby iabdalkader » Tue Aug 13, 2019 11:45 am

You need to disable the sensor shutdown, before another reset:

Code: Select all

sensor.shutdown(False)
As for the datetime issue, I'm not sure why it's not working, but you don't need to set datetime to get a callback. I'll work on fixing this issue. The ETA for the release is 2-3 weeks
otills
Posts: 16
Joined: Fri Aug 09, 2019 4:42 am

Re: Two Issues about autostart

Postby otills » Tue Aug 13, 2019 1:53 pm

Hi, given that that both setting and returning the date time via rtc.datetime() returns an invariant and incorrect datetime, can you confirm that the rtc.wakeup() with a given time period can be considered accurate in its periodicity over a prolonged period of numerous 'wakeups'?
User avatar
iabdalkader
Posts: 1028
Joined: Sun May 24, 2015 3:53 pm

Re: Two Issues about autostart

Postby iabdalkader » Tue Aug 13, 2019 2:11 pm

I think so, it just counts from a different date/time. Anyway, give it a test and let me know and I'll into it next weekend.
otills
Posts: 16
Joined: Fri Aug 09, 2019 4:42 am

Re: Two Issues about autostart

Postby otills » Tue Aug 13, 2019 5:55 pm

Hi, unfortunately rtc.wakeup does not appear to be working.

Changes to the time appear to have no effect on the sleep duration - which is only a few seconds..

I have persevered with this as thought it might be an issue with my code, but do think that the rtc.wakeup is broken!
User avatar
kwagyeman
Posts: 3504
Joined: Sun May 24, 2015 2:10 pm

Re: Two Issues about autostart

Postby kwagyeman » Wed Aug 14, 2019 11:50 am

I think Ibrahim put a fix in for this on github.
Nyamekye,
User avatar
iabdalkader
Posts: 1028
Joined: Sun May 24, 2015 3:53 pm

Re: Two Issues about autostart

Postby iabdalkader » Wed Aug 14, 2019 12:59 pm

Okay I'll have more time to work on this in the weekend.
User avatar
iabdalkader
Posts: 1028
Joined: Sun May 24, 2015 3:53 pm

Re: Two Issues about autostart

Postby iabdalkader » Mon Aug 19, 2019 6:52 pm

Hi, are you sure that what you are testing is the firmware image which I've attached here ? It should say Firmware Version: 3.4.2 on the bottom left when connected...
No matter what I do with rtc.datetime, I get the date time (2000, 1, 1, 1, 0, 0, 0, 0) returned
This test prints the right datetime:

Code: Select all

import pyb

rtc = pyb.RTC()
rtc.datetime((2019, 8, 12, 1, 11, 10, 10, 10))
print(rtc.datetime())
It prints:
>>> (2019, 8, 12, 1, 11, 10, 10, 255)
MicroPython v1.9.4-4574-gf31c61e4d on 2019-08-20; OPENMV4 with STM32H743
Type "help()" for more information
Changes to the time appear to have no effect on the sleep duration - which is only a few seconds..
I used this to test RTC wakeup calls, and changing the wakeup time changes the LED frequency as expected:

Code: Select all

import time, pyb, machine

led = pyb.LED(3)

def rtc_callback(arg):
    led.toggle()

rtc = pyb.RTC()
rtc.wakeup(500, rtc_callback)

while (True):
    time.sleep(10)

I noticed one issue with RTC and stop mode on the H7, it doesn't wake up from longer wakeup times (like >5000ms). I'll debug that.
otills
Posts: 16
Joined: Fri Aug 09, 2019 4:42 am

Re: Two Issues about autostart

Postby otills » Tue Aug 20, 2019 2:25 am

Hi, yes I’m using the firmware version you linked to here. I’m trying to wake from sleeps longer than 5000 ms so perhaps that’s the problem?
User avatar
iabdalkader
Posts: 1028
Joined: Sun May 24, 2015 3:53 pm

Re: Two Issues about autostart

Postby iabdalkader » Tue Aug 20, 2019 6:19 am

otills wrote:
Tue Aug 20, 2019 2:25 am
Hi, yes I’m using the firmware version you linked to here. I’m trying to wake from sleeps longer than 5000 ms so perhaps that’s the problem?
Yes there's an issue with that, it needs more debugging. For now you should only sleep for <= 5000 ms.
otills
Posts: 16
Joined: Fri Aug 09, 2019 4:42 am

Re: Two Issues about autostart

Postby otills » Tue Aug 20, 2019 9:06 am

Ok thanks. Yeh I need to put the board to sleep for many minutes to get them to run for long enough on batteries for my application so 5 seconds is not useful. I will have to wait.
User avatar
iabdalkader
Posts: 1028
Joined: Sun May 24, 2015 3:53 pm

Re: Two Issues about autostart

Postby iabdalkader » Fri Aug 23, 2019 10:14 am

Hi, I noticed wakeup is not consistent (I think it has something to do with the backup SRAM content), anyway I just updated the RTC driver from upstream and merged in another fix to disable it after soft reset. I think it works fine now. As for that other issue, the camera does wake up after long sleeps but the host does not re-enumerate the USB port after 5 or 6 seconds. So after long sleeps you can't reconnect, but the camera still wakes up and works just fine. To test just modify the default example, adding LED toggle after wake up:

Code: Select all

# Stop Mode Example
# This example demonstrates using the low-power Stop Mode.

import time, pyb, machine

# Create and init RTC object.
rtc = pyb.RTC()
# (year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])
rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0))

# Print RTC info.
print(rtc.datetime())

# Enable RTC interrupts every 5 seconds.
rtc.wakeup(2*60*1000)

# Enter Stop Mode.
# Note the IDE will disconnect.
machine.sleep()

led = pyb.LED(3)
while (True):
    led.toggle()
    time.sleep(500)
    led.toggle()
    time.sleep(500)
I'm attaching a firmware image if you want to test, just run this and wait 2 minutes and the blue LED will start to blink again.
Attachments
firmware.zip
(955.71 KiB) Downloaded 280 times
User avatar
iabdalkader
Posts: 1028
Joined: Sun May 24, 2015 3:53 pm

Re: Two Issues about autostart

Postby iabdalkader » Wed Aug 28, 2019 6:45 pm

deepsleep is now supported on the H7 in the latest development firmware on github:

https://github.com/openmv/openmv/tree/master/firmware
otills
Posts: 16
Joined: Fri Aug 09, 2019 4:42 am

Re: Two Issues about autostart

Postby otills » Thu Aug 29, 2019 8:10 am

Perfect!! Many thanks.

Sleep is working well for me now with the most recent firmware you shared posted.

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 2 guests