microSD

Discussion related to "under the hood" OpenMV topics.
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

microSD

Postby pcls1026 » Sun Apr 05, 2020 7:13 pm

Hi,
I bought a new microSD card.
Under tools on the IDE, I "save open script to OPENMV CAM". I verified that copy script file is on the microSD card by looking at the K drive removable disk. Being the novice I am, how does the CAM know to load the "Script File" that I put on the SD card into the CAM micro Controller memory? Is that called a boot loader?

Now, if I hook up the CAM 7 to my power supply does my script file start running automatically?
Can I monitor the script file print statements in the IDE serial terminal?

Thanks for your patience. I'm sure I'll be bugging you again.
Jim
User avatar
kwagyeman
Posts: 3985
Joined: Sun May 24, 2015 2:10 pm

Re: microSD

Postby kwagyeman » Sun Apr 05, 2020 8:12 pm

The OpenMV Cam runs whatever is called main.py on power on. Save script to OpenMV Cam in the ide just copies the current script to the main.py file on the disk.

If you want to see print statement output whatever opens the serial port on the OpenMV Cam will receive that data.

OpenMV IDE always sends a stop command when it connects to an OpenMV Cam so you won't see the script running through that. You can however use the Open Terminal feature I'm OpenMV IDE under tools to open up a terminal to see script output.
Nyamekye,
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Mon Apr 06, 2020 1:51 pm

Hi,
I am confused of course. I fiddled around but could not make it work.

Here are the steps I took.
Plugged in the cam 7 to a PC usb port.
Opened the IDE
Called up the "helloworld_1.py" script
Used tools to save this script to the cam7
Used tools to open a new terminal
NOW, WHICH OF THE 3 serial ports presented do I select?
ALSO, where will the PRINT data be presented. I.E., how do I see the print data?
See, I told you I was a novice!!

Thanks, Jim
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Mon Apr 06, 2020 2:05 pm

Hi I jumped the gun on my last post.

I copied the helloworld script file to the cam7.

I can see the file main.py on the Kdrive using windows explorer. I can look at the file using notepad; Loe and Behold, the helloworld file is their.

How do I run the Kdrive file using the usb power, or must I use my own power supply.
User avatar
kwagyeman
Posts: 3985
Joined: Sun May 24, 2015 2:10 pm

Re: microSD

Postby kwagyeman » Mon Apr 06, 2020 2:39 pm

Hi, when you power cycle the camera it will run whatever is in main.py. you can power via USB or Vin.
Nyamekye,
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Mon Apr 06, 2020 5:46 pm

how abut the serial ports. which one do I select?
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Mon Apr 06, 2020 5:48 pm

how abut the serial ports. which one do I select?
User avatar
kwagyeman
Posts: 3985
Joined: Sun May 24, 2015 2:10 pm

Re: microSD

Postby kwagyeman » Mon Apr 06, 2020 9:49 pm

Just try each until you find the camera. Alternatively, you can go into your device manager in windows and look for the COM port associated with the USB VCP device the camera appears as.

Please understand the Open Terminal feature allows communication with any serial port device. It's not just meant for control with the OpenMV Cam.
Nyamekye,
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Tue Apr 07, 2020 3:57 pm

under tools i select "open terminal ... new terminal"
under "new terminal" I select "connect to a serial port"
under "serial port", I select "com 3" because that is the only one available
I enter the baud rate "115200"

"ERROR: ACCESS IS DENIED"
User avatar
kwagyeman
Posts: 3985
Joined: Sun May 24, 2015 2:10 pm

Re: microSD

Postby kwagyeman » Tue Apr 07, 2020 6:25 pm

Can you out up your device manager in windows and search for the OpenMV Cam serial port? You should find a USB VCP port in the device tree with a COM number next to it.

If that's COM3, you need to disconnect the IDE normally from the cam before you can connect with the Open Terminal feature.

Again, the Open Terminal feature is a serial terminal that's unrelated to the main IDE window mainly. If the main IDE window is connected the OpenMV Cam open terminal cannot connect to it.
Nyamekye,
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Tue Apr 07, 2020 7:01 pm

From the device manager ---PORTS (COM & LPTA)>>>Openmv cam USB com port (COM 3).
I turned off the IDE serial.
Under tools I reopened serial port com 3, and I GOT THE COM 3 SERIAL PORT SCREEN.
ON the screen I used the run button and the script on the cam ran, with print statement data being printed.

You SIR are a genius.

I will try using my script instead of the HELLO WORLD demo script.

Thanks for the patience.
Jim
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Tue Apr 07, 2020 7:16 pm

Hi,
I ran my script in the IDE and it does what it should.

When I run my script in the serial terminal, it gives me the following
*********************
raw REPL; CTRL-B to exit
>OK
Traceback (most recent call last):
File "<stdin>", line 68
IndentationError: unindent doesn't match any outer indent level
>
MicroPython v1.11-omv OpenMV v3.5.0 2019-11-04; OPENMV3-STM32F765
Type "help()" for more information.
>>>
****************************
How ever, looking at my script the indentation is correct. And like I said above, the script ran correctly in the IDE.

I went through the process a second time. I also got an indentation error, but on line 292.

It seems like the script written to the cam is corrupted.

I'll send my script if you want.
User avatar
kwagyeman
Posts: 3985
Joined: Sun May 24, 2015 2:10 pm

Re: microSD

Postby kwagyeman » Tue Apr 07, 2020 9:38 pm

You probably have a tab in your code. The terminal may not be sending tabs correctly and it might be changing tabs to spaces. Please remove any tabs in your code. The IDE has an option to do that for you under edit.
Nyamekye,
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Wed Apr 08, 2020 12:13 pm

