4D systems dislpay + camera openmv

OpenMV related project discussion.
Drogon
Posts: 6
Joined: Fri Jul 20, 2018 10:24 am

4D systems dislpay + camera openmv

Postby Drogon » Fri Jul 20, 2018 10:37 am

Hello,

I'm starting to use openmv and i need to know if the camera can works good in mode spi slave. I have tested more things with openmv IDE like for example:
1>>

Code: Select all

SPI.init(SPI.SLAVE,polarity=0, phase=1, bits=8, firstbit=SPI.MSB, ti=False, crc=None) 
2>>

Code: Select all

spi = SPI(2, SPI.SLAVE, baudrate=600000, polarity=0, phase=1)
3>>

Code: Select all

spi = pyb.SPI(2, pyb.SPI.SLAVE, polarity=0, phase=1)
     pin = pyb.Pin("P3", pyb.Pin.IN, pull=pyb.Pin.PULL_UP) 
but it always give me the same OSError : 16 , and the bus is not busy.

I have the problem with this line of my code too: data = spi.send_recv(b'\xff\xff'). The ide show me the same error. I have tested it changing the pins on hardware but i dont get it works well.


I need your advices and help.


Thank you in advice :/

Drogon
Last edited by Drogon on Thu Jul 26, 2018 4:47 am, edited 1 time in total.
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: 4D systems dislpay + camera openmv

Postby kwagyeman » Sun Jul 22, 2018 1:19 pm

Hi, I thought I answered this a while back. Please see the Examples -> Board Control -> SPI Control Example. It shows how to drive our LCD shield in user space using the SPI code.
Nyamekye,
Drogon
Posts: 6
Joined: Fri Jul 20, 2018 10:24 am

Re: 4D systems dislpay + camera openmv

Postby Drogon » Mon Jul 23, 2018 3:58 am

Hi,


Yes, i did check this example and i modified repeatedly, my last try is:

Code: Select all

import sensor, image, time
from pyb import Pin, SPI

spi = SPI(2, SPI.SLAVE, baudrate=int(1000000000/66), polarity=0, phase=1)

def wait_sync():
    c = 0x00
    while (spi.recv(c) == 0 ):
        print("nothing")
        if (spi.recv(c) != 0 ):
          spi.send(c)
          print ("sync done")
          break

# Display On
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # must be this
sensor.set_framesize(sensor.VGA) # must be this
sensor.set_windowing((320, 240))
sensor.skip_frames() # Let new settings take affect.
clock = time.clock() # Tracks FPS.
print("Settings openmv ok")
while(True):
    clock.tick() # Track elapsed milliseconds between snapshots().
    img = sensor.snapshot() # Take a picture and return the image.
    wait_sync()
    spi.send(img)
    print(clock.fps()) 
But the openmv ide give me the error 5 (OSError: [Errno 5] EIO) and right now i dont know like i can solve it...


Thank you for your help Nyamekye
Last edited by Drogon on Thu Jul 26, 2018 4:46 am, edited 1 time in total.
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: 4D systems dislpay + camera openmv

Postby kwagyeman » Mon Jul 23, 2018 1:19 pm

Oh, yeah, that's most likely an STM HAL issue. Just wrap the method with a try and catch stament and retry on an error.

See the pixy emulation example script in SPI mode for how to deal with this. I can provide a more detailed answrr later if you need more help.

Um, these errors are how the MicroPython PYB works. I agree our I/O is hard to use than the Arduino.
Nyamekye,
Drogon
Posts: 6
Joined: Fri Jul 20, 2018 10:24 am

Re: 4D systems dislpay + camera openmv

Postby Drogon » Tue Jul 24, 2018 6:27 am

Hi,


I have seen the example of pixy with spi but i need more help ... my master wait the same byte (0x88) of my slave but i cannot get it. My idea is transfer the image of openmv to my display. At the moment only show the picture.

Can you help me with the script of openmv , please? its complex for me... :/