Hi,
I don't see any reference to TABS under IDE EDIT.
Under EDIT --ADVANCED there is "clean whitespace", is this the command that eliminates tabs?
Jim
User avatar
kwagyeman
Posts: 3985
Joined: Sun May 24, 2015 2:10 pm

Re: microSD

Postby kwagyeman » Wed Apr 08, 2020 1:22 pm

Um, just do show whitespace and then you can see tabs. They look like -> versus . when whitespace is visualized.

... I think I might be able to add a feature that fixes issues like this in the IDE automatically.
Nyamekye,
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Wed Apr 08, 2020 3:55 pm

I looked at all the white spaces: there was nothing but dots .

I entered a tab just to see what it looked like. When I entered the tab, the cursor went to the right four spaces and showed ....(four dots) not ->. However the line number was high lighted and a red bar appeared after the line number. I can't seem to get rid of the red bar. What does the command (under edit) "clean white space" do?
User avatar
kwagyeman
Posts: 3985
Joined: Sun May 24, 2015 2:10 pm

Re: microSD

Postby kwagyeman » Wed Apr 08, 2020 5:36 pm

The red bar is where you deleted things.

The clean white space command cleans all whitespace a at the end of lines. This is necessary to do in order to get rid of got commit issues where white space differences are marked as changes. Unless you are using a version control system this doesn't matter for you.

Okay, the only other thing I can think of is for you to send me your code and I can tell you where the issue is.
Nyamekye,
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Wed Apr 08, 2020 11:16 pm

The great code is attached.
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Wed Apr 08, 2020 11:26 pm

I forgot the code.
Attachments
blksearch.py
(11.34 KiB) Downloaded 23 times
User avatar
kwagyeman
Posts: 3985
Joined: Sun May 24, 2015 2:10 pm

Re: microSD

Postby kwagyeman » Thu Apr 09, 2020 4:41 pm

Hi, the code runs in the IDE and open terminal. I notice you print out "while -1" at a very high speed which crashes the IDE when using OpenTerminal.
Nyamekye,
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Fri Apr 10, 2020 5:05 pm

hi,
I put in a delay after the print in the code I sent you.
I get the same error printout.

>>>
>>>
raw REPL; CTRL-B to exit
>raw REPL; CTRL-B to exit
>OK
Traceback (most recent call last): File "<stdin>", line 174
SyntaxError: invalid syntax
>
MicroPython v1.11-omv OpenMV v3.5.0 2019-11-04; OPENMV3-STM32F765
Type "help()" for more information.
>>>
User avatar
kwagyeman
Posts: 3985
Joined: Sun May 24, 2015 2:10 pm

Re: microSD

Postby kwagyeman » Fri Apr 10, 2020 7:24 pm

Hi, it's probably then the IDE being unable to send a script over the serial port without error. There's no fix for this...

Use this script to send the your script to execute instead: https://github.com/micropython/micropyt ... ard.py#L57

It implements the REPL protocol to send a script correctly. Open Terminal doesn't do... all the things... one has to do to make sure a script makes it to the MicroPython board. The above script deals with edge cases that can cause issues.

...

I forget however, why do you need this again? Because you need to pass some user input?
Nyamekye,
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Sat Apr 11, 2020 11:10 am

Hi,
I want use the CAM on a robot without being connected to the USB port on The PC. In other words I want the CAM to run autonomously, like you guys do when your racing in California.
Jim
User avatar
kwagyeman
Posts: 3985
Joined: Sun May 24, 2015 2:10 pm

Re: microSD

Postby kwagyeman » Sat Apr 11, 2020 12:02 pm

Tools->Save Script to OpenMV Cam. Then Tools->Reset OpenMV Cam.

Then you can use open terminal to view output after the script is already running. Just don't hit the send script button.
Nyamekye,
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Sat Apr 11, 2020 1:45 pm

Yo dude, it works. I love it.

Thanks again
Jim
User avatar
CameraMan
Posts: 21
Joined: Thu Apr 09, 2020 3:41 pm

Re: microSD

Postby CameraMan » Sat Apr 11, 2020 6:01 pm

kwagyeman wrote:
Sat Apr 11, 2020 12:02 pm
Tools->Save Script to OpenMV Cam. The Tools->Reset OpenMV Cam.

Then you can use open terminal to view output after the script is already running. Just don't hit the send script button.
When you "Save Script to OpenMV Cam" does this mean that the py file no longer needs to be on the SD card?
-Chief Tinkering Officer
User avatar
kwagyeman
Posts: 3985
Joined: Sun May 24, 2015 2:10 pm

Re: microSD

Postby kwagyeman » Sat Apr 11, 2020 9:49 pm

No, the OpenMV Cam runs it from the sd card or upy flash if there's no SD card. The script is never hidden.

(If there's enough user demand and contracting work we could probably implement some time of protection system for the cameras. So far, no-one's pushed us on that yet).
Nyamekye,
pcls1026
Posts: 115
Joined: Tue Aug 22, 2017 1:33 am

Re: microSD

Postby pcls1026 » Sun Apr 12, 2020 6:00 pm

Hi,
I plugged in my 5 volt power supply to the CAM7 without the USB hooked up. A white light blinked on the CAM7. Is this the only indication that my code is running?
Also, since the IDE is no longer hooked up I can't get serial output to debug. Can I keep using the USB power and the OPEN TERMINAL so I can still debug the code using print statements?
Thank you very much for your indispensable help.
Jim
User avatar
kwagyeman
Posts: 3985
Joined: Sun May 24, 2015 2:10 pm

Re: microSD

Postby kwagyeman » Sun Apr 12, 2020 6:30 pm

You can modify your program to blink an LED.

And yes, the 5V supply is OR'ed with the USB so both can be attached at once.
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: Google [Bot] and 14 guests