Sorry and thank you so much
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: 4D systems dislpay + camera openmv

Postby kwagyeman » Tue Jul 24, 2018 12:02 pm

Hi, do you have any documentation for the display. I'll take a look.

That said, I'm generally unable to do coding for folks since I'm way to busy... if you send the documentation I'll try to give you a write up of what to do but I wouldn't wait on me for a solution.
Nyamekye,
Drogon
Posts: 6
Joined: Fri Jul 20, 2018 10:24 am

Re: 4D systems dislpay + camera openmv

Postby Drogon » Wed Jul 25, 2018 3:41 am

Hi,


the documentation: https://www.4dsystems.com.au/product/gen4_uLCD_70D/


I just hope a little help with this....because I cannot get the sync between the two devices....after of this I believe that I'll be able to get the data through, but the bus error is difficult for me because I don't understand why happen it.


Don't worry! I understand it :)

Thank you so much for your time!!
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: 4D systems dislpay + camera openmv

Postby kwagyeman » Thu Jul 26, 2018 1:18 am

Can you post your code using the code tags?
I can't figure out the indentation. Note that by try and catch I mean you can do this:

Code: Select all

def wait_sync():
    while True:
        data = spi.recv(1)
        if data == 0: break
        print("nothing")
    c = spi.recv(1)
    if (c != 0 ):
        spi.send(c)
    print ("sync done")
Note, I don't see any CS pin in your code. The SPI bus controller doesn't control the CS pin. It just does SCLK, MOSI, and MISO.
Nyamekye,
Drogon
Posts: 6
Joined: Fri Jul 20, 2018 10:24 am

Re: 4D systems dislpay + camera openmv

Postby Drogon » Thu Jul 26, 2018 5:45 am

Of course, I can do it. (done)


I have tried your lines and I have added the line <<cs = Pin("P3", Pin.OUT_OD)>>because when I saw your comment I saw the line in one of the examples.


Then I have tested all it and only show <nothing>. :/... any idea?


Thank you for your time again :=)
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: 4D systems dislpay + camera openmv

Postby kwagyeman » Thu Jul 26, 2018 11:47 am

Hi, did you try the code I posted above?

Note that I don't have your screen or even know what the protocol is... so, I'm not really sure how to help you...

If you want me to provide some useful answer you kind of need to narrow everything down to "one" line of code which is having the error. From the code you have for doing the sync I think you're passing the variables to the receive command wrong.
Nyamekye,
Drogon
Posts: 6
Joined: Fri Jul 20, 2018 10:24 am

Re: 4D systems dislpay + camera openmv

Postby Drogon » Fri Jul 27, 2018 3:14 am

Hi,

Yes, i did test your code but no works because show "nothing". And I do not have any compilation errors...:/

The program on the display to wait the sync is:

Code: Select all

 
 func slave_sync()
    var result := 0x00;
    while (result != 0x88)
        pin_LO(PA2); 
        SPI1_Write(0x88);
        result:= SPI1_Read();
        putnum(HEX, result);
        pin_HI(PA2); 
    wend
    //master recv data
    pin_LO(PA2);
    SPI1_Write(0x88 ^ 0xff);
    pin_HI(PA2);
endfunc


But you can explain me more about the variables that you think are worng :=)

Thank you so much for all your help!!!
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: 4D systems dislpay + camera openmv

Postby kwagyeman » Fri Jul 27, 2018 10:43 pm

Okay, so you want something like:

Code: Select all

pin = Pin('P1', Pin.OUT_PP, Pin.PULL_UP)
def wait_sync():
    while True:
    	pin .value(0)
    	spi.send(0x88)
        data = spi.recv(1)
        pin .value(1)
        print("%02x" % data)
        if data == 0x88: break
    pin .value(0)
    spi.send(0x88 ^ 0xff)
    pin .value(1)
    print ("sync done")
Please read the docs... http://docs.openmv.io/library/pyb.SPI.h ... hlight=spi
Nyamekye,

Return to “Project Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests